Rework ScriptAggregator so it only needs to be created once, and can then be reset.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-23 19:57:45 +02:00
parent 742d0c772c
commit 3a11bba913
4 changed files with 26 additions and 19 deletions

View File

@@ -7,18 +7,20 @@
namespace CreatureLib::Battling {
class ScriptWrapper {
std::variant<Script**, ScriptSet*> _value;
union {
Script** _script;
ScriptSet* _scriptSet;
};
bool _isSet;
public:
ScriptWrapper(Script** s) : _value(s), _isSet(false) {}
ScriptWrapper(ScriptSet* s) : _value(s), _isSet(true) {}
ScriptWrapper(Script** s) : _script(s), _isSet(false) {}
ScriptWrapper(ScriptSet* s) : _scriptSet(s), _isSet(true) {}
bool IsSet() const { return _isSet; }
Script** GetScript() const { return std::get<Script**>(_value); }
ScriptSet* GetScriptSet() const { return std::get<ScriptSet*>(_value); }
Script** GetScript() const { return _script; }
ScriptSet* GetScriptSet() const { return _scriptSet; }
};
}