More work on setting owner of a script.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -167,7 +167,7 @@ BattleScript* Battle::AddVolatileScript(const ArbUt::StringView& key) {
|
||||
script.GetValue()->Stack();
|
||||
return script.GetValue();
|
||||
}
|
||||
script = _library->LoadScript(ScriptCategory::Battle, key);
|
||||
script = _library->LoadScript(this, ScriptCategory::Battle, key);
|
||||
if (!script.HasValue()) {
|
||||
THROW("Invalid volatile script requested for battle: '" << key.c_str() << "'.");
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ BattleScript* BattleSide::AddVolatileScript(const ArbUt::StringView& key) {
|
||||
script.GetValue()->Stack();
|
||||
return script.GetValue();
|
||||
}
|
||||
script = _battle->GetLibrary()->LoadScript(ScriptCategory::Side, key);
|
||||
script = _battle->GetLibrary()->LoadScript(this, ScriptCategory::Side, key);
|
||||
if (!script.HasValue()) {
|
||||
THROW("Invalid volatile script requested for battleside: '" << key.c_str() << "'.");
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace CreatureLib::Battling {
|
||||
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem),
|
||||
_nickname(std::move(nickname)), _talentIndex(talent), _hasOverridenTalent(false), _attacks(attacks),
|
||||
_allowedExperienceGain(allowedExperienceGain) {
|
||||
_activeTalent = std::unique_ptr<BattleScript>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
|
||||
_activeTalent =
|
||||
std::unique_ptr<BattleScript>(_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent()));
|
||||
for (auto t : _variant->GetTypes()) {
|
||||
_types.push_back(t);
|
||||
}
|
||||
@@ -60,7 +61,8 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
|
||||
// Grab the new active talent.
|
||||
_activeTalent = std::unique_ptr<BattleScript>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
|
||||
_activeTalent =
|
||||
std::unique_ptr<BattleScript>(_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent()));
|
||||
|
||||
// We modify the health of the creature by the change in its max health.
|
||||
auto prevHealth = GetBoostedStat(CreatureLib::Library::Statistic::Health);
|
||||
@@ -214,7 +216,7 @@ namespace CreatureLib::Battling {
|
||||
_hasOverridenTalent = true;
|
||||
if (_activeTalent != nullptr) {
|
||||
_activeTalent->OnRemove();
|
||||
_activeTalent.reset(this->_library->LoadScript(ScriptCategory::Talent, talent));
|
||||
_activeTalent.reset(this->_library->LoadScript(this, ScriptCategory::Talent, talent));
|
||||
}
|
||||
_overridenTalentName = talent;
|
||||
}
|
||||
@@ -295,7 +297,7 @@ namespace CreatureLib::Battling {
|
||||
script.GetValue()->Stack();
|
||||
return script.GetValue();
|
||||
}
|
||||
script = this->_library->LoadScript(ScriptCategory::Creature, name);
|
||||
script = this->_library->LoadScript(this, ScriptCategory::Creature, name);
|
||||
if (!script.HasValue()) {
|
||||
THROW("Invalid volatile script requested for creature: '" << name.c_str() << "'.");
|
||||
}
|
||||
@@ -384,7 +386,8 @@ void CreatureLib::Battling::Creature::SetStatus(const ArbUt::StringView& name) {
|
||||
if (_status != nullptr) {
|
||||
_status->OnRemove();
|
||||
}
|
||||
_status = std::unique_ptr<CreatureLib::Battling::BattleScript>(_library->LoadScript(ScriptCategory::Status, name));
|
||||
_status =
|
||||
std::unique_ptr<CreatureLib::Battling::BattleScript>(_library->LoadScript(this, ScriptCategory::Status, name));
|
||||
if (_battleData.Battle.HasValue()) {
|
||||
_battleData.Battle.GetValue()->TriggerEventListener<StatusChangeEvent>(this, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user