NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_cc.hpp
1#pragma once
2#include <types.h>
3#include <game/bases/d_actor.hpp>
4
11class dCc_c {
12public:
18 };
19
29
30 enum CC_FLAG_e {
32 };
33
35 CAT_PLAYER_GENERIC,
41 CAT_YOSHI,
42 CAT_ENTITY,
43 CAT_BALLOON,
44 CAT_ITEM,
45 CAT_PROJECTILE,
46 CAT_CANNON,
47 CAT_GOAL_POLE
48 };
49
50 enum CC_ATTACK_e {
51 ATTACK_FIRE = 1,
52 ATTACK_ICE,
53 ATTACK_STAR,
54 ATTACK_ICE_BREAK,
55 ATTACK_SLIP,
56 ATTACK_KOOPA_FIRE,
57 ATTACK_HIP_ATTK,
58 ATTACK_WIRE_NET,
59 ATTACK_SHELL,
60 ATTACK_PENGUIN_SLIDE,
61 ATTACK_SPIN,
62 ATTACK_UNK12,
63 ATTACK_SPIN_FALL,
64 ATTACK_FIRE_2,
65 ATTACK_YOSHI_EAT,
66 ATTACK_YOSHI_MOUTH,
67 ATTACK_CANNON,
68 ATTACK_YOSHI_BULLET,
69 ATTACK_YOSHI_FIRE,
70 ATTACK_ICE_2,
71 ATTACK_SAND_PILLAR
72 };
73
78 struct CcData_s {
79 float mOffsetX;
80 float mOffsetY;
81
87 float mWidth;
88
94 float mHeight;
95
110
111 u16 mFlag;
112
113 void (*mCallback)(dCc_c *, dCc_c *);
114 };
115
116private:
117
118 // [Some unused class - but needed here because it has a static initializer.]
120 public:
121 u32 a, b, c;
122 bool d, e;
123
124 static class _init {
125 public:
126 _init() {
127 if (!dCc_c::msIsInitialized) {
128 dCc_c::msInitializedUnkClass.b = 0xa000a0;
129 dCc_c::msInitializedUnkClass.c = 0xa00000a0;
130 dCc_c::msIsInitialized = true;
131 }
132 }
133 } _initializer;
134 };
135 static char msIsInitialized; // [This might also be an auto-generated guard variable]
136 static InitializedUnkClass msInitializedUnkClass;
137
138public:
139 dCc_c();
140 virtual ~dCc_c();
141
142 void clear();
143
144 void entry();
145 void release();
146
153 void registerCc(dActor_c *actor, CcData_s *collInfo);
154
162 void registerCc(dActor_c *actor, CcData_s *collInfo, u8 nonCollideMask);
163
165 void setFriendActor(dActor_c *actor) { mFriendActor = actor; }
166
172 u16 isHit(u16 mask) const;
173
179 u16 isHitAtDmg(u16 mask) const;
180
181 float getTopPos();
182 float getUnderPos();
183 float getCenterPosY();
184
185 float getRightPos();
186 float getLeftPos();
187 float getCenterPosX();
188
192 }
193
199 bool isInside(dCc_c *other);
200
201private:
202 float getTrpOffset(int idx) {
203 return mTrpOffsets[idx];
204 }
205
206public:
215 static bool checkCollision(dCc_c *c1, dCc_c *c2, int active);
216
217 static void execute();
218
225 static void reset();
226
227private:
235 static bool _hitCheckSquare(dCc_c *c1, dCc_c *c2, mVec2_c pos1, mVec2_c pos2);
236
238 static bool _hitCheckNormal(dCc_c *c1, dCc_c *c2);
240 static bool _hitCheckLoop(dCc_c *c1, dCc_c *c2);
242 static bool _hitCheckCircle(dCc_c *c1, dCc_c *c2);
244 static bool _hitCheckBoxCircle(dCc_c *c1, dCc_c *c2);
245
246 static int _lineCheckUD(mVec2_c p1, mVec2_c p2, float p3, float p4);
248 static bool _hitCheckDaikeiUD_R(dCc_c *ccBox, dCc_c *ccTrp);
250 static bool _hitCheckDaikeiUD(dCc_c *ccTrp, dCc_c *ccBox);
251
252 static int _lineCheckLR(mVec2_c p1, mVec2_c p2, float p3, float p4);
254 static bool _hitCheckDaikeiLR_R(dCc_c *ccBox, dCc_c *ccTrp);
256 static bool _hitCheckDaikeiLR(dCc_c *ccTrp, dCc_c *ccBox);
257
258private:
261
262 u32 unk2;
263
266
267 u32 unk3;
268
270
271public:
279 float mTrpOffsets[4];
280
287 float mCollOffsetX[8];
294 float mCollOffsetY[8];
295
297
301
303
311
318
319 u8 mFlag;
320
321private:
323
324 typedef bool (*hitCheck)(dCc_c *, dCc_c *);
325
332 static hitCheck _hitCheck[4][4];
333
334 static dCc_c *mEntryN;
335 static dCc_c *mEntryB;
336};
Collider ("Collision Check") class - handles collisions between actors.
Definition d_cc.hpp:11
mVec2_c getCenterVec()
Gets the center of the collider as a vector.
Definition d_cc.hpp:190
static bool _hitCheckSquare(dCc_c *c1, dCc_c *c2, mVec2_c pos1, mVec2_c pos2)
A hit check function for rectangular colliders. Used in _hitCheckNormal and _hitCheckLoop.
Definition d_cc.cpp:268
bool mIsLinked
Whether this collider has been placed in the collider list.
Definition d_cc.hpp:322
u8 mFlag
Flags for this collider. See CC_FLAG_e .
Definition d_cc.hpp:319
static bool checkCollision(dCc_c *c1, dCc_c *c2, int active)
Checks for collisions between two colliders.
Definition d_cc.cpp:164
u8 mNonCollideMask
The non-collide mask for this collider.
Definition d_cc.hpp:310
static bool _hitCheckDaikeiUD_R(dCc_c *ccBox, dCc_c *ccTrp)
Check a rectangular collider against a trapezoid-shaped collider for collisions.
Definition d_cc.cpp:504
dActor_c * mpOwner
The actor this collider belongs to.
Definition d_cc.hpp:259
float getUnderPos()
Gets the Y position of the bottom of the collider.
Definition d_cc.cpp:124
static bool _hitCheckLoop(dCc_c *c1, dCc_c *c2)
Check two rectangular colliders against each other for collisions with stage looping.
Definition d_cc.cpp:317
u32 unk3
[Unused (?)].
Definition d_cc.hpp:267
CC_CATEGORY_e
Definition d_cc.hpp:34
@ CAT_PLAYER_ATTACK
Definition d_cc.hpp:40
float getTopPos()
Gets the Y position of the top of the collider.
Definition d_cc.cpp:120
static dCc_c * mEntryN
The first collider in the list.
Definition d_cc.hpp:334
u16 isHitAtDmg(u16 mask) const
Gets the result of an attack hit check.
Definition d_cc.cpp:116
float mTrpOffsets[4]
The X or Y offset of the four corners of a trapezoid-shaped collider.
Definition d_cc.hpp:279
dCc_c * mpPrev
The previous collider in the list.
Definition d_cc.hpp:265
void clear()
Clear the data related to previous collisions.
Definition d_cc.cpp:37
float getCenterPosY()
Gets the Y position of the center of the collider.
Definition d_cc.cpp:128
float mCollOffsetY[8]
The Y offset for a collision.
Definition d_cc.hpp:294
void entry()
Places this collider in the collider list.
Definition d_cc.cpp:48
u16 mCollidedWith
The categories of the previously collided with colliders.
Definition d_cc.hpp:298
u8 mShape
The shape of the collider. See CC_SHAPE_e .
Definition d_cc.hpp:302
u16 mAttSent
The attack types sent by this collider in the previous collisions.
Definition d_cc.hpp:299
u32 unk2
[Unused (?)].
Definition d_cc.hpp:262
u16 isHit(u16 mask) const
Gets the result of a hit check.
Definition d_cc.cpp:112
static hitCheck _hitCheck[4][4]
The hit check function for each combination of collider shapes.
Definition d_cc.hpp:16
u16 mAttReceived
The attack types received by this collider in the previous collisions.
Definition d_cc.hpp:300
u8 mLayer
The layer this collider is on.
Definition d_cc.hpp:317
CC_SHAPE_e
Definition d_cc.hpp:13
@ CC_SHAPE_BOX
Rectangular collider.
Definition d_cc.hpp:14
@ CC_SHAPE_DAIKEI_UD
Trapezoid-shaped collider (left/right sides are parallel)
Definition d_cc.hpp:16
@ CC_SHAPE_DAIKEI_LR
Trapezoid-shaped collider (top/bottom sides are parallel)
Definition d_cc.hpp:17
@ CC_SHAPE_CIRCLE
Circular / elliptical collider.
Definition d_cc.hpp:15
void registerCc(dActor_c *actor, CcData_s *collInfo)
Registers an owner actor to this collider and sets the collider data.
Definition d_cc.cpp:87
CcData_s mCcData
The collision data of this collider.
Definition d_cc.hpp:269
float getCenterPosX()
Gets the X position of the center of the collider.
Definition d_cc.cpp:140
static bool _hitCheckCircle(dCc_c *c1, dCc_c *c2)
Check two circle colliders against each other for collisions.
Definition d_cc.cpp:341
float getLeftPos()
Gets the X position of the left side of the collider.
Definition d_cc.cpp:136
CC_DATA_FLAG_e
Definition d_cc.hpp:20
@ CC_DATA_NO_OFFSET
Don't set the collision offset if a collision occurs.
Definition d_cc.hpp:21
@ CC_DATA_PASSIVE
Definition d_cc.hpp:27
mVec2_c mCollPos
The position where the last collision occurred.
Definition d_cc.hpp:296
float getRightPos()
Gets the X position of the right side of the collider.
Definition d_cc.cpp:132
static bool _hitCheckDaikeiLR_R(dCc_c *ccBox, dCc_c *ccTrp)
Check a rectangular collider against a trapezoid-shaped collider for collisions.
Definition d_cc.cpp:576
virtual ~dCc_c()
Destroys the collider.
Definition d_cc.cpp:33
static void execute()
Check all colliders against each other for collisions.
Definition d_cc.cpp:260
dActor_c * mFriendActor
A second actor that this collider will not collide with.
Definition d_cc.hpp:260
void release()
Removes this collider from the collider list.
Definition d_cc.cpp:66
float mCollOffsetX[8]
The X offset for a collision.
Definition d_cc.hpp:287
static bool _hitCheckDaikeiLR(dCc_c *ccTrp, dCc_c *ccBox)
Check a trapezoid-shaped collider against a rectangular collider for collisions.
Definition d_cc.cpp:580
CC_FLAG_e
Definition d_cc.hpp:30
@ CC_DISABLE
Disables all collisions with this collider.
Definition d_cc.hpp:31
void setFriendActor(dActor_c *actor)
Sets a friend actor for this collider.
Definition d_cc.hpp:165
static bool _hitCheckBoxCircle(dCc_c *c1, dCc_c *c2)
Check a rectangular and a circle collider against each other for collisions.
Definition d_cc.cpp:387
static void reset()
Clears the collider list.
Definition d_cc.cpp:98
dCc_c * mpNext
The next collider in the list.
Definition d_cc.hpp:264
dCc_c()
Constructs a new collider.
Definition d_cc.cpp:23
static dCc_c * mEntryB
The last collider in the list.
Definition d_cc.hpp:335
static bool _hitCheckNormal(dCc_c *c1, dCc_c *c2)
Check two rectangular colliders against each other for collisions without stage looping.
Definition d_cc.cpp:311
static bool _hitCheckDaikeiUD(dCc_c *ccTrp, dCc_c *ccBox)
Check a trapezoid-shaped collider against a rectangular collider for collisions.
Definition d_cc.cpp:508
bool isInside(dCc_c *other)
Checks if this collider is inside another collider.
Definition d_cc.cpp:144
A two-dimensional floating point vector.
Definition m_vec.hpp:9
A structure that contains information about a collider.
Definition d_cc.hpp:78
void(* mCallback)(dCc_c *, dCc_c *)
The callback to execute when a collision occurs.
Definition d_cc.hpp:113
float mHeight
The height of the collider.
Definition d_cc.hpp:94
u32 mAttackCategoryInteract
Which attack categories this collider should be able to receive.
Definition d_cc.hpp:109
u8 mAttackCategory
The attack category of this collider. See CC_ATTACK_e .
Definition d_cc.hpp:97
float mOffsetX
The X offset of the collider.
Definition d_cc.hpp:79
u32 mCategoryInteract
Which categories this collider should be able to collide with.
Definition d_cc.hpp:103
float mWidth
The width of the collider.
Definition d_cc.hpp:87
u16 mFlag
Flags for this collider. See CC_DATA_FLAG_e .
Definition d_cc.hpp:111
float mOffsetY
The Y offset of the collider.
Definition d_cc.hpp:80
u8 mCategory
The category of this collider. See CC_CATEGORY_e .
Definition d_cc.hpp:96