3 #include "../common/Stats.h"
4 #include "../graphics/Animation.h"
5 #include "../graphics/Sprite.h"
6 #include "../loader/Interpreter.h"
7 #include "../loader/TypeDescription.h"
8 #include "../math/Vector.h"
11 using graphics::Animation;
12 using graphics::Sprite;
13 using loader::FieldDescription;
14 using loader::Interpreter;
15 using loader::TypeDescription;
48 void Monster::SubtractHealth(int amount) {
49 if (amount > Health()) {
57 void Monster::CreateTypeDescription() {
60 TypeDescription &td(TypeDescription::Create(TYPE_ID, "Monster"));
61 td.SetDescription("All data of a monster.");
62 td.SetConstructor(&Construct);
63 td.SetSize(sizeof(Monster));
65 td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), Interpreter::STRING_ID).SetReferenced());
66 td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), Sprite::TYPE_ID).SetReferenced());
67 td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), Interpreter::NUMBER_ID));
69 td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), Interpreter::NUMBER_ID));
70 td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), Interpreter::NUMBER_ID));
71 td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), Interpreter::NUMBER_ID));
72 td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), Interpreter::NUMBER_ID));
73 td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), Stats::TYPE_ID));
75 td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
76 td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
77 td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
80 void Monster::Construct(void *data) {