1#include "Game/MapObj/AssemblyBlock.hpp"
2#include "Game/LiveActor/PartsModel.hpp"
3#include "JSystem/JMath/JMath.hpp"
6 static const char* sReturnPosName =
"合体ブロック故郷点";
9AssemblyBlock::AssemblyBlock(
const char *pName) :
LiveActor(pName) {
11 mActivationRange = -1.0f;
16 mActivationTime = 300;
17 mBloomModel =
nullptr;
31 MR::initDefaultPos(
this, rIter);
32 MR::tryRegisterNamePosLinkObj(
this, rIter);
34 if (!MR::tryFindLinkNamePos(
this, sReturnPosName, _EC.toMtxPtr())) {
39 _EC.setTrans(stack_3C);
42 MR::getMapPartsObjectNameIfExistShapeID(name, 0x100, rIter);
43 initModelManagerWithAnm(name,
nullptr,
false);
45 if (MR::isEqualString(name,
"AssemblyBlockPartsTimerA")) {
53 JMath::gekko_ps_copy12(&_8C, &_EC);
54 MR::setBaseTRMtx(
this, _8C);
56 if (MR::isEqualSubString(name,
"PartsIce")) {
57 MR::connectToSceneIndirectMapObj(
this);
60 MR::connectToSceneMapObj(
this);
64 MR::addBodyMessageSensorMapObj(
this);
65 MR::initCollisionPartsAutoEqualScaleOne(
this, name,
getSensor(
nullptr),
nullptr);
67 _BC.getTrans(stack_30);
68 _EC.getTrans(stack_24);
69 _124.add(stack_30, stack_24);
74 MR::calcModelBoundingRadius(&boundRadius,
this);
75 f32 dist = PSVECDistance(_124.toCVec(), stack_24.toCVec());
76 MR::setClippingTypeSphere(
this, (boundRadius + dist), &_124);
77 MR::getJMapInfoArg0NoInit(rIter, &mActivationRange);
78 if (mActivationRange <= 0.0f) {
79 mActivationRange = 2.0f * boundRadius;
82 MR::getJMapInfoArg1NoInit(rIter, &mActivationTime);
83 MR::getJMapInfoArg7NoInit(rIter, &_11C);
84 if (MR::getRandom((s32)0, (s32)2)) {
92 initEffectKeeper(0,
"AssemblyBlock",
false);
95 initEffectKeeper(0,
nullptr,
false);
103 MR::initStarPointerTarget(
this, 0.0f, stack_C);
105 if (MR::isEqualString(name,
"AssemblyBlockPartsTimerA")) {
106 mBloomModel = MR::createBloomModel(
this,
getBaseMtx());
109 MR::tryStartAllAnim(
this,
"Wait");
110 initNerve(&NrvAssemblyBlock::AssemblyBlockNrvWait::sInstance);
116void AssemblyBlock::exeAssemble() {
117 if (MR::isFirstStep(
this)) {
118 MR::emitEffect(
this,
"Blur");
121 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_ST_F_", -1, -1);
124 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_START", -1, -1);
127 MR::invalidateCollisionParts(
this);
128 MR::invalidateHitSensors(
this);
131 MR::blendMtx(_BC.toMtxPtr(), _EC.toMtxPtr(), MR::calcNerveRate(
this, 10), _8C.toMtxPtr());
133 if (MR::isStep(
this, 10)) {
135 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_ED_F", -1, -1);
138 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_END", -1, -1);
141 setNerve(&NrvAssemblyBlock::AssemblyBlockNrvWait::sInstance);
145void AssemblyBlock::exeAssembleWait() {
146 if (MR::isFirstStep(
this)) {
147 if (MR::isEffectValid(
this,
"Blur")) {
148 MR::deleteEffect(
this,
"Blur");
151 MR::tryRumblePadWeak(
this, 0);
152 MR::validateCollisionParts(
this);
153 MR::validateHitSensors(
this);
157 setNerve(&NrvAssemblyBlock::AssemblyBlockNrvTimer::sInstance);
164void AssemblyBlock::exeReturn() {
165 if (MR::isFirstStep(
this)) {
166 MR::tryRumblePadWeak(
this, 0);
167 MR::emitEffect(
this,
"Blur");
170 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_RET_F", -1, -1);
173 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_RETURN", -1, -1);
176 MR::invalidateCollisionParts(
this);
177 MR::invalidateHitSensors(
this);
180 MR::blendMtx(_BC.toMtxPtr(), _EC.toMtxPtr(), MR::calcNerveRate(
this, 10), _8C.toMtxPtr());
182 if (MR::isStep(
this, 10)) {
183 setNerve(&NrvAssemblyBlock::AssemblyBlockNrvWait::sInstance);
187void AssemblyBlock::exeTimer() {
188 if (MR::isStep(
this, mActivationTime - 100)) {
189 MR::tryStartAllAnim(
this,
"Disappear");
192 if (MR::isStep(
this, mActivationTime)) {
194 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_VAN_F", -1, -1);
197 MR::startSound(
this,
"SE_OJ_ASSEMBLE_BLOCK_VANISH", -1, -1);
209 MR::setBaseTRMtx(
this, _8C);
212bool AssemblyBlock::tryStartAssemble() {
213 bool isNotNear = !MR::isNearPlayerAnyTime(
this, mActivationRange);
219 if (MR::isPlayerDead()) {
223 setNerve(&NrvAssemblyBlock::AssemblyBlockNrvAssemble::sInstance);
227bool AssemblyBlock::tryStartReturn() {
228 if (MR::isStarPointerPointing2POnPressButton(
this,
"弱",
true,
false)) {
232 if (MR::isNearPlayerAnyTime(
this, (mActivationRange + 50.0f))) {
236 if (MR::isPlayerDead()) {
240 setNerve(&NrvAssemblyBlock::AssemblyBlockNrvReturn::sInstance);
244AssemblyBlock::~AssemblyBlock() {
248namespace NrvAssemblyBlock {
249 INIT_NERVE(AssemblyBlockNrvWait);
250 INIT_NERVE(AssemblyBlockNrvAssemble);
251 INIT_NERVE(AssemblyBlockNrvAssembleWait);
252 INIT_NERVE(AssemblyBlockNrvReturn);
253 INIT_NERVE(AssemblyBlockNrvTimer);
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.
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mPosition
3D vector of the actor's position.
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.