1#include "Game/MapObj/MapPartsFloatingForce.hpp"
2#include "Game/MapObj/FloaterFunction.hpp"
3#include "Game/LiveActor/LiveActor.hpp"
4#include "Game/Util.hpp"
6SpringStep::SpringStep(f32 cond, f32 speed, f32 angle) {
11 mSpringValue =
new SpringValue(cond, 0.0f, speed, angle, 0.0f);
14void SpringStep::addSpringVelocity(f32 vel) {
15 mSpringValue->_10 += vel;
18void SpringStep::setSpringBaseValue(f32 val) {
20 mSpringValue->setParam((f64)val, 0.0f, mSpeed, mAngle, 0.0f);
39 initNerve(&NrvMapPartsFloatingForce::HostTypeWait::sInstance);
40 MR::getMapPartsArgRotateAccelType(&mRotateAccelType, rIter);
42 if (mRotateAccelType != 1) {
43 initForNormalMotion(rIter);
46 initForSpringMotion(rIter);
49 MR::useStageSwitchReadA(mHost, rIter);
52void MapPartsFloatingForce::setObjectName(
const char *pName) {
56void MapPartsFloatingForce::initForNormalMotion(
const JMapInfoIter &rIter) {
57 s32 condition_type = 0;
58 MR::getMapPartsArgMoveConditionType(&condition_type, rIter);
60 MR::getMapPartsArgRotateSpeed(&mRotateSpeed, rIter);
61 MR::getMapPartsArgRotateAngle(&mRotateAngle, rIter);
64void MapPartsFloatingForce::initForSpringMotion(
const JMapInfoIter &rIter) {
65 s32 condition_type = 0;
66 MR::getMapPartsArgMoveConditionType(&condition_type, rIter);
68 f32 rotate_speed = 0.0f;
69 MR::getMapPartsArgRotateSpeed(&rotate_speed, rIter);
70 rotate_speed *= 0.001f;
71 f32 rotate_angle = 0.0f;
72 MR::getMapPartsArgRotateAngle(&rotate_angle, rIter);
73 rotate_angle *= 0.001f;
75 MR::getMapPartsArgRotateAxis(&rotate_axis, rIter);
76 _5C = 0.1f * rotate_axis;
77 mSpringStep =
new SpringStep(-condition_type, rotate_speed, rotate_angle);
80void MapPartsFloatingForce::updateVelocity() {
81 if (MR::isOnPlayer(MR::getBodySensor(mHost))) {
83 _4C = MR::converge<f32>(_4C, 0.0f, 0.050000001f);
86 _4C = _4C + (0.000099999997f * mRotateSpeed);
91 _4C = MR::converge<f32>(_4C, 0.0f, 0.050000001f);
94 _4C = _4C - (0.000099999997f * mRotateAngle);
99 _4C = MR::clamp(_4C, -50.0f, 50.0f);
104bool MapPartsFloatingForce::tryOn() {
105 bool isSwitchOn =
false;
107 if (MR::isValidSwitchA(mHost) && MR::isOnSwitchA(mHost)) {
115 if (MR::isOnPlayer(MR::getBodySensor(mHost))) {
116 const char* ground_sound = FloaterFunction::getSeGroundOn(mObjectName);
118 MR::startSound(mHost, ground_sound, -1, -1);
121 setNerve(&NrvMapPartsFloatingForce::HostTypeMoveSpring::sInstance);
128bool MapPartsFloatingForce::tryReturn() {
129 bool isSwitchOn =
false;
131 if (MR::isValidSwitchA(mHost) && MR::isOnSwitchA(mHost)) {
136 if (MR::isOnPlayer(MR::getBodySensor(mHost))) {
141 setNerve(&NrvMapPartsFloatingForce::HostTypeMoveReturn::sInstance);
145void MapPartsFloatingForce::exeWait() {
150 if (mRotateAccelType == 1) {
157void MapPartsFloatingForce::exeMoveSpring() {
159 mSpringStep->setSpringBaseValue(-_20);
160 mSpringStep->addSpringVelocity(-_5C);
163 updateVelocitySpring();
170MapPartsFloatingForce::~MapPartsFloatingForce() {
174namespace NrvMapPartsFloatingForce {
175 INIT_NERVE(HostTypeWait);
176 INIT_NERVE(HostTypeMove);
177 INIT_NERVE(HostTypeMoveSpring);
178 INIT_NERVE(HostTypeMoveReturn);
180 void HostTypeMoveReturn::execute(
Spine *pSpine)
const {
182 force->exeMoveReturn();
185 void HostTypeMoveSpring::execute(
Spine *pSpine)
const {
187 force->exeMoveSpring();
190 void HostTypeMove::execute(
Spine *pSpine)
const {
195 void HostTypeWait::execute(
Spine *pSpine)
const {
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mVelocity
3D vector of the actor's velocity.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.