A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectItemboxPress.cc
1#include "ObjectItemboxPress.hh"
2
3#include "game/field/obj/ObjectPress.hh"
4
5namespace Field {
6
8ObjectItemboxPress::ObjectItemboxPress(const System::MapdataGeoObj &params)
9 : ObjectCollidable(params) {}
10
12ObjectItemboxPress::~ObjectItemboxPress() = default;
13
15void ObjectItemboxPress::calc() {
16 switch (m_state) {
17 case 1:
18 case 2:
19 calcPosition();
20 break;
21 default:
22 break;
23 }
24}
25
27void ObjectItemboxPress::startPress() {
28 m_state = 2;
29 m_railInterpolator->init(0.0f, 0);
30 m_railInterpolator->setPerPointVelocities(true);
31}
32
34void ObjectItemboxPress::calcPosition() {
35 constexpr f32 HEIGHT_OFFSET = 180.0f;
36
37 auto result = m_railInterpolator->calc();
38
39 if (result == RailInterpolator::Status::SegmentEnd) {
40 if (m_railInterpolator->curPoint().setting[1] == 1) {
41 m_senko->setWindup(true);
42 }
43 } else if (result == RailInterpolator::Status::ChangingDirection) {
44 m_state = 0;
45 }
46
47 m_pos = m_railInterpolator->curPos();
48 m_pos.y = HEIGHT_OFFSET + m_pos.y;
49 m_flags.setBit(eFlags::Position);
50}
51
52} // namespace Field
Pertains to collision.