libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::Action Class Referenceabstract

Represents a discrete, repeatable operation run by a Tickable. More...

#include <Action.h>

Inheritance diagram for Ship::Action:
[legend]
Collaboration diagram for Ship::Action:
[legend]

Public Member Functions

 Action (std::shared_ptr< Tickable > tickable)
 Constructs an Action associated with a Tickable.
 
virtual ~Action ()=default
 
std::shared_ptr< TickableGetTickable () const
 Returns the Tickable that owns this Action, or nullptr if expired.
 
bool Run ()
 Executes the Action if it is currently running.
 
bool IsRunning () const
 Returns true if this Action is currently in the running state.
 
bool Start (const bool force=false)
 Starts the Action so that subsequent Run() calls will execute it.
 
bool Stop (const bool force=false)
 Stops the Action so that subsequent Run() calls become no-ops.
 
virtual bool CanStart ()
 Permission hook; override to prevent starting. Defaults to true.
 
virtual bool CanStop ()
 Permission hook; override to prevent stopping. Defaults to true.
 
virtual void Started (const bool forced)
 Notification hook called after the Action has been started.
 
virtual void Stopped (const bool forced)
 Notification hook called after the Action has been stopped.
 
double GetTime (const ClockType clockType) const
 Returns the wall-clock time for a profiling checkpoint.
 
- Public Member Functions inherited from Ship::Part
 Part ()
 Constructs a Part and assigns it a unique ID.
 
 Part (std::shared_ptr< Context > context)
 Constructs a Part with an explicit Context reference and unique ID.
 
virtual ~Part ()=default
 
uint64_t GetId () const
 Returns the unique identifier for this Part.
 
bool operator== (const Part &other) const
 Compares two Parts for equality by their unique IDs.
 
std::shared_ptr< ContextGetContext () const
 Returns the Context this Part belongs to, or nullptr if unset.
 
void SetContext (std::shared_ptr< Context > ctx)
 Sets the Context this Part belongs to.
 

Protected Member Functions

virtual bool ActionRan ()=0
 Pure virtual hook invoked by Run() each cycle.
 
- Protected Member Functions inherited from Ship::Part
virtual void OnAdded (bool forced)
 Called after this Part has been added to a PartList.
 
virtual void OnRemoved (bool forced)
 Called after this Part has been removed from a PartList.
 

Detailed Description

Represents a discrete, repeatable operation run by a Tickable.

Actions are owned by a Tickable and executed each frame/tick. Subclasses define behavior via ActionRan().

For event-driven actions that need dispatching via EventID, use EventAction.

Constructor & Destructor Documentation

◆ Action()

Ship::Action::Action ( std::shared_ptr< Tickable tickable)

Constructs an Action associated with a Tickable.

Parameters
tickableThe Tickable that owns and will run this Action.

◆ ~Action()

virtual Ship::Action::~Action ( )
virtualdefault

Member Function Documentation

◆ ActionRan()

virtual bool Ship::Action::ActionRan ( )
protectedpure virtual

Pure virtual hook invoked by Run() each cycle.

Subclasses must implement this to define the Action's behaviour.

Returns
True if the action executed successfully.

Implemented in Ship::EventAction, and Ship::ListenerAction.

◆ CanStart()

virtual bool Ship::Action::CanStart ( )
virtual

Permission hook; override to prevent starting. Defaults to true.

◆ CanStop()

virtual bool Ship::Action::CanStop ( )
virtual

Permission hook; override to prevent stopping. Defaults to true.

◆ GetTickable()

std::shared_ptr< Tickable > Ship::Action::GetTickable ( ) const

Returns the Tickable that owns this Action, or nullptr if expired.

◆ GetTime()

double Ship::Action::GetTime ( const ClockType  clockType) const

Returns the wall-clock time for a profiling checkpoint.

Parameters
clockTypeWhich checkpoint to query.
Returns
Elapsed time in seconds since the epoch for the requested checkpoint.

◆ IsRunning()

bool Ship::Action::IsRunning ( ) const

Returns true if this Action is currently in the running state.

◆ Run()

bool Ship::Action::Run ( )

Executes the Action if it is currently running.

Returns
True if the Action executed successfully.

◆ Start()

bool Ship::Action::Start ( const bool  force = false)

Starts the Action so that subsequent Run() calls will execute it.

Parameters
forceIf true, bypass the CanStart() check.
Returns
True if the Action was successfully started.

◆ Started()

virtual void Ship::Action::Started ( const bool  forced)
virtual

Notification hook called after the Action has been started.

Parameters
forcedWhether the start bypassed permission checks.

◆ Stop()

bool Ship::Action::Stop ( const bool  force = false)

Stops the Action so that subsequent Run() calls become no-ops.

Parameters
forceIf true, bypass the CanStop() check.
Returns
True if the Action was successfully stopped.

◆ Stopped()

virtual void Ship::Action::Stopped ( const bool  forced)
virtual

Notification hook called after the Action has been stopped.

Parameters
forcedWhether the stop bypassed permission checks.

The documentation for this class was generated from the following file: