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 ASSERT(m_mapObj);
39 u32 timer = static_cast<u32>(m_mapObj->setting(4));
40
41 if (timer == 0) {
42 timer = static_cast<u32>(m_mapObj->setting(5));
43 }
44
45 m_stompCooldown = timer;
46 m_curPressIdx = 0;
47}
48
50void ObjectItemboxLine::calc() {
51 if (--m_stompCooldown > 0) {
52 return;
53 }
54
55 m_stompCooldown = static_cast<u32>(m_mapObj->setting(5));
56
57 m_press[m_curPressIdx]->startPress();
58 m_curPressIdx = (m_curPressIdx + 1) % m_press.size();
59}
60
61} // namespace Field
Pertains to collision.