diff --git a/Source/MonoGame.Extended.Animations/AnimatedSprite.cs b/Source/MonoGame.Extended.Animations/AnimatedSprite.cs index f057e984..a04f2d25 100644 --- a/Source/MonoGame.Extended.Animations/AnimatedSprite.cs +++ b/Source/MonoGame.Extended.Animations/AnimatedSprite.cs @@ -1,10 +1,12 @@ using System; using Microsoft.Xna.Framework; using MonoGame.Extended.Animations.SpriteSheets; +using MonoGame.Extended.Entities; using MonoGame.Extended.Sprites; namespace MonoGame.Extended.Animations { + [EntityComponent] public class AnimatedSprite : Sprite { private readonly SpriteSheetAnimationFactory _animationFactory; diff --git a/Source/MonoGame.Extended.Entities/Entity.cs b/Source/MonoGame.Extended.Entities/Entity.cs index 900f8af2..f8facf6d 100644 --- a/Source/MonoGame.Extended.Entities/Entity.cs +++ b/Source/MonoGame.Extended.Entities/Entity.cs @@ -128,24 +128,29 @@ namespace MonoGame.Extended.Entities Manager.MarkEntityToBeRemoved(this); } - public T Attach(Action configure) where T : EntityComponent + public T Attach(T component) where T : class + { + return Manager.AddComponent(this, component); + } + + public T Attach(Action configure) where T : class { var component = Attach(); configure(component); return component; } - public T Attach() where T : EntityComponent + public T Attach() where T : class { return Manager.AddComponent(this); } - public void Detach() where T : EntityComponent + public void Detach() where T : class { Manager.MarkComponentToBeRemoved(this); } - public T Get() where T : EntityComponent + public T Get() where T : class { return Manager.GetComponent(this); } diff --git a/Source/MonoGame.Extended.Entities/EntityComponent.cs b/Source/MonoGame.Extended.Entities/EntityComponent.cs index 65d09bbe..e76905a6 100644 --- a/Source/MonoGame.Extended.Entities/EntityComponent.cs +++ b/Source/MonoGame.Extended.Entities/EntityComponent.cs @@ -38,51 +38,52 @@ using MonoGame.Extended.Collections; namespace MonoGame.Extended.Entities { - public abstract class EntityComponent : IPoolable - { - private ReturnToPoolDelegate _returnToPoolDelegate; + //public abstract class EntityComponent : IPoolable + //{ + // private ReturnToPoolDelegate _returnToPool; - public Entity Entity { get; internal set; } + // public Entity Entity { get; internal set; } - IPoolable IPoolable.NextNode { get; set; } - IPoolable IPoolable.PreviousNode { get; set; } + // IPoolable IPoolable.NextNode { get; set; } + // IPoolable IPoolable.PreviousNode { get; set; } - protected EntityComponent() - { - } + // protected EntityComponent() + // { + // } - public virtual void Reset() - { - } + // public virtual void Reset() + // { + // } - void IPoolable.Initialize(ReturnToPoolDelegate returnDelegate) - { - Reset(); - } + // void IPoolable.Initialize(ReturnToPoolDelegate returnDelegate) + // { + // _returnToPool = returnDelegate; + // Reset(); + // } - void IPoolable.Return() - { - Return(); - } + // void IPoolable.Return() + // { + // Return(); + // } - internal void Return() - { - Reset(); + // internal void Return() + // { + // Reset(); - if (_returnToPoolDelegate == null) - { - return; - } + // if (_returnToPool == null) + // { + // return; + // } - Entity = null; + // Entity = null; - _returnToPoolDelegate.Invoke(this); - _returnToPoolDelegate = null; - } + // _returnToPool.Invoke(this); + // _returnToPool = null; + // } - public override string ToString() - { - return $"Entity: {Entity}"; - } - } + // public override string ToString() + // { + // return $"Entity: {Entity}"; + // } + //} } \ No newline at end of file diff --git a/Source/MonoGame.Extended.Entities/EntityComponentDelegate.cs b/Source/MonoGame.Extended.Entities/EntityComponentDelegate.cs index 9944ba90..f1c893ae 100644 --- a/Source/MonoGame.Extended.Entities/EntityComponentDelegate.cs +++ b/Source/MonoGame.Extended.Entities/EntityComponentDelegate.cs @@ -1,4 +1,4 @@ namespace MonoGame.Extended.Entities { - public delegate void EntityComponentDelegate(Entity entity, EntityComponent component); + public delegate void EntityComponentDelegate(Entity entity, object component); } \ No newline at end of file diff --git a/Source/MonoGame.Extended.Entities/EntityComponentPool.cs b/Source/MonoGame.Extended.Entities/EntityComponentPool.cs index 635a7281..4ff1c853 100644 --- a/Source/MonoGame.Extended.Entities/EntityComponentPool.cs +++ b/Source/MonoGame.Extended.Entities/EntityComponentPool.cs @@ -4,10 +4,10 @@ namespace MonoGame.Extended.Entities { internal interface IComponentPool { - EntityComponent New(); + object New(); } - internal class ComponentPool : ObjectPool, IComponentPool where T : EntityComponent, IPoolable, new() + internal class ComponentPool : ObjectPool, IComponentPool where T : class, IPoolable, new() { public ComponentPool(int intitialSize = 16, ObjectPoolIsFullPolicy isFullPolicy = ObjectPoolIsFullPolicy.ReturnNull) : base(CreateObject, intitialSize, isFullPolicy) @@ -19,7 +19,7 @@ namespace MonoGame.Extended.Entities return new T(); } - EntityComponent IComponentPool.New() + object IComponentPool.New() { return base.New(); } diff --git a/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs b/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs index c16ebe41..ad9b94b1 100644 --- a/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs +++ b/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs @@ -34,6 +34,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using Microsoft.Xna.Framework; +using MonoGame.Extended.Animations; +using MonoGame.Extended.Sprites; namespace MonoGame.Extended.Entities { @@ -55,48 +57,31 @@ namespace MonoGame.Extended.Entities // don't call this every frame, lol public void Scan(params Assembly[] assemblies) { - var componentTypeInfos = new List(); - var entityTemplateTypeInfos = new List(); - var systemTypeInfos = new List(); - - var componentTypeInfo = typeof(EntityComponent).GetTypeInfo(); - var systemTypeInfo = typeof(EntitySystem).GetTypeInfo(); - var entityTempalteTypeInfo = typeof(EntityTemplate).GetTypeInfo(); - - foreach (var assembly in assemblies) - { - var typeInfos = assembly.ExportedTypes.Select(x => x.GetTypeInfo()).ToArray(); - - foreach (var typeInfo in typeInfos) + var exportedTypes = assemblies + .Concat(new [] { - var isComponent = componentTypeInfo.IsAssignableFrom(typeInfo); - if (isComponent) - { - componentTypeInfos.Add(typeInfo); - continue; - } + typeof(Sprite).GetTypeInfo().Assembly, + typeof(AnimatedSprite).GetTypeInfo().Assembly + }) + .SelectMany(a => a.ExportedTypes) + .Select(x => x.GetTypeInfo()) + .ToArray(); - var isSystem = systemTypeInfo.IsAssignableFrom(typeInfo); - if (isSystem) - { - systemTypeInfos.Add(typeInfo); - continue; - } + var componentTypes = exportedTypes + .Where(t => t.IsDefined(typeof(EntityComponentAttribute))) + .ToList(); - var isEntityTemplate = entityTempalteTypeInfo.IsAssignableFrom(typeInfo); - // ReSharper disable once InvertIf - if (isEntityTemplate) - { - entityTemplateTypeInfos.Add(typeInfo); - // ReSharper disable once RedundantJumpStatement - continue; - } - } - } + var systemTypes = exportedTypes + .Where(t => typeof(EntitySystem).GetTypeInfo().IsAssignableFrom(t)) + .ToList(); + + var templateTypes = exportedTypes + .Where(t => typeof(EntityTemplate).GetTypeInfo().IsAssignableFrom(t)) + .ToList(); - var registeredComponentCount = RegisterComponents(componentTypeInfos); - RegisterEntityTemplates(entityTemplateTypeInfos); - CreateSystems(systemTypeInfos, registeredComponentCount); + var registeredComponentCount = RegisterComponents(componentTypes); + RegisterEntityTemplates(templateTypes); + CreateSystems(systemTypes, registeredComponentCount); } private int RegisterComponents(List componentTypeInfos) @@ -226,11 +211,11 @@ namespace MonoGame.Extended.Entities var system = _dependencyResolver.Resolve(typeInfo.AsType()); var processingSystem = system as EntityProcessingSystem; + if (processingSystem != null) processingSystem.Aspect = new Aspect(andMask, orMask, norMask); - _systemManager.AddSystem(system, systemAttribute.GameLoopType, - systemAttribute.Layer, SystemExecutionType.Synchronous); + _systemManager.AddSystem(system, systemAttribute.GameLoopType, systemAttribute.Layer, SystemExecutionType.Synchronous); } } diff --git a/Source/MonoGame.Extended.Entities/EntityManager.cs b/Source/MonoGame.Extended.Entities/EntityManager.cs index 9e7621f0..f38bff99 100644 --- a/Source/MonoGame.Extended.Entities/EntityManager.cs +++ b/Source/MonoGame.Extended.Entities/EntityManager.cs @@ -53,7 +53,7 @@ namespace MonoGame.Extended.Entities private readonly List _markedEntities; private readonly Dictionary _componentPoolsByComponentTypeIndex; - private readonly Bag> _componentTypeEntitiesToComponents; + private readonly Bag> _entitiesToComponentsBag; private readonly List _componentsToRemove; private readonly Dictionary _componentTypes = new Dictionary(); @@ -82,7 +82,7 @@ namespace MonoGame.Extended.Entities _markedEntities = new List(); _componentPoolsByComponentTypeIndex = new Dictionary(); - _componentTypeEntitiesToComponents = new Bag>(); + _entitiesToComponentsBag = new Bag>(); _componentsToRemove = new List(); } @@ -108,6 +108,7 @@ namespace MonoGame.Extended.Entities EntityTemplate entityTemplate; _entityTemplatesByName.TryGetValue(name, out entityTemplate); + if (entityTemplate == null) throw new InvalidOperationException($"EntityTemplate '{name}' is not registered."); @@ -175,6 +176,7 @@ namespace MonoGame.Extended.Entities entity._group = group; Bag entities; + if (!_entitiesByGroup.TryGetValue(group, out entities)) { entities = new Bag(); @@ -228,8 +230,10 @@ namespace MonoGame.Extended.Entities Debug.Assert(entity != null); entity.WaitingToBeRemoved = true; + if (entity.WaitingToRefreshComponents) return; + entity.WaitingToRefreshComponents = true; _markedEntities.Add(entity); OnEntityRemoved(entity); @@ -283,50 +287,63 @@ namespace MonoGame.Extended.Entities EntityRemoved?.Invoke(entity); } - internal T AddComponent(Entity entity) where T : EntityComponent + internal T AddComponent(Entity entity, T component) where T : class + { + Debug.Assert(entity != null); + var type = typeof(T); + EntityComponentType entityComponentType; + + if (!_componentTypes.TryGetValue(type, out entityComponentType)) + _componentTypes[type] = entityComponentType = new EntityComponentType(type); + + return (T) AddComponent(entity, entityComponentType, component); + } + + internal T AddComponent(Entity entity) where T : class { Debug.Assert(entity != null); var componentType = GetComponentTypeFrom(typeof(T)); - return (T) AddComponent(entity, componentType); + return (T) AddComponent(entity, componentType, null); } - internal EntityComponent AddComponent(Entity entity, EntityComponentType componentType) + internal object AddComponent(Entity entity, EntityComponentType componentType, object component = null) { Debug.Assert(entity != null); Debug.Assert(componentType != null); - if (componentType.Index >= _componentTypeEntitiesToComponents.Capacity) - _componentTypeEntitiesToComponents[componentType.Index] = null; - var components = _componentTypeEntitiesToComponents[componentType.Index]; - if (components == null) - _componentTypeEntitiesToComponents[componentType.Index] = components = new Dictionary(); + if (componentType.Index >= _entitiesToComponentsBag.Capacity) + _entitiesToComponentsBag[componentType.Index] = null; - EntityComponent component; + var componentsByEntity = _entitiesToComponentsBag[componentType.Index]; - IComponentPool componentPool; - if (_componentPoolsByComponentTypeIndex.TryGetValue(componentType.Index, out componentPool)) + if (componentsByEntity == null) + _entitiesToComponentsBag[componentType.Index] = componentsByEntity = new Dictionary(); + + if (component == null) { - component = componentPool.New(); - if (component == null) - return null; - } - else - { - component = _dependencyResolver.Resolve(componentType.Type); + IComponentPool componentPool; + + if (_componentPoolsByComponentTypeIndex.TryGetValue(componentType.Index, out componentPool)) + { + component = componentPool.New(); + + if (component == null) + return null; + } + else + { + component = _dependencyResolver.Resolve(componentType.Type); + } } - component.Entity = entity; - components[entity] = component; - + componentsByEntity[entity] = component; entity.ComponentBits[componentType.Index] = true; - MarkEntityToBeRefreshed(entity); - return component; } - internal T GetComponent(Entity entity) where T : EntityComponent + internal T GetComponent(Entity entity) where T : class { Debug.Assert(entity != null); @@ -334,22 +351,23 @@ namespace MonoGame.Extended.Entities return (T)GetComponent(entity, componentType); } - internal EntityComponent GetComponent(Entity entity, EntityComponentType componentType) + internal object GetComponent(Entity entity, EntityComponentType componentType) { Debug.Assert(entity != null); Debug.Assert(componentType != null); - Debug.Assert(componentType.Index < _componentTypeEntitiesToComponents.Count); + Debug.Assert(componentType.Index < _entitiesToComponentsBag.Count); - var components = _componentTypeEntitiesToComponents[componentType.Index]; + var components = _entitiesToComponentsBag[componentType.Index]; - Debug.Assert(components != null); + if (components == null) + return null; - EntityComponent component; + object component; components.TryGetValue(entity, out component); return component; } - internal void MarkComponentToBeRemoved(Entity entity) where T : EntityComponent + internal void MarkComponentToBeRemoved(Entity entity) where T : class { Debug.Assert(entity != null); @@ -373,11 +391,11 @@ namespace MonoGame.Extended.Entities var pair = _componentsToRemove[i]; var entity = pair.Entity; var componentType = pair.ComponentType; - var components = _componentTypeEntitiesToComponents[componentType.Index]; + var components = _entitiesToComponentsBag[componentType.Index]; Debug.Assert(components != null); - EntityComponent component; + object component; if (!components.TryGetValue(entity, out component)) continue; @@ -385,7 +403,7 @@ namespace MonoGame.Extended.Entities MarkEntityToBeRefreshed(entity); components.Remove(entity); - component.Return(); + (component as IPoolable)?.Return(); } _componentsToRemove.Clear(); @@ -397,18 +415,18 @@ namespace MonoGame.Extended.Entities MarkEntityToBeRefreshed(entity); - for (var i = _componentTypeEntitiesToComponents.Count - 1; i >= 0; --i) + for (var i = _entitiesToComponentsBag.Count - 1; i >= 0; --i) { - var components = _componentTypeEntitiesToComponents[i]; + var components = _entitiesToComponentsBag[i]; Debug.Assert(components != null); - EntityComponent component; + object component; if (!components.TryGetValue(entity, out component)) continue; components.Remove(entity); - component.Return(); + (component as IPoolable)?.Return(); } } diff --git a/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs b/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs index 741d2b0a..7b70133b 100644 --- a/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs +++ b/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs @@ -80,9 +80,7 @@ namespace MonoGame.Extended.Entities } } - protected virtual void Process(GameTime gameTime, Entity entity) - { - } + protected abstract void Process(GameTime gameTime, Entity entity); protected bool IsInterestedIn(Entity entity) { diff --git a/Source/MonoGame.Extended.Entities/EntitySystem.cs b/Source/MonoGame.Extended.Entities/EntitySystem.cs index 6cdc5bda..907c62e7 100644 --- a/Source/MonoGame.Extended.Entities/EntitySystem.cs +++ b/Source/MonoGame.Extended.Entities/EntitySystem.cs @@ -44,11 +44,11 @@ namespace MonoGame.Extended.Entities { private TimeSpan _timer; - internal EntityComponentSystem Manager; + internal EntityComponentSystem EntityComponentSystem; public bool IsEnabled { get; set; } - public Game Game => Manager.Game; - public GraphicsDevice GraphicsDevice => Manager.GraphicsDevice; - public EntityManager EntityManager => Manager.EntityManager; + public Game Game => EntityComponentSystem.Game; + public GraphicsDevice GraphicsDevice => EntityComponentSystem.GraphicsDevice; + public EntityManager EntityManager => EntityComponentSystem.EntityManager; public TimeSpan ProcessingDelay { get; set; } diff --git a/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj b/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj index 971d00c9..9035c967 100644 --- a/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj +++ b/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj @@ -54,7 +54,6 @@ - @@ -69,7 +68,6 @@ - diff --git a/Source/MonoGame.Extended.Entities/SystemManager.cs b/Source/MonoGame.Extended.Entities/SystemManager.cs index 4f6015db..acb3a542 100644 --- a/Source/MonoGame.Extended.Entities/SystemManager.cs +++ b/Source/MonoGame.Extended.Entities/SystemManager.cs @@ -147,7 +147,7 @@ namespace MonoGame.Extended.Entities if (Systems.Contains(system)) throw new InvalidOperationException($"System '{systemType}' has already been added."); - system.Manager = _manager; + system.EntityComponentSystem = _manager; Systems.Add(system); diff --git a/Source/MonoGame.Extended.Entities/TransformComponent2D.cs b/Source/MonoGame.Extended.Entities/TransformComponent2D.cs deleted file mode 100644 index 9c87908e..00000000 --- a/Source/MonoGame.Extended.Entities/TransformComponent2D.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using Microsoft.Xna.Framework; - -namespace MonoGame.Extended.Entities -{ - [EntityComponent] - public class TransformComponent2D : EntityComponent, IMovable, IRotatable, IScalable - { - private TransformFlags _flags = TransformFlags.All; // dirty flags, set all dirty flags when created - private Matrix2D _localMatrix; // model space to local space - private TransformComponent2D _parent; // parent - private Matrix2D _worldMatrix; // local space to world space - private Vector2 _position; - private float _rotation; - private Vector2 _scale = Vector2.One; - - public Vector2 WorldPosition => WorldMatrix.Translation; - public Vector2 WorldScale => WorldMatrix.Scale; - public float WorldRotation => WorldMatrix.Rotation; - - public Vector2 Position - { - get { return _position; } - set - { - _position = value; - LocalMatrixBecameDirty(); - WorldMatrixBecameDirty(); - } - } - - public float Rotation - { - get { return _rotation; } - set - { - _rotation = value; - LocalMatrixBecameDirty(); - WorldMatrixBecameDirty(); - } - } - - public Vector2 Scale - { - get { return _scale; } - set - { - _scale = value; - LocalMatrixBecameDirty(); - WorldMatrixBecameDirty(); - } - } - - public Matrix2D LocalMatrix - { - get - { - RecalculateLocalMatrixIfNecessary(); - return _localMatrix; - } - } - - public Matrix2D WorldMatrix - { - get - { - RecalculateWorldMatrixIfNecessary(); - return _worldMatrix; - } - } - - public TransformComponent2D Parent - { - get { return _parent; } - set - { - if (_parent == value) - return; - - var oldParentTransform = Parent; - _parent = value; - OnParentChanged(oldParentTransform, value); - } - } - - internal event Action TransformBecameDirty; - - public override void Reset() - { - Parent = null; - _flags = TransformFlags.All; - _localMatrix = Matrix2D.Identity; - _worldMatrix = Matrix2D.Identity; - _position = Vector2.Zero; - _rotation = 0; - _scale = Vector2.One; - } - - public void GetLocalMatrix(out Matrix2D matrix) - { - RecalculateLocalMatrixIfNecessary(); - matrix = _localMatrix; - } - - public void GetWorldMatrix(out Matrix2D matrix) - { - RecalculateWorldMatrixIfNecessary(); - matrix = _worldMatrix; - } - - protected internal void LocalMatrixBecameDirty() - { - _flags |= TransformFlags.LocalMatrixIsDirty; - } - - protected internal void WorldMatrixBecameDirty() - { - _flags |= TransformFlags.WorldMatrixIsDirty; - TransformBecameDirty?.Invoke(); - } - - private void OnParentChanged(TransformComponent2D oldParent, TransformComponent2D newParent) - { - var parent = oldParent; - while (parent != null) - { - parent.TransformBecameDirty -= ParentOnTransformBecameDirty; - parent = parent.Parent; - } - - parent = newParent; - while (parent != null) - { - parent.TransformBecameDirty += ParentOnTransformBecameDirty; - parent = parent.Parent; - } - } - - private void ParentOnTransformBecameDirty() - { - _flags |= TransformFlags.All; - } - - private void RecalculateWorldMatrixIfNecessary() - { - if ((_flags & TransformFlags.WorldMatrixIsDirty) == 0) - return; - - RecalculateLocalMatrixIfNecessary(); - RecalculateWorldMatrix(ref _localMatrix, out _worldMatrix); - - _flags &= ~TransformFlags.WorldMatrixIsDirty; - } - - private void RecalculateLocalMatrixIfNecessary() - { - if ((_flags & TransformFlags.LocalMatrixIsDirty) == 0) - return; - - RecalculateLocalMatrix(out _localMatrix); - - _flags &= ~TransformFlags.LocalMatrixIsDirty; - WorldMatrixBecameDirty(); - } - - private void RecalculateWorldMatrix(ref Matrix2D localMatrix, out Matrix2D matrix) - { - if (Parent != null) - { - Parent.GetWorldMatrix(out matrix); - Matrix2D.Multiply(ref localMatrix, ref matrix, out matrix); - } - else - { - matrix = localMatrix; - } - } - - private void RecalculateLocalMatrix(out Matrix2D matrix) - { - matrix = Matrix2D.CreateScale(_scale) * - Matrix2D.CreateRotationZ(_rotation) * - Matrix2D.CreateTranslation(_position); - } - - [Flags] - private enum TransformFlags : byte - { - WorldMatrixIsDirty = 1 << 0, - LocalMatrixIsDirty = 1 << 1, - All = WorldMatrixIsDirty | LocalMatrixIsDirty - } - } -} diff --git a/Source/MonoGame.Extended/Collections/ObjectPool.cs b/Source/MonoGame.Extended/Collections/ObjectPool.cs index dd1f5201..dd0af384 100644 --- a/Source/MonoGame.Extended/Collections/ObjectPool.cs +++ b/Source/MonoGame.Extended/Collections/ObjectPool.cs @@ -15,7 +15,7 @@ namespace MonoGame.Extended.Collections public class ObjectPool : IEnumerable where T : class, IPoolable { - private ReturnToPoolDelegate _returnToPoolDelegate; + private readonly ReturnToPoolDelegate _returnToPoolDelegate; private readonly Deque _freeItems; // circular buffer for O(1) operations private T _headNode; // linked list for iteration diff --git a/Source/MonoGame.Extended.Entities/EntityComponentAttribute.cs b/Source/MonoGame.Extended/Entities/EntityComponentAttribute.cs similarity index 66% rename from Source/MonoGame.Extended.Entities/EntityComponentAttribute.cs rename to Source/MonoGame.Extended/Entities/EntityComponentAttribute.cs index da2b72ef..790e1fec 100644 --- a/Source/MonoGame.Extended.Entities/EntityComponentAttribute.cs +++ b/Source/MonoGame.Extended/Entities/EntityComponentAttribute.cs @@ -2,7 +2,7 @@ namespace MonoGame.Extended.Entities { - [AttributeUsage(AttributeTargets.Class, Inherited = false)] + [AttributeUsage(AttributeTargets.Class, Inherited = true)] public class EntityComponentAttribute : Attribute { } diff --git a/Source/MonoGame.Extended/MonoGame.Extended.csproj b/Source/MonoGame.Extended/MonoGame.Extended.csproj index 7cfdac70..8ae15407 100644 --- a/Source/MonoGame.Extended/MonoGame.Extended.csproj +++ b/Source/MonoGame.Extended/MonoGame.Extended.csproj @@ -41,6 +41,7 @@ + diff --git a/Source/MonoGame.Extended/Sprites/Sprite.cs b/Source/MonoGame.Extended/Sprites/Sprite.cs index 18059a2c..06f94faa 100644 --- a/Source/MonoGame.Extended/Sprites/Sprite.cs +++ b/Source/MonoGame.Extended/Sprites/Sprite.cs @@ -2,11 +2,13 @@ using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using MonoGame.Extended.Entities; using MonoGame.Extended.TextureAtlases; namespace MonoGame.Extended.Sprites { - public class Sprite : IColorable//, IRectangularF//, ISpriteBatchDrawable + [EntityComponent] + public class Sprite : IColorable { private TextureRegion2D _textureRegion; diff --git a/Source/MonoGame.Extended/Transform.cs b/Source/MonoGame.Extended/Transform.cs index 35aa1bc4..2eb577d4 100644 --- a/Source/MonoGame.Extended/Transform.cs +++ b/Source/MonoGame.Extended/Transform.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using Microsoft.Xna.Framework; +using MonoGame.Extended.Entities; namespace MonoGame.Extended { @@ -200,6 +201,7 @@ namespace MonoGame.Extended /// objects hierarchically. /// /// + [EntityComponent] public class Transform2D : BaseTransform, IMovable, IRotatable, IScalable { private Vector2 _position;