Support for suppressing a script, so that it temporarily does not function.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
53c27d35b6
commit
9ede453587
|
@ -17,12 +17,16 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
class BattleScript {
|
class BattleScript {
|
||||||
ArbUt::OptionalBorrowedPtr<void> _owner;
|
ArbUt::OptionalBorrowedPtr<void> _owner;
|
||||||
|
size_t _suppressed = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BattleScript(const ArbUt::OptionalBorrowedPtr<void>& owner) { _owner = owner; };
|
BattleScript(const ArbUt::OptionalBorrowedPtr<void>& owner) { _owner = owner; };
|
||||||
NO_COPY_OR_MOVE(BattleScript);
|
NO_COPY_OR_MOVE(BattleScript);
|
||||||
|
|
||||||
inline ArbUt::OptionalBorrowedPtr<void> GetOwner() const noexcept { return _owner; }
|
inline ArbUt::OptionalBorrowedPtr<void> GetOwner() const noexcept { return _owner; }
|
||||||
|
inline bool IsSuppressed() const noexcept { return _suppressed > 0; }
|
||||||
|
inline void Suppress() { _suppressed++; }
|
||||||
|
inline void Unsuppress() { _suppressed--; }
|
||||||
|
|
||||||
virtual ~BattleScript() = default;
|
virtual ~BattleScript() = default;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
auto aggregator = (source)->GetScriptIterator(); \
|
auto aggregator = (source)->GetScriptIterator(); \
|
||||||
ArbUt::BorrowedPtr<CreatureLib::Battling::BattleScript> next = (CreatureLib::Battling::BattleScript*)1; \
|
ArbUt::BorrowedPtr<CreatureLib::Battling::BattleScript> next = (CreatureLib::Battling::BattleScript*)1; \
|
||||||
while (aggregator.GetNext(next)) { \
|
while (aggregator.GetNext(next)) { \
|
||||||
|
if (next->IsSuppressed()) { \
|
||||||
|
continue; \
|
||||||
|
} \
|
||||||
try { \
|
try { \
|
||||||
next->hookName(__VA_ARGS__); \
|
next->hookName(__VA_ARGS__); \
|
||||||
} catch (const std::exception& e) { \
|
} catch (const std::exception& e) { \
|
||||||
|
@ -23,9 +26,15 @@
|
||||||
if (scriptWrapper.HasValue()) { \
|
if (scriptWrapper.HasValue()) { \
|
||||||
if (scriptWrapper.IsSet()) { \
|
if (scriptWrapper.IsSet()) { \
|
||||||
for (const auto& sv : scriptWrapper.GetScriptSet()->GetIterator()) { \
|
for (const auto& sv : scriptWrapper.GetScriptSet()->GetIterator()) { \
|
||||||
|
if (sv->IsSuppressed()) { \
|
||||||
|
continue; \
|
||||||
|
} \
|
||||||
sv->hookName(__VA_ARGS__); \
|
sv->hookName(__VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
|
if (scriptWrapper.GetScript()->get()->IsSuppressed()) { \
|
||||||
|
continue; \
|
||||||
|
} \
|
||||||
scriptWrapper.GetScript()->get()->hookName(__VA_ARGS__); \
|
scriptWrapper.GetScript()->get()->hookName(__VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
|
Loading…
Reference in New Issue