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.

46 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 Sequencer()
  14. {}
  15. public void SetSequence(Steps steps)
  16. {
  17. _steps = steps;
  18. }
  19. public void Next<T>(IEngine engine, ref T param)
  20. {
  21. Next(engine, ref param, Condition.always);
  22. }
  23. public void Next<T>(IEngine engine, ref T param, Enum condition)
  24. {
  25. var tos = _steps[engine];
  26. var steps = tos[condition];
  27. if (steps != null)
  28. for (int i = 0; i < steps.Length; i++)
  29. ((IStep<T>)steps[i]).Step(ref param, condition);
  30. }
  31. Steps _steps;
  32. }
  33. public enum Condition
  34. {
  35. always
  36. }
  37. }