Add support for saving and getting the owner of a script in script.
continuous-integration/drone/push Build is failing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2021-10-29 21:31:01 +02:00
parent 5fd8abb3a8
commit 949fc67831
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 8 additions and 4 deletions

View File

@ -12,10 +12,14 @@ namespace CreatureLib::Battling {
class Creature; class Creature;
class BattleScript { class BattleScript {
ArbUt::OptionalBorrowedPtr<void> _owner;
public: public:
BattleScript() = default; BattleScript(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; }
virtual ~BattleScript() = default; virtual ~BattleScript() = default;
virtual BattleScript* Clone() = 0; virtual BattleScript* Clone() = 0;

View File

@ -12,7 +12,7 @@ private:
ArbUt::StringView _name; ArbUt::StringView _name;
public: public:
explicit TestScript(const ArbUt::StringView& name) : _name(name){}; explicit TestScript(const ArbUt::StringView& name) : BattleScript(nullptr), _name(name){};
const ArbUt::StringView& GetName() const noexcept override { return _name; } const ArbUt::StringView& GetName() const noexcept override { return _name; }

View File

@ -12,7 +12,7 @@ private:
ArbUt::StringView _name; ArbUt::StringView _name;
public: public:
explicit TestScript(const ArbUt::StringView& name) : _name(name){}; explicit TestScript(const ArbUt::StringView& name) : BattleScript(nullptr), _name(name){};
const ArbUt::StringView& GetName() const noexcept override { return _name; } const ArbUt::StringView& GetName() const noexcept override { return _name; }
BattleScript* Clone() override { return new TestScript(_name); } BattleScript* Clone() override { return new TestScript(_name); }

View File

@ -11,7 +11,7 @@ private:
ArbUt::StringView _name; ArbUt::StringView _name;
public: public:
explicit TestScript(const ArbUt::StringView& name) : _name(name){}; explicit TestScript(const ArbUt::StringView& name) : BattleScript(nullptr), _name(name){};
const ArbUt::StringView& GetName() const noexcept override { return _name; } const ArbUt::StringView& GetName() const noexcept override { return _name; }
void TestMethod(int& runCount) { runCount++; } void TestMethod(int& runCount) { runCount++; }