X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FHero.cpp;h=02c4dcc05b8e4fc8807f0d266e31d9652d539c14;hb=7651db1476453d8d4162e8708265a36c1a3c0441;hp=98b92ca2fdafbbef48bad6fa86216060b380bc75;hpb=06b6411e5dc8fc6b905530f7adbde8bd0c2bb0ea;p=l2e.git diff --git a/src/common/Hero.cpp b/src/common/Hero.cpp index 98b92ca..02c4dcc 100644 --- a/src/common/Hero.cpp +++ b/src/common/Hero.cpp @@ -7,10 +7,18 @@ #include "Hero.h" +#include "../graphics/Animation.h" +#include "../graphics/Sprite.h" +#include "../loader/Interpreter.h" #include "../loader/TypeDescription.h" +#include "../map/Entity.h" +using graphics::Animation; +using graphics::Sprite; using loader::FieldDescription; +using loader::Interpreter; using loader::TypeDescription; +using map::Entity; namespace common { @@ -35,9 +43,7 @@ Hero::Hero() , battleSprite(0) , meleeAnimation(0) , attackAnimation(0) -, spellAnimation(0) - -, mapSprite(0) { +, spellAnimation(0) { } @@ -60,34 +66,28 @@ void Hero::SubtractHealth(int amount) { void Hero::CreateTypeDescription() { Hero h; - 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("Hero")); + TypeDescription &td(TypeDescription::Create(TYPE_ID, "Hero")); td.SetConstructor(&Construct); td.SetSize(sizeof(Hero)); - td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), stringId, true)); + td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), Interpreter::STRING_ID).SetReferenced()); - td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), numberId, false)); - td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), numberId, false)); - td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), numberId, false)); - td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), numberId, false)); - td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), numberId, false)); + td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), Interpreter::NUMBER_ID)); + td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), Interpreter::NUMBER_ID)); + td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), Interpreter::NUMBER_ID)); + td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), Interpreter::NUMBER_ID)); + td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), Interpreter::NUMBER_ID)); - td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), statsId, false)); + td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), Stats::TYPE_ID)); - td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId, false)); + td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), Interpreter::NUMBER_ID)); - td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), spriteId, true)); - td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), animationId, true)); - td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId, true)); - td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId, true)); + td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), Sprite::TYPE_ID).SetReferenced().SetDescription("the sprite used for battle scenes")); + td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), Animation::TYPE_ID).SetReferenced().SetDescription("the animation played for physical attacks")); + td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), Animation::TYPE_ID).SetReferenced().SetDescription("the animation played for magical attacks")); + td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), Animation::TYPE_ID).SetReferenced().SetDescription("the animation played on attacked monsters when the hero has no weapon")); - td.AddField("mapSprite", FieldDescription(((char *)&h.mapSprite) - ((char *)&h), spriteId, true)); + td.AddField("mapEntity", FieldDescription(((char *)&h.mapEntity) - ((char *)&h), Entity::TYPE_ID).SetDescription("the entity representing the hero on maps")); } void Hero::Construct(void *data) {