Renamed Script --> BattleScript, some cleanup on it.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -10,14 +10,17 @@ namespace CreatureLib::Battling {
|
||||
class ExecutingAttack;
|
||||
class Creature;
|
||||
|
||||
class Script {
|
||||
class BattleScript {
|
||||
public:
|
||||
virtual ~Script() = default;
|
||||
BattleScript() = default;
|
||||
NO_COPY_OR_MOVE(BattleScript);
|
||||
|
||||
virtual ~BattleScript() = default;
|
||||
|
||||
virtual void Stack(){};
|
||||
virtual void OnRemove(){};
|
||||
|
||||
virtual const ArbUt::StringView& GetName() const noexcept = 0;
|
||||
[[nodiscard]] virtual const ArbUt::StringView& GetName() const noexcept = 0;
|
||||
|
||||
virtual void
|
||||
OnInitialize([[maybe_unused]] const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
|
||||
@@ -37,31 +40,31 @@ namespace CreatureLib::Battling {
|
||||
[[maybe_unused]] bool* outResult){};
|
||||
virtual void OnAttackMiss([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target){};
|
||||
virtual void ChangeAttackType([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitNumber, [[maybe_unused]] uint8_t* outType){};
|
||||
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] u8* outType){};
|
||||
virtual void ChangeEffectiveness([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitNumber, [[maybe_unused]] float* effectiveness){};
|
||||
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] float* effectiveness){};
|
||||
|
||||
virtual void OverrideBasePower([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] uint8_t* basePower){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] u8* basePower){};
|
||||
virtual void ChangeDamageStatsUser([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] Creature** statsUser){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] Creature** statsUser){};
|
||||
|
||||
virtual void BypassDefensiveStat([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] bool* bypass){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] bool* bypass){};
|
||||
virtual void BypassOffensiveStat([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] bool* bypass){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] bool* bypass){};
|
||||
virtual void ModifyStatModifier([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] float* modifier){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] float* modifier){};
|
||||
virtual void ModifyDamageModifier([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] float* modifier){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] float* modifier){};
|
||||
virtual void OverrideDamage([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
||||
[[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] uint32_t* damage){};
|
||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] u32* damage){};
|
||||
|
||||
virtual void PreventSecondaryEffects([[maybe_unused]] const ExecutingAttack* attack,
|
||||
[[maybe_unused]] Creature* target, [[maybe_unused]] uint8_t hitNumber,
|
||||
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber,
|
||||
[[maybe_unused]] bool* outResult){};
|
||||
virtual void OnSecondaryEffect([[maybe_unused]] const ExecutingAttack* attack,
|
||||
[[maybe_unused]] Creature* target, [[maybe_unused]] uint8_t hitNumber){};
|
||||
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber){};
|
||||
|
||||
virtual void OnAfterHits([[maybe_unused]] const ExecutingAttack* attack, [[maybe_unused]] Creature* target){};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CREATURELIB_SCRIPTAGGREGATOR_HPP
|
||||
#define CREATURELIB_SCRIPTAGGREGATOR_HPP
|
||||
|
||||
#include "Script.hpp"
|
||||
#include "BattleScript.hpp"
|
||||
#include "ScriptSet.hpp"
|
||||
#include "ScriptWrapper.hpp"
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
inline bool HasNext() { return _index < _size; }
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<Script>> GetNextNotNull() {
|
||||
std::optional<ArbUt::BorrowedPtr<BattleScript>> GetNextNotNull() {
|
||||
while (HasNext()) {
|
||||
auto s = GetNext();
|
||||
return s;
|
||||
@@ -53,7 +53,7 @@ namespace CreatureLib::Battling {
|
||||
return {};
|
||||
}
|
||||
|
||||
ArbUt::BorrowedPtr<Script> GetNext() {
|
||||
ArbUt::BorrowedPtr<BattleScript> GetNext() {
|
||||
auto& current = _scripts[_index];
|
||||
if (!current.IsSet()) {
|
||||
auto s = current.GetScript();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CREATURELIB_SCRIPTRESOLVER_HPP
|
||||
#define CREATURELIB_SCRIPTRESOLVER_HPP
|
||||
|
||||
#include "Script.hpp"
|
||||
#include "BattleScript.hpp"
|
||||
#include "ScriptCategory.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
@@ -12,8 +12,8 @@ namespace CreatureLib::Battling {
|
||||
virtual ~ScriptResolver() = default;
|
||||
|
||||
virtual void Initialize([[maybe_unused]] BattleLibrary* library){};
|
||||
virtual Script* LoadScript([[maybe_unused]] ScriptCategory category,
|
||||
[[maybe_unused]] const ArbUt::StringView& scriptName) {
|
||||
virtual BattleScript* LoadScript([[maybe_unused]] ScriptCategory category,
|
||||
[[maybe_unused]] const ArbUt::StringView& scriptName) {
|
||||
return nullptr;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#define CREATURELIB_SCRIPTSET_HPP
|
||||
|
||||
#include <any>
|
||||
#include "Script.hpp"
|
||||
#include "BattleScript.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class ScriptSet {
|
||||
ArbUt::UniquePtrList<Script> _scripts;
|
||||
ArbUt::UniquePtrList<BattleScript> _scripts;
|
||||
ArbUt::Dictionary<uint32_t, size_t> _lookup;
|
||||
|
||||
public:
|
||||
@@ -15,7 +15,7 @@ namespace CreatureLib::Battling {
|
||||
static constexpr size_t defaultCapacity = 8;
|
||||
ScriptSet() : _scripts(defaultCapacity), _lookup(defaultCapacity){};
|
||||
|
||||
void Add(Script* script) {
|
||||
void Add(BattleScript* script) {
|
||||
auto v = _lookup.TryGet(script->GetName());
|
||||
if (v.has_value()) {
|
||||
_scripts[v.value()]->Stack();
|
||||
@@ -27,11 +27,11 @@ namespace CreatureLib::Battling {
|
||||
_lookup.Insert(script->GetName(), _scripts.Count() - 1);
|
||||
}
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<Script>> Get(const ArbUt::BasicStringView& key) const {
|
||||
std::optional<ArbUt::BorrowedPtr<BattleScript>> Get(const ArbUt::BasicStringView& key) const {
|
||||
return Get(key.GetHash());
|
||||
}
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<Script>> Get(uint32_t keyHash) const noexcept {
|
||||
std::optional<ArbUt::BorrowedPtr<BattleScript>> Get(uint32_t keyHash) const noexcept {
|
||||
auto v = _lookup.TryGet(keyHash);
|
||||
if (v.has_value()) {
|
||||
return _scripts[v.value()];
|
||||
@@ -66,7 +66,7 @@ namespace CreatureLib::Battling {
|
||||
|
||||
inline size_t Count() const { return _scripts.Count(); }
|
||||
|
||||
inline const ArbUt::UniquePtrList<Script>& GetIterator() const { return _scripts; }
|
||||
inline const ArbUt::UniquePtrList<BattleScript>& GetIterator() const { return _scripts; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CREATURELIB_SCRIPTWRAPPER_HPP
|
||||
#define CREATURELIB_SCRIPTWRAPPER_HPP
|
||||
|
||||
#include "Script.hpp"
|
||||
#include "BattleScript.hpp"
|
||||
#include "ScriptSet.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
@@ -9,20 +9,20 @@ namespace CreatureLib::Battling {
|
||||
bool _isSet;
|
||||
|
||||
union {
|
||||
std::unique_ptr<Script> const* _script;
|
||||
std::unique_ptr<BattleScript> const* _script;
|
||||
const ScriptSet* _scriptSet;
|
||||
};
|
||||
|
||||
ScriptWrapper(std::unique_ptr<Script>* s, bool isSet) : _isSet(isSet), _script(s){};
|
||||
ScriptWrapper(std::unique_ptr<BattleScript>* s, bool isSet) : _isSet(isSet), _script(s){};
|
||||
ScriptWrapper(ScriptSet* s, bool isSet) : _isSet(isSet), _scriptSet(s){};
|
||||
|
||||
public:
|
||||
static inline ScriptWrapper FromScript(std::unique_ptr<Script>* s) { return ScriptWrapper(s, false); }
|
||||
static inline ScriptWrapper FromScript(std::unique_ptr<BattleScript>* s) { return ScriptWrapper(s, false); }
|
||||
static inline ScriptWrapper FromSet(ScriptSet* s) { return ScriptWrapper(s, true); }
|
||||
|
||||
inline bool IsSet() const noexcept { return _isSet; }
|
||||
|
||||
inline const std::unique_ptr<Script>* GetScript() const noexcept { return _script; }
|
||||
inline const std::unique_ptr<BattleScript>* GetScript() const noexcept { return _script; }
|
||||
inline const ScriptSet* GetScriptSet() const noexcept { return _scriptSet; }
|
||||
|
||||
inline bool HasValue() const noexcept {
|
||||
|
||||
Reference in New Issue
Block a user