1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
|