diff --git a/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs b/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs index 6c37cb4b..e4b87010 100644 --- a/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs +++ b/Source/MonoGame.Extended.Entities/EntityComponentSystem.cs @@ -73,7 +73,7 @@ namespace MonoGame.Extended.Entities .ToList(); var systemTypes = exportedTypes - .Where(t => typeof(EntitySystem).GetTypeInfo().IsAssignableFrom(t)) + .Where(t => typeof(ProcessingSystem).GetTypeInfo().IsAssignableFrom(t)) .ToList(); var templateTypes = exportedTypes @@ -210,7 +210,7 @@ namespace MonoGame.Extended.Entities if (systemAttribute == null) return; - var system = _dependencyResolver.Resolve(typeInfo.AsType()); + var system = _dependencyResolver.Resolve(typeInfo.AsType()); var processingSystem = system as EntityProcessingSystem; if (processingSystem != null) diff --git a/Source/MonoGame.Extended.Entities/EntityManager.cs b/Source/MonoGame.Extended.Entities/EntityManager.cs index b2a61024..61a6ef68 100644 --- a/Source/MonoGame.Extended.Entities/EntityManager.cs +++ b/Source/MonoGame.Extended.Entities/EntityManager.cs @@ -428,6 +428,7 @@ namespace MonoGame.Extended.Entities components.Remove(entity); (component as IPoolable)?.Return(); + (component as IDisposable)?.Dispose(); } } diff --git a/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs b/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs index 741d2b0a..6c590576 100644 --- a/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs +++ b/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs @@ -39,7 +39,7 @@ using Microsoft.Xna.Framework; namespace MonoGame.Extended.Entities { - public abstract class EntityProcessingSystem : EntitySystem + public abstract class EntityProcessingSystem : ProcessingSystem { protected EntityProcessingSystem() { @@ -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/MonoGame.Extended.Entities.csproj b/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj index 1331f3ee..b4a7c08b 100644 --- a/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj +++ b/Source/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj @@ -69,7 +69,7 @@ - + diff --git a/Source/MonoGame.Extended.Entities/EntitySystem.cs b/Source/MonoGame.Extended.Entities/ProcessingSystem.cs similarity index 98% rename from Source/MonoGame.Extended.Entities/EntitySystem.cs rename to Source/MonoGame.Extended.Entities/ProcessingSystem.cs index 907c62e7..49d615f1 100644 --- a/Source/MonoGame.Extended.Entities/EntitySystem.cs +++ b/Source/MonoGame.Extended.Entities/ProcessingSystem.cs @@ -40,7 +40,7 @@ using Microsoft.Xna.Framework.Graphics; namespace MonoGame.Extended.Entities { - public abstract class EntitySystem + public abstract class ProcessingSystem { private TimeSpan _timer; @@ -52,7 +52,7 @@ namespace MonoGame.Extended.Entities public TimeSpan ProcessingDelay { get; set; } - protected EntitySystem() + protected ProcessingSystem() { IsEnabled = true; _timer = TimeSpan.Zero; diff --git a/Source/MonoGame.Extended.Entities/SystemManager.cs b/Source/MonoGame.Extended.Entities/SystemManager.cs index acb3a542..15a1010e 100644 --- a/Source/MonoGame.Extended.Entities/SystemManager.cs +++ b/Source/MonoGame.Extended.Entities/SystemManager.cs @@ -63,7 +63,7 @@ namespace MonoGame.Extended.Entities private readonly SystemLayer _dummyLayer; private bool _hasInitialized; - internal List Systems; + internal List Systems; internal List ProcessingSystems; internal SystemManager(EntityComponentSystem manager) @@ -72,7 +72,7 @@ namespace MonoGame.Extended.Entities _updateLayers = new SystemLayer[0]; _drawLayers = new SystemLayer[0]; _dummyLayer = new SystemLayer(); - Systems = new List(); + Systems = new List(); ProcessingSystems = new List(); } @@ -116,7 +116,7 @@ namespace MonoGame.Extended.Entities } } - private static void ProcessSystemsSynchronous(GameTime gameTime, Bag systems) + private static void ProcessSystemsSynchronous(GameTime gameTime, Bag systems) { Debug.Assert(systems != null); @@ -132,14 +132,14 @@ namespace MonoGame.Extended.Entities // Parallel.ForEach(systems, system => system.ProcessInternal()); //} - internal T AddSystem(T system, GameLoopType gameLoopType, int layer, SystemExecutionType executionType) where T : EntitySystem + internal T AddSystem(T system, GameLoopType gameLoopType, int layer, SystemExecutionType executionType) where T : ProcessingSystem { Debug.Assert(system != null); return (T)AddSystem(system.GetType(), system, gameLoopType, layer, executionType); } - private EntitySystem AddSystem(Type systemType, EntitySystem system, GameLoopType gameLoopType, int layer, SystemExecutionType executionType) + private ProcessingSystem AddSystem(Type systemType, ProcessingSystem system, GameLoopType gameLoopType, int layer, SystemExecutionType executionType) { Debug.Assert(systemType != null); Debug.Assert(system != null); @@ -174,7 +174,7 @@ namespace MonoGame.Extended.Entities return system; } - private void AddSystemTo(ref SystemLayer[] layers, EntitySystem system, int layerIndex, SystemExecutionType executionType) + private void AddSystemTo(ref SystemLayer[] layers, ProcessingSystem system, int layerIndex, SystemExecutionType executionType) { Debug.Assert(layers != null); @@ -210,14 +210,14 @@ namespace MonoGame.Extended.Entities { public int LayerIndex; - public readonly Bag SynchronousSystems; + public readonly Bag SynchronousSystems; //public readonly Bag AsynchronousSystems; public SystemLayer(int layerIndex = 0) { LayerIndex = layerIndex; //AsynchronousSystems = new Bag(); - SynchronousSystems = new Bag(); + SynchronousSystems = new Bag(); } public int CompareTo(SystemLayer other) diff --git a/Source/MonoGame.Extended/ShapeExtensions.cs b/Source/MonoGame.Extended/ShapeExtensions.cs index 0866f425..8cb9432f 100644 --- a/Source/MonoGame.Extended/ShapeExtensions.cs +++ b/Source/MonoGame.Extended/ShapeExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MonoGame.Extended.Shapes; @@ -47,13 +48,13 @@ namespace MonoGame.Extended /// The points to connect with lines /// The color to use /// The thickness of the lines - public static void DrawPolygon(this SpriteBatch spriteBatch, Vector2 offset, Vector2[] points, Color color, + public static void DrawPolygon(this SpriteBatch spriteBatch, Vector2 offset, IReadOnlyList points, Color color, float thickness = 1f) { - if (points.Length == 0) + if (points.Count == 0) return; - if (points.Length == 1) + if (points.Count == 1) { DrawPoint(spriteBatch, points[0], color, (int) thickness); return; @@ -61,10 +62,10 @@ namespace MonoGame.Extended var texture = GetTexture(spriteBatch); - for (var i = 0; i < points.Length - 1; i++) + for (var i = 0; i < points.Count - 1; i++) DrawPolygonEdge(spriteBatch, texture, points[i] + offset, points[i + 1] + offset, color, thickness); - DrawPolygonEdge(spriteBatch, texture, points[points.Length - 1] + offset, points[0] + offset, color, + DrawPolygonEdge(spriteBatch, texture, points[points.Count - 1] + offset, points[0] + offset, color, thickness); } diff --git a/Source/MonoGame.Extended/Transform.cs b/Source/MonoGame.Extended/Transform.cs index 5f3ccb10..03985136 100644 --- a/Source/MonoGame.Extended/Transform.cs +++ b/Source/MonoGame.Extended/Transform.cs @@ -310,5 +310,9 @@ namespace MonoGame.Extended Matrix2.CreateTranslation(_position); } + public override string ToString() + { + return $"Position: {Position}, Rotation: {Rotation}, Scale: {Scale}"; + } } } \ No newline at end of file