1#include "ObjectDossun.hh"
3#include "game/field/CollisionDirector.hh"
4#include "game/field/ObjectDirector.hh"
6#include "game/kart/KartObject.hh"
11ObjectDossun::ObjectDossun(
const System::MapdataGeoObj ¶ms)
15ObjectDossun::~ObjectDossun() =
default;
18void ObjectDossun::init() {
19 constexpr f32 BEFORE_FALL_VEL = 30.0f;
21 m_anmState = AnmState::Still;
25 if (m_railInterpolator) {
26 m_railInterpolator->init(0.0f, 0);
29 m_initialPosY = pos().y;
32 for (u32 i = 0; i < BEFORE_FALL_DURATION; ++i) {
33 setPos(EGG::Vector3f(pos().x, BEFORE_FALL_VEL + pos().y, pos().z));
37 auto *colDir = CollisionDirector::Instance();
44 setPos(EGG::Vector3f(pos().x, m_vel + pos().y, pos().z));
47 EGG::Vector3f colPos = pos() + STOMP_POS_OFFSET;
49 hasCol = colDir->checkSphereFull(STOMP_RADIUS, colPos, EGG::Vector3f::inf,
KCL_TYPE_FLOOR,
53 addPos(info.tangentOff);
56 f32 fallDuration = frameCount;
62 f32 posY = RISING_VEL + pos().y;
65 if (posY >= m_initialPosY) {
66 setPos(EGG::Vector3f(pos().x, m_initialPosY, pos().z));
67 riseDuration = frameCount;
70 setPos(EGG::Vector3f(pos().x, posY, pos().z));
74 m_fullDuration = fallDuration + GROUND_DURATION + riseDuration + BEFORE_FALL_DURATION;
75 m_touchingGround =
false;
79void ObjectDossun::calcCollisionTransform() {
80 constexpr f32 HEIGHT = 400.0f;
88 EGG::Matrix34f mat = transform();
89 mat[1, 3] += HEIGHT * scale().x;
91 collision()->transform(mat, scale());
95Kart::Reaction ObjectDossun::onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
96 Kart::Reaction , EGG::Vector3f & ) {
97 constexpr f32 SQUISH_DISTANCE = 375.0f;
99 EGG::Vector3f xzDist = kartObj->pos() - pos();
102 if (xzDist.length() < SQUISH_DISTANCE * scale().x &&
103 (m_anmState == AnmState::Falling || m_touchingGround)) {
104 const auto &hitTable = ObjectDirector::Instance()->hitTableKart();
105 return hitTable.reaction(hitTable.slot(ObjectId::DossuncSoko));
108 return reactionOnKart;
112void ObjectDossun::initState() {
113 m_stillTimer =
static_cast<u32
>(m_mapObj->setting(2));
114 if (m_stillTimer == 0) {
115 m_stillTimer =
static_cast<u32
>(m_mapObj->setting(3));
119 m_beforeFallTimer = 0;
124void ObjectDossun::calcStomp() {
125 switch (m_anmState) {
126 case AnmState::BeforeFall:
129 case AnmState::Falling:
132 case AnmState::Grounded:
135 case AnmState::Rising:
142 if (m_cycleTimer-- == 0) {
148void ObjectDossun::calcBeforeFall() {
149 constexpr f32 BEFORE_FALL_VEL = 50.0f;
151 setPos(EGG::Vector3f(pos().x, BEFORE_FALL_VEL + pos().y, pos().z));
153 if (--m_beforeFallTimer == 0) {
154 m_anmState = AnmState::Falling;
159void ObjectDossun::checkFloorCollision() {
161 EGG::Vector3f colPos = pos() + STOMP_POS_OFFSET;
163 if (!CollisionDirector::Instance()->checkSphereFull(STOMP_RADIUS, colPos, EGG::Vector3f::inf,
169 addPos(info.tangentOff);
172 m_touchingGround =
true;
#define KCL_TYPE_FLOOR
0x20E80FFF - Any KCL that the player or items can drive/land on.