VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtMetaRoleControlLogic Class Reference

Detailed Description

DtMetaRoleControlLogic instantiates and owns multiple sub-role PlayerStation instances, with input bindings to switch between them. This component creates a role that combines several role definitions into one group that behaves like a single role with multiple views or positions. For example, a tank crew member could switch between different stations within the vehicle.

#include <metaRoleControlLogic.h>

Inheritance diagram for makVre::DtMetaRoleControlLogic:
[legend]

Public Member Functions

 DtMetaRoleControlLogic ()
 
virtual ~DtMetaRoleControlLogic () override
 
virtual bool initialize (DtPlayerStation *player, DtInitTable &config) override
 
virtual bool postInitialize () override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual void activateSubRole (const std::string &station)
 
virtual void activateSubRole (int index)
 
virtual void nextSubRole (double keyState)
 
virtual void previousSubRole (double keyState)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Attributes

DtInputLogic myInputLogic
 
std::vector< DtPlayerStation * > mySubStations
 
std::map< std::string, int > mySubStationIndex
 
int myCurrentSubStation
 
double myActivateDelay
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Additional Inherited Members

- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Constructor & Destructor Documentation

◆ DtMetaRoleControlLogic()

makVre::DtMetaRoleControlLogic::DtMetaRoleControlLogic ( )

Constructor for DtMetaRoleControlLogic.

Initializes component state with default values

◆ ~DtMetaRoleControlLogic()

virtual makVre::DtMetaRoleControlLogic::~DtMetaRoleControlLogic ( )
overridevirtual

Virtual destructor for DtMetaRoleControlLogic.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtMetaRoleControlLogic::initialize ( DtPlayerStation * player,
DtInitTable & config )
overridevirtual

Initializes the meta-role control component.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing meta-role settings
Returns
True if initialization succeeded, false otherwise

Loads input configuration, creates sub-role player stations based on the provided configurations, and prepares them for activation

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

virtual bool makVre::DtMetaRoleControlLogic::postInitialize ( )
overridevirtual

Performs post-initialization after all components are initialized.

Returns
True if post-initialization succeeded, false otherwise

Activates the first sub-role and checks that it initialized successfully

Reimplemented from makVre::DtPlayerComponent.

◆ tick()

virtual void makVre::DtMetaRoleControlLogic::tick ( double dt)
overridevirtual

Called every frame to update the meta-role and its sub-roles.

Parameters
dtDelta time since the last frame in seconds

Updates all sub-role player stations, regardless of which one is active

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void makVre::DtMetaRoleControlLogic::shutdown ( )
overridevirtual

Shuts down the meta-role control component.

Shuts down all sub-role player stations and performs cleanup operations

Reimplemented from makVre::DtPlayerComponent.

◆ type()

virtual const char * makVre::DtMetaRoleControlLogic::type ( ) const
overridevirtual

Returns the component type identifier.

Returns
The component type string

Implements makVre::DtPlayerComponent.

◆ activateSubRole() [1/2]

virtual void makVre::DtMetaRoleControlLogic::activateSubRole ( const std::string & station)
virtual

Activates a specific sub-role by name.

Parameters
stationName of the sub-role to activate

Looks up the sub-role by name and activates it if found

◆ activateSubRole() [2/2]

virtual void makVre::DtMetaRoleControlLogic::activateSubRole ( int index)
virtual

Activates a specific sub-role by index.

Parameters
indexZero-based index of the sub-role to activate

Shuts down the currently active sub-role and initializes the specified one

◆ nextSubRole()

virtual void makVre::DtMetaRoleControlLogic::nextSubRole ( double keyState)
virtual

Input handler function to switch to the next sub-role.

Parameters
keyStateInput value (> 0.5 to trigger the action)

Cycles to the next sub-role in the list, wrapping around to the first if the current role is the last one

◆ previousSubRole()

virtual void makVre::DtMetaRoleControlLogic::previousSubRole ( double keyState)
virtual

Input handler function to switch to the previous sub-role.

Parameters
keyStateInput value (> 0.5 to trigger the action)

Cycles to the previous sub-role in the list, wrapping around to the last if the current role is the first one

Member Data Documentation

◆ myInputLogic

DtInputLogic makVre::DtMetaRoleControlLogic::myInputLogic
protected

Input logic that handles mapping of input actions to functions.

◆ mySubStations

std::vector<DtPlayerStation*> makVre::DtMetaRoleControlLogic::mySubStations
protected

Collection of all sub-role player station instances.

◆ mySubStationIndex

std::map<std::string, int> makVre::DtMetaRoleControlLogic::mySubStationIndex
protected

Mapping from sub-role names to their indices in mySubStations.

◆ myCurrentSubStation

int makVre::DtMetaRoleControlLogic::myCurrentSubStation
protected

Index of the currently active sub-role.

◆ myActivateDelay

double makVre::DtMetaRoleControlLogic::myActivateDelay
protected

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