Cleaned up Events, added events on species and variant changes.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-08-14 13:52:22 +02:00
parent c484c376c3
commit 64b08d4ff0
21 changed files with 249 additions and 121 deletions

View File

@@ -1,6 +1,7 @@
#include "Battle.hpp"
#include <Arbutils/Assert.hpp>
#include <memory>
#include "../EventHooks/EventDataClasses.hpp"
#include "../Flow/TurnHandler.hpp"
#include "../Flow/TurnOrdering.hpp"

View File

@@ -1,6 +1,6 @@
#include "BattleSide.hpp"
#include <algorithm>
#include "../../Library/Exceptions/CreatureException.hpp"
#include "../EventHooks/EventDataClasses.hpp"
#include "Battle.hpp"
using namespace CreatureLib::Battling;

View File

@@ -1,6 +1,7 @@
#include "Creature.hpp"
#include <algorithm>
#include <utility>
#include "../EventHooks/EventDataClasses.hpp"
#include "../Models/Battle.hpp"
#include "../ScriptHandling/ScriptMacros.hpp"
@@ -36,7 +37,6 @@ namespace CreatureLib::Battling {
AssertNotNull(species);
AssertNotNull(variant);
_species = species;
ChangeVariant(variant);
// If the creature is genderless, but it's new species is not, we want to set its gender
if (_gender != CreatureLib::Library::Gender::Genderless && _species->GetGenderRate() != -1) {
@@ -53,6 +53,10 @@ namespace CreatureLib::Battling {
else if (_species->GetGenderRate() == -1 && _gender != CreatureLib::Library::Gender::Genderless) {
_gender = CreatureLib::Library::Gender::Genderless;
}
if (_battle != nullptr) {
_battle->TriggerEventListener<ChangeSpeciesEvent>(this, _species);
}
ChangeVariant(variant);
}
void Creature::ChangeVariant(const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant) {
@@ -79,6 +83,10 @@ namespace CreatureLib::Battling {
}
// TODO: consider variant specific attacks?
if (_battle != nullptr) {
_battle->TriggerEventListener<ChangeVariantEvent>(this, _variant);
}
}
void Creature::ChangeLevelBy(int8_t amount) {