First one uses templates.
Code: Select all
HealthComponetTemplate testtemplate = new HealthComponetTemplate("testTemplate");
HealthComponet test = new HealthComponet();
test.setIntialHealth(test::leg , 100);
testtemplate.setComponet(test);
entity.setComponet(entitymanager.getTemplate("testTemplate").object);
Code: Select all
HealthComponet test = new HealthComponet();
entity.setComponet(test);
Now from what i understand is what id do is use the entity itself and use the attached componets functions.
Code: Select all
if(entity.getComponet(test).type == "healthComponet"){
((HealthComponet*)entity.getComponet(test))->setHealth(0);
}