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.SetDescription("All data of a monster.");
66 td.SetConstructor(&Construct);
67 td.SetSize(sizeof(Monster));
69 td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId).SetReferenced());
70 td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId).SetReferenced());
71 td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId));
73 td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId));
74 td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId));
75 td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId));
76 td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId));
77 td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId));
79 td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId).SetReferenced());
80 td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId).SetReferenced());
81 td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId).SetReferenced());
84 void Monster::Construct(void *data) {