NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
dRail_c Class Reference

#include <game/bases/d_rail.hpp>

Description

Manages movement along rails.

Definition at line 7 of file d_rail.hpp.

Public Types

enum  RAIL_FLAGS_e {
  RAIL_FLAG_LOOP = BIT_FLAG(1) ,
  RAIL_FLAG_DELAYING = BIT_FLAG(2) ,
  RAIL_FLAG_DISABLED = BIT_FLAG(3)
}
 
enum  NODE_FLAGS_e { NODE_FLAG_1 = BIT_FLAG(0) }
 

Public Member Functions

virtual ~dRail_c ()
 Destroys the rail handler.
 
virtual void calcSpeed ()
 Calculates and applies the new speed based on the current and next node.
 
bool set (u8 id, mVec3_c *pos, mVec3_c *speed, float *speedF, u16 startIndex, u8 reverse)
 Initializes the rail with the specified ID and parameters.
 
bool calcNextPoint ()
 Advances the node index to the next target point.
 
void calcTargetPos ()
 Calculates the target position based on the next node.
 
bool execute ()
 Executes the rail movement logic. Returns whether a target node has been reached.
 
bool checkArrive ()
 Checks whether the rail has arrived at the next target node.
 

Static Public Member Functions

static sRailInfoDatagetRailInfoP (u8 id)
 Gets the rail data for the specified ID.
 

Public Attributes

sRailNodeDatampNodes
 The array of rail nodes.
 
mVec2_c mTargetPos
 The position of the next node.
 
mVec3_cmpPos
 Reference to the position of the object on the rail.
 
mVec3_cmpSpeed
 Reference to the speed vector of the object on the rail.
 
float * mpSpeedF
 Reference to the forward speed of the object on the rail.
 
u16 mCount
 The number of nodes in the rail.
 
short mIdxCurr
 The current node index.
 
short mIdxNext
 The next node index.
 
u16 mDelayTimer
 By how many frames to delay before starting movement from a node.
 
u16 mAngle
 The current angle of movement.
 
u16 mFlags
 The rail flags.
 
u16 mNodeFlags
 The current node flags.
 
u8 mReverse
 Whether to go through the rail in reverse.
 
int mAngleCalcTimer
 Cooldown timer for angle recalculation.
 
bool mBounce
 Whether to reverse direction at the ends of the rail (only applicable if not looping).
 

Member Enumeration Documentation

◆ RAIL_FLAGS_e

Definition at line 34 of file d_rail.hpp.

◆ NODE_FLAGS_e

Definition at line 41 of file d_rail.hpp.

Constructor & Destructor Documentation

◆ ~dRail_c()

virtual dRail_c::~dRail_c ( )
inlinevirtual

Destroys the rail handler.

Definition at line 9 of file d_rail.hpp.

Member Function Documentation

◆ calcSpeed()

void dRail_c::calcSpeed ( )
virtual

Calculates and applies the new speed based on the current and next node.

Definition at line 95 of file d_rail.cpp.

◆ set()

bool dRail_c::set ( u8 id,
mVec3_c * pos,
mVec3_c * speed,
float * speedF,
u16 startIndex,
u8 reverse )

Initializes the rail with the specified ID and parameters.

Parameters
idThe ID of the rail to use.
posPointer to the position vector of the object on the rail.
speedPointer to the speed vector of the object on the rail.
speedFPointer to the forward speed of the object on the rail.
startIndexThe starting node index on the rail.
reverseWhether the object should travel the rail in reverse.
Returns
Whether the rail was successfully initialized.

Definition at line 16 of file d_rail.cpp.

◆ calcNextPoint()

bool dRail_c::calcNextPoint ( )

Advances the node index to the next target point.

Returns
Whether the end of the rail has been reached.

Definition at line 53 of file d_rail.cpp.

◆ calcTargetPos()

void dRail_c::calcTargetPos ( )

Calculates the target position based on the next node.

Definition at line 85 of file d_rail.cpp.

◆ execute()

bool dRail_c::execute ( )

Executes the rail movement logic. Returns whether a target node has been reached.

Definition at line 133 of file d_rail.cpp.

◆ checkArrive()

bool dRail_c::checkArrive ( )

Checks whether the rail has arrived at the next target node.

Definition at line 170 of file d_rail.cpp.

◆ getRailInfoP()

sRailInfoData * dRail_c::getRailInfoP ( u8 id)
static

Gets the rail data for the specified ID.

Definition at line 4 of file d_rail.cpp.

Member Data Documentation

◆ mpNodes

sRailNodeData* dRail_c::mpNodes

The array of rail nodes.

Definition at line 45 of file d_rail.hpp.

◆ mTargetPos

mVec2_c dRail_c::mTargetPos

The position of the next node.

Definition at line 46 of file d_rail.hpp.

◆ mpPos

mVec3_c* dRail_c::mpPos

Reference to the position of the object on the rail.

Definition at line 47 of file d_rail.hpp.

◆ mpSpeed

mVec3_c* dRail_c::mpSpeed

Reference to the speed vector of the object on the rail.

Definition at line 48 of file d_rail.hpp.

◆ mpSpeedF

float* dRail_c::mpSpeedF

Reference to the forward speed of the object on the rail.

Definition at line 49 of file d_rail.hpp.

◆ mCount

u16 dRail_c::mCount

The number of nodes in the rail.

Definition at line 50 of file d_rail.hpp.

◆ mIdxCurr

short dRail_c::mIdxCurr

The current node index.

Definition at line 51 of file d_rail.hpp.

◆ mIdxNext

short dRail_c::mIdxNext

The next node index.

Definition at line 52 of file d_rail.hpp.

◆ mDelayTimer

u16 dRail_c::mDelayTimer

By how many frames to delay before starting movement from a node.

Definition at line 53 of file d_rail.hpp.

◆ mAngle

u16 dRail_c::mAngle

The current angle of movement.

Definition at line 54 of file d_rail.hpp.

◆ mFlags

u16 dRail_c::mFlags

The rail flags.

Definition at line 55 of file d_rail.hpp.

◆ mNodeFlags

u16 dRail_c::mNodeFlags

The current node flags.

Definition at line 56 of file d_rail.hpp.

◆ mReverse

u8 dRail_c::mReverse

Whether to go through the rail in reverse.

Definition at line 57 of file d_rail.hpp.

◆ mAngleCalcTimer

int dRail_c::mAngleCalcTimer

Cooldown timer for angle recalculation.

Definition at line 58 of file d_rail.hpp.

◆ mBounce

bool dRail_c::mBounce

Whether to reverse direction at the ends of the rail (only applicable if not looping).

Definition at line 59 of file d_rail.hpp.