1#include "Game/MapObj/ItemBlock.hpp"
2#include "Game/Util.hpp"
3#include "JSystem/JGeometry/TVec.hpp"
5namespace NrvItemBlock {
6 INIT_NERVE(ItemBlockNrvStandby);
7 INIT_NERVE(ItemBlockNrvWait);
8 INIT_NERVE(ItemBlockNrvAppearItem);
9 INIT_NERVE(ItemBlockNrvAppearItemSplash);
11 void ItemBlockNrvAppearItemSplash::execute(
Spine *pSpine)
const {
13 block->exeAppearItemSplash();
16 void ItemBlockNrvAppearItem::execute(
Spine *pSpine)
const {
18 block->exeAppearItem();
21 void ItemBlockNrvWait::execute(
Spine *pSpine)
const {
26 void ItemBlockNrvStandby::execute(
Spine *pSpine)
const {
28 if (MR::isFirstStep(block)) {
29 MR::startBck(block,
"Wait",
nullptr);
35 static Color8 hPointLight(0xFF, 0xE6, 0, 0xFF);
38ItemBlock::ItemBlock(
const char *pName) :
LiveActor(pName) {
43 mCalcShadowOneTime =
false;
47 MR::initDefaultPos(
this, rIter);
50 MR::connectToSceneMapObjStrongLight(
this);
51 MR::useStageSwitchSleep(
this, rIter);
52 initEffectKeeper(1,
"CoinBlock",
false);
54 initNerve(&NrvItemBlock::ItemBlockNrvStandby::sInstance);
56 MR::getJMapInfoArg4NoInit(rIter, &arg);
57 MR::initShadowVolumeBox(
this, TVec3f(150.0f, 150.0f, 150.0f));
58 MR::setShadowVolumeStartDropOffset(
this, 0, 77.0f);
61 MR::setShadowDropLength(
this,
nullptr, arg);
64 MR::onShadowVolumeCutDropLength(
this,
nullptr);
65 MR::excludeCalcShadowToMyCollision(
this,
nullptr);
67 if (mCalcShadowOneTime) {
68 MR::onCalcShadowOneTime(
this,
nullptr);
70 MR::onCalcShadow(
this,
nullptr);
73 if (MR::isZeroGravity(
this)) {
75 MR::calcUpVec(&upVec,
this);
76 MR::setShadowDropDirection(
this, 0, -upVec);
78 MR::calcGravity(
this);
81 MR::offCalcGravity(
this);
82 MR::setGroupClipping(
this, rIter, 16);
83 MR::validateClipping(
this);
88void ItemBlock::startClipped() {
89 LiveActor::startClipped();
90 MR::forceDeleteEffect(
this,
"Glow");
93void ItemBlock::endClipped() {
94 LiveActor::endClipped();
95 MR::emitEffect(
this,
"Glow");
99 const char *name =
nullptr;
100 MR::getObjectName(&name, rIter);
102 if (MR::isEqualString(name,
"ItemBlockSwitch")) {
103 MR::needStageSwitchWriteDead(
this, rIter);
105 }
else if (MR::isEqualString(name,
"TimerCoinBlock")) {
107 MR::declareCoin(
this, 10);
108 }
else if (MR::isEqualString(name,
"SplashCoinBlock")) {
110 MR::declareCoin(
this, mItemCount);
111 }
else if (MR::isEqualString(name,
"TimerPieceBlock")) {
113 MR::declareStarPiece(
this, 20);
114 }
else if (MR::isEqualString(name,
"SplashPieceBlock")) {
116 MR::declareStarPiece(
this, mItemCount);
121 if (mKind == 2 || mKind == 4) {
123 MR::getJMapInfoArg0NoInit(rIter, &arg);
132 if (mKind == 1 || mKind == 3) {
133 MR::getJMapInfoArg1NoInit(rIter, &arg);
143 MR::getJMapInfoArg2NoInit(rIter, &arg);
144 mCalcShadowOneTime = !(arg - 1);
160void ItemBlock::appear() {
162 initNerve(&NrvItemBlock::ItemBlockNrvStandby::sInstance);
164 if (mKind > 6 || mKind < 1) {
168 MR::startBrk(
this,
"CoinBlock");
171void ItemBlock::kill() {
172 MR::startSound(
this,
"SE_EM_EXPLODE_S", -1, -1);
173 MR::emitEffect(
this,
"Break");
184 if (MR::isMsgPlayerUpperPunch(msg) && MR::isPlayerExistDown(
this, 0.0f, 0.25f) && tryStartJumpPunch()) {
185 MR::sendArbitraryMsg(64, a1, a2);
192bool ItemBlock::tryStartJumpPunch() {
193 if (isNerve(&NrvItemBlock::ItemBlockNrvStandby::sInstance)) {
194 if (mKind == 1 || mKind == 3) {
195 MR::startBck(
this,
"Appear",
nullptr);
198 setNerve(&NrvItemBlock::ItemBlockNrvAppearItem::sInstance);
199 }
else if (mKind == 2 || (u32)(mKind - 4) <= 1) {
200 setNerve(&NrvItemBlock::ItemBlockNrvAppearItemSplash::sInstance);
206 if (isNerve(&NrvItemBlock::ItemBlockNrvWait::sInstance)) {
207 if (mKind == 1 || mKind == 3) {
209 if (MR::getDeclareRemnantCoinCount(
this) == 1) {
213 if (!(MR::getDeclareRemnantStarPieceCountNotExist(
this) - 11)) {
218 MR::startBck(
this,
"Appear",
nullptr);
221 setNerve(&NrvItemBlock::ItemBlockNrvAppearItem::sInstance);
230void ItemBlock::exeWait() {
231 if (MR::isFirstStep(
this)) {
232 MR::startBck(
this,
"Wait",
nullptr);
233 MR::invalidateClipping(
this);
289void ItemBlock::exeAppearItemSplash() {
290 if (MR::isFirstStep(
this)) {
291 MR::forceDeleteEffect(
this,
"Glow");
292 MR::startBck(
this,
"Bomb",
nullptr);
295 if (!MR::isBckStopped(
this)) {
300 if (mItemCount == 1) {
303 MR::appearCoinCircle(
this,
mPosition, mItemCount);
305 }
else if (mKind == 4) {
306 MR::appearStarPiece(
this,
mPosition, mItemCount, 10.0f, 40.0f,
false);
307 MR::startSound(
this,
"SE_OJ_STAR_PIECE_BURST", -1, -1);
308 }
else if (mKind == 5) {
309 MR::onSwitchDead(
this);
316void ItemBlock::decTimer() {
324void ItemBlock::calcAnim() {
326 LiveActor::calcAnim();
331ItemBlock::~ItemBlock() {
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.