gohyperr / hecs

A high performance lightweight ECS with a plugin ecosystem!
MIT License
23 stars 1 forks source link

What are `order` and `active` properties of Systems? #11

Closed canadaduane closed 4 years ago

canadaduane commented 4 years ago

I see these properties in the LookAtSystem:

  active = IS_BROWSER
  order = Groups.Initialization

This looks interesting!

Does this imply HECS can work on both client and server? Does setting active = IS_BROWSER make the system inactive on the server?

What does setting the order of a System do? (What happens "at initialization" in the case of LookAtSystem?)

ashconnell commented 4 years ago

Yep Hecs also runs on the server!

The active field controls whether the system's update is called each frame. You can also change this on your own systems at runtime if needed.

For the LookAtSystem there's no point in it running because each client has everything it needs to update the rotation to look at another entity. Other systems like the RenderSystem, ShapeSystem, ModelSystem are all disabled on the server as they don't need to render or build meshes :)

The order field controls the order that systems run. Since plugins aren't aware of other plugin systems (and your own systems) we use some common enums to stamp where a system should run. You can also do things like order = Groups.Initialization - 10 to do "pre-initialization" etc. Unity DOTS works the same way: https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/system_update_order.html

canadaduane commented 4 years ago

Cool, thank you. Closing since this answers my questions.