Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions data/file_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74572,75 +74572,75 @@ MapObj/KuriboTowerSwitch.o:
- offset: 0x2b0850
size: 156
label: _ZN17KuriboTowerSwitchC2EPKc
status: NotDecompiled
status: Matching
- offset: 0x2b08ec
size: 168
label: _ZN17KuriboTowerSwitchC1EPKc
status: NotDecompiled
status: Matching
- offset: 0x2b0994
size: 336
label: _ZN17KuriboTowerSwitch4initERKN2al13ActorInitInfoE
status: NotDecompiled
status: Matching
- offset: 0x2b0ae4
size: 28
label: _ZN17KuriboTowerSwitch18initAfterPlacementEv
status: NotDecompiled
status: Matching
- offset: 0x2b0b00
size: 84
label: _ZN17KuriboTowerSwitch7controlEv
status: NotDecompiled
status: Matching
- offset: 0x2b0b54
size: 476
label: _ZN17KuriboTowerSwitch10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_
status: NotDecompiled
status: Matching
- offset: 0x2b0d30
size: 72
label: _ZNK17KuriboTowerSwitch15isReactionNerveEv
status: NotDecompiled
status: Matching
- offset: 0x2b0d78
size: 60
label: _ZN17KuriboTowerSwitch10exeDisableEv
status: NotDecompiled
status: Matching
- offset: 0x2b0db4
size: 60
label: _ZN17KuriboTowerSwitch10exeOffWaitEv
status: NotDecompiled
status: Matching
- offset: 0x2b0df0
size: 88
label: _ZN17KuriboTowerSwitch15exeReactionLandEv
status: NotDecompiled
status: Matching
- offset: 0x2b0e48
size: 176
label: _ZN17KuriboTowerSwitch5exeOnEv
status: NotDecompiled
status: Matching
- offset: 0x2b0ef8
size: 84
label: _ZN17KuriboTowerSwitch9exeOnWaitEv
status: NotDecompiled
status: Matching
- offset: 0x2b0f4c
size: 64
label: _ZNK12_GLOBAL__N_127KuriboTowerSwitchNrvOffWait7executeEPN2al11NerveKeeperE
status: NotDecompiled
status: Matching
guess: true
- offset: 0x2b0f8c
size: 8
label: _ZNK12_GLOBAL__N_122KuriboTowerSwitchNrvOn7executeEPN2al11NerveKeeperE
status: NotDecompiled
status: Matching
guess: true
- offset: 0x2b0f94
size: 88
label: _ZNK12_GLOBAL__N_126KuriboTowerSwitchNrvOnWait7executeEPN2al11NerveKeeperE
status: NotDecompiled
status: Matching
guess: true
- offset: 0x2b0fec
size: 64
label: _ZNK12_GLOBAL__N_127KuriboTowerSwitchNrvDisable7executeEPN2al11NerveKeeperE
status: NotDecompiled
status: Matching
guess: true
- offset: 0x2b102c
size: 92
label: _ZNK12_GLOBAL__N_132KuriboTowerSwitchNrvReactionLand7executeEPN2al11NerveKeeperE
status: NotDecompiled
status: Matching
guess: true
MapObj/LapRecorder.o:
'.text':
Expand Down
157 changes: 157 additions & 0 deletions src/MapObj/KuriboTowerSwitch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#include "MapObj/KuriboTowerSwitch.h"

#include <math/seadMathCalcCommon.h>
#include <math/seadVector.h>

#include "Library/Audio/System/SimpleAudioUser.h"
#include "Library/Collision/PartsConnectorUtil.h"
#include "Library/LiveActor/ActorActionFunction.h"
#include "Library/LiveActor/ActorAnimFunction.h"
#include "Library/LiveActor/ActorClippingFunction.h"
#include "Library/LiveActor/ActorCollisionFunction.h"
#include "Library/LiveActor/ActorInitInfo.h"
#include "Library/LiveActor/ActorInitUtil.h"
#include "Library/LiveActor/ActorPoseUtil.h"
#include "Library/LiveActor/ActorSensorUtil.h"
#include "Library/Math/MathUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Nerve/NerveUtil.h"
#include "Library/Obj/CollisionObj.h"
#include "Library/Obj/PartsFunction.h"
#include "Library/Placement/PlacementFunction.h"
#include "Library/Se/SeFunction.h"
#include "Library/Stage/StageSwitchUtil.h"

#include "Util/SensorMsgFunction.h"

namespace {
NERVE_IMPL(KuriboTowerSwitch, OffWait);
NERVE_IMPL(KuriboTowerSwitch, On);
NERVE_IMPL(KuriboTowerSwitch, OnWait);
NERVE_IMPL(KuriboTowerSwitch, Disable);
NERVE_IMPL(KuriboTowerSwitch, ReactionLand);

NERVES_MAKE_STRUCT(KuriboTowerSwitch, OffWait, On, OnWait, Disable, ReactionLand);
} // namespace

KuriboTowerSwitch::KuriboTowerSwitch(const char* name) : al::LiveActor(name) {}

void KuriboTowerSwitch::init(const al::ActorInitInfo& initInfo) {
al::initActorWithArchiveName(this, initInfo, "KuriboTowerSwitch", nullptr);
al::initNerve(this, &NrvKuriboTowerSwitch.OffWait, 0);
mMtxConnector = al::createMtxConnector(this);
mCollisionObj = al::createCollisionObj(this, initInfo, "KuriboTowerSwitch_Body",
al::getHitSensor(this, "Collision"), "Move", nullptr);
mCollisionObj->makeActorAlive();
al::validateCollisionParts(mCollisionObj);
makeActorAlive();

al::tryGetArg(&mNum, initInfo, "Num");
al::startMtpAnimAndSetFrameAndStop(this, "Number", sead::Mathi::min(mNum - 1, 9));

bool isPlaySuccessSe = false;
al::tryGetArg(&isPlaySuccessSe, initInfo, "IsPlaySuccessSe");
if (isPlaySuccessSe)
mAudioUser = new al::SimpleAudioUser("SuccessSeObj", initInfo);
}

void KuriboTowerSwitch::initAfterPlacement() {
if (mMtxConnector)
al::attachMtxConnectorToCollision(mMtxConnector, this, false);
}

void KuriboTowerSwitch::control() {
if (mMtxConnector)
al::connectPoseQT(this, mMtxConnector);

if (!_129)
_128 = true;
_129 = false;

if (mDisplayNum < 4)
mDisplayNum++;
}

bool KuriboTowerSwitch::receiveMsg(const al::SensorMsg* message, al::HitSensor* other,
al::HitSensor* self) {
if (rs::isMsgPlayerDisregardHomingAttack(message))
return true;

if (al::isNerve(this, &NrvKuriboTowerSwitch.On) ||
al::isNerve(this, &NrvKuriboTowerSwitch.OnWait) ||
al::isNerve(this, &NrvKuriboTowerSwitch.Disable)) {
return false;
}

if (rs::getNumKuriboTowerOn(message) < (u32)mNum) {
if (!al::isMsgPlayerFloorTouch(message))
return false;

if (3 < mDisplayNum && _128 && isReactionNerve()) {
_128 = false;
al::setNerve(this, &NrvKuriboTowerSwitch.ReactionLand);
}

_129 = true;
mDisplayNum = 0;
return true;
}

sead::Vector3f dir = al::getSensorPos(other) - al::getSensorPos(self);
sead::Vector3f up;
al::calcUpDir(&up, this);
al::verticalizeVec(&dir, up, dir);
if (dir.length() > 100.0f)
return false;

al::startHitReaction(this, "規定数乗っかった");
al::invalidateClipping(this);
al::setNerve(this, &NrvKuriboTowerSwitch.On);
return true;
}

bool KuriboTowerSwitch::isReactionNerve() const {
return al::isNerve(this, &NrvKuriboTowerSwitch.OffWait) ||
al::isNerve(this, &NrvKuriboTowerSwitch.ReactionLand);
}

void KuriboTowerSwitch::exeDisable() {
if (al::isFirstStep(this))
al::tryStartActionIfNotPlaying(this, "OffWait");
}

void KuriboTowerSwitch::exeOffWait() {
if (al::isFirstStep(this))
al::tryStartActionIfNotPlaying(this, "OffWait");
}

void KuriboTowerSwitch::exeReactionLand() {
if (al::isFirstStep(this))
al::startAction(this, "ReactionLand");

if (al::isActionEnd(this))
al::setNerve(this, &NrvKuriboTowerSwitch.OffWait);
}

void KuriboTowerSwitch::exeOn() {
if (al::isFirstStep(this)) {
al::invalidateHitSensors(this);
al::startAction(this, "On");
if (mAudioUser)
al::startSe(mAudioUser, "Riddle");
}

if (al::isActionEnd(this)) {
mCollisionObj->kill();
al::startHitReaction(this, "スイッチ押し込み終わり");
al::setNerve(this, &NrvKuriboTowerSwitch.OnWait);
}
}

void KuriboTowerSwitch::exeOnWait() {
if (al::isFirstStep(this)) {
al::tryOnStageSwitch(this, "SwitchTrampleOn");
al::startAction(this, "OnWait");
al::validateClipping(this);
}
}
40 changes: 40 additions & 0 deletions src/MapObj/KuriboTowerSwitch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <basis/seadTypes.h>

#include "Library/LiveActor/LiveActor.h"

namespace al {
class CollisionObj;
class HitSensor;
class MtxConnector;
class SensorMsg;
class SimpleAudioUser;
} // namespace al

class KuriboTowerSwitch : public al::LiveActor {
public:
KuriboTowerSwitch(const char* name);
void init(const al::ActorInitInfo& initInfo) override;
void initAfterPlacement() override;
void control() override;
bool receiveMsg(const al::SensorMsg* message, al::HitSensor* other,
al::HitSensor* self) override;
bool isReactionNerve() const;
void exeDisable();
void exeOffWait();
void exeReactionLand();
void exeOn();
void exeOnWait();

private:
al::MtxConnector* mMtxConnector = nullptr;
s32 mNum = 10;
al::SimpleAudioUser* mAudioUser = nullptr;
al::CollisionObj* mCollisionObj = nullptr;
bool _128 = true;
bool _129 = false;
u32 mDisplayNum = 4;
};

static_assert(sizeof(KuriboTowerSwitch) == 0x130);
Loading