d_a_obj_pinwheel OK

This commit is contained in:
swekka
2025-09-18 23:31:31 +02:00
parent f475873a90
commit 5d91704858
4 changed files with 192 additions and 32 deletions
+145 -9
View File
@@ -1,5 +1,16 @@
#include "d/a/obj/d_a_obj_pinwheel.h"
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/cc/d_cc_d.h"
#include "d/col/cc/d_cc_s.h"
#include "d/d_stage.h"
#include "d/snd/d_snd_wzsound.h"
#include "f/f_base.h"
#include "m/m_vec.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
SPECIAL_ACTOR_PROFILE(OBJ_PINWHEEL, dAcOpinwheel_c, fProfile::OBJ_PINWHEEL, 0x1DD, 0, 2);
STATE_DEFINE(dAcOpinwheel_c, Wait);
@@ -7,15 +18,140 @@ STATE_DEFINE(dAcOpinwheel_c, Acceleration);
STATE_DEFINE(dAcOpinwheel_c, RollMaxSpeed);
STATE_DEFINE(dAcOpinwheel_c, Deceleration);
void dAcOpinwheel_c::initializeState_Wait() {}
void dAcOpinwheel_c::executeState_Wait() {}
dCcD_SrcSph dAcOpinwheel_c::sSphSrc = {
/* mObjInf */
{/* mObjAt */ {0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0},
/* mObjTg */
{~(AT_TYPE_BUGNET | AT_TYPE_BEETLE | AT_TYPE_0x80000 | AT_TYPE_0x8000 | AT_TYPE_WIND), 0x111, {0, 6, 0x8}, 8, 0},
/* mObjCo */ {0xE9}},
/* mSphInf */
{50.f},
};
const u32 dAcOpinwheel_c::unused = 0x1E1388;
bool dAcOpinwheel_c::createHeap() {
void *data = getOarcResFile("Pinwheel");
mResFile = nw4r::g3d::ResFile(data);
dStage_c::bindStageResToFile(&mResFile);
dStage_c::bindSkyCmnToResFile(&mResFile);
nw4r::g3d::ResMdl mdl = mResFile.GetResMdl("Pinwheel");
TRY_CREATE(mMdl.create(mdl, &mAllocator, 0x120, 1, nullptr));
void *dzb = getOarcFile("Pinwheel", "dzb/Pinwheel.dzb");
void *plc = getOarcFile("Pinwheel", "dat/Pinwheel.plc");
updateMatrix();
return !mBgW.Set((cBgD_t *)dzb, (PLC *)plc, cBgW::MOVE_BG_e, &mWorldMtx, &mScale);
}
int dAcOpinwheel_c::create() {
CREATE_ALLOCATOR(dAcOpinwheel_c);
dBgS::GetInstance()->Regist(&mBgW, this);
mStts.SetRank(0xD);
mSph.Set(sSphSrc);
mSph.SetStts(mStts);
mStateMgr.changeState(StateID_Wait);
mMdl.setPriorityDraw(0x1C, 9);
mBoundingBox.Set(mVec3_c(-75.f, -75.f, -10.f), mVec3_c(75.f, 75.f, 50.f));
return SUCCEEDED;
}
int dAcOpinwheel_c::doDelete() {
return SUCCEEDED;
}
int dAcOpinwheel_c::actorExecute() {
mStateMgr.executeState();
mSph.SetC(mPosition);
dCcS::GetInstance()->Set(&mSph);
updateMatrix();
mMdl.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
int dAcOpinwheel_c::draw() {
drawModelType1(&mMdl);
return SUCCEEDED;
}
void dAcOpinwheel_c::initializeState_Wait() {
mRotationSpeed = 0;
}
void dAcOpinwheel_c::executeState_Wait() {
if (isBeingBlown()) {
mStateMgr.changeState(StateID_Acceleration);
}
}
void dAcOpinwheel_c::finalizeState_Wait() {}
void dAcOpinwheel_c::initializeState_Acceleration() {}
void dAcOpinwheel_c::executeState_Acceleration() {}
void dAcOpinwheel_c::initializeState_Acceleration() {
mStateTimer = 0x1E;
}
void dAcOpinwheel_c::executeState_Acceleration() {
holdSound(SE_Pinwhel_ROLL_LV);
mRotationSpeed += 0xA6;
mRotation.z += mRotationSpeed;
if (decrement(&mStateTimer) == 0) {
mStateMgr.changeState(StateID_RollMaxSpeed);
} else if (!isBeingBlown()) {
u16 stateTimer = 0x1E - mStateTimer;
mStateMgr.changeState(StateID_Deceleration);
mStateTimer = stateTimer;
}
}
s16 dAcOpinwheel_c::decrement(s16 *value) {
if (*value != 0) {
(*value)--;
}
return *value;
}
void dAcOpinwheel_c::finalizeState_Acceleration() {}
void dAcOpinwheel_c::initializeState_RollMaxSpeed() {}
void dAcOpinwheel_c::executeState_RollMaxSpeed() {}
void dAcOpinwheel_c::finalizeState_RollMaxSpeed() {}
void dAcOpinwheel_c::initializeState_Deceleration() {}
void dAcOpinwheel_c::executeState_Deceleration() {}
void dAcOpinwheel_c::initializeState_RollMaxSpeed() {
mBeingBlown = true;
}
void dAcOpinwheel_c::executeState_RollMaxSpeed() {
holdSound(SE_Pinwhel_ROLL_LV);
mRotation.z += mRotationSpeed;
if (!isBeingBlown()) {
if (decrement(&mStateTimer) == 0) {
mStateMgr.changeState(StateID_Deceleration);
}
} else {
mStateTimer = 2;
}
}
void dAcOpinwheel_c::finalizeState_RollMaxSpeed() {
mBeingBlown = false;
}
void dAcOpinwheel_c::initializeState_Deceleration() {
mStateTimer = 0x1E;
}
void dAcOpinwheel_c::executeState_Deceleration() {
holdSound(SE_Pinwhel_ROLL_LV);
mRotationSpeed -= 0xA6;
mRotation.z += mRotationSpeed;
if (decrement(&mStateTimer) == 0) {
mStateMgr.changeState(StateID_Wait);
} else if (isBeingBlown()) {
u16 stateTimer = 0x1E - mStateTimer;
mStateMgr.changeState(StateID_Acceleration);
mStateTimer = stateTimer;
}
}
void dAcOpinwheel_c::finalizeState_Deceleration() {}
bool dAcOpinwheel_c::isBeingBlown() {
return mSph.ChkTgHit() && mSph.ChkTgAtHitType(AT_TYPE_BELLOWS);
}