entityset.adoc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. = EntitySets
  2. :author:
  3. :revnumber:
  4. :revdate: 2016/03/17 20:48
  5. :relfileprefix: ../../../
  6. :imagesdir: ../../..
  7. ifdef::env-github,env-browser[:outfilesuffix: .adoc]
  8. == Introduction
  9. 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.
  10. This leads to a unique design of the components and the introduction to Entity Sets.
  11. == Why EntitySets?
  12. One huge benefit of Zay-ES is that you are able to create a separate class for each job.
  13. This leads to clean code and you always know which class is responsible for bugs.
  14. For example you can have a class for Collision, Movement, Enemies, PlayerInput,….
  15. All of these classes are only interested in entities which have special components.
  16. == How to use them
  17. === Create an EntitySet
  18. [source,java]
  19. ----
  20. //This set is interested in entities with a TestComponent
  21. EntitySet entitySet = entityData.getEntities(TestComponent.class);
  22. ----
  23. === Update an EntitySet
  24. [source,java]
  25. ----
  26. //Apply all new changes to the EntitySet and return false if nothing changed
  27. if(entitySet.applyChanges())
  28. {
  29. entitySet.getAddedEntities();
  30. entitySet.getChangedEntities();
  31. entitySet.getRemovedEntities();
  32. }
  33. ----