A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectPillar.hh
1
2#pragma once
3
4#include "game/field/obj/ObjectCollidable.hh"
5#include "game/field/obj/ObjectKCL.hh"
6
7#include "game/kart/KartCollide.hh"
8
9#include "game/system/RaceManager.hh"
10
11namespace Field {
12
15public:
17 ~ObjectPillarBase() override;
18
20 [[nodiscard]] const char *getKclName() const override {
21 return "dc_pillar_base";
22 }
23
25 [[nodiscard]] virtual f32 colRadiusAdditionalLength() const override {
26 return 0.0f;
27 }
28};
29
34public:
36 ~ObjectPillarC() override;
37
38 void calcCollisionTransform() override;
39
41 [[nodiscard]] f32 getCollisionRadius() const override {
42 return 3000.0f;
43 }
44
46 [[nodiscard]] ObjectId id() const override {
47 return ObjectId::DCPillarC;
48 }
49
51 Kart::Reaction onCollision(Kart::KartObject * /*kartObj*/, Kart::Reaction reactionOnKart,
52 Kart::Reaction /*reactionOnObj*/, EGG::Vector3f & /*hitDepth*/) override {
53 auto *raceMgr = System::RaceManager::Instance();
54 return raceMgr->timer() < m_fallStart ? Kart::Reaction::WallAllSpeed : reactionOnKart;
55 }
56
57private:
58 const u32 m_fallStart;
59};
60
64class ObjectPillar : public ObjectKCL {
65public:
67 ~ObjectPillar() override;
68
69 void init() override;
70 void calc() override;
71
73 [[nodiscard]] u32 loadFlags() const override {
74 return 1;
75 }
76
78 [[nodiscard]] f32 colRadiusAdditionalLength() const override {
79 return 4000.0f;
80 }
81
82 [[nodiscard]] const EGG::Matrix34f &getUpdatedMatrix(u32 timeOffset) override;
83
84private:
85 enum class State {
86 Upright = 0,
87 Break = 1,
88 Ground = 2,
89 };
90
91 [[nodiscard]] f32 calcRot(s32 frame) const;
92
93 State m_state;
94 const u32 m_fallStart;
95 const f32 m_targetRotation;
96 const f32 m_initRot;
102};
103
104} // namespace Field
A 3 x 4 matrix.
Definition Matrix.hh:8
The stationary portion of the Dry Dry Ruins pillars. It just acts as a wall.
Represents the part of the Dry Dry Ruins pillar that falls.
f32 getCollisionRadius() const override
Finds the radius that fits fully in a BoxColUnit.
const u32 m_fallStart
The number of frames before the pillar will start to fall.
Represents the entirety of a pillar that falls on Dry Dry Ruins.
State m_state
0 when upright, 1 when falling, and 2 afterwards.
s32 m_groundFrame
Frame the pillar has finished falling.
EGG::Vector3f m_setupRot
Initial rotation of the pillar.
EGG::Matrix34f m_workMat
Rotation and translation matrix;.
const f32 m_targetRotation
How much the pillar rotates during the fall, in radians.
ObjectPillarC * m_collidable
Wall and hazard collision of the upright/falling pillar.
const u32 m_fallStart
The number of frames before the pillar will start to fall.
ObjectPillarBase * m_base
Stationary portion of pillar.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88