A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectCarTGE.hh
1
2
3#pragma once
4
5#include "game/field/StateManager.hh"
6#include "game/field/obj/ObjectCollidable.hh"
7
8namespace Field {
9
10class ObjectCarTGE;
11class ObjectHighwayManager;
12
13class ObjectCarTGE : public ObjectCollidable, public StateManager<ObjectCarTGE> {
15
16public:
17 enum class CarType {
18 Normal = 0,
19 Truck = 1,
20 BombCar = 2,
21 };
22
24 ~ObjectCarTGE() override;
25
26 void init() override;
27 void calc() override;
28
30 [[nodiscard]] u32 loadFlags() const override {
31 return 1;
32 }
33
35 [[nodiscard]] const char *getResources() const override {
36 return m_carName;
37 }
38
40 [[nodiscard]] const char *getKclName() const override {
41 return m_mdlName;
42 }
43
44 void createCollision() override;
45 void calcCollisionTransform() override;
46 [[nodiscard]] f32 getCollisionRadius() const override;
47 Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
48 Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override;
49 bool checkCollision(ObjectCollisionBase *lhs, EGG::Vector3f &dist) override;
50 [[nodiscard]] const EGG::Vector3f &collisionCenter() const override;
51
52 void setHighwayManager(const ObjectHighwayManager *highwayMgr) {
53 m_highwayMgr = highwayMgr;
54 }
55
57 void reset() {
58 m_squashed = false;
59 }
60
61 [[nodiscard]] bool squashed() const {
62 return m_squashed;
63 }
64
65private:
66 static constexpr f32 TOLL_BOOTH_ACCEL = 200.0f;
67
68 void enterStateStub();
69 void calcStateStub();
70 void calcState1();
71 void calcState2();
72
73 void calcPos();
74
75 const ObjectHighwayManager *m_highwayMgr;
76 ObjectCollisionBase *m_auxCollision;
79 char m_carName[32];
80 char m_mdlName[32];
82 ObjectId m_dummyId;
83 EGG::Vector3f m_scaledTangentDir;
84 f32 m_currSpeed;
85 EGG::Vector3f m_up;
86 EGG::Vector3f m_tangent;
87 bool m_squashed;
88 bool m_hasAuxCollision;
89 f32 m_hitAngle;
90
91 static constexpr std::array<StateManagerEntry<ObjectCarTGE>, 3> STATE_ENTRIES = {{
92 {0, &ObjectCarTGE::enterStateStub, &ObjectCarTGE::calcStateStub},
93 {1, &ObjectCarTGE::enterStateStub, &ObjectCarTGE::calcState1},
94 {2, &ObjectCarTGE::enterStateStub, &ObjectCarTGE::calcState2},
95 }};
96};
97
98} // namespace Field
void calcState1()
The state when cars are speeding up.
f32 m_localVel
Speed while off the highway.
CarType m_carType
Car, truck, or bomb car.
void calcState2()
The state when cars are slowing down.
f32 m_highwayVel
Speed while on the highway.
@ BombCar
Unused in time trials.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88