Trigger OnRemove on a Creatures scripts when it gets switched out.

This commit is contained in:
Deukhoofd 2021-11-19 13:49:19 +01:00
parent a570e90f67
commit 364bac7de7
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 2 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include "BattleSide.hpp"
#include "../EventHooks/EventDataClasses.hpp"
#include "Battle.hpp"
#include "../ScriptHandling/ScriptMacros.hpp"
using namespace CreatureLib::Battling;
@ -52,6 +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);
old.GetValue()->SetOnBattleField(false);
}
_creatures[index] = creature;