4 * Created on: Aug 3, 2012
10 #include "../loader/TypeDescription.h"
12 using loader::FieldDescription;
13 using loader::TypeDescription;
46 void Monster::SubtractHealth(int amount) {
47 if (amount > Health()) {
55 void Monster::CreateTypeDescription() {
58 int animationId(TypeDescription::GetTypeId("Animation"));
59 int numberId(TypeDescription::GetTypeId("Number"));
60 int spriteId(TypeDescription::GetTypeId("Sprite"));
61 int statsId(TypeDescription::GetTypeId("Stats"));
62 int stringId(TypeDescription::GetTypeId("String"));
64 TypeDescription &td(TypeDescription::CreateOrGet("Monster"));
65 td.SetConstructor(&Construct);
66 td.SetSize(sizeof(Monster));
68 td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId, true));
69 td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId, true));
70 td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId, false));
72 td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId, false));
73 td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId, false));
74 td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId, false));
75 td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId, false));
76 td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId, false));
78 td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId, true));
79 td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId, true));
80 td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId, true));
83 void Monster::Construct(void *data) {