Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0KB

  1. using System;
  2. using Steps = System.Collections.Generic.Dictionary<Svelto.ECS.IEngine, System.Collections.Generic.Dictionary<System.Enum, Svelto.ECS.IStep[]>>;
  3. namespace Svelto.ECS
  4. {
  5. public interface IStep
  6. { }
  7. public interface IStep<T>:IStep
  8. {
  9. void Step(ref T token, Enum condition);
  10. }
  11. public class Sequencer
  12. {
  13. public void SetSequence(Steps steps)
  14. {
  15. _steps = steps;
  16. }
  17. public void Next<T>(IEngine engine, ref T param)
  18. {
  19. Next(engine, ref param, Condition.always);
  20. }
  21. public void Next<T>(IEngine engine, ref T param, Enum condition)
  22. {
  23. var tos = _steps[engine];
  24. var steps = tos[condition];
  25. if (steps != null)
  26. for (int i = 0; i < steps.Length; i++)
  27. ((IStep<T>)steps[i]).Step(ref param, condition);
  28. }
  29. Steps _steps;
  30. }
  31. //you can inherit from Condition and add yours
  32. public enum Condition
  33. {
  34. always
  35. }
  36. }