From 21dcf2d39db6ce3f2b10903019a01191ee50e148 Mon Sep 17 00:00:00 2001 From: sebas77 Date: Sat, 27 Jan 2018 18:12:21 +0000 Subject: [PATCH] Breaking change: the Sequencer now accept int and not enum to avoid boxing improve sequencer code add comments --- .../Context/Factories/GameObjectFactory.cs | 10 ++++----- Svelto.ECS/ECS/Sequencer.cs | 21 ++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Svelto.ECS/Context/Factories/GameObjectFactory.cs b/Svelto.ECS/Context/Factories/GameObjectFactory.cs index ecd3350..9b73f0a 100644 --- a/Svelto.ECS/Context/Factories/GameObjectFactory.cs +++ b/Svelto.ECS/Context/Factories/GameObjectFactory.cs @@ -39,17 +39,17 @@ namespace Svelto.Context return go; } - /// - /// Register a prefab to be built later using a string ID. - /// - /// original prefab - virtual public GameObject Build(GameObject prefab) + public virtual GameObject Build(GameObject prefab) { var copy = Object.Instantiate(prefab) as GameObject; return copy; } + /// + /// Register a prefab to be built later using a string ID. + /// + /// original prefab public void RegisterPrefab(GameObject prefab, string prefabName, GameObject parent = null) { var objects = new GameObject[2]; diff --git a/Svelto.ECS/ECS/Sequencer.cs b/Svelto.ECS/ECS/Sequencer.cs index c554429..52fad56 100644 --- a/Svelto.ECS/ECS/Sequencer.cs +++ b/Svelto.ECS/ECS/Sequencer.cs @@ -1,14 +1,25 @@ using System; -using Steps = System.Collections.Generic.Dictionary>; +using System.Collections.Generic; namespace Svelto.ECS { + public class Steps : Dictionary> + {} + + public class To : Dictionary + { + public void Add(IStep engine) + { + Add(Condition.always, new [] {engine}); + } + } + public interface IStep { } public interface IStep:IStep { - void Step(ref T token, Enum condition); + void Step(ref T token, int condition); } public class Sequencer @@ -23,7 +34,7 @@ namespace Svelto.ECS Next(engine, ref param, Condition.always); } - public void Next(IEngine engine, ref T param, Enum condition) + public void Next(IEngine engine, ref T param, int condition) { var tos = _steps[engine]; var steps = tos[condition]; @@ -37,8 +48,8 @@ namespace Svelto.ECS } //you can inherit from Condition and add yours - public enum Condition + public class Condition { - always + public const int always = 0; } } \ No newline at end of file