summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-02-06 15:41:57 +0100
committerLéo Lam <leo@leolam.fr>2021-02-06 16:10:20 +0100
commit123e27528329df4e9afcd3fe5ed5dd513fddabad (patch)
treec7d591f2f8c00185feba30dc095f270ff935f082
parentd5b981a233dd625815798e7f0db91fd14c2a30d8 (diff)
ksys/act: Add ActorEditorNode
-rw-r--r--data/uking_functions.csv16
-rw-r--r--src/KingSystem/ActorSystem/CMakeLists.txt2
-rw-r--r--src/KingSystem/ActorSystem/actActorEditorNode.cpp66
-rw-r--r--src/KingSystem/ActorSystem/actActorEditorNode.h40
-rw-r--r--src/KingSystem/System/KingEditor.h1
5 files changed, 117 insertions, 8 deletions
diff --git a/data/uking_functions.csv b/data/uking_functions.csv
index b8bd072d..40b5d769 100644
--- a/data/uking_functions.csv
+++ b/data/uking_functions.csv
@@ -93962,14 +93962,14 @@
0x0000007101241f64,sub_7101241F64,8,
0x0000007101241f6c,sub_7101241F6C,72,
0x0000007101241fb4,sub_7101241FB4,72,
-0x0000007101241ffc,ActorEditorNode::ctor,60,
-0x0000007101242038,ActorEditorNode::dtor,20,
-0x000000710124204c,ActorEditorNode::disconnect,308,
-0x0000007101242180,sub_7101242180,52,
-0x00000071012421b4,connectActorAIAndASEditor,324,
-0x00000071012422f8,sub_71012422F8,340,
-0x000000710124244c,sub_710124244C,136,
-0x00000071012424d4,sub_71012424D4,16,
+0x0000007101241ffc,ActorEditorNode::ctor,60,_ZN4ksys3act15ActorEditorNodeC1Ev
+0x0000007101242038,ActorEditorNode::dtor,20,_ZN4ksys3act15ActorEditorNodeD1Ev
+0x000000710124204c,ActorEditorNode::disconnect,308,_ZN4ksys3act15ActorEditorNode10disconnectEv
+0x0000007101242180,sub_7101242180,52,_ZN4ksys3act15ActorEditorNodeD0Ev
+0x00000071012421b4,connectActorAIAndASEditor,324,_ZN4ksys3act15ActorEditorNode7connectERKNS1_10ConnectArgE
+0x00000071012422f8,sub_71012422F8,340,_ZN4ksys3act15ActorEditorNode9onAiEnterEv
+0x000000710124244c,sub_710124244C,136,_ZNK4ksys3act15ActorEditorNode3logERKN4sead14SafeStringBaseIcEES6_
+0x00000071012424d4,sub_71012424D4,16,_ZNK4ksys3act15ActorEditorNode11isConnectedEv
0x00000071012424e4,ClusteredRenderer::ctor,568,
0x000000710124271c,sub_710124271C,4,
0x0000007101242720,sub_7101242720,84,
diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt
index 17a8eae2..61ad9331 100644
--- a/src/KingSystem/ActorSystem/CMakeLists.txt
+++ b/src/KingSystem/ActorSystem/CMakeLists.txt
@@ -12,6 +12,8 @@ target_sources(uking PRIVATE
actActorConstDataAccess.h
actActorCreator.cpp
actActorCreator.h
+ actActorEditorNode.cpp
+ actActorEditorNode.h
actActorFactory.cpp
actActorFactory.h
actActorHeapUtil.cpp
diff --git a/src/KingSystem/ActorSystem/actActorEditorNode.cpp b/src/KingSystem/ActorSystem/actActorEditorNode.cpp
new file mode 100644
index 00000000..47b6621e
--- /dev/null
+++ b/src/KingSystem/ActorSystem/actActorEditorNode.cpp
@@ -0,0 +1,66 @@
+#include "KingSystem/ActorSystem/actActorEditorNode.h"
+#include "KingSystem/ActorSystem/actAiRoot.h"
+#include "KingSystem/System/KingEditor.h"
+
+namespace ksys::act {
+
+ActorEditorNode::ActorEditorNode() = default;
+
+ActorEditorNode::~ActorEditorNode() {
+ disconnect();
+}
+
+void ActorEditorNode::connect(const ConnectArg& arg) {
+ if (isConnected())
+ return;
+
+ mRootAi = arg.root_ai;
+ mActorName = arg.actor_name;
+ mActorId = arg.actor_id;
+
+ sead::FixedSafeString<256> message;
+ message.format("[Connect][Actor:%s:%u]", mActorName.cstr(), mActorId);
+ KingEditor::instance()->log("AIEditor", message.cstr());
+ KingEditor::instance()->log("ASEditor", message.cstr());
+ mState = State::Connected;
+}
+
+void ActorEditorNode::disconnect() {
+ if (mState == State::Disconnected)
+ return;
+
+ sead::FixedSafeString<256> message;
+ message.format("[Disconnect][Actor:%s:%u]", mActorName.cstr(), mActorId);
+ KingEditor::instance()->log("AIEditor", message.cstr());
+ KingEditor::instance()->log("ASEditor", message.cstr());
+ mRootAi = nullptr;
+ mActorName = sead::SafeString::cEmptyString;
+ mActorId = 0xffffffff;
+ mState = State::Disconnected;
+}
+
+void ActorEditorNode::onAiEnter() {
+ if (!isConnected())
+ return;
+
+ sead::FixedSafeString<0x200> ai_path;
+ if (mRootAi)
+ mRootAi->getCurrentName(&ai_path, nullptr);
+
+ sead::FixedSafeString<0x300> message;
+ message.format("[AIPath][FromPick][Actor:%s:%u][AIPath:%s]", mActorName.cstr(), mActorId,
+ ai_path.cstr());
+ KingEditor::instance()->log("AIEditor", message.cstr());
+}
+
+void ActorEditorNode::log(const sead::SafeString& system, const sead::SafeString& message) const {
+ if (!isConnected())
+ return;
+ KingEditor::instance()->log(system.cstr(), message.cstr());
+}
+
+bool ActorEditorNode::isConnected() const {
+ return mState == State::Connected;
+}
+
+} // namespace ksys::act
diff --git a/src/KingSystem/ActorSystem/actActorEditorNode.h b/src/KingSystem/ActorSystem/actActorEditorNode.h
new file mode 100644
index 00000000..3416a28b
--- /dev/null
+++ b/src/KingSystem/ActorSystem/actActorEditorNode.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <prim/seadSafeString.h>
+
+namespace ksys::act {
+
+namespace ai {
+class RootAi;
+}
+
+class ActorEditorNode {
+public:
+ struct ConnectArg {
+ ai::RootAi* root_ai;
+ sead::SafeString actor_name;
+ u32 actor_id;
+ };
+
+ ActorEditorNode();
+ virtual ~ActorEditorNode();
+
+ void connect(const ConnectArg& arg);
+ void disconnect();
+ void onAiEnter();
+ void log(const sead::SafeString& system, const sead::SafeString& message) const;
+ bool isConnected() const;
+
+private:
+ enum class State : u8 {
+ Disconnected = 0,
+ Connected = 1,
+ };
+
+ State mState = State::Disconnected;
+ ai::RootAi* mRootAi = nullptr;
+ sead::SafeString mActorName;
+ u32 mActorId = 0xffffffff;
+};
+
+} // namespace ksys::act
diff --git a/src/KingSystem/System/KingEditor.h b/src/KingSystem/System/KingEditor.h
index ffd97660..c5ac181b 100644
--- a/src/KingSystem/System/KingEditor.h
+++ b/src/KingSystem/System/KingEditor.h
@@ -20,6 +20,7 @@ class KingEditor {
public:
void registerComponent(KingEditorComponent* component);
+ void log(const char* system, const char* message, void* = {}, int = {});
};
} // namespace ksys