summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-06-21 14:53:52 +0200
committerLéo Lam <leo@leolam.fr>2021-06-21 17:56:14 +0200
commit4f2f4ede4fa051bb2456d5ea245d8176b4f90d65 (patch)
tree129e169dc378d5ee33ee4860b2eb6ce0e9f21f8b /src/KingSystem/ActorSystem
parent952a40d47284503bb49a224e0afbc90828367291 (diff)
ksys/act: Finish Query
Diffstat (limited to 'src/KingSystem/ActorSystem')
-rw-r--r--src/KingSystem/ActorSystem/actAiParam.h8
-rw-r--r--src/KingSystem/ActorSystem/actAiQuery.cpp33
2 files changed, 38 insertions, 3 deletions
diff --git a/src/KingSystem/ActorSystem/actAiParam.h b/src/KingSystem/ActorSystem/actAiParam.h
index 5644b56c..e132ef8b 100644
--- a/src/KingSystem/ActorSystem/actAiParam.h
+++ b/src/KingSystem/ActorSystem/actAiParam.h
@@ -74,10 +74,12 @@ public:
T* getVariable(const sead::SafeString& key, AIDefParamType type, bool a4 = true) const;
template <typename T>
- void setVariable(const sead::SafeString& key, AIDefParamType type, const T& val) const {
+ bool setVariable(const sead::SafeString& key, AIDefParamType type, const T& val) const {
T* variable = getVariable<T>(key, type, true);
- if (variable)
- *variable = val;
+ if (!variable)
+ return false;
+ *variable = val;
+ return true;
}
bool load(const Actor& actor, const ParamNameTypePairs& pairs, s32 count, sead::Heap* heap);
diff --git a/src/KingSystem/ActorSystem/actAiQuery.cpp b/src/KingSystem/ActorSystem/actAiQuery.cpp
index b5467bb2..87b7af6b 100644
--- a/src/KingSystem/ActorSystem/actAiQuery.cpp
+++ b/src/KingSystem/ActorSystem/actAiQuery.cpp
@@ -1,4 +1,5 @@
#include "KingSystem/ActorSystem/actAiQuery.h"
+#include <evfl/Param.h>
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/ActorSystem/actActorParam.h"
#include "KingSystem/ActorSystem/actAiClassDef.h"
@@ -70,6 +71,38 @@ bool Query::getDynamicParam(bool** value, const sead::SafeString& param) const {
return ret != nullptr;
}
+bool Query::loadString(const evfl::ParamAccessor& accessor, const sead::SafeString& param) {
+ ore::StringView value;
+ if (!accessor.FindString(&value, param.cstr()))
+ return false;
+
+ return mParamPack.setString(value.data(), param);
+}
+
+bool Query::loadInt(const evfl::ParamAccessor& accessor, const sead::SafeString& param) {
+ int value;
+ if (!accessor.FindInt(&value, param.cstr()))
+ return false;
+
+ return mParamPack.setVariable(param, AIDefParamType::Int, value);
+}
+
+bool Query::loadFloat(const evfl::ParamAccessor& accessor, const sead::SafeString& param) {
+ float value;
+ if (!accessor.FindFloat(&value, param.cstr()))
+ return false;
+
+ return mParamPack.setVariable(param, AIDefParamType::Float, value);
+}
+
+bool Query::loadBool(const evfl::ParamAccessor& accessor, const sead::SafeString& param) {
+ bool value;
+ if (!accessor.FindBool(&value, param.cstr()))
+ return false;
+
+ return mParamPack.setVariable(param, AIDefParamType::Bool, value);
+}
+
bool Query::getAITreeVariable(sead::SafeString** value, const sead::SafeString& param) const {
return mActor->getRootAi()->getAITreeVariable(value, param);
}