X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FMonster.cpp;h=0088c7935856f817ebdd05015f287635c46c6be7;hb=e518ac67cf94e244df16078dcbc536e6b659e758;hp=dd653383a5151132777e1f6ef6ddb6fb568e680f;hpb=46d158b25b842d2ec4b9734af09ca6006c934498;p=l2e.git diff --git a/src/battle/Monster.cpp b/src/battle/Monster.cpp index dd65338..0088c79 100644 --- a/src/battle/Monster.cpp +++ b/src/battle/Monster.cpp @@ -1,15 +1,16 @@ -/* - * Monster.cpp - * - * Created on: Aug 3, 2012 - * Author: holy - */ - #include "Monster.h" +#include "../common/Stats.h" +#include "../graphics/Animation.h" +#include "../graphics/Sprite.h" +#include "../loader/Interpreter.h" #include "../loader/TypeDescription.h" +using common::Stats; +using graphics::Animation; +using graphics::Sprite; using loader::FieldDescription; +using loader::Interpreter; using loader::TypeDescription; namespace battle { @@ -55,28 +56,28 @@ void Monster::SubtractHealth(int amount) { void Monster::CreateTypeDescription() { Monster m; - int animationId(TypeDescription::GetTypeId("Animation")); - int numberId(TypeDescription::GetTypeId("Number")); - int spriteId(TypeDescription::GetTypeId("Sprite")); - int statsId(TypeDescription::GetTypeId("Stats")); - int stringId(TypeDescription::GetTypeId("String")); - - TypeDescription &td(TypeDescription::CreateOrGet("Monster")); + TypeDescription &td(TypeDescription::Create(TYPE_ID, "Monster")); + td.SetDescription("All data of a monster."); + td.SetConstructor(&Construct); td.SetSize(sizeof(Monster)); - td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId, true)); - td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId, true)); - td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId, false)); + td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), Interpreter::STRING_ID).SetReferenced()); + td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), Sprite::TYPE_ID).SetReferenced()); + td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), Interpreter::NUMBER_ID)); - td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId, false)); - td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId, false)); - td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId, false)); - td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId, false)); - td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId, false)); + td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), Interpreter::NUMBER_ID)); + td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), Interpreter::NUMBER_ID)); + td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), Interpreter::NUMBER_ID)); + td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), Interpreter::NUMBER_ID)); + td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), Stats::TYPE_ID)); + + td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced()); + td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced()); + td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced()); +} - td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId, true)); - td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId, true)); - td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId, true)); +void Monster::Construct(void *data) { + new (data) Monster; } }