Split off initialization of Creature into new function that's not called in the constructor.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This has to do with specific implementations of stat calculator requiring an inherited type of the Creature class, and by calling it in the constructor casting to this inherited type will fail.
This commit is contained in:
parent
dd8d4d738d
commit
568232c7a5
|
@ -59,6 +59,8 @@ Creature* CreateCreature::Create() {
|
|||
auto kv = _attacks[i];
|
||||
attacks[i] = new LearnedAttack(std::get<0>(kv), std::get<1>(kv));
|
||||
}
|
||||
return new Creature(_library, species, variant, _level, experience, identifier, gender, _coloring, heldItem,
|
||||
auto c = new Creature(_library, species, variant, _level, experience, identifier, gender, _coloring, heldItem,
|
||||
_nickname, talent, attacks);
|
||||
c->Initialize();
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ Battling::Creature::Creature(const BattleLibrary* library, const Library::Creatu
|
|||
: _library(library), __Species(species), __Variant(variant), __Level(level), __Experience(experience),
|
||||
__UniqueIdentifier(uid), __Gender(gender), __Coloring(coloring), __HeldItem(heldItem),
|
||||
_nickname(std::move(nickname)), _talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
|
||||
RecalculateFlatStats();
|
||||
__CurrentHealth = GetBoostedStat(Core::Statistic::Health);
|
||||
_activeTalent = _library->LoadScript(ScriptResolver::ScriptCategory::Talent, GetActiveTalent());
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
};
|
||||
|
||||
virtual void Initialize() {
|
||||
RecalculateFlatStats();
|
||||
__CurrentHealth = GetBoostedStat(Core::Statistic::Health);
|
||||
}
|
||||
|
||||
void SetBattleData(Battle* battle, BattleSide* side);
|
||||
Battle* GetBattle() const;
|
||||
BattleSide* GetBattleSide() const;
|
||||
|
|
Loading…
Reference in New Issue