• Advertisement
Sign in to follow this  

A little design problem with my entitmanager, could anyone help?

This topic is 3765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have finished writting my entity manager. It is simple, I register some types to the entity manager and I get instances through pools. When the instanced is created it is added to an internal list, and will be updated every frame. So far, so good. But here I have ran into a little problem, and it is the initialization of the entities when created. I´m using a Init/End protocol but people using RAII will have some problem. I use a call to CEntityManager::CreateInstance<T>(String defining type, name of instance). This creates the instance the way I exposed before and Initializes it calling to the instance Init. Problem, all objects doesn´t have same signature in initialization. For example a visible object will have (name,mesh file), etc... The only way I have come across to fix this is having a Param class, to all params a entity needs to initialize, and change all entities init() to use this Param class, so when I call entitymanager to crate an instance I will do: ParamClass params; params["name"]="MyInstanceName"; params["mesh"]="MyMessFileName"; EntityMgr->Create<CCamera>("CAMERA",params); and internally the create will do a pObj->Init(params), and the camera init know s how to handle the params class. So, Is this a good solution? too much overenginiering, am I crazy? any other better solution?. Thanks in advance, NotBad.

Share this post


Link to post
Share on other sites
Advertisement
I don't have an answer, but i have the same problem kindof :)

At the moment i send a string containing parameters like "12 14 32 32 goblin.bmp" or something and let the init method use it as it wants(actually i'm using XML but its the same principle). I don't like it though. But it works as intended, so until someone tells me a better approach, it's there.

So i hope someone else has a better answer :) (bump)

Share this post


Link to post
Share on other sites
<opinion>
I think you're overdoing it a little. Do you really need a single "create" method?
</opinion>

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement