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/actActorEditorNode.cpp | |
| parent | d5b981a233dd625815798e7f0db91fd14c2a30d8 (diff) | |
ksys/act: Add ActorEditorNode
Diffstat (limited to 'src/KingSystem/ActorSystem/actActorEditorNode.cpp')
| -rw-r--r-- | src/KingSystem/ActorSystem/actActorEditorNode.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
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 |
