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

TBS Engine progress

Sign in to follow this  
Metron

787 views

I've implemented the template management for the entities within the TBS engine yesterday evening. Basically, templates are the blue print for the entities generated within the game. They hold the default values for entities. A default value for a unit would be "hitpoints" or "attackrange".

Since an template isn't any different (yet) to an entity, creating an entity from a template is as simple as this :

CEntity *pTemplate = oManager.GetTemplateWhere( "name", "Unit01" );
CEntity *pNewUnit = new CEntity(pTemplate);


This is how it's done now. The way it's implemented now has some problems :

a) You could get a template and then simply call oManager.AddEntity(pTemplate) which would push the template into the managed entities. This will result in mirroring the altered values within the "entity" into the template which is bad. Entities put into the entity management have only their reference counter increased.

b) You could be tempted to manually add new parameter to the template. This would lead to unclean code since you'll have to name parameters through strings within your code.

So I think that I'll implement a real template class instead of using the CEntity class as my template class. The template class then would have a create function to create a new instance of an entity.

Another thing I'll do is to return a CEntityList class instead of an AR::TDynArray. The new class would have exposed some search functions similar to the entity manager. The entity manager would be derived from the entity list. Why this ? Because I need to be able to have search functions for the lists I get back from the entity manager. If I don't have those functions, I'ld have to implement then within the game which would result in code duplication where it is not necessary.

A last thing I'm thinking of is the possibility to add categories to the entity management. This would either me a named category such as "units", "buildings" and "landmarks" (and others) or predefined enum values. For a complete data driven approach, the first way seems the way to go... I'll have to think about this.

The advantage of this approach is quite obvious : Speed up. When you have several hundreds or thousands of entities, it would take some ms to search through all entities to find thouse you need.

The new approach would also mean that I'll have to add new functions to the entity manager such as GetEntitiesFromCategory( "units" ) or GetEntitiesWhere( "units", "type", "vehicle" ).

And this would lead to a changement within the xml files you would do. Until now you're able to have a entity definition like this :




...




...





...




...


Now it would look more like this :




...



...






...



...



I have to think more about this but it seems to me that those "limitations" make sense to me.

What do you think about all this ? What is your point of view ? Am I going into the wrong direction ?
Sign in to follow this  


0 Comments


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!