entityset.adoc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. = EntitySets
  2. :revnumber: 2.0
  3. :revdate: 2020/07/27
  4. == Introduction
  5. One difference between Zay-ES and other Entity Systems is that you are allowed to access the system from various threads. This can give your game a huge performance boost because costly tasks can easily be separated out into their own thread.
  6. This leads to a unique design of the components and the introduction to Entity Sets.
  7. == Why EntitySets?
  8. One huge benefit of Zay-ES is that you are able to create a separate class for each job.
  9. This leads to clean code and you always know which class is responsible for bugs.
  10. For example you can have a class for Collision, Movement, Enemies, PlayerInput,….
  11. All of these classes are only interested in entities which have special components.
  12. == How to use them
  13. === Create an EntitySet
  14. [source,java]
  15. ----
  16. //This set is interested in entities with a TestComponent
  17. EntitySet entitySet = entityData.getEntities(TestComponent.class);
  18. ----
  19. === Update an EntitySet
  20. [source,java]
  21. ----
  22. //Apply all new changes to the EntitySet and return false if nothing changed
  23. if(entitySet.applyChanges())
  24. {
  25. entitySet.getAddedEntities();
  26. entitySet.getChangedEntities();
  27. entitySet.getRemovedEntities();
  28. }
  29. ----