A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectCrab.hh
1#pragma once
2
3#include "game/field/obj/ObjectCollidable.hh"
4
5namespace Field {
6
7class ObjectCrab final : public ObjectCollidable {
8public:
10 ~ObjectCrab() override;
11
12 void init() override;
13 void calc() override;
14
16 [[nodiscard]] u32 loadFlags() const override {
17 return 1;
18 }
19
20private:
21 enum class State {
22 Walking = 0,
23 Still = 1,
24 Deactivated = 2,
25 Resurfacing = 3,
26 };
27
28 enum class StatePhase {
29 Start = 0,
30 Middle = 1,
31 End = 2,
32 };
33
34 enum class StateResult {
35 Walking = 0,
36 Middle = 1,
37 BeginWalking = 2,
38 };
39
40 bool calcRail();
41 StateResult calcState();
42
43 void calcCurRot(const EGG::Vector3f &rot);
44 void calcTransMat(const EGG::Vector3f &rot);
45
46 const f32 m_vel;
47 u32 m_stillDuration;
48 u32 m_stillFrame;
49 bool m_still;
50 const bool m_backwards;
51 EGG::Vector3f m_curRot;
52 State m_state;
53 StatePhase m_statePhase;
54
55 // In the base game, there is a m_timer member variable at offset 0xcc which ends up resulting
56 // in the calc function being run only once during the intro timer.
57 bool m_introCalc;
58
59 static constexpr f32 YAW = F_PI / 2.0f;
60 STATIC_ASSERT(YAW == 1.5707964f);
61 static constexpr EGG::Vector3f INIT_ROT = EGG::Vector3f(0.0f, YAW, 0.0f);
62
63 static constexpr u32 COUNT = 3;
64};
65
66} // namespace Field
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88