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 ObjectHighwayManager;
11
13public:
14 enum class CarType {
15 Normal = 0,
16 Truck = 1,
17 BombCar = 2,
18 };
19
21 ~ObjectCarTGE() override;
22
23 void init() override;
24 void calc() override;
25
27 [[nodiscard]] u32 loadFlags() const override {
28 return 1;
29 }
30
32 [[nodiscard]] const char *getResources() const override {
33 return m_carName;
34 }
35
37 [[nodiscard]] const char *getKclName() const override {
38 return m_mdlName;
39 }
40
41 void createCollision() override;
42 void calcCollisionTransform() override;
43 [[nodiscard]] f32 getCollisionRadius() const override;
44 Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
45 Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override;
46 bool checkCollision(ObjectCollisionBase *lhs, EGG::Vector3f &dist) override;
47 [[nodiscard]] const EGG::Vector3f &collisionCenter() const override;
48
49 void setHighwayManager(const ObjectHighwayManager *highwayMgr) {
50 m_highwayMgr = highwayMgr;
51 }
52
54 void reset() {
55 m_squashed = false;
56 }
57
58 [[nodiscard]] bool squashed() const {
59 return m_squashed;
60 }
61
62private:
63 static constexpr f32 TOLL_BOOTH_ACCEL = 200.0f;
64
65 void enterStateStub();
66 void calcStateStub();
67 void calcState1();
68 void calcState2();
69
70 void calcPos();
71
72 const ObjectHighwayManager *m_highwayMgr;
73 ObjectCollisionBase *m_auxCollision;
76 char m_carName[32];
77 char m_mdlName[32];
79 ObjectId m_dummyId;
80 EGG::Vector3f m_scaledTangentDir;
81 f32 m_currSpeed;
82 EGG::Vector3f m_up;
83 EGG::Vector3f m_tangent;
84 bool m_squashed;
85 bool m_hasAuxCollision;
86 f32 m_hitAngle;
87
88 static constexpr std::array<StateManagerEntry, 3> STATE_ENTRIES = {{
89 {StateEntry<ObjectCarTGE, &ObjectCarTGE::enterStateStub, &ObjectCarTGE::calcStateStub>(
90 0)},
91 {StateEntry<ObjectCarTGE, &ObjectCarTGE::enterStateStub, &ObjectCarTGE::calcState1>(1)},
92 {StateEntry<ObjectCarTGE, &ObjectCarTGE::enterStateStub, &ObjectCarTGE::calcState2>(2)},
93 }};
94};
95
96} // 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.
Base class that represents different "states" for an object.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88