jeudi 1 janvier 2015

Managers/Systems design in Entity based systems [on hold]

I was wondering how a Entity system/Manager for a certain group of entities/components can be designed.


Considering Unity3D architecture for below scenarios(but it should hold for general cases as well). [Please just read the text in bold if you feel it lengthy post.]


Edit: Manager here I meant the one which manages group of similar components. For example Physics Manager which is responsible for resolving the collisions with in the engine.


Approach 1


"Manager as a Component" - Considering Components are just for holding data if it has a Manager


Group all similar components/Entities under one manager(Component Manager/Entity Manager) and update those components from the Managers update.


Pros :



We don't need to update data of each component individually as we can just send data to its manager, which will deliver to its children(i.e, components which it is managing)




ex: ParallaxManager.Move(directionOfMovement); //Which moves all the parallax layers in the specified direction.


Cons :



We are not using the Update() method of the components which are under that manager. (Is it wrong to think this way? as I see component should update on its own from Update)


Unity's basic managers like - Physics,Input are derived from Object instead of Component which creates some confusion in choosing this approach.


Confusion of having when to have update method overridden and when not to have it overridden in components.



Approach 2


"Making Manager as a Component but just to update the components with the data they may need"



ex: ParallaxManager.SetDirection(directionOfMovement);


Pros:



This approach leaves the components to call Update method themselves which is a normal behaviour of a component.



Cons:



We need to make sure this Manager's Update will be running ahead of all the other components its holding which i see is not intuitive(yes changing execution order I see its not straight forward approach - Anyone can correct me on this pls.)



Approach 3


Creating all Managers just derive from Object.


Pros:



Following similar to Unity's Manager classes



Cons :



Every task should be a component is violated.


No proper sign on where we can update all these managers similar to what unity does.



I would really appreciate if anyone can give a clear and standard approach to follow. I might be wrong in some statements, please feel free to correct me anywhere.


Aucun commentaire:

Enregistrer un commentaire