Component based entity system implementation?
Posted: Sun Sep 14, 2014 3:58 am
First of all, congratulations ES team for realizing your dream. You guys are the arguably the biggest inspiration for me and countless others. Do not ever give up.
Ok, so I've been roaming around the internet looking for actual code implementations (C++) of component based entity systems and so far I have found none. I understand the concept; you can attach components to a single 'Entity' class, and as soon as you do that a system will add the entity to a list of entities to be updated. For example you have a 'Render' component. You would do something like this:
Any help is greatly appreciated.
Ok, so I've been roaming around the internet looking for actual code implementations (C++) of component based entity systems and so far I have found none. I understand the concept; you can attach components to a single 'Entity' class, and as soon as you do that a system will add the entity to a list of entities to be updated. For example you have a 'Render' component. You would do something like this:
// UNTESTED PSUEDO-C++ CODE RenderComponentSystem rcs; Entity e; /* This will somehow add the RenderComponent to a vector(?) of pointers to the base 'Component' class. It will also add the entity to the RenderComponentSystem to be updated accordingly. */ e.attachComponent(static_cast<Component*>(new RenderComponent()), static_cast<ComponentSystem*>(&rcs)); // But how would you access that component? // e.components(RENDER_COMPONENT)->blah() ?Then you would have the issue of removing components. Perhaps the entity could store a pointer to the ComponentSystem for each Component, then update the system accordingly?
Any help is greatly appreciated.