From aaadbfb4f2f9abf5c4524421bf8291b48db77fdf Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 19 Nov 2021 15:36:48 +0100 Subject: [PATCH] Adds OnSwitchIn hook. --- src/Battling/Models/BattleSide.cpp | 5 +++-- src/Battling/ScriptHandling/BattleScript.hpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Battling/Models/BattleSide.cpp b/src/Battling/Models/BattleSide.cpp index 245746a..189680b 100644 --- a/src/Battling/Models/BattleSide.cpp +++ b/src/Battling/Models/BattleSide.cpp @@ -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, 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, uint } } _battle->TriggerEventListener(CreatureIndex(this->_index, index), creature.GetValue()); + HOOK(OnSwitchIn, creature.GetValue(), creature.GetValue()); } bool BattleSide::CreatureOnSide(const ArbUt::BorrowedPtr& creature) const { diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index ec785d0..8304f27 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -108,6 +108,7 @@ namespace CreatureLib::Battling { virtual void OnEndTurn(){}; virtual void OnFaint(Creature*, DamageSource){}; + virtual void OnSwitchIn(Creature*){}; }; }