I've done a bit of updating to my source-code for the component system. Among other things I added an event system that sides with the commands system. I also added in the necessary source from ClanLib, so that the code will compile straight out from the box (at least for those running VC++).
I made some touch ups to the main.cpp example that was mentioned on the last page. Sorry, I had totally forgotten it was there! I added a seperate project for it, but it's included in the SLN file under /Source/. Make sure you download the component system from here:
http://svn2.xp-dev.com/svn/Trefall-ComponentSystem
The new component system is under the /Source/ folder. The ClanLib extraction is under /ClanLibExtract/, the event/command system I've included in it's own project as well, to extract it from the EntityEngine sourcecode /EventEngine/, and then there's the test application under /TestEntity/.
The test app is very simple. It includes three components. Health, Claws and Explosive. I then start it up with this piece of code:
Code: Select all
void main()
{
EntityEngine::ComponentFactory factory;
ComponentRegistrator::Register(factory);
//Make a barrel
Object barrel(factory);
barrel.setName("Barrel");
barrel.setType("Barrel");
barrel.setId(1);
barrel.AddComponent("Health");
barrel.AddComponent("Explosive");
barrel.GetProperty<float>("Health") = 90.0f;
barrel.GetProperty<float>("MaxHealth") = 100.0f;
//Make a monster
Object monster(factory);
monster.setName("Monster");
monster.setType("Monster");
monster.setId(2);
monster.AddComponent("Health");
monster.AddComponent("Claws");
monster.GetProperty<float>("Health") = 100.0f;
monster.GetProperty<float>("MaxHealth") = 100.0f;
monster.setTarget(&barrel);
barrel.setTarget(&monster);
//Inflict some damage to our barrel!
monster.executeCommand(EventEngine::COMMAND_ATTACK_TARGET, NULL);
monster.executeCommand(EventEngine::COMMAND_ATTACK_TARGET_SPECIAL, NULL);
}