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.

41 lines
990B

  1. using UnityEngine;
  2. namespace Svelto.ES
  3. {
  4. public class UnityEnginesRoot : INodeEnginesRoot
  5. {
  6. public void AddEngine(IEngine engine)
  7. {
  8. _engineRoot.AddEngine(engine);
  9. }
  10. public void Add(INode node)
  11. {
  12. _engineRoot.Add(node);
  13. }
  14. public void Remove(INode node)
  15. {
  16. _engineRoot.Remove(node);
  17. }
  18. public void AddGameObjectEntity(GameObject entity)
  19. {
  20. INodeHolder[] nodeHolders = entity.GetComponents<INodeHolder>();
  21. for (int i = 0; i < nodeHolders.Length; i++)
  22. nodeHolders[i].engineRoot = this;
  23. }
  24. public void RemoveGameObjectEntity(GameObject entity)
  25. {
  26. INodeHolder[] nodeHolders = entity.GetComponents<INodeHolder>();
  27. for (int i = 0; i < nodeHolders.Length; i++)
  28. Remove(nodeHolders[i].node);
  29. }
  30. EnginesRoot _engineRoot = new EnginesRoot();
  31. }
  32. }