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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
/**
* @file d_a_obj_hasu2.cpp
*
*/
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_obj_hasu2.h"
static void rideCallBack(dBgW* param_0, fopAc_ac_c* param_1, fopAc_ac_c* param_2) {
UNUSED(param_0);
if (fopAcM_GetName(param_2) == fpcNm_ALINK_e) {
nObjMHasu::daObjMHasu_c* hasu = (nObjMHasu::daObjMHasu_c*)(param_1);
hasu->setRideFlag(true);
hasu->setHasuCount(param_2->speedF);
}
}
const int l_dzbidx = {7};
const int l_bmdidx = {4};
static const cull_box l_cull_box = {
{-123.0f, -175.0f, -142.0f},
{133.0f, 29.0f, 127.0f}
};
static char* l_arcName = "M_Hasu";
nObjMHasu::daObjMHasu_c::daObjMHasu_c() :
mConst1(25.5f),
mConst2(6.5f),
mConst3(5.5f)
{
}
int nObjMHasu::daObjMHasu_c::create1st() {
cPhs_Step phase = dComIfG_resLoad(this, l_arcName);
if (phase == cPhs_COMPLEATE_e)
{
setMtx();
phase = MoveBGCreate(l_arcName, l_dzbidx, dBgS_MoveBGProc_TypicalRotY, 0x1450, &mMtx);
if (phase == cPhs_ERROR_e)
{
return phase;
}
}
return phase;
}
void nObjMHasu::daObjMHasu_c::setMtx() {
mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z);
mDoMtx_stack_c::YrotM(current.angle.y);
MTXCopy(mDoMtx_stack_c::get(), mMtx2);
MTXCopy(mDoMtx_stack_c::get(), mMtx);
}
int nObjMHasu::daObjMHasu_c::CreateHeap() {
J3DModelData* model_data = (J3DModelData*)dComIfG_getObjectRes(l_arcName, l_bmdidx);
JUT_ASSERT(193, model_data != NULL);
mModel = mDoExt_J3DModel__create(model_data, 0x80000, 0x11000084);
if (mModel == NULL)
{
return FALSE;
}
return TRUE;
}
int nObjMHasu::daObjMHasu_c::Create() {
mModel->setBaseTRMtx(mMtx2);
fopAcM_SetMtx(this, mMtx2);
fopAcM_setCullSizeBox(this, l_cull_box.min.x, l_cull_box.min.y, l_cull_box.min.z,
l_cull_box.max.x, l_cull_box.max.y, l_cull_box.max.z);
mpBgW->SetRideCallback(rideCallBack);
mRideFlag = false;
if (cM_rnd() > 0.5f) {
unk62C = mConst2;
} else {
unk62C = -mConst2;
}
mPos = current.pos;
mStep = 0.35f + cM_rndF(0.2f);
mTimer = 0;
return 1;
}
int nObjMHasu::daObjMHasu_c::Execute(Mtx** i_pMtx) {
setMtx();
mModel->setBaseTRMtx(mMtx2);
*i_pMtx = &mMtx;
upDownHasu();
return 1;
}
int nObjMHasu::daObjMHasu_c::Draw() {
g_env_light.settingTevStruct(0x10, ¤t.pos, &tevStr);
g_env_light.setLightTevColorType_MAJI(mModel, &tevStr);
dComIfGd_setListBG();
mDoExt_modelUpdateDL(mModel);
dComIfGd_setList();
return 1;
}
int nObjMHasu::daObjMHasu_c::Delete() {
dComIfG_resDelete(this, l_arcName);
return 1;
}
void nObjMHasu::daObjMHasu_c::upDownHasu() {
{ // nested scope from debug
f32 step;
f32 target;
if (mRideFlag) {
target = unk62C + (mPos.y - mConst1);
if (current.pos.y > (mPos.y - mConst1) + mConst2 + mConst2) {
step = mStep + mConst3;
} else if (mTimer) {
step = 6.0f * mStep;
target += unk62C;
} else {
step = mStep / 2.0f;
}
if (mTimer) {
--mTimer;
}
} else {
target = mPos.y + unk62C;
step = mStep;
}
if (step > mStep) {
u32 x = fabsf(current.pos.y - mPos.y);
Z2GetAudioMgr()->seStartLevel(Z2SE_OBJ_HASU_WTR, ¤t.pos, x, 0, 1.0f, 1.0f, -1.0f,
-1.0f, 0);
}
if (cLib_addCalc(¤t.pos.y, target, 0.35f, step, step) == 0.0f) {
unk62C *= -1.0f;
}
}
unk60c_1 = mRideFlag;
mRideFlag = 0;
}
void nObjMHasu::daObjMHasu_c::updateCount(u8 i_count) {
if (mTimer < i_count) {
mTimer = i_count;
}
}
void nObjMHasu::daObjMHasu_c::setHasuCount(f32 i_count) {
if (!unk60c_1) {
mTimer = 45;
} else if (i_count > 1.5f) {
if (i_count < 6.5f) {
updateCount(25);
} else if (i_count < 10.0f) {
updateCount(40);
} else {
updateCount(60);
}
}
}
static int daObjMHasu_create1st(nObjMHasu::daObjMHasu_c* i_this) {
fopAcM_ct(i_this, nObjMHasu::daObjMHasu_c);
return i_this->create1st();
}
static int daObjMHasu_MoveBGDelete(nObjMHasu::daObjMHasu_c* i_this) {
return i_this->MoveBGDelete();
}
static int daObjMHasu_MoveBGExecute(nObjMHasu::daObjMHasu_c* i_this) {
return i_this->MoveBGExecute();
}
static int daObjMHasu_MoveBGDraw(nObjMHasu::daObjMHasu_c* i_this) {
return i_this->MoveBGDraw();
}
actor_method_class daObjMHasu_METHODS = {
(process_method_func)&daObjMHasu_create1st,
(process_method_func)&daObjMHasu_MoveBGDelete,
(process_method_func)&daObjMHasu_MoveBGExecute,
0,
(process_method_func)&daObjMHasu_MoveBGDraw,
};
actor_process_profile_definition g_profile_Obj_MHasu = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 3,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_Obj_MHasu_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(nObjMHasu::daObjMHasu_c),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_Obj_MHasu_e,
/* Actor SubMtd */ &daObjMHasu_METHODS,
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_CULL_e,
/* Group */ fopAc_ACTOR_e,
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
};
|