1#include "Game/MapObj/ChooChooTrain.hpp"
2#include "Game/Util.hpp"
3#include "Game/Util/Array.hpp"
5ChooChooTrain::ChooChooTrain(
const char *pName) :
LiveActor(pName), mModelArray() {
13void ChooChooTrain::startClipped() {
14 LiveActor::startClipped();
16 for (s32 i = 0; i < mModelArray.mCount; i++) {
17 mModelArray.mArray.mArr[i]->startClipped();
21void ChooChooTrain::endClipped() {
22 LiveActor::endClipped();
24 for (s32 i = 0; i < mModelArray.mCount; i++) {
25 mModelArray.mArray.mArr[i]->endClipped();
30 if (MR::isValidInfo(rIter)) {
31 MR::isConnectedWithRail(rIter);
34 MR::initDefaultPos(
this, rIter);
36 initModelManagerWithAnm(
"ChooChooTrain", 0,
false);
37 MR::connectToSceneCollisionMapObj(
this);
38 initEffectKeeper(0, 0,
false);
40 mWhistleTimer = MR::getRandom((s32)0xB4, (s32)0x258);
41 MR::onCalcGravity(
this);
42 MR::initShadowVolumeSphere(
this, 80.0f *
mScale.y);
44 MR::addMessageSensorMapObjMoveCollision(
this,
"body");
45 MR::initCollisionParts(
this,
"ChooChooTrain",
getSensor(
"body"), 0);
46 MR::onCalcGravity(
this);
48 s32 defTrainParts = 3;
49 MR::getJMapInfoArg0NoInit(rIter, &temp_var);
52 defTrainParts = temp_var;
56 MR::getJMapInfoArg1NoInit(rIter, &temp_var);
59 mRailCoord = temp_var;
62 mModelArray.mArray.mArr =
new ModelObj*[defTrainParts];
63 mModelArray.mArray.mMaxSize = defTrainParts;
66 while (curIdx < defTrainParts) {
67 ModelObj* obj =
new ModelObj(
"汽車ポッポ客車",
"ChooChooTrainBody", 0, -2, 0x1E, 2,
false);
69 MR::initCollisionParts(obj,
"ChooChooTrainBody",
getSensor(
"body"), 0);
70 MR::invalidateClipping(obj);
71 s32 curCount = mModelArray.mCount;
72 mModelArray.mCount = curCount + 1;
73 mModelArray.mArray.mArr[curCount] = obj;
78 MR::moveCoordToNearestPos(
this,
mPosition);
79 MR::moveTransToCurrentRailPos(
this);
80 f32 railCoord = MR::getRailCoord(
this);
81 MR::reverseRailDirection(
this);
84 while (curIdx < defTrainParts) {
85 MR::moveCoord(
this, 1080.0f *
mScale.y);
86 MR::moveTransToOtherActorRailPos(mModelArray.mArray.mArr[curIdx],
this);
87 MR::onCalcGravity(mModelArray.mArray.mArr[curIdx]);
88 mModelArray.mArray.mArr[curIdx]->makeActorAppeared();
89 MR::startBck(mModelArray.mArray.mArr[curIdx],
"Run", 0);
93 MR::reverseRailDirection(
this);
94 MR::setRailCoord(
this, railCoord);
95 MR::initAndSetRailClipping(&_98,
this, 100.0f, 500.0f);
96 MR::startBck(
this,
"Run", 0);
99void ChooChooTrain::control() {
100 MR::moveCoord(
this, mRailCoord);
101 MR::moveTransToCurrentRailPos(
this);
102 TVec3f stack_74(MR::getRailDirection(
this));
103 MR::turnDirectionAndGravityH(
this, stack_74, 0.5f, 1.0f);
104 f32 railCoord = MR::getRailCoord(
this);
106 MR::calcFrontVec(&stack_68,
this);
109 MR::reverseRailDirection(
this);
114 while (curIdx < mModelArray.mCount) {
115 MR::moveCoord(
this, 1080.0f *
mScale.y);
116 MR::moveTransToOtherActorRailPos(mModelArray.mArray.mArr[curIdx],
this);
117 stack_74 = (stack_5C - mModelArray.mArray.mArr[curIdx]->
mPosition);
118 MR::turnDirectionAndGravityH(mModelArray.mArray.mArr[curIdx], stack_74, 0.5f, 1.0f);
119 MR::calcFrontVec(&stack_68, mModelArray.mArray.mArr[curIdx]);
121 vec = &mModelArray.mArray.mArr[curIdx]->
mPosition;
122 stack_5C = (*vec - ((stack_68 * 532.0f) *
mScale.y));
126 MR::reverseRailDirection(
this);
127 MR::setRailCoord(
this, railCoord);
128 MR::startLevelSound(
this,
"SE_OJ_LV_TOY_SL_MOVE", -1, -1, -1);
130 if (mWhistleTimer < 0) {
131 MR::startSound(
this,
"SE_OJ_TOY_SL_WHISTLE", -1, -1);
132 mWhistleTimer = MR::getRandom((s32)0xB4, (s32)0x258);
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mPosition
3D vector of the actor's position.
TVec3f mScale
3D vector of the actor's scale.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
void initWithoutIter()
Initializes a NameObj without a JMapInfoIter instance.