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() {
57 TypeDescription &td(TypeDescription::CreateOrGet("Monster"));
59 td.SetSize(sizeof(Monster));
61 int animationId(TypeDescription::GetTypeId("Animation"));
62 int numberId(TypeDescription::GetTypeId("Number"));
63 int spriteId(TypeDescription::GetTypeId("Sprite"));
64 int statsId(TypeDescription::GetTypeId("Stats"));
65 int stringId(TypeDescription::GetTypeId("String"));
67 td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId, true));
68 td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId, true));
69 td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId, false));
71 td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId, false));
72 td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId, false));
73 td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId, false));
74 td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId, false));
75 td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId, false));
77 td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId, true));
78 td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId, true));
79 td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId, true));