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 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 = std::span<ObjectItemboxPress *>(new ObjectItemboxPress *[pressCount], 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() {
32 // Individual objects' lifecycle is managed by the ObjectDirector.
33 delete[] m_press.data();
34}
35
37void ObjectItemboxLine::init() {
38 u32 timer = static_cast<u32>(m_mapObj->setting(4));
39
40 if (timer == 0) {
41 timer = static_cast<u32>(m_mapObj->setting(5));
42 }
43
44 m_stompCooldown = timer;
45 m_curPressIdx = 0;
46}
47
49void ObjectItemboxLine::calc() {
50 if (--m_stompCooldown > 0) {
51 return;
52 }
53
54 m_stompCooldown = static_cast<u32>(m_mapObj->setting(5));
55
56 m_press[m_curPressIdx]->startPress();
57 m_curPressIdx = (m_curPressIdx + 1) % m_press.size();
58}
59
60} // namespace Field
Pertains to collision.