WorldBuilder.cs 563 B

1234567891011121314151617181920212223242526
  1. using System.Collections.Generic;
  2. using MonoGame.Extended.ECS.Systems;
  3. namespace MonoGame.Extended.ECS
  4. {
  5. public class WorldBuilder
  6. {
  7. private readonly List<ISystem> _systems = new List<ISystem>();
  8. public WorldBuilder AddSystem(ISystem system)
  9. {
  10. _systems.Add(system);
  11. return this;
  12. }
  13. public World Build()
  14. {
  15. var world = new World();
  16. foreach (var system in _systems)
  17. world.RegisterSystem(system);
  18. return world;
  19. }
  20. }
  21. }