mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-26 23:26:45 -04:00
414a650f9f
* d_a_obj_syRock + waterPillar debug equivalent * Implemented HIO genMessage * Added drawCylinder debug drawing * d_a_obj_waterfall debug equivalent * Implemented HIO genMessage * Added unused tri collider and cull box data * Various LV3 d_a_obj_* actors debug equivalent * Added/modified some documentation * Added some widescreen support functions * Added relevant HIO stuff * Noted weak ordering issues in configure.py * Refactoring according to feedback
254 lines
6.7 KiB
C++
254 lines
6.7 KiB
C++
/**
|
|
* d_a_obj_bsGate.cpp
|
|
* Object - Lakebed Temple Gate
|
|
*/
|
|
|
|
#include "d/dolzel_rel.h" // IWYU pragma: keep
|
|
|
|
#include "d/actor/d_a_obj_bsGate.h"
|
|
#include "d/d_com_inf_game.h"
|
|
#include "d/d_procname.h"
|
|
|
|
class daBsGate_HIO_c : public mDoHIO_entry_c {
|
|
public:
|
|
daBsGate_HIO_c();
|
|
~daBsGate_HIO_c() {}
|
|
|
|
void genMessage(JORMContext*);
|
|
|
|
/* 0x4 */ f32 mOpenSpeed;
|
|
/* 0x8 */ f32 mCloseSpeed;
|
|
/* 0xC */ u8 mShockStrength;
|
|
};
|
|
|
|
STATIC_ASSERT(sizeof(daBsGate_HIO_c) == 0x10);
|
|
|
|
static daBsGate_HIO_c l_HIO;
|
|
|
|
daBsGate_HIO_c::daBsGate_HIO_c() {
|
|
mOpenSpeed = 2.0f;
|
|
mCloseSpeed = 12.0f;
|
|
mShockStrength = 3;
|
|
}
|
|
|
|
#if DEBUG
|
|
void daBsGate_HIO_c::genMessage(JORMContext* mctx) {
|
|
// OPEN speed
|
|
mctx->genSlider("OPEN速度", &mOpenSpeed, 0.1f, 100.0f);
|
|
// CLOSE speed
|
|
mctx->genSlider("CLOSE速度", &mCloseSpeed, 0.1f, 100.0f);
|
|
|
|
/* Vibration */
|
|
/* Vibration */
|
|
mctx->startComboBox("振動", &mShockStrength);
|
|
// Strength 1
|
|
mctx->genComboBoxItem("強さ1", VIBMODE_S_POWER1);
|
|
// Strength 2
|
|
mctx->genComboBoxItem("強さ2", VIBMODE_S_POWER2);
|
|
// Strength 3
|
|
mctx->genComboBoxItem("強さ3", VIBMODE_S_POWER3);
|
|
// Strength 4
|
|
mctx->genComboBoxItem("強さ4", VIBMODE_S_POWER4);
|
|
// Strength 5
|
|
mctx->genComboBoxItem("強さ5", VIBMODE_S_POWER5);
|
|
// Strength 6
|
|
mctx->genComboBoxItem("強さ6", VIBMODE_S_POWER6);
|
|
// Strength 7
|
|
mctx->genComboBoxItem("強さ7", VIBMODE_S_POWER7);
|
|
// Strength 8
|
|
mctx->genComboBoxItem("強さ8", VIBMODE_S_POWER8);
|
|
mctx->endComboBox();
|
|
}
|
|
#endif
|
|
|
|
void daBsGate_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);
|
|
mDoMtx_stack_c::transM(mOpenDist, 0.0f, 0.0f);
|
|
mpModel->setBaseScale(scale);
|
|
mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
|
|
}
|
|
|
|
int daBsGate_c::CreateHeap() {
|
|
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("S_Zgate", 4);
|
|
|
|
JUT_ASSERT(178, modelData != NULL);
|
|
|
|
mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
|
|
if (mpModel == NULL) {
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
cPhs_Step daBsGate_c::create() {
|
|
fopAcM_ct(this, daBsGate_c);
|
|
cPhs_Step step = dComIfG_resLoad(&mPhaseReq, "S_Zgate");
|
|
if (step == cPhs_COMPLEATE_e) {
|
|
if (MoveBGCreate("S_Zgate", 7, dBgS_MoveBGProc_TypicalRotY, 0xf00, NULL) == cPhs_ERROR_e) {
|
|
return cPhs_ERROR_e;
|
|
}
|
|
fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
|
|
fopAcM_setCullSizeBox2(this, mpModel->getModelData());
|
|
mOpen = fopAcM_isSwitch(this, fopAcM_GetParam(this) & 0xff);
|
|
mSide = (fopAcM_GetParam(this) & 0xFF00) >> 8;
|
|
mTargetDist = -250.0f;
|
|
if (mSide == 1) {
|
|
#if DEBUG
|
|
shape_angle.y += static_cast<s16>(0x8000);
|
|
#else
|
|
shape_angle.y += 0x8000;
|
|
#endif
|
|
}
|
|
mOpenDist = 0.0f;
|
|
if (mOpen) {
|
|
mOpenDist = mTargetDist;
|
|
}
|
|
init_modeWait();
|
|
setBaseMtx();
|
|
|
|
#if DEBUG
|
|
l_HIO.entryHIO("ぶら下がりスイッチゲート"); // "Hanging Switch Gate" / "Pull-Down Switch Gate"
|
|
#endif
|
|
}
|
|
return step;
|
|
}
|
|
|
|
int daBsGate_c::Execute(Mtx** i_mtxP) {
|
|
moveGate();
|
|
*i_mtxP = &mpModel->getBaseTRMtx();
|
|
setBaseMtx();
|
|
return 1;
|
|
}
|
|
|
|
void daBsGate_c::moveGate() {
|
|
typedef void (daBsGate_c::*daBsGate_modeFunc)();
|
|
static const daBsGate_modeFunc mode_proc[3] = {
|
|
&daBsGate_c::modeWait,
|
|
&daBsGate_c::modeOpen,
|
|
&daBsGate_c::modeClose,
|
|
};
|
|
u8 was_open = mOpen;
|
|
mOpen = fopAcM_isSwitch(this, fopAcM_GetParam(this) & 0xff);
|
|
if (mOpen != was_open) {
|
|
if (mOpen) {
|
|
init_modeOpen();
|
|
} else {
|
|
init_modeClose();
|
|
}
|
|
}
|
|
(this->*mode_proc[mMode])();
|
|
}
|
|
|
|
void daBsGate_c::init_modeWait() {
|
|
mMode = MODE_WAIT;
|
|
}
|
|
|
|
void daBsGate_c::modeWait() {
|
|
/* empty function */
|
|
}
|
|
|
|
void daBsGate_c::init_modeOpen() {
|
|
mMode = MODE_OPEN;
|
|
}
|
|
|
|
void daBsGate_c::modeOpen() {
|
|
if (mSide == 0) {
|
|
mDoAud_seStartLevel(Z2SE_OBJ_SW_W_DR_OP, ¤t.pos, 0,
|
|
dComIfGp_getReverb(fopAcM_GetRoomNo(this)));
|
|
}
|
|
|
|
const f32 distanceToOpenPosition = cLib_addCalc(&mOpenDist, mTargetDist, 0.2f, l_HIO.mOpenSpeed, 0.5f);
|
|
if (distanceToOpenPosition == 0.0f) {
|
|
if (mSide == 0) {
|
|
mDoAud_seStart(Z2SE_OBJ_SW_W_DR_OP_STOP, ¤t.pos, 0,
|
|
dComIfGp_getReverb(fopAcM_GetRoomNo(this)));
|
|
}
|
|
dComIfGp_getVibration().StartShock(l_HIO.mShockStrength, 0xf, cXyz(0.0f, 1.0f, 0.0f));
|
|
init_modeWait();
|
|
}
|
|
}
|
|
|
|
void daBsGate_c::init_modeClose() {
|
|
mMode = MODE_CLOSE;
|
|
}
|
|
|
|
void daBsGate_c::modeClose() {
|
|
if (mSide == 0) {
|
|
mDoAud_seStartLevel(Z2SE_OBJ_SW_W_DR_CL, ¤t.pos, 0,
|
|
dComIfGp_getReverb(fopAcM_GetRoomNo(this)));
|
|
}
|
|
|
|
const f32 distanceToClosedPosition = cLib_addCalc(&mOpenDist, 0.0f, 0.4f, l_HIO.mCloseSpeed, 0.5f);
|
|
if (distanceToClosedPosition == 0.0f) {
|
|
if (mSide == 0) {
|
|
mDoAud_seStart(Z2SE_OBJ_SW_W_DR_CL_STOP, ¤t.pos, 0,
|
|
dComIfGp_getReverb(fopAcM_GetRoomNo(this)));
|
|
}
|
|
dComIfGp_getVibration().StartShock(l_HIO.mShockStrength, 0xf, cXyz(0.0f, 1.0f, 0.0f));
|
|
init_modeWait();
|
|
}
|
|
}
|
|
|
|
int daBsGate_c::Draw() {
|
|
g_env_light.settingTevStruct(0x10, ¤t.pos, &tevStr);
|
|
g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);
|
|
dComIfGd_setListBG();
|
|
mDoExt_modelUpdateDL(mpModel);
|
|
dComIfGd_setList();
|
|
return 1;
|
|
}
|
|
|
|
int daBsGate_c::Delete() {
|
|
dComIfG_resDelete(&mPhaseReq, "S_Zgate");
|
|
|
|
#if DEBUG
|
|
l_HIO.removeHIO();
|
|
#endif
|
|
|
|
return 1;
|
|
}
|
|
|
|
static int daBsGate_Draw(daBsGate_c* i_this) {
|
|
return i_this->MoveBGDraw();
|
|
}
|
|
|
|
|
|
static int daBsGate_Execute(daBsGate_c* i_this) {
|
|
return i_this->MoveBGExecute();
|
|
}
|
|
|
|
static int daBsGate_Delete(daBsGate_c* i_this) {
|
|
fopAcM_RegisterDeleteID(i_this, "daBsGate");
|
|
return i_this->MoveBGDelete();
|
|
}
|
|
|
|
static cPhs_Step daBsGate_Create(fopAc_ac_c* i_this) {
|
|
return static_cast<daBsGate_c*>(i_this)->create();
|
|
}
|
|
|
|
static actor_method_class l_daBsGate_Method = {
|
|
(process_method_func)daBsGate_Create,
|
|
(process_method_func)daBsGate_Delete,
|
|
(process_method_func)daBsGate_Execute,
|
|
(process_method_func)NULL,
|
|
(process_method_func)daBsGate_Draw,
|
|
};
|
|
|
|
actor_process_profile_definition g_profile_Obj_BsGate = {
|
|
fpcLy_CURRENT_e,
|
|
3,
|
|
fpcPi_CURRENT_e,
|
|
PROC_Obj_BsGate,
|
|
&g_fpcLf_Method.base,
|
|
sizeof(daBsGate_c),
|
|
0,
|
|
0,
|
|
&g_fopAc_Method.base,
|
|
0x206,
|
|
&l_daBsGate_Method,
|
|
0x40000,
|
|
fopAc_ACTOR_e,
|
|
fopAc_CULLBOX_CUSTOM_e,
|
|
};
|