Adds support for removing volatile script by its hash, checking if Creature has attack by hash.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2022-05-28 11:24:16 +02:00
parent c208394d18
commit 6f0e664e74
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 14 additions and 2 deletions

View File

@ -99,7 +99,7 @@ namespace CreatureLib::Battling {
BattleScript* non_null AddVolatileScript(const ArbUt::StringView& key); BattleScript* non_null AddVolatileScript(const ArbUt::StringView& key);
BattleScript* non_null AddVolatileScript(BattleScript* non_null script); BattleScript* non_null AddVolatileScript(BattleScript* non_null script);
void RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); } void RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); }
void RemoveVolatileScript(u32 keyHash) { _volatile.Remove(keyHash); } void RemoveVolatileScriptByHash(u32 keyHash) { _volatile.Remove(keyHash); }
void RemoveVolatileScript(BattleScript* non_null script); void RemoveVolatileScript(BattleScript* non_null script);
bool HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); } bool HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }
bool HasVolatileScript(u32 keyHash) const { return _volatile.Has(keyHash); } bool HasVolatileScript(u32 keyHash) const { return _volatile.Has(keyHash); }

View File

@ -116,7 +116,7 @@ namespace CreatureLib::Battling {
BattleScript* non_null AddVolatileScript(const ArbUt::StringView& key); BattleScript* non_null AddVolatileScript(const ArbUt::StringView& key);
BattleScript* non_null AddVolatileScript(BattleScript* non_null script); BattleScript* non_null AddVolatileScript(BattleScript* non_null script);
void RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); } void RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); }
void RemoveVolatileScript(u32 keyHash) { _volatile.Remove(keyHash); } void RemoveVolatileScriptByHash(u32 keyHash) { _volatile.Remove(keyHash); }
void RemoveVolatileScript(BattleScript* non_null script); void RemoveVolatileScript(BattleScript* non_null script);
bool HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); } bool HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }
bool HasVolatileScript(u32 keyHash) const { return _volatile.Has(keyHash); } bool HasVolatileScript(u32 keyHash) const { return _volatile.Has(keyHash); }

View File

@ -400,6 +400,7 @@ namespace CreatureLib::Battling {
BattleScript* Creature::AddVolatileScript(BattleScript* script) { return _volatile.Add(script); } BattleScript* Creature::AddVolatileScript(BattleScript* script) { return _volatile.Add(script); }
void Creature::RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); } void Creature::RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); }
void Creature::RemoveVolatileScriptByHash(u32 nameHash) { _volatile.Remove(nameHash); }
void Creature::RemoveVolatileScript(BattleScript* script) { _volatile.Remove(script->GetName()); } void Creature::RemoveVolatileScript(BattleScript* script) { _volatile.Remove(script->GetName()); }
bool Creature::HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); } bool Creature::HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }
void Creature::AddAttack(LearnedAttack* attack) { void Creature::AddAttack(LearnedAttack* attack) {

View File

@ -177,6 +177,7 @@ namespace CreatureLib::Battling {
BattleScript* non_null AddVolatileScript(const ArbUt::StringView& name); BattleScript* non_null AddVolatileScript(const ArbUt::StringView& name);
BattleScript* non_null AddVolatileScript(BattleScript* non_null script); BattleScript* non_null AddVolatileScript(BattleScript* non_null script);
void RemoveVolatileScript(const ArbUt::BasicStringView& name); void RemoveVolatileScript(const ArbUt::BasicStringView& name);
void RemoveVolatileScriptByHash(u32 nameHash);
void RemoveVolatileScript(BattleScript* non_null script); void RemoveVolatileScript(BattleScript* non_null script);
bool HasVolatileScript(const ArbUt::BasicStringView& name) const; bool HasVolatileScript(const ArbUt::BasicStringView& name) const;
@ -191,6 +192,16 @@ namespace CreatureLib::Battling {
return false; return false;
} }
bool HasAttackByHash(u32 nameHash) {
for (auto& a : _attacks) {
if (a == nullptr)
continue;
if (a->GetAttack()->GetName().GetHash() == nameHash)
return true;
}
return false;
}
ArbUt::OptionalBorrowedPtr<const Library::CreatureSpecies> GetDisplaySpecies() const noexcept; ArbUt::OptionalBorrowedPtr<const Library::CreatureSpecies> GetDisplaySpecies() const noexcept;
ArbUt::OptionalBorrowedPtr<const Library::SpeciesVariant> GetDisplayVariant() const noexcept; ArbUt::OptionalBorrowedPtr<const Library::SpeciesVariant> GetDisplayVariant() const noexcept;