From 2107d5b9a89dde23d6717f923c05ab7f5c07de14 Mon Sep 17 00:00:00 2001 From: Dylan Wilson Date: Fri, 1 Dec 2017 23:26:38 +1000 Subject: [PATCH] more ecs stuff --- Source/MonoGame.Extended.Entities/Entity.cs | 2 +- Source/MonoGame.Extended.Entities/EntityManager.cs | 3 ++- .../MonoGame.Extended.Entities/EntityProcessingSystem.cs | 4 +++- Source/MonoGame.Extended/Transform.cs | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/MonoGame.Extended.Entities/Entity.cs b/Source/MonoGame.Extended.Entities/Entity.cs index f8facf6d..c35f0122 100644 --- a/Source/MonoGame.Extended.Entities/Entity.cs +++ b/Source/MonoGame.Extended.Entities/Entity.cs @@ -166,7 +166,7 @@ namespace MonoGame.Extended.Entities public override string ToString() { - return $"{RuntimeHelpers.GetHashCode(this):X8}"; + return $"{RuntimeHelpers.GetHashCode(this):X8} {Name}"; } void IPoolable.Initialize(ReturnToPoolDelegate returnDelegate) diff --git a/Source/MonoGame.Extended.Entities/EntityManager.cs b/Source/MonoGame.Extended.Entities/EntityManager.cs index f38bff99..41d6777b 100644 --- a/Source/MonoGame.Extended.Entities/EntityManager.cs +++ b/Source/MonoGame.Extended.Entities/EntityManager.cs @@ -91,9 +91,10 @@ namespace MonoGame.Extended.Entities return new Entity(_systemManager.ProcessingSystems.Count, _componentTypes.Count); } - public Entity CreateEntity() + public Entity CreateEntity(string name = null) { var entity = _pool.New(); + entity.Name = name; MarkEntityToBeAdded(entity); return entity; } diff --git a/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs b/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs index 7b70133b..741d2b0a 100644 --- a/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs +++ b/Source/MonoGame.Extended.Entities/EntityProcessingSystem.cs @@ -80,7 +80,9 @@ namespace MonoGame.Extended.Entities } } - protected abstract void Process(GameTime gameTime, Entity entity); + protected virtual void Process(GameTime gameTime, Entity entity) + { + } protected bool IsInterestedIn(Entity entity) { diff --git a/Source/MonoGame.Extended/Transform.cs b/Source/MonoGame.Extended/Transform.cs index 2eb577d4..6f9f29cc 100644 --- a/Source/MonoGame.Extended/Transform.cs +++ b/Source/MonoGame.Extended/Transform.cs @@ -208,6 +208,13 @@ namespace MonoGame.Extended private float _rotation; private Vector2 _scale = Vector2.One; + public Transform2D(Vector2? position = null, float rotation = 0, Vector2? scale = null) + { + Position = position ?? Vector2.Zero; + Rotation = rotation; + Scale = scale ?? Vector2.One; + } + /// /// Gets the world position. ///