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.

112 lines
4.4KB

  1. systems do not hold component data, but only system states
  2. systems cannot be injected
  3. systems are SRP and OCP
  4. systems communicates between component, mediators, producer/consumer, Svelto.ECS.Example.Observers. producer/consumer and observers must be defined in the layer of the engine.
  5. systems can have injected dependencies
  6. components don't have logic
  7. components can have only getter and setter
  8. components cannot define patterns that requires logic.
  9. components cannot issues commands
  10. High Cohesion[edit]
  11. Main article: Cohesion (computer science)
  12. High Cohesion is an evaluative pattern that attempts to keep objects appropriately focused, manageable and understandable. High cohesion is generally used in support of Low Coupling. High cohesion means that the responsibilities of a given element are strongly related and highly focused. Breaking programs into classes and subsystems is an example of activities that increase the cohesive properties of a system. Alternatively, low cohesion is a situation in which a given element has too many unrelated responsibilities. Elements with low cohesion often suffer from being hard to comprehend, hard to reuse, hard to maintain and averse to change.[3]
  13. Low Coupling[edit]
  14. Main article: Loose coupling
  15. Low Coupling is an evaluative pattern, which dictates how to assign responsibilities to support:
  16. lower dependency between the classes,
  17. change in one class having lower impact on other classes,
  18. higher reuse potential.
  19. events, observers and mediators have the inconvience to hold the reference to the engine, which forces to use cleanup if the engine must be removed.
  20. Observers are easy to clean up from the engine. Mediators needs to be integrated to the framework to be simple to clean up. Component events need the clean up function.
  21. producer/consumer has the inconvienent to force check the number of jobs available everyframe
  22. Engine can't be removed, they can only be disabled, but the logic of disabling must be handled by the engine itself
  23. Should components have just one element? Should engines use just nodes? Components are ditacted by the entities and Nodes by the engines
  24. http://thelinuxlich.github.io/artemis_CSharp/
  25. differences: components no events, everthing must be update
  26. give more responsabiltiy to the user, semplicity
  27. https://github.com/sschmid/Entitas-CSharp/wiki/Overview
  28. no groups, no queries
  29. http://entity-systems.wikidot.com/es-articles
  30. http://www.ashframework.org/
  31. it's very important to give a namespace to the engines. In this way it's impossible to create semantically wrong nodes (PlayerNode Vs TargetNode)
  32. ToDo:
  33. it's not safe to remove an engine without having called being denitialised internal states. A special ClearOnRemove function must be added for each engine
  34. namespace GameFramework.RayCast
  35. {
  36. public class RayCastEngineEngine
  37. {
  38. public RayCastEngine(RayCastEmployer jobList)
  39. {
  40. jobList.onJobassigned += OnRaycastRequested;
  41. }
  42. public void Add(IComponent obj)
  43. {}
  44. public void Remove(IComponent obj)
  45. {}
  46. void OnRaycastRequested(RayCastJob job)
  47. {
  48. RaycastHit shootHit;
  49. Physics.Raycast(job.rayVector, out shootHit, job.range, _enemyMask);
  50. job.Done(shootHit);
  51. }
  52. RayCastEmployer _employer;
  53. int _enemyMask;
  54. }
  55. public struct RayCastJob
  56. {
  57. readonly public Ray rayVector;
  58. readonly public float range;
  59. readonly public Action<RaycastHit> Done;
  60. public RayCastJob(Ray direction, float distance, Action<RaycastHit> OnDone)
  61. {
  62. rayVector = direction;
  63. range = distance;
  64. Done = OnDone;
  65. }
  66. }
  67. public class RayCastEmployer
  68. {
  69. public event Action<RayCastJob> onJobassigned;
  70. public void AssignJob(RayCastJob data, Action<RaycastHit> onJobdone)
  71. {
  72. onJobassigned(data);
  73. }
  74. }
  75. }
  76. if your code can be read as
  77. A tells B to do something is direct
  78. A register B event is indirect
  79. althoggh if B tells A something through event is direct again. B must say something like I don't know who you are, but this just happened. you say B.SomethingHappenedToMe() not B.YouMustDoThis();
  80. un engine non deve mai avere concetti di un altro engine. dire all'engine sonoro suona morte � sbagliato. � l'engine death che triggera l'evento e l'engine sound ad ascoltarlo.