From 1f82ffa4d3ee8355215d43bf43edf8cecaca0d1d Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 16 Oct 2024 17:21:04 +0200 Subject: fix user script implementation --- src/crepe/api/BehaviorScript.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/crepe/api/BehaviorScript.hpp (limited to 'src/crepe/api/BehaviorScript.hpp') diff --git a/src/crepe/api/BehaviorScript.hpp b/src/crepe/api/BehaviorScript.hpp new file mode 100644 index 0000000..0401c0d --- /dev/null +++ b/src/crepe/api/BehaviorScript.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include "../util/log.h" +#include "BehaviorScript.h" + +namespace crepe::api { + +template +BehaviorScript & BehaviorScript::set_script() { + static_assert(std::is_base_of::value); + dbg_trace(); + this->script = new T(); + return *this; +} + +} -- cgit v1.2.3 From 9fd3bdca9de2d37b63e1646b22d32b0b182f01ee Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 16 Oct 2024 18:24:16 +0200 Subject: use unique_ptr instead of manual memory management in behaviorscript --- src/crepe/ScriptSystem.cpp | 2 +- src/crepe/api/BehaviorScript.cpp | 7 ------- src/crepe/api/BehaviorScript.h | 6 ++++-- src/crepe/api/BehaviorScript.hpp | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/crepe/api/BehaviorScript.hpp') diff --git a/src/crepe/ScriptSystem.cpp b/src/crepe/ScriptSystem.cpp index 0537c16..1a7bff4 100644 --- a/src/crepe/ScriptSystem.cpp +++ b/src/crepe/ScriptSystem.cpp @@ -40,7 +40,7 @@ forward_list