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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
/**
* @file d_a_obj_lv6elevta.cpp
*
*/
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "JSystem/JUtility/JUTAssert.h"
#include "d/actor/d_a_obj_lv6swturn.h"
#include "d/actor/d_a_obj_lv6elevta.h"
//
// Declarations:
//
static char* l_arcName = "Lv6ElevtA";
static const int l_dzbidx = {7};
static const int l_bmdidx = {4};
#if DEBUG
daObjLv6ElevtA_HIO_c::daObjLv6ElevtA_HIO_c() {
mRightAngleTurnFrameCount = 150;
}
void daObjLv6ElevtA_HIO_c::genMessage(JORMContext* context) {
context->genLabel("Lv6回転エレベータ", 0);
context->genSlider("90度回転フレーム数", &mRightAngleTurnFrameCount, 0, 1000);
}
static daObjLv6ElevtA_HIO_c l_HIO;
#endif
int daObjLv6ElevtA_c::create1st() {
int phase = dComIfG_resLoad(this, l_arcName);
if (phase == cPhs_COMPLEATE_e) {
setMtx();
phase = MoveBGCreate(l_arcName, l_dzbidx, dBgS_MoveBGProc_TypicalRotY, 0x55b0, &mMtx1);
if (phase == cPhs_ERROR_e) {
return phase;
}
#if DEBUG
l_HIO.entryHIO("Lv6回転エレベータ");
#endif
}
return phase;
}
void daObjLv6ElevtA_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(), mMtx1);
}
int daObjLv6ElevtA_c::CreateHeap() {
J3DModelData* model_data = (J3DModelData*)dComIfG_getObjectRes(l_arcName, l_bmdidx);
JUT_ASSERT(145, model_data != NULL);
mModel = mDoExt_J3DModel__create(model_data, 0x80000, 0x11000084);
if (mModel == NULL) {
return FALSE;
}
return TRUE;
}
static const cull_box l_cull_box = {
-393.13f, -3000.0f, -750.0f,
393.13f, 150.0f, 393.13f
};
int daObjLv6ElevtA_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);
if (getSwNo() == 0xff || getSw2No() == 0xff) {
mAngle = 0;
} else if (fopAcM_isSwitch(this, getSwNo())) {
mAngle = 0x3fff;
} else if (fopAcM_isSwitch(this, getSw2No())) {
mAngle = -0x3fff;
} else {
mAngle = 0;
}
mMode = 0;
mIsMoving = false;
return TRUE;
}
static void* searchObjLv6SwTurn(void* i_turn, void* i_elevta) {
if (i_turn != NULL && fopAcM_IsActor(i_turn) &&
fopAcM_GetProfName(i_turn) == fpcNm_Obj_Lv6SwTurn_e)
{
daObjLv6SwTurn_c* this_turn = (daObjLv6SwTurn_c*)i_turn;
daObjLv6ElevtA_c* this_elevta = (daObjLv6ElevtA_c*)i_elevta;
if (this_turn->getSwbit() == this_elevta->getSwNo() &&
this_turn->getSwbit2() == this_elevta->getSw2No())
{
return i_turn;
}
}
return NULL;
}
bool daObjLv6ElevtA_c::eventStart() {
if (fopAcM_isSwitch(this, getSwNo())) {
mMode = 2;
} else if (fopAcM_isSwitch(this, getSw2No())) {
mMode = 3;
} else {
mMode = 1;
}
return true;
}
void daObjLv6ElevtA_c::moveAngle(void* i_FoundActor) {
fopAc_ac_c* found = (fopAc_ac_c*)i_FoundActor;
if (mAngle > 0) {
f32 v = (mAngle / (f32)0x3fff) * 1500.0f;
current.pos.y = home.pos.y - v;
current.angle.y = home.angle.y + mAngle;
found->current.pos.y = found->home.pos.y - v;
found->current.angle.y = found->home.angle.y + mAngle;
} else {
f32 v = (mAngle / (f32)0x3fff) * 800.0f;
current.pos.y = home.pos.y - v;
current.angle.y = home.angle.y + mAngle;
found->current.pos.y = found->home.pos.y - v;
found->current.angle.y = found->home.angle.y + mAngle;
}
shape_angle = current.angle;
mIsMoving = true;
Z2GetAudioMgr()->seStartLevel(Z2SE_OBJ_L6_RL_FLR_MV, ¤t.pos, 0, 0, 1.0f, 1.0f, -1.0f,
-1.0f, 0);
}
int daObjLv6ElevtA_c::Execute(Mtx** i_pMtx) {
fopAc_ac_c* found = fopAcM_Search(searchObjLv6SwTurn, this);
if (found == NULL || getSwNo() == 0xff || getSw2No() == 0xff) {
mAngle = 0;
setMtx();
mModel->setBaseTRMtx(mMtx2);
*i_pMtx = &mMtx1;
return TRUE;
}
if (!eventUpdate()) {
if (fopAcM_isSwitch(this, getSwNo())) {
if (mAngle == 0) {
if (getEvent() != 0xff) {
orderEvent(getEvent(), 0xff, 1);
} else {
mMode = 2;
}
}
} else if (fopAcM_isSwitch(this, getSw2No())) {
if (mAngle == 0) {
if (getEvent() != 0xff) {
orderEvent(getEvent(), 0xff, 1);
} else {
mMode = 3;
}
}
} else {
if (mAngle != 0) {
if (getEvent() != 0xff) {
orderEvent(getEvent(), 0xff, 1);
} else {
mMode = 1;
}
}
}
}
if (mMode == 2) {
#if DEBUG
ANGLE_ADD(mAngle, (f32)0x3fff / l_HIO.mRightAngleTurnFrameCount);
#else
ANGLE_ADD(mAngle, (f32)0x3fff / 150);
#endif
if (mAngle > 0x3fff) {
mAngle = 0x3fff;
mMode = 0;
}
moveAngle(found);
} else if (mMode == 3) {
#if DEBUG
ANGLE_SUB(mAngle, (f32)0x3fff / l_HIO.mRightAngleTurnFrameCount);
#else
ANGLE_SUB(mAngle, (f32)0x3fff / 150);
#endif
if (mAngle < -0x3fff) {
mAngle = -0x3fff;
mMode = 0;
}
moveAngle(found);
} else if (mMode == 1) {
if (mAngle > 0) {
#if DEBUG
ANGLE_SUB(mAngle, (f32)0x3fff / l_HIO.mRightAngleTurnFrameCount);
#else
ANGLE_SUB(mAngle, (f32)0x3fff / 150);
#endif
if (mAngle < 0) {
mAngle = 0;
mMode = 0;
}
moveAngle(found);
} else if (mAngle < 0) {
#if DEBUG
ANGLE_ADD(mAngle, (f32)0x3fff / l_HIO.mRightAngleTurnFrameCount);
#else
ANGLE_ADD(mAngle, (f32)0x3fff / 150);
#endif
if (mAngle > 0) {
mAngle = 0;
mMode = 0;
}
moveAngle(found);
}
} else if (mIsMoving) {
Z2GetAudioMgr()->seStart(Z2SE_OBJ_L6_RL_FLR_ST, ¤t.pos, 0, 0, 1.0f, 1.0f, -1.0f,
-1.0f, 0);
mIsMoving = false;
}
setMtx();
mModel->setBaseTRMtx(mMtx2);
*i_pMtx = &mMtx1;
return TRUE;
}
int daObjLv6ElevtA_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 TRUE;
}
int daObjLv6ElevtA_c::Delete() {
dComIfG_resDelete(this, l_arcName);
#if DEBUG
l_HIO.removeHIO();
#endif
return TRUE;
}
static int daObjLv6ElevtA_create1st(daObjLv6ElevtA_c* i_this) {
fopAcM_ct(i_this, daObjLv6ElevtA_c);
return i_this->create1st();
}
static int daObjLv6ElevtA_MoveBGDelete(daObjLv6ElevtA_c* i_this) {
return i_this->MoveBGDelete();
}
static int daObjLv6ElevtA_MoveBGExecute(daObjLv6ElevtA_c* i_this) {
return i_this->MoveBGExecute();
}
static int daObjLv6ElevtA_MoveBGDraw(daObjLv6ElevtA_c* i_this) {
return i_this->MoveBGDraw();
}
static actor_method_class daObjLv6ElevtA_METHODS = {
(process_method_func)daObjLv6ElevtA_create1st,
(process_method_func)daObjLv6ElevtA_MoveBGDelete,
(process_method_func)daObjLv6ElevtA_MoveBGExecute,
NULL,
(process_method_func)daObjLv6ElevtA_MoveBGDraw,
};
actor_process_profile_definition g_profile_Obj_Lv6ElevtA = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 2,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_Obj_Lv6ElevtA_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(daObjLv6ElevtA_c),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_Obj_Lv6ElevtA_e,
/* Actor SubMtd */ &daObjLv6ElevtA_METHODS,
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_CULL_e,
/* Group */ fopAc_ACTOR_e,
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
};
|