NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ef_effect.h
1#ifndef NW4R_EF_EFFECT_H
2#define NW4R_EF_EFFECT_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ef/ef_activitylist.h>
6#include <nw4r/ef/ef_draworder.h>
7#include <nw4r/ef/ef_particlemanager.h>
8#include <nw4r/ef/ef_referencedobject.h>
9#include <nw4r/ef/ef_res_emitter.h>
10#include <nw4r/ef/ef_types.h>
11
12#include <nw4r/math.h>
13#include <nw4r/ut.h>
14
15namespace nw4r {
16namespace ef {
17
18// Forward declarations
19class Emitter;
20class ParticleManager;
21class Particle;
22class EffectSystem;
23class DrawOrderBase;
24
25class Effect : public ReferencedObject {
26 friend class EffectSystem;
27 friend class DrawOrderBase;
28
29private:
30 enum Flag {
31 FLAG_DISABLE_CALC = (1 << 0),
32 FLAG_DISABLE_DRAW = (1 << 1),
33 FLAG_EXIST_CALC_REMAIN = (1 << 16),
34 };
35
36 struct CallBack {
37 typedef void (*PrevEmissionFunc)(Emitter* pEmitter,
38 ParticleManager* pManager, int* pCount,
39 ulong* pFlags,
40 f32 (*pParams)[NUM_PARAMS], u16* pLife,
41 f32* pLifeRnd, math::MTX34* pSpace);
42
43 typedef void (*PtclCalcFunc)(ParticleManager* pManager, ut::List* pList,
44 Particle* pParticle);
45
46 PrevEmissionFunc mPrevEmission; // at 0x0
47 PtclCalcFunc mPrevPtclCalc; // at 0x4
48 PtclCalcFunc mPostPtclCalc; // at 0x8
49 };
50
51public:
52 EffectSystem* mManagerES; // at 0x20
53 ActivityList mActivityList; // at 0x24
54 ulong mGroupID; // at 0x40
55 CallBack mCallBack; // at 0x44
56
57protected:
58 ulong mFlags; // at 0x50
59 math::MTX34 mRootMtx; // at 0x54
60 math::VEC3 mVelocity; // at 0x84
61 ut::List mParticleManager; // at 0x90
62 DrawOrderBase* mDrawOrderFunc; // at 0x9C
63
64public:
65 Effect();
66 ~Effect();
67
68 virtual void SendClosing(); // at 0x8
69 virtual void DestroyFunc(); // at 0xC
70
71 virtual bool Initialize(EffectSystem* pSystem, EmitterResource* pResource,
72 u16 calcRemain); // at 0x10
73 virtual Emitter* CreateEmitter(ResEmitter res, u8 drawWeight,
74 u16 calcRemain) {
75 return CreateEmitter(res.ptr(), drawWeight, calcRemain);
76 } // at 0x14
77
78 virtual void Calc(bool onlyBillboard); // at 0x18
79 virtual void Draw(const DrawInfo& rInfo); // at 0x1C
80
81 bool Closing(Emitter* pEmitter);
82
83 Emitter* CreateEmitter(EmitterResource* pResource, u8 drawWeight,
84 u16 calcRemain);
85 ulong RetireEmitter(Emitter* pEmitter);
86
87 ulong RetireEmitterAll();
88 ulong RetireParticleAll();
89
90 u16 GetNumEmitter() const;
91 Emitter* GetEmitter(u16 idx);
92
93 ulong ForeachParticleManager(ForEachFunc pFunc, ForEachParam param,
94 bool ignoreLifeStatus);
95 ulong ForeachEmitterFrom(ForEachFunc pFunc, ForEachParam param,
96 bool ignoreLifeStatus, Emitter* pEmitter);
97
98 void ParticleManagerAdd(ParticleManager* pManager) {
99 mDrawOrderFunc->Add(this, pManager);
100 }
101 void ParticleManagerRemove(ParticleManager* pManager) {
102 mDrawOrderFunc->Remove(this, pManager);
103 }
104
105 void Modifier_SetSimpleLightType(u8 type, bool ignoreLifeStatus) {
106 ForeachParticleManager(
107 ParticleManager::ModifierTravFunc_SetSimpleLightType,
108 static_cast<ulong>(type), ignoreLifeStatus);
109 }
110
111 void Modifier_SetSimpleLightAmbient(const GXColor& rColor,
112 bool ignoreLifeStatus) {
113 ForeachParticleManager(
114 ParticleManager::ModifierTravFunc_SetSimpleLightAmbient,
115 reinterpret_cast<ulong>(&rColor), ignoreLifeStatus);
116 }
117
118 // @bug Surely meant to be a const reference...
119 void Modifier_SetScale(math::VEC2& rScale, bool ignoreLifeStatus) {
120 ForeachParticleManager(ParticleManager::ModifierTravFunc_SetScale,
121 reinterpret_cast<ulong>(&rScale),
122 ignoreLifeStatus);
123 }
124
125 void Modifier_SetRotate(const math::VEC3& rRot, bool ignoreLifeStatus) {
126 ForeachParticleManager(ParticleManager::ModifierTravFunc_SetRotate,
127 reinterpret_cast<ulong>(&rRot), ignoreLifeStatus);
128 }
129
130 bool GetFlagDisableCalc() const {
131 return mFlags & FLAG_DISABLE_CALC;
132 }
133 void SetFlagDisableCalc(bool disable) {
134 if (disable) {
135 mFlags |= FLAG_DISABLE_CALC;
136 } else {
137 mFlags &= ~FLAG_DISABLE_CALC;
138 }
139 }
140
141 bool GetFlagDisableDraw() const {
142 return mFlags & FLAG_DISABLE_DRAW;
143 }
144 void SetFlagDisableDraw(bool disable) {
145 if (disable) {
146 mFlags |= FLAG_DISABLE_DRAW;
147 } else {
148 mFlags &= ~FLAG_DISABLE_DRAW;
149 }
150 }
151
152 bool GetFlagExistCalcRemain() const {
153 return mFlags & FLAG_EXIST_CALC_REMAIN;
154 }
155 void SetFlagExistCalcRemain(bool exist) {
156 if (exist) {
157 mFlags |= FLAG_EXIST_CALC_REMAIN;
158 } else {
159 mFlags &= ~FLAG_EXIST_CALC_REMAIN;
160 }
161 }
162
163 const math::MTX34* GetRootMtx() const {
164 return &mRootMtx;
165 }
166
167 void SetRootMtx(const math::MTX34& rMtx);
168
169 const math::VEC3* GetVelocity() const {
170 return &mVelocity;
171 }
172};
173
174} // namespace ef
175} // namespace nw4r
176
177#endif