mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-24 06:50:43 -04:00
56890c32e8
* Consolidate fopAcM_STATUS into fopAc_Status_e * Add _e suffix to fopAcStts enums * Prepare for profile enumeration * Correct typo in scene_process_profile_definition * Manually handle g_profile_Obj_DamCps (inline preprocessing) * Correct g_profile_TAG_LV5SOUP procname to enum * Create d_priority.h * Update process profile definitions * Moved inline comments to the left * Add missing fopAcStts enums * Add d_priority.h include in f_pc_leaf.h * Manually update d_a_obj_damCps profile * Replace fopAcStts enums replacing and anticipatory profile size correction * Changed profile size from literal to sizeof() in anticipation of PR #3116 * Provided putative names to staff-related status enums * Replaced appropriate literals with fopAcStts enums * Fix borked merge * Rename item number enums and move to d_item_data.h * Rename process profile name & draw priority enums * Move process profile name & draw priority enums to appropriate files * Moved fpcNm_ enums from d/d_procname.h to f_pc/f_pc_name.h * Moved fpcDwPi_ enums from d/d_priority.h to f_pc/f_pc_draw_priority.h * ACTUALLY (whoops) stage merge * Correct item mistranslation Co-authored-by: LagoLunatic <LagoLunatic@users.noreply.github.com> --------- Co-authored-by: LagoLunatic <LagoLunatic@users.noreply.github.com>
261 lines
6.9 KiB
C++
261 lines
6.9 KiB
C++
/**
|
|
* @file d_a_obj_magLift.cpp
|
|
*
|
|
*/
|
|
|
|
#include "d/dolzel_rel.h" // IWYU pragma: keep
|
|
|
|
#include "d/actor/d_a_obj_magLift.h"
|
|
#include "d/d_path.h"
|
|
|
|
static daMagLift_HIO_c l_HIO;
|
|
|
|
daMagLift_HIO_c::daMagLift_HIO_c() {
|
|
field_0x4 = 0x3c;
|
|
field_0x5 = 1;
|
|
}
|
|
|
|
void daMagLift_c::setBaseMtx() {
|
|
mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z);
|
|
mDoMtx_stack_c::ZXYrotM(current.angle.x, current.angle.y, current.angle.z);
|
|
mpModel->setBaseScale(scale);
|
|
mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
|
|
}
|
|
|
|
int daMagLift_c::CreateHeap() {
|
|
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("L_maglift", 4);
|
|
|
|
if (modelData == NULL) {
|
|
// FIXME: For shield decomp matching, needs a JUT assert.
|
|
}
|
|
|
|
mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
|
|
if (mpModel == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
const f32 daMagLift_c::mSpeed[16] = {
|
|
5.0f, 6.6666665f, 8.333333f, 10.0f, 11.666667f, 13.333333f, 15.0f, 16.666666f,
|
|
18.333334f, 20.0f, 21.666666f, 23.333334f, 25.0f, 26.666666f, 28.333334f, 3.3333333f,
|
|
};
|
|
|
|
int daMagLift_c::create() {
|
|
fopAcM_ct(this, daMagLift_c);
|
|
int phase = dComIfG_resLoad(&mPhaseReq,"L_maglift");
|
|
if (phase == cPhs_COMPLEATE_e) {
|
|
if (MoveBGCreate("L_maglift", 7, dBgS_MoveBGProc_TypicalRotY, 0x4000, NULL) == cPhs_ERROR_e) {
|
|
return cPhs_ERROR_e;
|
|
}
|
|
field_0x5ae = fopAcM_GetParam(this);
|
|
dPath* path = dPath_GetRoomPath(field_0x5ae, fopAcM_GetRoomNo(this));
|
|
if (path == NULL) {
|
|
return cPhs_INIT_e;
|
|
}
|
|
current.pos = path->m_points->m_position;
|
|
field_0x5af = 1;
|
|
mPoint = 0;
|
|
mMoveSpeed = mSpeed[getMoveSpeed()];
|
|
fopAcM_SetSpeedF(this, 0.0f);
|
|
u8 mInitMove = fopAcM_GetParam(this) >> 0xc & 0xFF;
|
|
if (mInitMove == 0xff) {
|
|
init_modeWaitInit();
|
|
} else {
|
|
is_switch = dComIfGs_isSwitch(mInitMove, fopAcM_GetHomeRoomNo(this));
|
|
if (is_switch) {
|
|
init_modeWaitInit();
|
|
} else {
|
|
init_modeMoveWait();
|
|
}
|
|
}
|
|
fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
|
|
fopAcM_setCullSizeBox2(this, mpModel->getModelData());
|
|
setBaseMtx();
|
|
}
|
|
return phase;
|
|
}
|
|
|
|
int daMagLift_c::Execute(Mtx** i_mtx) {
|
|
moveLift();
|
|
*i_mtx = &mpModel->getBaseTRMtx();
|
|
setBaseMtx();
|
|
return 1;
|
|
}
|
|
|
|
void daMagLift_c::moveLift() {
|
|
if (field_0x5ae != 0xff) {
|
|
typedef void (daMagLift_c::*modeFunc)();
|
|
static modeFunc mode_proc[8] = {&daMagLift_c::modeAcc, &daMagLift_c::modeMove,
|
|
&daMagLift_c::modeBrk, &daMagLift_c::modeWait,
|
|
&daMagLift_c::modeWaitInit, &daMagLift_c::modeDead,
|
|
&daMagLift_c::modeMoveWait};
|
|
|
|
(this->*mode_proc[mMode])();
|
|
}
|
|
}
|
|
|
|
void daMagLift_c::modeAcc() {
|
|
if (TRUE == cLib_chaseF(&speedF, mMoveSpeed, mMoveSpeed / 30.0f) || current.pos == field_0x5b4) {
|
|
init_modeMove();
|
|
}
|
|
cLib_addCalcPos(¤t.pos, field_0x5b4, 1.0f, fopAcM_GetSpeedF(this), 0.1f);
|
|
}
|
|
|
|
void daMagLift_c::init_modeMove() {
|
|
mMode = MODE_MOVE_e;
|
|
}
|
|
|
|
void daMagLift_c::modeMove() {
|
|
cXyz sp54(field_0x5c0);
|
|
cXyz sp60(field_0x5b4);
|
|
|
|
f32 magn = (sp54 - sp60).abs() * 0.3f;
|
|
f32 min = 30.0f;
|
|
f32 max = 300.0f;
|
|
|
|
if (magn < min) {
|
|
magn = min;
|
|
}
|
|
|
|
if (magn > max) {
|
|
magn = max;
|
|
}
|
|
|
|
f32 o_magn = (current.pos - field_0x5b4).abs();
|
|
if (magn > o_magn) {
|
|
init_modeBrk();
|
|
}
|
|
cLib_addCalcPos(¤t.pos, field_0x5b4, 1.0f, fopAcM_GetSpeedF(this), 0.1f);
|
|
}
|
|
|
|
void daMagLift_c::init_modeBrk() {
|
|
mMode = MODE_BRK_e;
|
|
}
|
|
|
|
void daMagLift_c::modeBrk() {
|
|
f32 val = cLib_addCalcPos(¤t.pos, field_0x5b4, 0.1f, fopAcM_GetSpeedF(this), 0.5f);
|
|
if (val == 0.0f) {
|
|
fopAcM_SetSpeedF(this, 0.0f);
|
|
init_modeWaitInit();
|
|
}
|
|
}
|
|
|
|
void daMagLift_c::init_modeWaitInit() {
|
|
mMode = MODE_WAIT_INIT_e;
|
|
}
|
|
|
|
void daMagLift_c::modeWaitInit() {
|
|
setNextPoint();
|
|
init_modeWait();
|
|
}
|
|
|
|
void daMagLift_c::init_modeWait() {
|
|
mMode = MODE_WAIT_e;
|
|
}
|
|
|
|
void daMagLift_c::modeWait() {
|
|
mMode = MODE_ACC_e;
|
|
}
|
|
|
|
void daMagLift_c::init_modeMoveWait() {
|
|
mMode = MODE_MOVE_WAIT_e;
|
|
}
|
|
|
|
void daMagLift_c::modeMoveWait() {
|
|
if (fopAcM_isSwitch(this, (fopAcM_GetParam(this) & 0xff000) >> 0xc) & 0xff) {
|
|
init_modeWaitInit();
|
|
}
|
|
}
|
|
|
|
void daMagLift_c::modeDead() {
|
|
/* empty function */
|
|
}
|
|
|
|
void daMagLift_c::setNextPoint() {
|
|
s16 sVar1 = mPoint + field_0x5af;
|
|
dPath* path = dPath_GetRoomPath(field_0x5ae, fopAcM_GetRoomNo(this));
|
|
if (dPath_ChkClose(path) != 0) {
|
|
int val = path->m_num - 1;
|
|
if (sVar1 > val) {
|
|
sVar1 = 0;
|
|
} else if (sVar1 < 0) {
|
|
sVar1 = (s8) val;
|
|
}
|
|
} else {
|
|
if (sVar1 > path->m_num - 1) {
|
|
field_0x5af = 0xff;
|
|
sVar1 = (s8) (path->m_num - 2);
|
|
} else if (sVar1 < 0) {
|
|
field_0x5af = 0x1;
|
|
sVar1 = 1;
|
|
} else {
|
|
dPnt* pnt = &path->m_points[mPoint];
|
|
if (pnt->mArg0 == 0) {
|
|
sVar1 = mPoint;
|
|
}
|
|
}
|
|
}
|
|
field_0x5c0 = field_0x5b4;
|
|
dPnt* pnt = &path->m_points[sVar1];
|
|
field_0x5b4 = pnt->m_position;
|
|
mPoint = sVar1;
|
|
}
|
|
|
|
int daMagLift_c::Draw() {
|
|
g_env_light.settingTevStruct(0x40, ¤t.pos, &tevStr);
|
|
g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);
|
|
|
|
dComIfGd_setListBG();
|
|
mDoExt_modelUpdateDL(mpModel);
|
|
dComIfGd_setList();
|
|
return 1;
|
|
}
|
|
|
|
int daMagLift_c::Delete() {
|
|
dComIfG_resDelete(&mPhaseReq, "L_maglift");
|
|
return 1;
|
|
}
|
|
|
|
static int daMagLift_Draw(daMagLift_c* i_this) {
|
|
return i_this->Draw();
|
|
}
|
|
|
|
static int daMagLift_Execute(daMagLift_c* i_this) {
|
|
return i_this->MoveBGExecute();
|
|
}
|
|
|
|
static int daMagLift_Delete(daMagLift_c* i_this) {
|
|
return i_this->MoveBGDelete();
|
|
}
|
|
|
|
static int daMagLift_Create(fopAc_ac_c* i_this) {
|
|
return static_cast<daMagLift_c*>(i_this)->create();
|
|
}
|
|
|
|
static actor_method_class l_daMagLift_Method = {
|
|
(process_method_func) daMagLift_Create,
|
|
(process_method_func) daMagLift_Delete,
|
|
(process_method_func) daMagLift_Execute,
|
|
(process_method_func) NULL,
|
|
(process_method_func) daMagLift_Draw,
|
|
};
|
|
|
|
actor_process_profile_definition g_profile_Obj_MagLift = {
|
|
/* Layer ID */ fpcLy_CURRENT_e,
|
|
/* List ID */ 3,
|
|
/* List Prio */ fpcPi_CURRENT_e,
|
|
/* Proc Name */ fpcNm_Obj_MagLift_e,
|
|
/* Proc SubMtd */ &g_fpcLf_Method.base,
|
|
/* Size */ sizeof(daMagLift_c),
|
|
/* Size Other */ 0,
|
|
/* Parameters */ 0,
|
|
/* Leaf SubMtd */ &g_fopAc_Method.base,
|
|
/* Draw Prio */ fpcDwPi_Obj_MagLift_e,
|
|
/* Actor SubMtd */ &l_daMagLift_Method,
|
|
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_CULL_e,
|
|
/* Group */ fopAc_ACTOR_e,
|
|
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
|
|
};
|