A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectDossunNormal.cc
1#include "ObjectDossunNormal.hh"
2
3namespace Kinoko::Field {
4
6ObjectDossunNormal::ObjectDossunNormal(const System::MapdataGeoObj &params)
7 : ObjectDossun(params) {}
8
10ObjectDossunNormal::~ObjectDossunNormal() = default;
11
13void ObjectDossunNormal::init() {
14 ObjectDossun::init();
15
16 m_stompState = StompState::Inactive;
17 m_currRot = rot().y;
18
19 if (m_currRot <= F_PI) {
20 m_currRot -= F_TAU;
21 }
22}
23
25void ObjectDossunNormal::calc() {
26 m_touchingGround = false;
27
28 switch (m_stompState) {
29 case StompState::Inactive:
30 calcInactive();
31 break;
32 case StompState::Active:
33 calcStomp();
34 break;
35 default:
36 break;
37 }
38}
39
41void ObjectDossunNormal::startStill() {
42 m_anmState = AnmState::Still;
43 m_shakePhase = 0;
44 m_vel = 0.0f;
45 setRot(EGG::Vector3f(rot().x, m_currRot, rot().z));
46 m_stompState = StompState::Inactive;
47 m_stillTimer = static_cast<s32>(m_mapObj->setting(3));
48}
49
51void ObjectDossunNormal::startBeforeFall() {
52 m_stompState = StompState::Active;
53 m_anmState = AnmState::BeforeFall;
54 m_beforeFallTimer = static_cast<s32>(BEFORE_FALL_DURATION);
55 m_cycleTimer = static_cast<s32>(m_fullDuration);
56}
57
59void ObjectDossunNormal::calcInactive() {
60 constexpr s32 SHAKE_DURATION = 30;
61 constexpr s32 SHAKE_PHASE_CHANGE = 30;
62 constexpr f32 SHAKE_AMPLITUDE = 30.0f;
63
64 if (--m_stillTimer == 0) {
65 startBeforeFall();
66 }
67
68 if (m_stillTimer <= SHAKE_DURATION) {
69 m_shakePhase += SHAKE_PHASE_CHANGE;
70 f32 posY = m_initialPosY +
71 SHAKE_AMPLITUDE * EGG::Mathf::sin(static_cast<f32>(m_shakePhase) * DEG2RAD);
72 setPos(EGG::Vector3f(pos().x, posY, pos().z));
73 }
74}
75
76} // namespace Kinoko::Field
Base class for the various different Thwomp types in the game.
Pertains to collision.