mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-22 03:39:45 +02:00
Added overloaded version of getObjectHandler to CGHeroInstance
This commit is contained in:
parent
184d8de82e
commit
ad7f0416a7
@ -370,7 +370,7 @@ void CGameStateCampaign::replaceHeroesPlaceholders()
|
||||
heroToPlace->tempOwner = heroPlaceholder->tempOwner;
|
||||
heroToPlace->setAnchorPos(heroPlaceholder->anchorPos());
|
||||
heroToPlace->setHeroType(heroToPlace->getHeroTypeID());
|
||||
heroToPlace->appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, heroToPlace->getHeroTypeID())->getTemplates().front();
|
||||
heroToPlace->appearance = heroToPlace->getObjectHandler()->getTemplates().front();
|
||||
|
||||
gameState->map->removeBlockVisTiles(heroPlaceholder, true);
|
||||
gameState->map->objects[heroPlaceholder->id.getNum()] = nullptr;
|
||||
|
@ -339,12 +339,20 @@ void CGHeroInstance::initHero(vstd::RNG & rand, const HeroTypeID & SUBID)
|
||||
initHero(rand);
|
||||
}
|
||||
|
||||
TObjectTypeHandler CGHeroInstance::getObjectHandler() const
|
||||
{
|
||||
if (ID == Obj::HERO)
|
||||
return VLC->objtypeh->getHandlerFor(ID, getHeroClass()->getIndex());
|
||||
else // prison or random hero
|
||||
return VLC->objtypeh->getHandlerFor(ID, 0);
|
||||
}
|
||||
|
||||
void CGHeroInstance::initHero(vstd::RNG & rand)
|
||||
{
|
||||
assert(validTypes(true));
|
||||
|
||||
if (ID == Obj::HERO)
|
||||
appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, getHeroClass()->getIndex())->getTemplates().front();
|
||||
appearance = getObjectHandler()->getTemplates().front();
|
||||
|
||||
if(!vstd::contains(spells, SpellID::PRESET))
|
||||
{
|
||||
|
@ -307,6 +307,8 @@ public:
|
||||
std::string getHoverText(PlayerColor player) const override;
|
||||
std::string getMovementPointsTextIfOwner(PlayerColor player) const;
|
||||
|
||||
TObjectTypeHandler getObjectHandler() const override;
|
||||
|
||||
void afterAddToMap(CMap * map) override;
|
||||
void afterRemoveFromMap(CMap * map) override;
|
||||
|
||||
|
@ -360,8 +360,11 @@ void CGObjectInstance::serializeJson(JsonSerializeFormat & handler)
|
||||
//only save here, loading is handled by map loader
|
||||
if(handler.saving)
|
||||
{
|
||||
handler.serializeString("type", typeName);
|
||||
handler.serializeString("subtype", subTypeName);
|
||||
std::string ourTypeName = getTypeName();
|
||||
std::string ourSubtypeName = getSubtypeName();
|
||||
|
||||
handler.serializeString("type", ourTypeName);
|
||||
handler.serializeString("subtype", ourSubtypeName);
|
||||
|
||||
handler.serializeInt("x", pos.x);
|
||||
handler.serializeInt("y", pos.y);
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
std::optional<AudioPath> getVisitSound(vstd::RNG & rng) const;
|
||||
std::optional<AudioPath> getRemovalSound(vstd::RNG & rng) const;
|
||||
|
||||
TObjectTypeHandler getObjectHandler() const;
|
||||
virtual TObjectTypeHandler getObjectHandler() const;
|
||||
|
||||
/** VIRTUAL METHODS **/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user