Adds OnSwitchIn hook.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-19 15:36:48 +01:00
parent a78b2e54a4
commit aaadbfb4f2
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,7 @@
#include "BattleSide.hpp"
#include "../EventHooks/EventDataClasses.hpp"
#include "Battle.hpp"
#include "../ScriptHandling/ScriptMacros.hpp"
#include "Battle.hpp"
using namespace CreatureLib::Battling;
@ -53,7 +53,7 @@ void BattleSide::SetChoice(BaseTurnChoice* choice) {
void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, uint8_t index) {
auto old = _creatures[index];
if (old.HasValue()) {
HOOK(OnRemove, this);
HOOK(OnRemove, old.GetValue());
old.GetValue()->SetOnBattleField(false);
}
_creatures[index] = creature;
@ -75,6 +75,7 @@ void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, uint
}
}
_battle->TriggerEventListener<SwitchEvent>(CreatureIndex(this->_index, index), creature.GetValue());
HOOK(OnSwitchIn, creature.GetValue(), creature.GetValue());
}
bool BattleSide::CreatureOnSide(const ArbUt::BorrowedPtr<Creature>& creature) const {

View File

@ -108,6 +108,7 @@ namespace CreatureLib::Battling {
virtual void OnEndTurn(){};
virtual void OnFaint(Creature*, DamageSource){};
virtual void OnSwitchIn(Creature*){};
};
}