1#include <game/bases/d_a_obj_center2.hpp>
3#include <game/bases/d_bg.hpp>
4#include <game/bases/d_center_save_mng.hpp>
5#include <game/bases/d_enemy.hpp>
6#include <game/bases/d_quake.hpp>
7#include <game/bases/d_switch_flag_mng.hpp>
17 if (ACTOR_PARAM(RotateCoinSE)) {
18 dAudio::g_pSndObjMap->startSound(SE_OBJ_COIN_POP_UP,
mPos, 0);
31 static const s16 l_RotSpeed[] = {
32 0x40, 0x80, 0xc0, 0x100, 0x20, 0x200, 0x400
35 u32 rotSpeedMode = ACTOR_PARAM(RotationSpeed);
36 if (rotSpeedMode >= ARRAY_SIZE(l_RotSpeed)) {
72 float ang = std::fabs((
float)
mAngle.z / 0x4000);
79 dBg_c::m_bg_p->mZoomRelated = 3;
80 dBg_c::m_bg_p->mZoomWeight = 1.0f - ang * ang * ang;
81 dBg_c::m_bg_p->setZoomPos(
mPos);
88 return l_EnMuki[
mRotDir] * (ACTOR_PARAM(InitialRotation) * 0x1000) + 0xc000;
98void daObjCenter2_c::initializeState_ReturnHome() {
101 mRotDir = ACTOR_PARAM(IsCCW) ^ 1;
106void daObjCenter2_c::finalizeState_ReturnHome() {}
108void daObjCenter2_c::executeState_ReturnHome() {
109 if (dSwitchFlagMng_c::m_instance->mFlag &
mEventMask) {
118 if (abs(
mAngle.z.mAngle - target) < deltaAbs) {
120 if (ACTOR_PARAM(RotateShock)) {
121 dQuake_c::m_instance->startShockAll(dQuake_c::TYPE_0, 3, 0,
false);
127void daObjCenter2_c::initializeState_GoAim() {
139void daObjCenter2_c::finalizeState_GoAim() {}
141void daObjCenter2_c::executeState_GoAim() {
143 if ((dSwitchFlagMng_c::m_instance->mFlag &
mEventMask) == 0) {
158 if (abs(
mAngle.z.mAngle - target) < deltaAbs) {
161 if (ACTOR_PARAM(RotateShock)) {
162 dQuake_c::m_instance->startShockAll(dQuake_c::TYPE_0, 3, 0,
false);
168void daObjCenter2_c::initializeState_Move() {
176void daObjCenter2_c::finalizeState_Move() {}
178void daObjCenter2_c::executeState_Move() {
180 if (dSwitchFlagMng_c::m_instance->mFlag &
mEventMask) {
188 int deltaAbs = labs(delta >> 7);
sFStateMgr_c< dActorState_c, sStateMethodUsr_FI_c > mStateMgr
The state manager.
static u8 mExecStop
The actors for which the execute operation is currently disabled.
u8 mExecStopMask
The mask required to disable the execute operation for the actor.
static u8 m_flag_keep[2]
Temporary storage for the next created sprite actor's tracked event IDs. See mEventNums.
static u64 m_flagbit_keep
Temporary storage for the next created sprite actor's event mask. See mEventMask.
u64 mEventMask
The event mask, generated from mEventNums.
@ STAGE_ACTOR_ENEMY
An enemy actor.
mVec3_c mPos
The actor's position.
mAng3_c mAngle
The actor's rotation (for 2D actors).
void center_entry(const mVec3_c *pos, u8 id, short rotation)
Saves the rotation state for a given position and ID.
static dCenterSaveMng_c * m_instance
The singleton instance of the manager.
A controller for rotating objects around a center point.
u8 mZoomControl
Whether the zoom level is controlled by the rotation controller. [Unknown what 1 and 2 mean].
int mAngDelta
The incremental change in rotation per frame.
short getAngle()
Returns the home rotation angle of this rotation controller.
void tryPlayCoinSE()
Plays a coin sound effect if it has not been played yet for the current rotation.
u8 mRotationID
The rotation ID to be set on the affected objects.
virtual int create() override
do method for the create operation.
short mHomeRotation
The starting rotation.
virtual int execute() override
do method for the execute operation.
@ MODE_PERMANENT
Permamently rotate in one direction.
@ MODE_BACK_AND_FORTH
Move to the stop target when active, move back when inactive.
bool mCoinSoundReady
Whether the coin sound is ready to be played.
u8 mRotationMode
The rotation mode. See RotationMode_e.
bool mCoinSoundPlayed
Whether the coin sound has been played.
static sFStateID_c< daObjCenter2_c > StateID_GoAim
Rotating to the stop rotation.
short mTargetRotation
The current rotation the controller is targeting.
u8 mRotDir
The rotation direction. See DIRECTION_LR_e (right = clockwise, left = counter-clockwise).
static sFStateID_c< daObjCenter2_c > StateID_ReturnHome
Returning to the home rotation.
short mRotationSpeed
The angular speed of the rotation.
void coinSE()
Plays a coin sound effect if the actor is configured to do so.
static sFStateID_c< daObjCenter2_c > StateID_Move
Rotating in one direction.
@ SUCCEEDED
The step was completed successfully.
#define ACTOR_PROFILE(profName, className, properties)
Creates an actor profile, using the profile number as the execute and draw order value.
#define STATE_DEFINE(class, name)
Defines a state.