I'm trying to get my head around component based entity design.
My first step was to create various components that could be added to an object. For every component type i had a manager, which would call every component's update function, passing in things like keyboard state etc. as required.
The next thing i did was remove the object, and just have each component with an Id. So an object is defined by components having the same Ids.
Now, i'm thinking that i don't need a manager for all my components, for example i have a SizeComponent
, which just has a Size
property). As a result the SizeComponent
doesn't have an update method, and the manager's update method does nothing.
My first thought was to have an ObjectProperty
class which components could query, instead of having them as properties of components. So an object would have a number of ObjectProperty
and ObjectComponent
. Components would have update logic that queries the object for properties. The manager would manage calling the component's update method.
This seems like over-engineering to me, but i don't think i can get rid of the components, because i need a way for the managers to know what objects need what component logic to run (otherwise i'd just remove the component completely and push its update logic into the manager).
- Is this (having
ObjectProperty
,ObjectComponent
andComponentManager
classes) over-engineering? - What would be a good alternative?
SizeComponent
is overkill - you can assume that most objects have a size - it's things like rendering, AI and physics where the component model is used; Size will always behave the same - so you can share that code. \$\endgroup\$RenderingComponent
and aPhysicsComponent
. Am i over-thinking the decision of where to put the property? Should i just stick it in either, then have the other query an object for the component that has the needed property? \$\endgroup\$PhysicalStateInstance
(one per object) alongside aGravityPhysicsShared
(one per game); however I am tempted to say this is venturing into the realms of architects euphoria, don't architect yourself into a hole (exactly what I did with my first component system). KISS. \$\endgroup\$