32 lines
996 B
C++
32 lines
996 B
C++
#ifndef CREATURELIB_SCRIPTWRAPPER_HPP
|
|
#define CREATURELIB_SCRIPTWRAPPER_HPP
|
|
|
|
#include <memory>
|
|
#include "Script.hpp"
|
|
#include "ScriptSet.hpp"
|
|
|
|
namespace CreatureLib::Battling {
|
|
class ScriptWrapper {
|
|
bool _isSet;
|
|
|
|
union {
|
|
std::unique_ptr<Script> const* _script;
|
|
const ScriptSet* _scriptSet;
|
|
};
|
|
|
|
ScriptWrapper(std::unique_ptr<Script>* 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 FromSet(ScriptSet* s) { return ScriptWrapper(s, true); }
|
|
|
|
bool IsSet() const { return _isSet; }
|
|
|
|
inline const std::unique_ptr<Script>* GetScript() const { return _script; }
|
|
inline const ScriptSet* GetScriptSet() const { return _scriptSet; }
|
|
};
|
|
}
|
|
|
|
#endif // CREATURELIB_SCRIPTWRAPPER_HPP
|