Every thing in my game world is an Entity, Entity is not derived from anything and has no derived classes. What makes a projectile different from a player, different from an enemy, different from an inanimate object, is what that entity has. Each Entity has a list of components that it owns. Some components are graphical, some are physical, some are AI components, some are control components(takes player input), ect.
I'm trying to use inheritance as little as possible and use a data driven approach. Component is the only class currently that has any derived classes, the 4 I mentioned above. Entity types are defined in a txt file, which is as simple as listing a type name, which components that type has, and any raw values those components may need.
I have a EntityBuilder class that I want to work like this. It first reads that txt file and stores 1 of each type. Then when the worldManager needs a new anything, (projectile, enemy, box, ect.) it asks the Entitybuilder for a new Entity of "type x" Then the builder looks through it's list of types and and if it finds one that matches that type name it copies it and passes it to the worldManager. Entity and and each Component implement a copy function, so the EntityBuilder simply calls that copy function on the matching entity(which in turn calls it on each of its components). In this way I hope to be able to design new stuff for my game world without changing any code and just editing a txt file.
I'm not sure if there and actual question in there, maybe just looking for feedback. Also I'm a bit rusty with my design patterns, is this the a factory or prototype pattern?
Edited by Grain, 26 July 2013 - 03:54 PM.