Reworks ScriptSources so we can get individual scripts on a source. Fixed OnEndTurn making no sense.
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:
@@ -91,7 +91,7 @@ namespace CreatureLib::Battling {
|
||||
virtual void PreventOpponentRunAway([[maybe_unused]] const FleeTurnChoice* choice,
|
||||
[[maybe_unused]] bool* result){};
|
||||
|
||||
virtual void OnEndTurn([[maybe_unused]] Creature* creature){};
|
||||
virtual void OnEndTurn(){};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,3 +16,22 @@
|
||||
THROW("Exception setting up script hook '" #hookName "': " << e.what()) \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EXECUTE_SCRIPT_FUNC(scriptWrapper, hookName, ...) \
|
||||
{ \
|
||||
try { \
|
||||
if (scriptWrapper.HasValue()) { \
|
||||
if (scriptWrapper.IsSet()) { \
|
||||
for (const auto& sv : scriptWrapper.GetScriptSet()->GetIterator()) { \
|
||||
sv->hookName(__VA_ARGS__); \
|
||||
} \
|
||||
} else { \
|
||||
scriptWrapper.GetScript()->get()->hookName(__VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} catch (const ArbUt::Exception& e) { \
|
||||
throw e; \
|
||||
} catch (const std::exception& e) { \
|
||||
THROW("Exception setting up script hook '" #hookName "': " << e.what()) \
|
||||
} \
|
||||
}
|
||||
@@ -12,7 +12,6 @@ namespace CreatureLib::Battling {
|
||||
ScriptAggregator _scriptsIterator;
|
||||
|
||||
protected:
|
||||
virtual void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) = 0;
|
||||
void ResetActiveScripts() {
|
||||
_areScriptsInitialized = false;
|
||||
_scripts.Clear();
|
||||
@@ -30,6 +29,9 @@ namespace CreatureLib::Battling {
|
||||
_scriptsIterator.Reset();
|
||||
return _scriptsIterator;
|
||||
}
|
||||
|
||||
virtual void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) = 0;
|
||||
virtual void GetOwnScripts(ArbUt::List<ScriptWrapper>& scripts) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user