1#include "ObjectHwanwan.hh"
3#include "game/field/CollisionDirector.hh"
9 : ObjectCollidable(params), StateManager(this, STATE_ENTRIES), m_initPos(m_pos) {}
12ObjectHwanwan::~ObjectHwanwan() =
default;
15void ObjectHwanwan::init() {
16 m_workPos = m_initPos + EGG::Vector3f::ey * DIAMETER;
18 m_bounceVel.setZero();
19 m_tangent = EGG::Vector3f::ez;
20 m_up = EGG::Vector3f::ey;
21 m_targetUp = EGG::Vector3f::ey;
22 m_touchingGround =
false;
24 m_targetY = m_workPos.y;
32void ObjectHwanwan::calc() {
35 m_extVel += m_bounceVel - GRAVITY;
36 m_workPos += m_extVel;
37 m_bounceVel.setZero();
39 checkFloorCollision();
41 SetRotTangentHorizontal(m_transform, m_up, m_tangent);
42 m_transform.setBase(3, m_workPos);
47void ObjectHwanwan::checkFloorCollision() {
48 constexpr f32 RADIUS = DIAMETER * 0.5f;
50 m_touchingGround =
false;
52 CollisionInfo colInfo;
56 bool hasCol = CollisionDirector::Instance()->checkSphereFullPush(RADIUS, pos,
59 if (!hasCol || pos.y - m_targetY >= 300.0f) {
63 m_touchingGround =
true;
65 f32 len = colInfo.tangentOff.length();
66 m_workPos += EGG::Vector3f::ey * len;
68 if (colInfo.floorDist > -std::numeric_limits<f32>::min()) {
69 m_targetUp = colInfo.floorNrm;
75void ObjectHwanwan::calcUp() {
76 m_up = Interpolate(0.1f, m_up, m_targetUp);
77 if (m_up.squaredLength() > std::numeric_limits<f32>::epsilon()) {
80 m_up = EGG::Vector3f::ey;
86 : ObjectCollidable(params) {
87 m_hwanwan =
new ObjectHwanwan(params);
93ObjectHwanwanManager::~ObjectHwanwanManager() =
default;
96void ObjectHwanwanManager::init() {
97 m_railInterpolator->init(0.0f, 0);
98 m_hwanwan->m_tangent = m_railInterpolator->curTangentDir();
99 const auto &curPos = m_railInterpolator->curPos();
100 m_hwanwan->m_workPos.x = curPos.x;
101 m_hwanwan->m_workPos.z = curPos.z;
102 m_hwanwan->m_targetY = curPos.y;
108 m_railInterpolator->setCurrVel(
static_cast<f32
>(m_mapObj->setting(0)));
112void ObjectHwanwanManager::calc() {
115 const auto &curPos = m_railInterpolator->curPos();
116 m_hwanwan->m_workPos.x = curPos.x;
117 m_hwanwan->m_workPos.z = curPos.z;
118 m_hwanwan->m_targetY = curPos.y;
119 m_hwanwan->m_tangent = m_railInterpolator->curTangentDir();
123void ObjectHwanwanManager::calcState() {
124 if (m_railInterpolator->calc() == RailInterpolator::Status::SegmentEnd &&
125 m_railInterpolator->curPoint().setting[1] == 1 && m_hwanwan->m_currentStateId != 2) {
126 m_hwanwan->m_nextStateId = 1;
129 if (m_hwanwan->m_currentStateId == 1 && m_hwanwan->m_currentFrame >= 60) {
130 m_hwanwan->m_nextStateId = 0;
#define KCL_TYPE_FLOOR
0x20E80FFF - Any KCL that the player or items can drive/land on.