A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectSniper.cc
1#include "ObjectSniper.hh"
2
3#include "game/field/RailManager.hh"
4
5namespace Field {
6
8ObjectSniper::ObjectSniper()
9 : ObjectCollidable("MapObjSniper", EGG::Vector3f::zero, EGG::Vector3f::ez,
10 EGG::Vector3f::unit) {}
11
13ObjectSniper::~ObjectSniper() = default;
14
16void ObjectSniper::init() {
17 const auto *launcherRailInterp = m_launcher->railInterpolator();
18
19 for (auto &point : m_pointIdxs) {
20 point = -1;
21 }
22
23 auto *launcherRail = RailManager::Instance()->rail(launcherRailInterp->railIdx());
24
25 for (size_t i = 0; i < m_projectiles.size(); ++i) {
26 auto *obj = m_projectiles[i];
27 m_pointIdxs[obj->idx()] = i;
28 obj->initProjectile(launcherRail->pointPos(obj->idx()));
29 }
30}
31
33void ObjectSniper::calc() {
34 s32 idx = m_launcher->launchPointIdx();
35
36 if (idx != -1) {
37 m_projectiles[m_pointIdxs[idx]]->onLaunch();
38 }
39}
40
41} // namespace Field
EGG core library.
Definition Archive.cc:6
Pertains to collision.