NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_enemy_state.cpp
1#include <game/bases/d_enemy.hpp>
3#include <game/bases/d_a_player_base.hpp>
4#include <game/bases/d_a_player_manager.hpp>
5#include <game/bases/d_actor_manager.hpp>
6#include <game/bases/d_effectmanager.hpp>
7#include <game/bases/d_enemy_manager.hpp>
8#include <game/bases/d_game_com.hpp>
9#include <game/bases/d_multi_manager.hpp>
10#include <game/bases/d_score_manager.hpp>
11#include <game/mLib/m_effect.hpp>
13
19
21 if (isState(StateID_Ice)) {
22 mStateMgr.returnState();
23 }
24 mStateMgr.changeState(id);
25}
26
27void dEn_c::initializeState_Ice() {
28 mIceMng.initialize();
29 createIceActor();
30
31 mBc.mFlags = 0;
32 setIceAnm();
33 removeCc();
34
35 if (mIceMng.checkInstantBreak(mFlags & EN_FLAG_16)) {
36 mIceMng.mDestroyMode = dIceMng_c::DESTROY_BREAK;
37 }
38 mIceMng.mActive = true;
39}
40
41void dEn_c::finalizeState_Ice() {
42 mIceMng.mActive = false;
43}
44
45void dEn_c::executeState_Ice() {
46 switch (mIceMng.manageProc()) {
47 case dIceMng_c::PROC_DEFAULT:
48 returnAnm_Ice();
49 returnState_Ice();
50 break;
51
52 case dIceMng_c::PROC_MELT:
53 reviveCc();
54 break;
55
56 case dIceMng_c::PROC_FROZEN: {
57 dIceMng_c::DESTROY_MODE_e destroyMode = mIceMng.mDestroyMode;
58 if (destroyMode == dIceMng_c::DESTROY_NONE) {
59 break;
60 }
61
62 mIceMng.breakEffect();
63 dAudio::g_pSndObjMap->startSound(SE_OBJ_PNGN_ICE_BREAK, mPos, 0);
64 switch (destroyMode) {
65 case dIceMng_c::DESTROY_BREAK:
66 setDeathInfo_IceBreak();
67 break;
68 case dIceMng_c::DESTROY_VANISH:
69 setDeathInfo_IceVanish();
70 break;
71 default:
72 break;
73 }
74 break;
75 }
76
77 default:
78 break;
79 }
80}
81
82bool dEn_c::createIceActor() {
83 dIceInfo iceInfo[] = {
84 {
85 getIceMode(),
86 mPos,
87 mVec3_c(1.0f, 1.0f, 1.0f)
88 }
89 };
90 return mIceMng.createIce(iceInfo, ARRAY_SIZE(iceInfo));
91}
92
93void dEn_c::setIceAnm() {}
94
95void dEn_c::returnAnm_Ice() {}
96
97void dEn_c::killIce() {
98 mIceMng.removeIce();
99}
100
101void dEn_c::returnState_Ice() {
102 mStateMgr.returnState();
103}
104
105void dEn_c::initializeState_HitSpin() {}
106
107void dEn_c::finalizeState_HitSpin() {}
108
109void dEn_c::executeState_HitSpin() {}
110
111void dEn_c::initializeState_EatIn() {}
112
113void dEn_c::finalizeState_EatIn() {}
114
115void dEn_c::executeState_EatIn() {
116 if (mEatState == EAT_STATE_EATEN) {
117 changeState(StateID_EatNow);
118 } else {
120 if (eatActor != nullptr) {
121 calcEatInScale(eatActor);
122 }
123 }
124}
125
126void dEn_c::initializeState_EatNow() {}
127
128void dEn_c::finalizeState_EatNow() {}
129
130void dEn_c::executeState_EatNow() {}
131
132void dEn_c::initializeState_EatOut() {}
133
134void dEn_c::finalizeState_EatOut() {}
135
136void dEn_c::executeState_EatOut() {}
bool isState(const sStateIDIf_c &other) const
Checks if the actor is currently in the given state.
sFStateStateMgr_c< dActorMultiState_c, sStateMethodUsr_FI_c, sStateMethodUsr_FI_c > mStateMgr
The state manager.
fBaseID_e mEatenByID
The unique identifier of the eating actor.
Definition d_actor.hpp:364
virtual void reviveCc()
Enables the actor's collision.
Definition d_actor.cpp:804
dBc_c mBc
The actor-to-tile collision sensor.
Definition d_actor.hpp:342
u8 mEatState
The actor's eat state. Value is a EAT_STATE_e.
Definition d_actor.hpp:365
virtual void removeCc()
Disables the actor's collision.
Definition d_actor.cpp:800
@ EAT_STATE_EATEN
The actor has been successfully eaten.
Definition d_actor.hpp:29
dActor_c()
Constructs a new actor.
Definition d_actor.cpp:46
mVec3_c mPos
The actor's position.
An enemy actor. Note that the definition of "enemy" in this context is actually any interactible stag...
Definition d_enemy.hpp:88
dIceMng_c mIceMng
The ice manager for this enemy.
Definition d_enemy.hpp:285
virtual void changeState(const sStateIDIf_c &newState)
Changes the actor's state to the given state.
virtual void calcEatInScale(dActor_c *)
Adjusts the actor's scale while being eaten.
Definition d_enemy.cpp:968
u32 mFlags
Flags for this actor. See FLAGS_e.
Definition d_enemy.hpp:289
static fBase_c * searchBaseByID(fBaseID_e id)
Searches for a base with the given ID.
Definition f_manager.cpp:18
The interface for state IDs.
#define STATE_VIRTUAL_DEFINE(class, name)
Defines a virtual state.
Definition s_State.hpp:46