1#include "Game/MapObj/MarblePlanet.hpp"
2#include "Game/LiveActor/ModelObj.hpp"
3#include "JSystem/JMath.hpp"
5MarblePlanet::MarblePlanet(
const char *pName) :
LiveActor(pName) {
8 mWatermelonCollision = 0;
10 mRemainingElectrons = 3;
14 MR::initDefaultPos(
this, rIter);
15 initModelManagerWithAnm(
"MarblePlanet", 0,
false);
16 MR::connectToScenePlanet(
this);
18 MR::addHitSensorEnemy(
this,
"core", 8, 50.0f, TVec3f(0.0f, 0.0f, 0.0f));
19 MR::initCollisionParts(
this,
"MarblePlanet",
getSensor(0), 0);
20 mWatermelonCollision = MR::createCollisionPartsFromLiveActor(
this,
"WaterMelon",
getSensor(0), (MR::CollisionScaleType)2);
21 initEffectKeeper(0, 0,
false);
23 MR::setClippingTypeSphereContainsModelBoundingBox(
this, 100.0f);
24 MR::setClippingFar(
this, -1.0f);
25 MR::needStageSwitchWriteDead(
this, rIter);
26 MR::getJMapInfoArg0NoInit(rIter, &mNumElectrons);
27 mRemainingElectrons = mNumElectrons;
28 initCoreAndElectron();
29 MR::declarePowerStar(
this);
30 initNerve(&NrvMarblePlanet::MarblePlanetNrvWait::sInstance);
34void MarblePlanet::exeScaleUpCore() {
35 if (MR::isFirstStep(
this)) {
36 MR::tryRumblePadMiddle(
this, 0);
37 MR::shakeCameraNormal();
38 mRemainingElectrons = mRemainingElectrons - 1;
39 switch (mRemainingElectrons) {
41 MR::emitEffect(
this,
"Break");
42 MR::startSound(
this,
"SE_OJ_MARBLE_HIT_CORE_3", -1, -1);
43 MR::startSystemSE(
"SE_SY_MARBLE_HIT_CORE_3", -1, -1);
46 MR::emitEffect(
this,
"Smoke6f");
47 MR::startSound(
this,
"SE_OJ_MARBLE_HIT_CORE_2", -1, -1);
48 MR::startSystemSE(
"SE_SY_MARBLE_HIT_CORE_2", -1, -1);
52 MR::emitEffect(
this,
"Smoke3f");
53 MR::startSound(
this,
"SE_OJ_MARBLE_HIT_CORE_1", -1, -1);
54 MR::startSystemSE(
"SE_SY_MARBLE_HIT_CORE_1", -1, -1);
58 if (mRemainingElectrons <= 0) {
59 setNerve(&NrvMarblePlanet::MarblePlanetNrvBreakCore::sInstance);
63 s32 electronCount = mNumElectrons;
64 f32 frameMax = MR::getBckFrameMax(mCorePlanetModel);
65 f32 frame = ((electronCount - mRemainingElectrons) * frameMax) / electronCount;
66 MR::setBckFrameAndStop(mCorePlanetModel, frame);
67 MR::setBtkFrameAndStop(mCorePlanetModel, frame);
71 f32 nerveRate = MR::calcNerveRate(
this, 0x1E);
72 f32 scale = MR::getScaleWithReactionValueZeroToOne(nerveRate, 0.5f, -0.5f);
73 mCorePlanetModel->
mScale.setAll(MR::getLinerValue(scale, 1.3f, 1.0f, 1.0f));
75 if (MR::isStep(
this, 0x1E)) {
76 setNerve(&NrvMarblePlanet::MarblePlanetNrvWait::sInstance);
80void MarblePlanet::exeBreakCore() {
81 if (MR::isFirstStep(
this)) {
82 MR::setBckFrameAndStop(mCorePlanetModel, MR::getBckFrameMax(mCorePlanetModel));
83 MR::setBtkFrameAndStop(mCorePlanetModel, MR::getBtkFrameMax(mCorePlanetModel));
86 if (MR::isStep(
this, 1)) {
87 MR::tryRumblePadStrong(
this, 0);
88 MR::shakeCameraStrong();
89 MR::startAfterBossBGM();
90 MR::requestAppearPowerStar(
this,
mPosition);
92 MR::invalidateCollisionParts(
this);
93 MR::validateCollisionParts(mWatermelonCollision);
94 MR::onSwitchDead(
this);
98void MarblePlanet::startClipped() {
99 mCorePlanetModel->startClipped();
101 for (
int i = 0; i < mNumElectrons; i++) {
102 mPlanetElectrons[i]->startClipped();
105 LiveActor::startClipped();
108void MarblePlanet::endClipped() {
109 mCorePlanetModel->endClipped();
111 for (
int i = 0; i < mNumElectrons; i++) {
112 mPlanetElectrons[i]->endClipped();
115 LiveActor::endClipped();
118void MarblePlanet::kill() {
119 MR::onSwitchDead(
this);
120 mCorePlanetModel->kill();
125 if (isNerve(&NrvMarblePlanet::MarblePlanetNrvScaleUpCore::sInstance)) {
129 if (isNerve(&NrvMarblePlanet::MarblePlanetNrvBreakCore::sInstance)) {
133 setNerve(&NrvMarblePlanet::MarblePlanetNrvScaleUpCore::sInstance);
137void MarblePlanet::initCoreAndElectron() {
138 mCorePlanetModel = MR::createModelObjMapObj(
"ビー玉惑星コア",
"MarblePlanetCore",
getBaseMtx());
139 MR::invalidateClipping(mCorePlanetModel);
140 MR::startBck(mCorePlanetModel,
"MarblePlanetCore", 0);
141 MR::startBtk(mCorePlanetModel,
"MarblePlanetCore");
142 MR::setBckFrameAndStop(mCorePlanetModel, 0.0f);
143 MR::setBtkFrameAndStop(mCorePlanetModel, 0.0f);
147 MR::calcFrontVec(&front,
this);
152 if (mNumElectrons > 0) {
154 for (; i < mNumElectrons; i++) {
157 MR::calcUpVec(&up,
this);
158 MR::rotateVecDegree(&front, up, (360.0f / mNumElectrons));
162 JMAVECScaleAdd(front.toCVec(), pos->toCVec(), position.toVec(), 1000.0f);
164 rotation.setAll((360.0f * i) / mNumElectrons);
171MarblePlanetElectron::MarblePlanetElectron(
LiveActor *pPlanet,
const TVec3f &rPosition,
const TVec3f &rRotation,
const char *pName) :
LiveActor(pName) {
182 initModelManagerWithAnm(
"MarblePlanetElectron", 0,
false);
183 MR::connectToScenePlanet(
this);
185 MR::addHitSensorEnemy(
this,
"body", 8, 500.0f, TVec3f(0.0f, 0.0f, 0.0f));
186 initBinder(200.0f, 0.0f, 0);
187 initEffectKeeper(1, 0,
false);
188 MR::addEffectHitNormal(
this, 0);
190 MR::invalidateClipping(
this);
193 MR::calcGravity(
this);
198 MR::setBaseTRMtx(
this, mtx);
199 MR::calcFrontVec(&_94,
this);
200 MR::startBck(
this,
"MarblePlanetElectron", 0);
201 initNerve(&NrvMarblePlanetElectron::MarblePlanetElectronNrvMove::sInstance);
205void MarblePlanetElectron::exeMove() {
206 MR::turnDirectionToGround(
this, &_94);
207 MR::attenuateVelocity(
this, 0.99000001f);
209 f32 scale = (mag >= 13.0f ? mag : 13.0f);
211 MR::startLevelSound(
this,
"SE_OJ_LV_MARBLE_ROTATE", -1, -1, -1);
214void MarblePlanetElectron::exeAttack() {
215 if (MR::isFirstStep(
this)) {
216 MR::startSound(
this,
"SE_OJ_MARBLE_FLIP", -1, -1);
221 MR::normalize(&velocity);
225void MarblePlanetElectron::control() {
226 MR::calcGravity(
this);
229 if (isNerve(&NrvMarblePlanetElectron::MarblePlanetElectronNrvMove::sInstance)) {
230 MR::restrictVelocity(
this, 30.0f);
235 if (MR::isSensorEnemy(a2)) {
236 if (MR::sendMsgEnemyAttack(a2, a1)) {
237 mElectronShadow->kill();
241 bool isNear = !MR::isNear(
this, a2->mActor->
mPosition, 440.0f);
244 if (MR::sendMsgPush(a2, a1)) {
245 MR::tryRumblePadVeryWeak(
this, 0);
247 if (!MR::isEffectValid(
this,
"HitMarkNormal")) {
248 MR::emitEffectHitBetweenSensors(
this, a1, a2, 0.0f, 0);
251 MR::killVelocityToTarget(
this, a2->mActor->
mPosition);
258bool MarblePlanetElectron::receiveMsgPlayerAttack(u32 msg,
HitSensor *a2,
HitSensor *a3) {
259 if (isNerve(&NrvMarblePlanetElectron::MarblePlanetElectronNrvAttack::sInstance)) {
263 if (MR::isMsgPlayerHipDrop(msg)) {
264 setNerve(&NrvMarblePlanetElectron::MarblePlanetElectronNrvAttack::sInstance);
272 if (!MR::isSensorEnemy(a1)) {
280void MarblePlanetElectron::crashElectron(
HitSensor *pSensor) {
283 MR::normalize(&stack_8);
289 MR::startSound(
this,
"SE_OJ_MARBLE_HIT_EACH", -1, -1);
292MarblePlanetElectronShadow::MarblePlanetElectronShadow(
LiveActor *pElectronPtr,
const TVec3f &rVec,
const char *pName) :
LiveActor(pName) {
298 initModelManagerWithAnm(
"MarblePlanetElectronShadow", 0,
false);
299 MR::connectToScenePlanet(
this);
300 MR::invalidateClipping(
this);
307 stack_8.sub(mParentElectron->
mPosition, *_90);
308 MR::normalize(&stack_8);
310 MR::makeMtxUpNoSupportPos(&up_mtx, stack_8, *_90);
311 MR::setBaseTRMtx(
this, up_mtx);
314MarblePlanet::~MarblePlanet() {
318MarblePlanetElectron::~MarblePlanetElectron() {
322MarblePlanetElectronShadow::~MarblePlanetElectronShadow() {
326namespace NrvMarblePlanet {
327 INIT_NERVE(MarblePlanetNrvWait);
328 INIT_NERVE(MarblePlanetNrvScaleUpCore);
329 INIT_NERVE(MarblePlanetNrvBreakCore);
332namespace NrvMarblePlanetElectron {
333 INIT_NERVE(MarblePlanetElectronNrvMove);
334 INIT_NERVE(MarblePlanetElectronNrvAttack);
336 void MarblePlanetElectronNrvAttack::execute(
Spine *pSpine)
const {
338 electron->exeAttack();
341 void MarblePlanetElectronNrvMove::execute(
Spine *pSpine)
const {
347namespace NrvMarblePlanet {
348 void MarblePlanetNrvBreakCore::execute(
Spine *pSpine)
const {
350 marble->exeBreakCore();
353 void MarblePlanetNrvScaleUpCore::execute(
Spine *pSpine)
const {
355 marble->exeScaleUpCore();
358 void MarblePlanetNrvWait::execute(
Spine *pSpine)
const {
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mRotation
3D vector of the actor's rotation.
TVec3f mPosition
3D vector of the actor's position.
TVec3f mScale
3D vector of the actor's scale.
TVec3f mVelocity
3D vector of the actor's velocity.
TVec3f mGravity
3D vector of the actor's gravity.
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
void initWithoutIter()
Initializes a NameObj without a JMapInfoIter instance.