A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectItemboxLine.cc
1#include "ObjectItemboxLine.hh"
2
3#include "game/field/obj/ObjectItemboxPress.hh"
4#include "game/field/obj/ObjectPress.hh"
5
6namespace Kinoko::Field {
7
9ObjectItemboxLine::ObjectItemboxLine(const System::MapdataGeoObj &params)
10 : ObjectCollidable(params) {
11 constexpr u32 DEFAULT_PRESS_COUNT = 5;
12
13 auto *senko = new ObjectPressSenko(params);
14 senko->load();
15
16 u32 pressCount = params.setting(6);
17 if (pressCount == 0) {
18 pressCount = DEFAULT_PRESS_COUNT;
19 }
20
21 m_press = owning_span<ObjectItemboxPress *>(pressCount);
22
23 for (auto *&press : m_press) {
24 press = new ObjectItemboxPress(params);
25 press->load();
26 press->setSenko(senko);
27 }
28}
29
31ObjectItemboxLine::~ObjectItemboxLine() = default;
32
34void ObjectItemboxLine::init() {
35 ASSERT(m_mapObj);
36 u32 timer = static_cast<u32>(m_mapObj->setting(4));
37
38 if (timer == 0) {
39 timer = static_cast<u32>(m_mapObj->setting(5));
40 }
41
42 m_stompCooldown = timer;
43 m_curPressIdx = 0;
44}
45
47void ObjectItemboxLine::calc() {
48 if (--m_stompCooldown > 0) {
49 return;
50 }
51
52 m_stompCooldown = static_cast<u32>(m_mapObj->setting(5));
53
54 m_press[m_curPressIdx]->startPress();
55 m_curPressIdx = (m_curPressIdx + 1) % m_press.size();
56}
57
58} // namespace Kinoko::Field
Pertains to collision.