Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


I've been working on my TBS Engine yesterday evening and I'm progressing quite well. I've implemented some more access functions to the entity manager I've written and have tested them. I've also added functions to load entities from an xml file.

The core of my entities are parameters. There is nothing that really specialises my entities. It's a bunch of paramters. I had to write some classes to manage those parameters.

I have a class called CParameter which contains one parameter. It's identified by its name and a value, which can either be a string or a float value. There's a function in this class which can load/save the name/value from/to an xml file. The xml structure of a parameter looks like this :

The first one is a string value parameter while the second one is a float value.

Since it doesn't make to only have one parameter, I've created the CParameterList class. This class also has I/O functions to load/save parameter lists from/to an xml file. There are also functions to find a parameter given its name. So you could do something like this :

CParameterList oParamList;
CParameter *pParam = oParamList.Find( "type" );

This code snipped would return the first parameter of the above shown xml file structure.

The third class I've created is the CParameterized class, where classes who can have parameters are derived from. It has a function to access the parameter list and I/O functions that pass to the CParameterList I/O functions. It's possible to have named parameter lists (more than one parameter list) but this option is not yet fully implemented.

My CEntity class is derived from the CParameterized class. This enabled my CEntityManager class to find entities by looking an the parameters. A possible access would look like this :

CEntityManager oManager;

// Access entities by a param/value pair.
AR::TDynArray apAllBuildings = oManager.GetEntityWhere( "type", "building" );
AR::TDynArray apAllUnits = oManager.GetEntityWhere( "type", "units" );
AR::TDynArray apAllVehicles = oManager.GetEntityWhere( "subtype", "vehicles" );

// or access all entities having a given parameter.
AR::TDynArray apAllEntitiesWithBonusValue = oManager.GetEntityWith( "bonus" );

I did some tests and it works all as expected : Fast and simple.

One thing I have to think of is the templates. I would like to have templates which are the base of an entity that has to be created. It's solvable through either having a parameter that will automatically filter out entities with a given parameter name or though a seperate template management within the CEntityManager class. I think I prefer the second option since it's more easy to implement and more intuitive.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!