-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Library/MapObj: Implement
RotateMapParts
(#212)
- Loading branch information
Showing
7 changed files
with
192 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include "Library/MapObj/RotateMapParts.h" | ||
|
||
#include "Library/LiveActor/ActorActionFunction.h" | ||
#include "Library/LiveActor/ActorAreaFunction.h" | ||
#include "Library/LiveActor/ActorInitFunction.h" | ||
#include "Library/LiveActor/ActorModelFunction.h" | ||
#include "Library/LiveActor/ActorMovementFunction.h" | ||
#include "Library/LiveActor/ActorPoseKeeper.h" | ||
#include "Library/LiveActor/ActorSensorMsgFunction.h" | ||
#include "Library/MapObj/ChildStep.h" | ||
#include "Library/Nerve/NerveSetupUtil.h" | ||
#include "Library/Placement/PlacementFunction.h" | ||
#include "Library/Se/SeFunction.h" | ||
#include "Library/Stage/StageSwitchKeeper.h" | ||
#include "Library/Thread/FunctorV0M.h" | ||
|
||
namespace al { | ||
namespace { | ||
NERVE_ACTION_IMPL(RotateMapParts, StandBy) | ||
NERVE_ACTION_IMPL(RotateMapParts, Rotate) | ||
NERVE_ACTION_IMPL(RotateMapParts, AssistStop) | ||
|
||
NERVE_ACTIONS_MAKE_STRUCT(RotateMapParts, StandBy, Rotate, AssistStop) | ||
} // namespace | ||
|
||
RotateMapParts::RotateMapParts(const char* name) : LiveActor(name) {} | ||
|
||
void RotateMapParts::init(const ActorInitInfo& info) { | ||
using RotateMapPartsFunctor = FunctorV0M<RotateMapParts*, void (RotateMapParts::*)()>; | ||
|
||
tryInitSubActorKeeperChildStep(this, info); | ||
initNerveAction(this, "Rotate", &NrvRotateMapParts.mCollector, 0); | ||
initMapPartsActor(this, info, nullptr); | ||
tryGetQuatPtr(this); | ||
registerAreaHostMtx(this, info); | ||
|
||
mQuat.set(getQuat(this)); | ||
tryGetArg((s32*)&mRotateAxis, info, "RotateAxis"); | ||
tryGetArg(&mRotateSpeed, info, "RotateSpeed"); | ||
|
||
createChildStep(info, this, true); | ||
initMaterialCode(this, info); | ||
|
||
if (listenStageSwitchOnStart(this, RotateMapPartsFunctor(this, &RotateMapParts::start))) | ||
startNerveAction(this, "StandBy"); | ||
|
||
trySyncStageSwitchAppear(this); | ||
} | ||
|
||
void RotateMapParts::start() { | ||
if (isNerve(this, NrvRotateMapParts.StandBy.data())) | ||
startNerveAction(this, "Rotate"); | ||
} | ||
|
||
bool RotateMapParts::receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) { | ||
if (isMsgTouchAssist(message)) { | ||
mAssistTimer = 45; | ||
|
||
return true; | ||
} | ||
|
||
if (isMsgShowModel(message)) { | ||
showModelIfHide(this); | ||
|
||
return true; | ||
} | ||
|
||
if (isMsgHideModel(message)) { | ||
hideModelIfShow(this); | ||
|
||
return true; | ||
} | ||
|
||
if (isMsgRestart(message)) { | ||
appearAndSetStart(); | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void RotateMapParts::appearAndSetStart() { | ||
mAssistTimer = 0; | ||
setQuat(this, mQuat); | ||
|
||
makeActorAlive(); | ||
} | ||
|
||
void RotateMapParts::exeStandBy() {} | ||
|
||
void RotateMapParts::exeRotate() { | ||
rotateQuatLocalDirDegree(this, (s32)mRotateAxis, mRotateSpeed / 100.0f); | ||
if (mAssistTimer > 0) | ||
startNerveAction(this, "AssistStop"); | ||
|
||
tryHoldSeWithParam(this, "RotateWithSpeed", mRotateSpeed, ""); | ||
} | ||
|
||
void RotateMapParts::exeAssistStop() { | ||
mAssistTimer--; | ||
if (mAssistTimer <= 0) { | ||
mAssistTimer = 0; | ||
startNerveAction(this, "Rotate"); | ||
} | ||
} | ||
} // namespace al |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "Library/LiveActor/LiveActor.h" | ||
#include "Library/Math/Axis.h" | ||
|
||
namespace al { | ||
class RotateMapParts : public LiveActor { | ||
public: | ||
RotateMapParts(const char* name); | ||
|
||
void init(const ActorInitInfo& info) override; | ||
void start(); | ||
bool receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) override; | ||
void appearAndSetStart(); | ||
|
||
void exeStandBy(); | ||
void exeRotate(); | ||
void exeAssistStop(); | ||
|
||
private: | ||
sead::Quatf mQuat = sead::Quatf::unit; | ||
Axis mRotateAxis = Axis::X; | ||
f32 mRotateSpeed = 100.0f; | ||
s32 mAssistTimer = 0; | ||
}; | ||
|
||
static_assert(sizeof(RotateMapParts) == 0x128); | ||
} // namespace al |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <basis/seadTypes.h> | ||
|
||
namespace al { | ||
enum class Axis : s32 { | ||
InvertZ = -3, | ||
InvertY = -2, | ||
InvertX = -1, | ||
None = 0, | ||
X = 1, | ||
Y = 2, | ||
Z = 3, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters