diff options
| author | Léo Lam <leo@leolam.fr> | 2021-02-06 15:41:57 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2021-02-06 16:10:20 +0100 |
| commit | 123e27528329df4e9afcd3fe5ed5dd513fddabad (patch) | |
| tree | c7d591f2f8c00185feba30dc095f270ff935f082 /src/KingSystem/ActorSystem | |
| parent | d5b981a233dd625815798e7f0db91fd14c2a30d8 (diff) | |
ksys/act: Add ActorEditorNode
Diffstat (limited to 'src/KingSystem/ActorSystem')
| -rw-r--r-- | src/KingSystem/ActorSystem/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actActorEditorNode.cpp | 66 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actActorEditorNode.h | 40 |
3 files changed, 108 insertions, 0 deletions
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 |
