Files
dusklight/src/d/actor/d_a_obj_lv8KekkaiTrap.cpp
T
Huitzi 56890c32e8 Actor status consolidation & process profile definition editing (#3117)
* 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>
2026-03-09 18:33:31 -07:00

230 lines
5.7 KiB
C++

/**
* @file d_a_obj_lv8KekkaiTrap.cpp
*
*/
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_obj_lv8KekkaiTrap.h"
class daKekaiTrap_HIO_c : public mDoHIO_entry_c {
public:
daKekaiTrap_HIO_c();
virtual ~daKekaiTrap_HIO_c() {}
void genMessage(JORMContext*);
/* 0x04 */ f32 appear_init_speed;
/* 0x08 */ f32 appear_max_speed;
/* 0x0C */ u8 appear_wait;
/* 0x10 */ f32 disappear_init_speed;
/* 0x14 */ f32 disappear_max_speed;
/* 0x18 */ u8 disappear_wait;
};
static daKekaiTrap_HIO_c l_HIO;
static char* l_type[] = {"Lv8Kekkai"};
static int l_bmdIdx[] = {4};
static int l_dzbIdx[] = {7};
daKekaiTrap_HIO_c::daKekaiTrap_HIO_c() {
appear_init_speed = 0.0f;
appear_max_speed = 0.7f;
appear_wait = 10;
disappear_init_speed = 0.0f;
disappear_max_speed = 0.7f;
disappear_wait = 30;
}
void daKekaiTrap_c::setBaseMtx() {
mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z);
mDoMtx_stack_c::ZXYrotM(shape_angle.x, shape_angle.y, shape_angle.z);
mpModel->setBaseScale(scale);
mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
}
int daKekaiTrap_c::CreateHeap() {
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(l_type[mType], l_bmdIdx[mType]);
JUT_ASSERT(170, modelData != NULL);
mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
if (mpModel == NULL) {
return 0;
}
return 1;
}
int daKekaiTrap_c::create() {
fopAcM_ct(this, daKekaiTrap_c);
mType = getType();
int phase_state = dComIfG_resLoad(&mPhase, l_type[mType]);
if (phase_state == cPhs_COMPLEATE_e) {
if (MoveBGCreate(l_type[mType], l_dzbIdx[mType], dBgS_MoveBGProc_TypicalRotY, 0x4000, NULL) == cPhs_ERROR_e) {
return cPhs_ERROR_e;
}
fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
fopAcM_setCullSizeBox2(this, mpModel->getModelData());
mSwbit = getSwBit();
mIsSwitch = fopAcM_isSwitch(this, mSwbit);
if (!mIsSwitch) {
if (mpBgW != NULL) {
dComIfG_Bgsp().Release(mpBgW);
}
scale.y = 0.0f;
}
init_modeWait();
setBaseMtx();
#if DEBUG
l_HIO.entryHIO("結界トラップ(Lv8)");
#endif
}
return phase_state;
}
int daKekaiTrap_c::Execute(Mtx** param_0) {
moveMain();
*param_0 = &mpModel->getBaseTRMtx();
setBaseMtx();
return 1;
}
void daKekaiTrap_c::moveMain() {
static void (daKekaiTrap_c::*mode_proc[])() = {
&daKekaiTrap_c::modeWait,
&daKekaiTrap_c::modeMoveUp,
&daKekaiTrap_c::modeMoveDown,
};
u8 prev_switch = mIsSwitch;
mIsSwitch = fopAcM_isSwitch(this, mSwbit);
if (mIsSwitch != prev_switch) {
if (mIsSwitch) {
init_modeMoveUp();
} else {
init_modeMoveDown();
}
}
(this->*mode_proc[mMode])();
}
void daKekaiTrap_c::init_modeWait() {
mMode = 0;
}
void daKekaiTrap_c::modeWait() {}
void daKekaiTrap_c::init_modeMoveUp() {
fopAcM_SetSpeedF(this, l_HIO.appear_init_speed);
mTimer = l_HIO.appear_wait;
mMode = 1;
}
void daKekaiTrap_c::modeMoveUp() {
if (mTimer != 0) {
mTimer--;
return;
}
cLib_chaseF(&speedF, l_HIO.appear_max_speed, l_HIO.appear_max_speed / 30.0f);
if (cLib_addCalc(&scale.y, 1.0f, 1.0f, fopAcM_GetSpeedF(this), 0.03f) == 0.0f) {
if (mpBgW != NULL) {
dComIfG_Bgsp().Regist(mpBgW, this);
}
init_modeWait();
}
}
void daKekaiTrap_c::init_modeMoveDown() {
fopAcM_SetSpeedF(this, l_HIO.disappear_init_speed);
mTimer = l_HIO.disappear_wait;
mMode = 2;
}
void daKekaiTrap_c::modeMoveDown() {
if (mTimer != 0) {
mTimer--;
return;
}
cLib_chaseF(&speedF, l_HIO.disappear_max_speed, l_HIO.disappear_max_speed / 30.0f);
if (cLib_addCalc(&scale.y, 0.0f, 1.0f, fopAcM_GetSpeedF(this), 0.03f) == 0.0f) {
if (mpBgW != NULL) {
dComIfG_Bgsp().Release(mpBgW);
}
init_modeWait();
}
}
int daKekaiTrap_c::Draw() {
g_env_light.settingTevStruct(16, &current.pos, &tevStr);
g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);
dComIfGd_setListBG();
mDoExt_modelUpdateDL(mpModel);
dComIfGd_setList();
return 1;
}
int daKekaiTrap_c::Delete() {
dComIfG_resDelete(&mPhase, l_type[mType]);
#if DEBUG
l_HIO.removeHIO();
#endif
return 1;
}
static int daKekaiTrap_Draw(daKekaiTrap_c* i_this) {
return i_this->MoveBGDraw();
}
static int daKekaiTrap_Execute(daKekaiTrap_c* i_this) {
return i_this->MoveBGExecute();
}
static int daKekaiTrap_Delete(daKekaiTrap_c* i_this) {
return i_this->MoveBGDelete();
}
static int daKekaiTrap_Create(fopAc_ac_c* i_this) {
return ((daKekaiTrap_c*)i_this)->create();
}
static actor_method_class l_daKekaiTrap_Method = {
(process_method_func)daKekaiTrap_Create,
(process_method_func)daKekaiTrap_Delete,
(process_method_func)daKekaiTrap_Execute,
NULL,
(process_method_func)daKekaiTrap_Draw,
};
actor_process_profile_definition g_profile_Obj_Lv8KekkaiTrap = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 3,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_Obj_Lv8KekkaiTrap_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(daKekaiTrap_c),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_Obj_Lv8KekkaiTrap_e,
/* Actor SubMtd */ &l_daKekaiTrap_Method,
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e,
/* Group */ fopAc_ACTOR_e,
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
};