-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from robojumper/d_a_obj_tower_gearD101
d_a_obj_tower_gearD101 OK
- Loading branch information
Showing
8 changed files
with
268 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,66 @@ | ||
#ifndef D_A_OBJ_TOWER_GEARD101_H | ||
#define D_A_OBJ_TOWER_GEARD101_H | ||
|
||
#include "common.h" | ||
#include "d/a/obj/d_a_obj_base.h" | ||
#include "m/m3d/m_mdl.h" | ||
#include "m/m_angle.h" | ||
#include "m/m_mtx.h" | ||
#include "m/m_vec.h" | ||
#include "nw4r/g3d/g3d_resfile.h" | ||
#include "s/s_State.hpp" | ||
#include "s/s_StateMgr.hpp" | ||
#include "toBeSorted/effects_struct.h" | ||
|
||
/** | ||
* A callback implementation that controls the button node in the switch model. | ||
*/ | ||
class dAcOTowerGearD101_callback_c : public m3d::callback_c { | ||
public: | ||
dAcOTowerGearD101_callback_c() {} | ||
virtual ~dAcOTowerGearD101_callback_c() {} | ||
virtual void timingB(u32, nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl) override; | ||
|
||
/* 0x04 */ u32 mNodeId; | ||
/* 0x08 */ mAng mGearRotation; | ||
|
||
void init(u32 nodeId) { | ||
mNodeId = nodeId; | ||
} | ||
}; | ||
|
||
class dAcOTowerGearD101_c : public dAcObjBase_c { | ||
public: | ||
dAcOTowerGearD101_c() : mStateMgr(*this, sStateID::null) {} | ||
dAcOTowerGearD101_c() | ||
: mStateMgr(*this, sStateID::null), field_0x3A0(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z), | ||
field_0x3AC(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z), field_0x3B8(mAng3_c::Zero) {} | ||
virtual ~dAcOTowerGearD101_c() {} | ||
|
||
STATE_FUNC_DECLARE(dAcOTowerGearD101_c, Wait); | ||
|
||
virtual bool createHeap() override; | ||
virtual int actorCreate() override; | ||
virtual int actorPostCreate() override; | ||
virtual int doDelete() override; | ||
virtual int actorExecute() override; | ||
virtual int draw() override; | ||
|
||
private: | ||
/* 0x??? */ STATE_MGR_DECLARE(dAcOTowerGearD101_c); | ||
void initTransform(); | ||
void playVisualEffect(); | ||
|
||
/* 0x330 */ nw4r::g3d::ResFile mRes; | ||
/* 0x334 */ m3d::mdl_c mMdl; | ||
/* 0x350 */ STATE_MGR_DECLARE(dAcOTowerGearD101_c); | ||
/* 0x394 */ dAcOTowerGearD101_callback_c mMdlCallback; | ||
/* 0x3A0 */ mVec3_c field_0x3A0; | ||
/* 0x3AC */ mVec3_c field_0x3AC; | ||
/* 0x3B8 */ mAng3_c field_0x3B8; | ||
/* 0x3BE */ u8 field_0x3BE[2]; | ||
/* 0x3C0 */ mAng mCurrRotation; | ||
/* 0x3C2 */ s16 mPreviousTurnSpeed; | ||
/* 0x3C4 */ mMtx_c field_0x3C4; | ||
/* 0x3F4 */ mVec3_c field_0x3F4; | ||
/* 0x400 */ EffectsStruct mEffects; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,132 @@ | ||
#include "d/a/obj/d_a_obj_tower_gearD101.h" | ||
|
||
#include "common.h" | ||
#include "d/a/d_a_base.h" | ||
#include "d/a/obj/d_a_obj_tower_D101.h" | ||
#include "d/col/bg/d_bg_s_wtr_chk.h" | ||
#include "f/f_base.h" | ||
#include "f/f_manager.h" | ||
#include "f/f_profile_name.h" | ||
#include "m/m_vec.h" | ||
#include "nw4r/g3d/g3d_resmdl.h" | ||
#include "toBeSorted/room_manager.h" | ||
|
||
SPECIAL_ACTOR_PROFILE(OBJ_TOWER_GEAR_D101, dAcOTowerGearD101_c, fProfile::OBJ_TOWER_GEAR_D101, 0x17E, 0, 7); | ||
|
||
STATE_DEFINE(dAcOTowerGearD101_c, Wait); | ||
|
||
extern "C" void fn_80067340(mVec3_c &, nw4r::g3d::ResMdl *, const char *); | ||
|
||
bool dAcOTowerGearD101_c::createHeap() { | ||
const char *name = "TowerGearD101"; | ||
mRes = getOarcResFile(name); | ||
RoomManager::bindStageResToFile(&mRes); | ||
nw4r::g3d::ResMdl mdl = mRes.GetResMdl(name); | ||
if (!mMdl.create(mdl, &heap_allocator, 0x120, 1, nullptr)) { | ||
return false; | ||
} | ||
fn_80067340(field_0x3A0, &mdl, "model0"); | ||
position = field_0x3A0; | ||
position.rotY(rotation.y); | ||
|
||
return true; | ||
} | ||
|
||
int dAcOTowerGearD101_c::actorCreate() { | ||
if (!initAllocatorWork1Heap(0x1000, "dAcOTowerGearD101_c::m_allocator", 0x20)) { | ||
return FAILED; | ||
} | ||
nw4r::g3d::ResMdl mdl = mMdl.getResMdl(); | ||
mMdlCallback.init(mdl.GetResNode("model0").GetID()); | ||
mMdl.setCallback(&mMdlCallback); | ||
forwardAccel = 0.0f; | ||
forwardMaxSpeed = 0.0f; | ||
mStateMgr.changeState(StateID_Wait); | ||
|
||
mVec3_c s = field_0x3AC; | ||
boundingBox.Set( | ||
mVec3_c(s.x * -200.0f, s.y * -200.0f, s.z * -50.0f), mVec3_c(s.x * 200.0f, s.y * 200.0f, s.z * 50.0f) | ||
); | ||
|
||
initTransform(); | ||
if (dBgS_WtrChk::CheckPos(&position, true, 500.0f, -500.0f)) { | ||
field_0x3F4 = mVec3_c::Zero; | ||
field_0x3F4.y = dBgS_WtrChk::GetWaterHeight(); | ||
} else { | ||
field_0x3F4 = mVec3_c::Zero; | ||
} | ||
mEffects.init(this); | ||
return SUCCEEDED; | ||
} | ||
|
||
int dAcOTowerGearD101_c::actorPostCreate() { | ||
fBase_c *ac = fManager_c::searchBaseByProfName(fProfile::OBJ_TOWER_D101, nullptr); | ||
if (ac == nullptr) { | ||
return NOT_READY; | ||
} | ||
setActorRef(static_cast<dAcOTowerD101_c *>(ac)); | ||
return SUCCEEDED; | ||
} | ||
|
||
int dAcOTowerGearD101_c::doDelete() { | ||
return SUCCEEDED; | ||
} | ||
|
||
int dAcOTowerGearD101_c::actorExecute() { | ||
mStateMgr.executeState(); | ||
return SUCCEEDED; | ||
} | ||
|
||
int dAcOTowerGearD101_c::draw() { | ||
drawModelType1(&mMdl); | ||
return SUCCEEDED; | ||
} | ||
|
||
void dAcOTowerGearD101_c::initializeState_Wait() {} | ||
void dAcOTowerGearD101_c::executeState_Wait() {} | ||
void dAcOTowerGearD101_c::executeState_Wait() { | ||
dAcOTowerD101_c *tower = static_cast<dAcOTowerD101_c *>(actor_node.get()); | ||
if (tower != nullptr) { | ||
f32 diff = tower->mGoalElevation - tower->mCurrentElevation; | ||
s32 scale5 = 0x50000; | ||
mAng prevRotation = mCurrRotation; | ||
mAng newRotation = diff * scale5 / 2400.0f; | ||
if (newRotation != mCurrRotation) { | ||
if (mPreviousTurnSpeed == 0) { | ||
playSound(0xBF8); | ||
} else { | ||
playSoundEffect1(0xBF9); | ||
playVisualEffect(); | ||
} | ||
} | ||
s32 turnSpeed = newRotation - prevRotation; | ||
|
||
mCurrRotation = newRotation; | ||
mPreviousTurnSpeed = turnSpeed; | ||
mMdlCallback.mGearRotation = newRotation; | ||
} | ||
} | ||
void dAcOTowerGearD101_c::finalizeState_Wait() {} | ||
|
||
void dAcOTowerGearD101_callback_c::timingB(u32 nodeId, nw4r::g3d::WorldMtxManip *manip, nw4r::g3d::ResMdl mdl) { | ||
if (nodeId == mNodeId) { | ||
mMtx_c mtx1; | ||
manip->GetMtx(mtx1); | ||
mtx1.ZrotM(mGearRotation); | ||
manip->SetMtx(mtx1); | ||
} | ||
} | ||
|
||
void dAcOTowerGearD101_c::initTransform() { | ||
mWorldMtx.transS(mVec3_c::Zero); | ||
mMtx_c mtx1; | ||
mtx1.transS(position); | ||
mWorldMtx += mtx1; | ||
field_0x3C4.transS(mVec3_c::Zero); | ||
field_0x3C4.ZXYrotM(rotation.x, rotation.y, rotation.z); | ||
mMdl.setLocalMtx(field_0x3C4); | ||
} | ||
|
||
extern "C" u16 PARTICLE_RESOURCE_ID_MAPPING_585_; | ||
void dAcOTowerGearD101_c::playVisualEffect() { | ||
mEffects.fn_80029A10(PARTICLE_RESOURCE_ID_MAPPING_585_, &field_0x3F4, &rotation, nullptr, nullptr, nullptr); | ||
} |