mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-04 18:28:45 -04:00
5d68762590
* Add a *ton* of const and constexpr around the codebase. This makes the codebase compile without strings being cast to non-const char*. I also went through and added constexpr where appropriate for tons of static data. * Make process definitions const too Might as well
263 lines
7.1 KiB
C++
263 lines
7.1 KiB
C++
//
|
|
// d_a_obj_lv3Candle.cpp
|
|
// Object - Level 3 Candle
|
|
//
|
|
|
|
#include "d/dolzel_rel.h" // IWYU pragma: keep
|
|
|
|
#include "d/actor/d_a_obj_lv3Candle.h"
|
|
|
|
#include "d/d_com_inf_game.h"
|
|
#include "d/d_s_play.h"
|
|
#include "d/d_cc_uty.h"
|
|
|
|
class daLv3Candle_HIO_c : public mDoHIO_entry_c {
|
|
public:
|
|
daLv3Candle_HIO_c();
|
|
virtual ~daLv3Candle_HIO_c() {}
|
|
|
|
void genMessage(JORMContext*);
|
|
|
|
/* 0x00 vtable */
|
|
/* 0x04 */ u8 mTimer; // Written to, but never read
|
|
};
|
|
|
|
static daLv3Candle_HIO_c l_HIO;
|
|
|
|
daLv3Candle_HIO_c::daLv3Candle_HIO_c() {
|
|
mTimer = 0x1e;
|
|
}
|
|
|
|
#if DEBUG
|
|
void daLv3Candle_HIO_c::genMessage(JORMContext* mctx) {
|
|
mctx->genSlider("timer", &mTimer, 0, 0xFF);
|
|
}
|
|
#endif
|
|
|
|
dCcD_SrcGObjInf const daLv3Candle_c::mCcDObjInfo = {
|
|
{0, {{0x200, 0, 0x13}, {0xd8fbfdff, 0x1f}, {0x79}}},
|
|
{1, 0, 0, 0, 0},
|
|
{0xa, 0, 0, 0, 6},
|
|
{0},
|
|
};
|
|
|
|
dCcD_SrcSph daLv3Candle_c::mCcDSph = {daLv3Candle_c::mCcDObjInfo, {{{0.0f, 0.0f, 0.0f}, 0.0f}}};
|
|
|
|
static DUSK_CONSTEXPR char DUSK_CONST* l_resNameIdx[] = {"L3candl", "L3candl2"};
|
|
|
|
void daLv3Candle_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());
|
|
}
|
|
|
|
static u32 const l_bmdIdx[] = {0x03, 0x03};
|
|
|
|
int daLv3Candle_c::CreateHeap() {
|
|
J3DModelData* modelData =
|
|
(J3DModelData*)dComIfG_getObjectRes(l_resNameIdx[mType], l_bmdIdx[mType]);
|
|
|
|
JUT_ASSERT(226, modelData != NULL);
|
|
|
|
mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
|
|
|
|
if (mpModel == NULL) {
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
cPhs_Step daLv3Candle_c::create() {
|
|
fopAcM_ct(this, daLv3Candle_c);
|
|
|
|
mType = getType();
|
|
if (mType == 0xff) {
|
|
mType = 0;
|
|
}
|
|
|
|
cPhs_Step step = dComIfG_resLoad(&mPhaseReq, l_resNameIdx[mType]);
|
|
if (step == cPhs_COMPLEATE_e) {
|
|
if (!fopAcM_entrySolidHeap(this, createHeapCallBack, 0x900)) {
|
|
return cPhs_ERROR_e;
|
|
} else {
|
|
setBaseMtx();
|
|
fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
|
|
fopAcM_setCullSizeBox2(this, mpModel->getModelData());
|
|
|
|
mStts.Init(0xff, 0xff, this);
|
|
mSph.Set(mCcDSph);
|
|
mSph.SetStts(&mStts);
|
|
mTorchPos = current.pos;
|
|
|
|
if (mType == 0) {
|
|
cXyz v(0.0f, 20.0f, 125.0f);
|
|
mDoMtx_stack_c::ZXYrotS(shape_angle.x, shape_angle.y, shape_angle.z);
|
|
mDoMtx_stack_c::multVec(&v, &v);
|
|
mTorchPos += v;
|
|
} else {
|
|
mTorchPos.y -= 200.0f;
|
|
}
|
|
|
|
mIsLit = getSwBit();
|
|
if (mIsLit == 0xff) {
|
|
mIsLit = 0;
|
|
}
|
|
|
|
lightInit();
|
|
|
|
eyePos = mTorchPos;
|
|
mSound.init(¤t.pos, 1);
|
|
mTgHit = 0;
|
|
}
|
|
}
|
|
|
|
return step;
|
|
}
|
|
|
|
int daLv3Candle_c::createHeapCallBack(fopAc_ac_c* i_this) {
|
|
daLv3Candle_c* actor = static_cast<daLv3Candle_c*>(i_this);
|
|
return actor->CreateHeap();
|
|
}
|
|
|
|
void daLv3Candle_c::lightInit() {
|
|
mLightPos = mTorchPos;
|
|
mLightPos.y += 10.0f;
|
|
|
|
if (mIsLit) {
|
|
mLight.mPosition = mLightPos;
|
|
mLight.mColor.r = 188;
|
|
mLight.mColor.g = 102;
|
|
mLight.mColor.b = 66;
|
|
mLight.mPow = 500.0f;
|
|
mLight.mFluctuation = 1.0f;
|
|
return;
|
|
}
|
|
|
|
mIntensity = 0.0f;
|
|
}
|
|
|
|
void daLv3Candle_c::pointLightProc() {
|
|
if (mIsLit)
|
|
return;
|
|
|
|
GXColor color = {188, 102, 66, 255};
|
|
cLib_addCalc(&mIntensity, 1.0f, 0.5f, 0.1f, 0.0001f);
|
|
|
|
if (mIntensity >= 0.000001f)
|
|
dKy_BossLight_set(&mLightPos, &color, mIntensity, 0);
|
|
}
|
|
|
|
int daLv3Candle_c::Execute() {
|
|
dComIfGp_particle_setSimple(0x100, &mTorchPos, 0xff, g_whiteColor, g_whiteColor, 0, 0.0f);
|
|
dComIfGp_particle_setSimple(0x101, &mTorchPos, 0xff, g_whiteColor, g_whiteColor, 0, 0.0f);
|
|
dComIfGp_particle_setSimple(0x103, &mTorchPos, 0xff, g_whiteColor, g_whiteColor, 0, 0.0f);
|
|
|
|
mDoAud_seStartLevel(Z2SE_OBJ_FIRE_BURNING, &mTorchPos, 0,
|
|
dComIfGp_getReverb(fopAcM_GetRoomNo(this)));
|
|
|
|
if (mSph.ChkTgHit()) {
|
|
cCcD_Obj* obj = mSph.GetTgHitObj();
|
|
if (obj != NULL) {
|
|
u8 play_sound = true;
|
|
fopAc_ac_c* actor = dCc_GetAc(obj->GetAc());
|
|
if (fopAcM_GetName(actor) == fpcNm_ALINK_e) {
|
|
dCcD_GObjInf* gobj = mSph.GetTgHitGObj();
|
|
if (gobj->GetAtType() & AT_TYPE_NORMAL_SWORD && mTgHit != 0) {
|
|
play_sound = false;
|
|
}
|
|
}
|
|
|
|
if (play_sound) {
|
|
u32 se_id = mSph.GetTgHitObjHitSeID(1);
|
|
mSound.startCollisionSE(se_id, 9, NULL);
|
|
}
|
|
}
|
|
} else {
|
|
mTgHit = 0;
|
|
}
|
|
|
|
mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this)));
|
|
setBaseMtx();
|
|
|
|
cXyz pos = current.pos;
|
|
if (mType == 0) {
|
|
mSph.SetR(90.0f + oREG_F(0));
|
|
pos.z += 70.0f + oREG_F(1);
|
|
} else {
|
|
mSph.SetR(60.0f + oREG_F(3));
|
|
pos.y -= 200.0f + oREG_F(2);
|
|
}
|
|
|
|
mSph.SetC(pos);
|
|
dComIfG_Ccsp()->Set(&mSph);
|
|
|
|
pointLightProc();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int daLv3Candle_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 TRUE;
|
|
}
|
|
|
|
int daLv3Candle_c::Delete() {
|
|
mSound.deleteObject();
|
|
dComIfG_resDelete(&mPhaseReq, l_resNameIdx[mType]);
|
|
|
|
if (mIsLit) {
|
|
dKy_plight_cut(&mLight);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
static int daLv3Candle_Draw(daLv3Candle_c* i_this) {
|
|
return static_cast<daLv3Candle_c*>(i_this)->Draw();
|
|
}
|
|
|
|
static int daLv3Candle_Execute(daLv3Candle_c* i_this) {
|
|
return static_cast<daLv3Candle_c*>(i_this)->Execute();
|
|
}
|
|
|
|
static int daLv3Candle_Delete(daLv3Candle_c* i_this) {
|
|
fopAcM_RegisterDeleteID(i_this, "daLv3Candle");
|
|
return static_cast<daLv3Candle_c*>(i_this)->Delete();
|
|
}
|
|
|
|
static int daLv3Candle_Create(fopAc_ac_c* i_this) {
|
|
daLv3Candle_c* const actor = static_cast<daLv3Candle_c*>(i_this);
|
|
fopAcM_RegisterCreateID(i_this, "daLv3Candle");
|
|
return actor->create();
|
|
}
|
|
|
|
static DUSK_CONST actor_method_class l_daLv3Candle_Method = {
|
|
(process_method_func)daLv3Candle_Create, (process_method_func)daLv3Candle_Delete,
|
|
(process_method_func)daLv3Candle_Execute, NULL,
|
|
(process_method_func)daLv3Candle_Draw,
|
|
};
|
|
|
|
DUSK_PROFILE actor_process_profile_definition DUSK_CONST g_profile_Obj_Lv3Candle = {
|
|
/* Layer ID */ fpcLy_CURRENT_e,
|
|
/* List ID */ 7,
|
|
/* List Prio */ fpcPi_CURRENT_e,
|
|
/* Proc Name */ fpcNm_Obj_Lv3Candle_e,
|
|
/* Proc SubMtd */ &g_fpcLf_Method.base,
|
|
/* Size */ sizeof(daLv3Candle_c),
|
|
/* Size Other */ 0,
|
|
/* Parameters */ 0,
|
|
/* Leaf SubMtd */ &g_fopAc_Method.base,
|
|
/* Draw Prio */ fpcDwPi_Obj_Lv3Candle_e,
|
|
/* Actor SubMtd */ &l_daLv3Candle_Method,
|
|
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_NOPAUSE_e,
|
|
/* Group */ fopAc_ACTOR_e,
|
|
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
|
|
};
|