New Super Mario Bros. U Headers
Loading...
Searching...
No Matches
ActorBase Class Reference

Base interface class for all actors in the game. Lifecycle is handled by ActorMgr. More...

#include <ActorBase.h>

Inherited by Actor, BgCenter, and CourseSelectActor.

Public Types

enum  MainState { cState_None = 0 , cState_Failed , cState_Success , cState_Wait }
 Represents the execution state of a main operation, and whether it was skipped. More...
enum  Result { cResult_Wait = 0 , cResult_Success , cResult_Failed }
 Defines signals to pass to ActorMgr when performing create and delete operations on the actor. More...
typedef sead::OffsetList< ActorBaseList

Public Member Functions

bool isActive () const
 Whether this actor has been successfully created and is now active.
void deleteRequest ()
 Schedule this actor for deletion on the next frame.
bool isRequestedDelete () const
 Whether this actor has been scheduled for deletion on the next frame.
ActorUniqueID getActorUniqueID () const
 The unique identifier handle for this actor.
s32 getProfileID () const
 The specific profile ID which this actor was instantiated from.
ProfilegetProfile () const
 The specific profile which this actor was instantiated from.
bool isCreatedImmediately () const
 Whether the actor was created with ActorMgr::createImmediately(), rather than deferred with ActorMgr::createLater().
bool isMapActor () const
 Whether the actor was spawned from the level with ActorCreateMgr, rather than dynamically spawned by another actor.
u32 getParam0 () const
 Level designer configuration. Also known as "nybbles" or "spritedata".
u32 getParam1 () const
 Level designer configuration. Also known as "nybbles" or "spritedata".
ActorParamEx1 getParamEx () const
 Extra level designer configuration. Also known as "nybbles" or "spritedata".
const ListgetChildList () const
 sead::OffsetList used for holding child actors spawned by this actor. Managed automatically if param.parent_id is set when spawning.
sead::HeapgetActorHeap () const
 The personal heap for this actor.
ActorBasegetParent () const
template<typename T>
T * getParent () const
 The parent actor pointer if this actor is a child, nullptr otherwise.
void removeChild (ActorBase *child)
 Disconnects a child from this actor's family tree.

Protected Member Functions

 ActorBase (const ActorCreateParam &param)
 Constructs an actor from configuration data.
virtual ~ActorBase ()
 Destroys the actor and orphans all of its children.
virtual bool preCreate ()
 Callback invoked before the create operation.
virtual Result create ()
 Main initialization/setup callback for the actor.
virtual void postCreate (MainState state)
 Callback invoked unconditionally after the create phase completes. It executes even if preCreate() bypassed the main create() operation.
virtual bool preExecute ()
 Callback invoked before the execute operation.
virtual bool execute ()
 Main execution/logic callback for the actor. Called every frame (the game runs at exactly 60 FPS).
virtual void postExecute (MainState state)
 Callback invoked unconditionally after the execute phase completes. It executes even if preExecute() bypassed the main execute() operation.
virtual void finalUpdate ()
 Callback which is called after all other actors have finished executing for this frame.
virtual bool preDraw ()
 Callback invoked before the draw operation.
virtual bool draw ()
 Main rendering callback for the actor. Called every frame (the game runs at exactly 60 FPS).
virtual void postDraw (MainState state)
 Callback invoked unconditionally after the draw phase completes. It executes even if preDraw() bypassed the main draw() operation.
virtual bool preDelete ()
 Callback invoked before the delete operation.
virtual Result doDelete ()
 Main deletion callback for the actor.
virtual void postDelete (MainState state)
 Unconditionally called callback for after the delete operation.
void setActive_ (bool active)

Protected Attributes

sead::HeapmActorHeap
 Personal heap for this actor of type sead::FrameHeap. Capacity of 0x20200, but profiles in the player whitelist get 0x1A0200.
ActorUniqueID mActorUniqueID
 The unique identifier handle for this actor.
ProfilemActorProfile
 The specific profile which this actor was instantiated from.
bool mCreatedImmediately
 Whether the actor was created with ActorMgr::createImmediately(), rather than deferred with ActorMgr::createLater().
bool mIsMapActor
 Whether the actor was spawned from the level with ActorCreateMgr, rather than dynamically spawned by another actor.
bool mIsActive
 Whether the create operation has completed and the actor is executing.
bool mDeleteRequestFlag
 Whether to delete this actor on the next frame.
u32 mParam0
 Level designer configuration. Also known as "nybbles" or "spritedata".
u32 mParam1
 Level designer configuration. Also known as "nybbles" or "spritedata".
ActorParamEx1 mParamEx
 Extra level designer configuration. Also known as "nybbles" or "spritedata".
List mChildList
 sead::OffsetList used for holding child actors spawned by this actor. Managed automatically if param.parent_id is set when spawning.
sead::ListNode mChildNode
 Implementation detail. Used to track our position in the parent's mChildList.
ActorBasemParent
 The parent actor if this actor is a child. Automatically set to nullptr if orphaned.
sead::ListNode mExecuteNode
 Implementation detail. Used to track our position in ActorMgr lists.
sead::ListNode mDrawNode
 Implementation detail. Used to track our position in ActorMgr mDrawManage list.
sead::BitFlag32 mFlag

Friends

class ActorMgr

Detailed Description

Base interface class for all actors in the game. Lifecycle is handled by ActorMgr.

Size: 0x50
vtable Address: 0x100006C0

Member Typedef Documentation

◆ List

Member Enumeration Documentation

◆ MainState

Represents the execution state of a main operation, and whether it was skipped.

In the case of preX skipping the main callback, cState_None will be passed to postX. Otherwise, the signal is forwarded.

Enumerator
cState_None 

The operation was skipped.

cState_Failed 

The operation was cancelled.

cState_Success 

The operation was successful.

cState_Wait 

The operation was stalled.

◆ Result

Defines signals to pass to ActorMgr when performing create and delete operations on the actor.

Enumerator
cResult_Wait 

Stall the operation, tries to call again the next frame.

cResult_Success 

The operation was successful, continue execution.

cResult_Failed 

Cancel the operation. This deletes the actor.

Constructor & Destructor Documentation

◆ ActorBase()

ActorBase::ActorBase ( const ActorCreateParam & param)
protected

Constructs an actor from configuration data.

Parameters
paramParameters and user configuration to pass to the actor.
Address: 0x02002CE0

◆ ~ActorBase()

virtual ActorBase::~ActorBase ( )
protectedvirtual

Destroys the actor and orphans all of its children.

Address: 0x02002E68

Member Function Documentation

◆ isActive()

bool ActorBase::isActive ( ) const
inline

Whether this actor has been successfully created and is now active.

◆ deleteRequest()

void ActorBase::deleteRequest ( )
inline

Schedule this actor for deletion on the next frame.

◆ isRequestedDelete()

bool ActorBase::isRequestedDelete ( ) const
inline

Whether this actor has been scheduled for deletion on the next frame.

◆ getActorUniqueID()

ActorUniqueID ActorBase::getActorUniqueID ( ) const
inline

The unique identifier handle for this actor.

◆ getProfileID()

s32 ActorBase::getProfileID ( ) const

The specific profile ID which this actor was instantiated from.

Address: 0x02002C80

◆ getProfile()

Profile * ActorBase::getProfile ( ) const
inline

The specific profile which this actor was instantiated from.

◆ isCreatedImmediately()

bool ActorBase::isCreatedImmediately ( ) const
inline

Whether the actor was created with ActorMgr::createImmediately(), rather than deferred with ActorMgr::createLater().

◆ isMapActor()

bool ActorBase::isMapActor ( ) const
inline

Whether the actor was spawned from the level with ActorCreateMgr, rather than dynamically spawned by another actor.

◆ getParam0()

u32 ActorBase::getParam0 ( ) const
inline

Level designer configuration. Also known as "nybbles" or "spritedata".

◆ getParam1()

u32 ActorBase::getParam1 ( ) const
inline

Level designer configuration. Also known as "nybbles" or "spritedata".

◆ getParamEx()

ActorParamEx1 ActorBase::getParamEx ( ) const
inline

Extra level designer configuration. Also known as "nybbles" or "spritedata".

◆ getChildList()

const List & ActorBase::getChildList ( ) const
inline

sead::OffsetList used for holding child actors spawned by this actor. Managed automatically if param.parent_id is set when spawning.

◆ getActorHeap()

sead::Heap * ActorBase::getActorHeap ( ) const
inline

The personal heap for this actor.

◆ getParent() [1/2]

ActorBase * ActorBase::getParent ( ) const
inline

The parent actor pointer if this actor is a child, nullptr otherwise.

◆ getParent() [2/2]

template<typename T>
T * ActorBase::getParent ( ) const
inline

The parent actor pointer if this actor is a child, nullptr otherwise.

Template Parameters
TThe parent type to cast to, returns nullptr if the types are incompatible.

◆ removeChild()

void ActorBase::removeChild ( ActorBase * child)

Disconnects a child from this actor's family tree.

Parameters
childThe target actor to orphan.
Address: 0x02002C8C

◆ preCreate()

virtual bool ActorBase::preCreate ( )
protectedvirtual

Callback invoked before the create operation.

Returns
Whether to continue to the main create callback, rather than skip to postExecute().

Returns true by default.

Address: 0x02002F7C

◆ create()

virtual Result ActorBase::create ( )
protectedvirtual

Main initialization/setup callback for the actor.

Returns
A signal for how to handle the operation.

Returns cResult_Success by default.

Address: 0x02002F84

Reimplemented in Birikyu, Bomhei, Boss, BossDemo, BrosBase, KillerHoudai, Koton, KuriboBase, MechaKoopa, PlayerBase, PlayerObject, and TarzanIvyBase.

◆ postCreate()

virtual void ActorBase::postCreate ( MainState state)
protectedvirtual

Callback invoked unconditionally after the create phase completes. It executes even if preCreate() bypassed the main create() operation.

Parameters
stateThe signal which create() returned, or cState_None if preCreate() skipped it.
Address: 0x02002F00

Reimplemented in Actor, and ActorCollision.

◆ preExecute()

virtual bool ActorBase::preExecute ( )
protectedvirtual

Callback invoked before the execute operation.

Returns
Whether to continue to the main execute callback, rather than skip to postExecute().

Returns true by default unless the game is paused or frozen. See EventMgr::isJoin().

Address: 0x02002F04

Reimplemented in Actor, ActorCollision, Boss, CarryEnemy, CourseSelectActor, Enemy, PlayerBase, and PlayerObject.

◆ execute()

virtual bool ActorBase::execute ( )
protectedvirtual

Main execution/logic callback for the actor. Called every frame (the game runs at exactly 60 FPS).

Returns
A signal for how to handle the operation. true / false imply cState_Success / cState_Failed.

Returns true by default.

Address: 0x02002F8C

Reimplemented in ActorBlockBase, Birikyu, Bomhei, BossDemo, BrosBase, KillerHoudai, Koton, KuriboBase, MechaKoopa, PlayerBase, and TarzanIvyBase.

◆ postExecute()

virtual void ActorBase::postExecute ( MainState state)
protectedvirtual

Callback invoked unconditionally after the execute phase completes. It executes even if preExecute() bypassed the main execute() operation.

Parameters
stateThe signal which execute() returned, or cState_None if preExecute() skipped it.
Address: 0x02002F34

Reimplemented in Actor, ActorCollision, Boss, PlayerBase, and PlayerObject.

◆ finalUpdate()

virtual void ActorBase::finalUpdate ( )
protectedvirtual

Callback which is called after all other actors have finished executing for this frame.

The actor must subscribe to the finalUpdate signal on a per-frame basis via ActorMgr::addToFinalUpdate().

Address: 0x02002F94

◆ preDraw()

virtual bool ActorBase::preDraw ( )
protectedvirtual

Callback invoked before the draw operation.

Returns
Whether to continue to the main draw callback, rather than skip to postDraw().

Returns true by default.

Reimplemented in Actor, CourseSelectActor, PlayerBase, and PlayerObject.

◆ draw()

virtual bool ActorBase::draw ( )
protectedvirtual

Main rendering callback for the actor. Called every frame (the game runs at exactly 60 FPS).

Note
This is only for scheduling deferred render tasks; actual rendering may not be performed at this stage.
Returns
A signal for how to handle the operation. true / false imply cState_Success / cState_Failed. However, signaling failure does not delete the actor.

Returns true by default.

Address 0x02002FA0

Reimplemented in ActorBlockAngle, ActorBlockBase, Birikyu, Bomhei, BrosBase, ChikuwaBlockBase, KillerHoudai, Koton, KuriboBase, MechaKoopa, PlayerObject, and TarzanIvyBase.

◆ postDraw()

virtual void ActorBase::postDraw ( MainState state)
protectedvirtual

Callback invoked unconditionally after the draw phase completes. It executes even if preDraw() bypassed the main draw() operation.

Parameters
stateThe signal which draw() returned, or cState_None if preDraw() skipped it.
Address 0x02002F38

◆ preDelete()

virtual bool ActorBase::preDelete ( )
protectedvirtual

Callback invoked before the delete operation.

Returns
Whether to continue to the main doDelete callback.

Returns true by default.

Address: 0x02002FA8

◆ doDelete()

virtual Result ActorBase::doDelete ( )
protectedvirtual

Main deletion callback for the actor.

Returns
A signal for how to handle the operation.

Failure and Success both result in deletion. Only Wait results in a stall.

Address: 0x02002FB0

Reimplemented in ActorCollision, Birikyu, Bomhei, Boss, BossDemo, BrosBase, CarryEnemy, KillerHoudai, Koton, Kuribo, KuriboBase, and PlayerObject.

◆ postDelete()

virtual void ActorBase::postDelete ( MainState state)
protectedvirtual

Unconditionally called callback for after the delete operation.

Parameters
stateThe signal which doDelete() returned, or cState_None if preDelete() skipped it.
Note
The actor has still technically not been deleted yet at this point, that occurs right after this call.
Address: 0x02002F3C

◆ setActive_()

void ActorBase::setActive_ ( bool active)
inlineprotected

◆ ActorMgr

friend class ActorMgr
friend

Member Data Documentation

◆ mActorHeap

sead::Heap* ActorBase::mActorHeap
protected

Personal heap for this actor of type sead::FrameHeap. Capacity of 0x20200, but profiles in the player whitelist get 0x1A0200.

◆ mActorUniqueID

ActorUniqueID ActorBase::mActorUniqueID
protected

The unique identifier handle for this actor.

◆ mActorProfile

Profile* ActorBase::mActorProfile
protected

The specific profile which this actor was instantiated from.

◆ mCreatedImmediately

bool ActorBase::mCreatedImmediately
protected

Whether the actor was created with ActorMgr::createImmediately(), rather than deferred with ActorMgr::createLater().

◆ mIsMapActor

bool ActorBase::mIsMapActor
protected

Whether the actor was spawned from the level with ActorCreateMgr, rather than dynamically spawned by another actor.

◆ mIsActive

bool ActorBase::mIsActive
protected

Whether the create operation has completed and the actor is executing.

◆ mDeleteRequestFlag

bool ActorBase::mDeleteRequestFlag
protected

Whether to delete this actor on the next frame.

◆ mParam0

u32 ActorBase::mParam0
protected

Level designer configuration. Also known as "nybbles" or "spritedata".

◆ mParam1

u32 ActorBase::mParam1
protected

Level designer configuration. Also known as "nybbles" or "spritedata".

◆ mParamEx

ActorParamEx1 ActorBase::mParamEx
protected

Extra level designer configuration. Also known as "nybbles" or "spritedata".

◆ mChildList

List ActorBase::mChildList
protected

sead::OffsetList used for holding child actors spawned by this actor. Managed automatically if param.parent_id is set when spawning.

◆ mChildNode

sead::ListNode ActorBase::mChildNode
protected

Implementation detail. Used to track our position in the parent's mChildList.

◆ mParent

ActorBase* ActorBase::mParent
protected

The parent actor if this actor is a child. Automatically set to nullptr if orphaned.

◆ mExecuteNode

sead::ListNode ActorBase::mExecuteNode
protected

Implementation detail. Used to track our position in ActorMgr lists.

◆ mDrawNode

sead::ListNode ActorBase::mDrawNode
protected

Implementation detail. Used to track our position in ActorMgr mDrawManage list.

◆ mFlag

sead::BitFlag32 ActorBase::mFlag
protected