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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#include "Game/Actor/AI/aiAirOctaFlyUp.h"
#include "Game/Actor/AI/aiAirOctaDataMgr.h"
#include "Game/Actor/AI/aiAirOctaRoot.h"
#include "KingSystem/ActorSystem/AS/ASList.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/ActorSystem/actActorLinkConstDataAccess.h"
#include "KingSystem/ActorSystem/actAiAi.h"
#include "KingSystem/ActorSystem/actBaseProcLink.h"
#include "KingSystem/System/VFR.h"
#include "KingSystem/Utils/Thread/Message.h"
namespace uking::ai {
AirOctaFlyUp::AirOctaFlyUp(const InitArg& arg) : ksys::act::ai::Ai(arg) {}
AirOctaFlyUp::~AirOctaFlyUp() = default;
bool AirOctaFlyUp::init_(sead::Heap* heap) {
return ksys::act::ai::Ai::init_(heap);
}
// NON_MATCHING: stack for the sendMessage() message, type that y is casted to
void AirOctaFlyUp::calc_() {
auto* data_mgr = getDataMgr();
if (!data_mgr) {
return;
}
auto dt = ksys::VFR::instance()->getDeltaTime();
mElapsedTime += dt;
auto fly_up_turning_pts =
(sead::Mathf::min(1.0f, mElapsedTime / *mFlyUpDuration_s) * 2.f) - 1.f;
auto fly_up_multiplier = fly_up_turning_pts < 1.f ?
sead::Mathf::exp((fly_up_turning_pts * 2.f) - 1.f * 10.f) :
2.f - sead::Mathf::exp((fly_up_turning_pts * 2.f) - 1.f * -10.f);
data_mgr->unk_114 = fly_up_multiplier * 0.5f * *mTargetDistance_d;
data_mgr->changeOctasYheightMaybe();
auto y = getActor()->getMtx().m[1][3];
if (isCurrentChild("終了")) { // "End"
if (!mIsEnded) {
auto currentChild = getCurrentChild();
if (currentChild->isFinished() || currentChild->isFailed()) {
auto as_list = getActor()->getASList();
if (as_list) {
as_list->startAnimationMaybe(-1.f, -1.f, "Wait", 0, 0, true);
}
mIsEnded = true;
} else if (!mIsEnded) {
return;
}
}
if ((fly_up_multiplier * 0.5f >= 1.f && y >= getDataMgr()->vec_F8.y) ||
mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) {
ksys::act::ActorLinkConstDataAccess linkData;
if (ksys::act::acquireActor(&getDataMgr()->mBaseProcLink, &linkData)) {
mUserData = 3;
getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &mUserData,
false);
}
}
} else if (y - AirOctaY >= *mTargetDistance_d * 0.9f ||
mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) {
ksys::act::ActorLinkConstDataAccess linkData;
if (ksys::act::acquireActor(&getDataMgr()->mBaseProcLink, &linkData)) {
mUserData = 2;
getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &mUserData,
false);
}
}
}
bool AirOctaFlyUp::handleMessage_(const ksys::Message& message) {
if (message.getType().value != 0x80000c8) {
return false;
}
u32* user_data = static_cast<u32*>(message.getUserData());
auto* data_mgr = getDataMgr();
if (!data_mgr) {
return true;
}
if (user_data == nullptr) {
return true;
}
if (*user_data == 3) {
Ai::changeChild("終了"); // Ended
} else if (*user_data == 4) {
ActionBase::setFinished();
}
return true;
}
void AirOctaFlyUp::enter_(ksys::act::ai::InlineParamPack* params) {
if (auto* data_mgr = getDataMgr()) {
data_mgr->unk_114 = 0;
data_mgr->changeOctasYheightMaybe();
}
auto& mtx = mActor->getMtx();
AirOctaY = mtx(1, 3);
ksys::act::ai::Ai::changeChild("開始");
}
void AirOctaFlyUp::leave_() {
if (auto* data_mgr = getDataMgr()) {
data_mgr->unk_118 += *mTargetDistance_d;
data_mgr->unk_114 = 0;
data_mgr->changeOctasYheightMaybe();
}
}
// NON_MATCHING: addresses that variables are loaded from
void AirOctaFlyUp::loadParams_() {
getStaticParam(&mFlyUpDuration_s, "FlyUpDuration");
getDynamicParam(&mTargetDistance_d, "TargetDistance");
getAITreeVariable(&mAirOctaDataMgr_a, "AirOctaDataMgr");
}
} // namespace uking::ai
|