Adds support for changing talent by its hash, adds support for loading scripts by their name hash.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
782e9b90a8
commit
e3c997af31
|
@ -48,4 +48,9 @@ ArbUt::OptionalUniquePtr<BattleScript> BattleLibrary::LoadScript(const ArbUt::Op
|
|||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) const {
|
||||
return _scriptResolver->LoadScript(owner, category, scriptName).TakeOwnership();
|
||||
}
|
||||
}
|
||||
ArbUt::OptionalUniquePtr<BattleScript> BattleLibrary::LoadScriptByHash(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
u32 scriptNameHash) const {
|
||||
return _scriptResolver->LoadScriptByHash(owner, category, scriptNameHash).TakeOwnership();
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ namespace CreatureLib::Battling {
|
|||
[[nodiscard]] ArbUt::OptionalUniquePtr<BattleScript> LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) const;
|
||||
[[nodiscard]] ArbUt::OptionalUniquePtr<BattleScript>
|
||||
LoadScriptByHash(const ArbUt::OptionalBorrowedPtr<void>& owner, ScriptCategory category,
|
||||
u32 scriptNameHash) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -273,6 +273,15 @@ namespace CreatureLib::Battling {
|
|||
_overridenTalent = _library->GetStaticLib()->GetTalentLibrary()->Get(talent);
|
||||
}
|
||||
|
||||
void Creature::OverrideActiveTalentByHash(u32 talentHash) {
|
||||
_hasOverridenTalent = true;
|
||||
if (_activeTalent.HasValue()) {
|
||||
_activeTalent.GetValue()->OnRemove();
|
||||
_activeTalent = this->_library->LoadScriptByHash(this, ScriptCategory::Talent, talentHash).TakeOwnership();
|
||||
}
|
||||
_overridenTalent = _library->GetStaticLib()->GetTalentLibrary()->GetByHash(talentHash);
|
||||
}
|
||||
|
||||
void Creature::SetType(u8 index, u8 type) noexcept {
|
||||
if (_types.Count() > index) {
|
||||
_types[index] = type;
|
||||
|
|
|
@ -163,6 +163,7 @@ namespace CreatureLib::Battling {
|
|||
void Heal(u32 amount, bool canRevive = false);
|
||||
void RestoreAllAttackUses() noexcept;
|
||||
void OverrideActiveTalent(const ArbUt::StringView& talent);
|
||||
void OverrideActiveTalentByHash(u32 talentHash);
|
||||
void AddExperience(u32 amount);
|
||||
|
||||
void MarkOpponentAsSeen(ArbUt::BorrowedPtr<Creature> creature) { _battleData.SeenOpponents.insert(creature); }
|
||||
|
|
|
@ -18,9 +18,20 @@ namespace CreatureLib::Battling {
|
|||
virtual ~ScriptResolver() = default;
|
||||
|
||||
virtual void Initialize([[maybe_unused]] BattleLibrary* non_null library){};
|
||||
virtual ArbUt::OptionalUniquePtr<BattleScript>
|
||||
LoadScript([[maybe_unused]] const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
[[maybe_unused]] ScriptCategory category, [[maybe_unused]] const ArbUt::StringView& scriptName) {
|
||||
virtual ArbUt::OptionalUniquePtr<BattleScript> LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) {
|
||||
(void)owner;
|
||||
(void)category;
|
||||
(void)scriptName;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual ArbUt::OptionalUniquePtr<BattleScript> LoadScriptByHash(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category, u32 scriptNameHash) {
|
||||
(void)owner;
|
||||
(void)category;
|
||||
(void)scriptNameHash;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue