VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtEngagedState Class Reference

Detailed Description

DtEngagedState represents the application state where the user is actively controlling an entity in the simulation. It manages gameplay controls, processes relevant messages, and handles transitions between gameplay-related states such as pausing and resuming. This state is typically nested within the network connected state.

#include <engagedState.h>

Inheritance diagram for makVre::DtEngagedState:
[legend]

Public Member Functions

 DtEngagedState (DtPlayerStationApp &app)
 
virtual ~DtEngagedState () override
 
virtual void onEnter (const DtPlayerStationStateArgs *args) override
 
virtual void onExit () override
 
virtual void tick (double dt) override
 
virtual void onExposed (const DtPlayerStationStateArgs *args) override
 
virtual void onStacked () override
 
virtual bool isPlaying () const
 
virtual DtVreMessageResult handleEscKey (DtVreMessage *message)
 
virtual DtVreMessageResult handleBackButtonClicked (DtVreMessage *message)
 
QString buildEngagedTitle () const
 
- Public Member Functions inherited from makVre::DtPlayerStationState
 DtPlayerStationState (DtPlayerStationApp &app, std::string stateType)
 
virtual ~DtPlayerStationState ()
 
 DtPlayerStationState (const DtPlayerStationState &)=delete
 
DtPlayerStationState & operator= (const DtPlayerStationState &)=delete
 
virtual void onEnter ()
 
virtual void onExposed ()
 
bool active () const
 
bool exposed () const
 
bool exiting () const
 
bool stacking () const
 
const std::string & stateType () const
 
DtPlayerStationApp & app () const
 

Protected Member Functions

virtual DtVreMessageResult handleSimulationStateMessage (DtVreMessage *msg)
 
virtual DtVreMessageResult handleVrfSetEmbarkMessage (DtVreMessage *msg)
 
void elementRemoved (makVrv::DtElementID elementId)
 
virtual DtVreMessageResult handleSessionPlayState (DtVreMessage *message)
 
virtual DtVreMessageResult handleModalState (DtVreMessage *message)
 
virtual DtVreMessageResult handleVrfRewind (DtVreMessage *message)
 
virtual void updatePlayerControlsState ()
 
bool isPlayerLoadInProgress () const
 
void loadPlayer (const DtEntityIdentifier &entityId, const std::string &stationName, LoadPlayerRequestMessage::LoadPolicy loadPolicy=LoadPlayerRequestMessage::LoadPolicy_PreserveExisting, const DtEntityIdentifier &destroyEntityId=DtEntityIdentifier::nullId(), const std::string &destroyStationName=std::string(), bool isEmbarkation=false, bool isEmbarkationTransition=false)
 
void resolveDestroyTarget (const DtEntityIdentifier &targetEntity, const std::string &targetStation, DtEntityIdentifier &outDestroyEntity, std::string &outDestroyStation)
 
void processEmbarkationChange (const DtEntityIdentifier &newHost, const std::string &newRole)
 
std::string resolveEmbarkedRoleFromSlot (const VrfSetEmbarkMessage *embarkMsg)
 
void syncEmbarkationTrackingFromActivePlayer ()
 
virtual DtVreMessageResult handleAssignRolePlayer (DtVreMessage *message)
 
virtual DtVreMessageResult handleUnassignRolePlayer (DtVreMessage *message)
 
virtual DtVreMessageResult handleEntityRemoved (DtVreMessage *message)
 
virtual DtVreMessageResult handleChooseRoleButtonClicked (DtVreMessage *message)
 
- Protected Member Functions inherited from makVre::DtPlayerStationState
bool pushState (const std::string &newState, DtPlayerStationStateArgs *args=NULL)
 
bool popSelf ()
 
bool popUntilSelf ()
 
bool popUntilState (const std::string &parentState, DtPlayerStationStateArgs *args=NULL)
 
bool switchToState (const std::string &newState, DtPlayerStationStateArgs *args=NULL)
 
bool pushSelf ()
 

Protected Attributes

std::shared_ptr< DtVreHeaderFooterUI > myPersistentNotification
 
bool myIsPlaying
 
bool myIsModalOpen
 
boost::signals2::connection myEntityRemovedConnection
 
bool myLoadingPlayer
 
bool myAutoRunPending
 
DtEntityIdentifier myBaseEntityId
 
std::string myBaseStationName
 
std::string myBaseDisplayLayout
 
bool myBaseSpectatorMode
 
std::string myEmbarkedRole
 
DtEntityIdentifier myEmbarkedHost
 
bool myBasePlayerIsInvisible
 
- Protected Attributes inherited from makVre::DtPlayerStationState
DtPlayerStationApp & myApp
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtVreMessageHandlerGroup myMessageHandlers
 

Constructor & Destructor Documentation

◆ DtEngagedState()

makVre::DtEngagedState::DtEngagedState ( DtPlayerStationApp & app)

Constructor.

Parameters
appReference to the player station application

Creates a new engaged state associated with the given application.

References makVre::DtPlayerStationState::app().

◆ ~DtEngagedState()

virtual makVre::DtEngagedState::~DtEngagedState ( )
overridevirtual

Virtual destructor.

Ensures proper cleanup of the engaged state resources.

Member Function Documentation

◆ onEnter()

virtual void makVre::DtEngagedState::onEnter ( const DtPlayerStationStateArgs * args)
overridevirtual

Called when the state is entered.

Parameters
argsPointer to arguments from the previous state

Sets up the gameplay environment, registers message handlers, and initializes the player controls. This is called when the player first enters the engaged state, typically after selecting a role.

When LOADING_PLAYER_STATE chained an embarked-host load (re-engaging an entity that was already embarked), this method also syncs the embarkation tracking fields so that subsequent SimulationStateMessage handlers see the correct baseline.

Reimplemented from makVre::DtPlayerStationState.

Reimplemented in makVre::DtExtendedEngagedState.

◆ onExit()

virtual void makVre::DtEngagedState::onExit ( )
overridevirtual

Called when the state is exited.

Cleans up resources, disconnects from the controlled entity, and unregisters message handlers. This is called when the player leaves the engaged state, typically when disengaging from a role.

Reimplemented from makVre::DtPlayerStationState.

Reimplemented in makVre::DtExtendedEngagedState.

◆ tick()

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

Updates the state each frame.

Parameters
dtTime in seconds since the last update

Handles per-frame processing for gameplay, including checking for entity status changes and updating UI elements as needed.

Reimplemented from makVre::DtPlayerStationState.

Reimplemented in makVre::DtExtendedEngagedState.

◆ onExposed()

virtual void makVre::DtEngagedState::onExposed ( const DtPlayerStationStateArgs * args)
overridevirtual

Called when the state becomes the topmost state again.

Parameters
argsPointer to arguments from the popped state

Restores gameplay functionality when this state is exposed after another state (like a menu) has been popped from the stack. If args are non-null (LOADING_PLAYER_STATE failure), routes to CHOOSE_ROLE_STATE instead of setting up the HUD.

Reimplemented from makVre::DtPlayerStationState.

◆ onStacked()

virtual void makVre::DtEngagedState::onStacked ( )
overridevirtual

Called when another state is pushed on top of this one.

Temporarily disables certain gameplay functionality while this state is covered by another state on the stack, such as a pause menu.

Reimplemented from makVre::DtPlayerStationState.

Reimplemented in makVre::DtExtendedEngagedState.

◆ isPlaying()

virtual bool makVre::DtEngagedState::isPlaying ( ) const
virtual

Checks if the simulation is currently playing.

Returns
True if the simulation is playing, false if paused

Reports whether the simulation is currently in a playing state or if it's paused. This affects how inputs are processed.

◆ handleEscKey()

virtual DtVreMessageResult makVre::DtEngagedState::handleEscKey ( DtVreMessage * message)
virtual

Handles escape key press messages.

Parameters
messagePointer to the key press message
Returns
Message handling result

Processes escape key presses, typically bringing up the pause menu or other options during gameplay.

◆ handleBackButtonClicked()

virtual DtVreMessageResult makVre::DtEngagedState::handleBackButtonClicked ( DtVreMessage * message)
virtual

Handles back button click messages.

Parameters
messagePointer to the button click message
Returns
Message handling result

Processes back button clicks, typically navigating back to a previous screen or opening the pause menu during gameplay.

◆ buildEngagedTitle()

QString makVre::DtEngagedState::buildEngagedTitle ( ) const

Builds the header title for the engaged state.

Returns
"MarkingText - Role" or a partial fallback if either is unavailable

◆ handleAssignRolePlayer()

virtual DtVreMessageResult makVre::DtEngagedState::handleAssignRolePlayer ( DtVreMessage * message)
protectedvirtual

Message handlers for role assignment.

Handles role assignment messages

Parameters
messagePointer to the role assignment message
Returns
Message handling result

Processes messages relating to assigning roles to players.

◆ handleUnassignRolePlayer()

virtual DtVreMessageResult makVre::DtEngagedState::handleUnassignRolePlayer ( DtVreMessage * message)
protectedvirtual

Handles role unassignment messages.

Parameters
messagePointer to the role unassignment message
Returns
Message handling result

Processes messages relating to removing players from roles.

◆ handleEntityRemoved()

virtual DtVreMessageResult makVre::DtEngagedState::handleEntityRemoved ( DtVreMessage * message)
protectedvirtual

Handles entity removal messages.

Parameters
messagePointer to the entity removal message
Returns
Message handling result

Processes messages relating to entities being removed from the simulation, which may require disengaging if the player's entity is removed.

◆ handleChooseRoleButtonClicked()

virtual DtVreMessageResult makVre::DtEngagedState::handleChooseRoleButtonClicked ( DtVreMessage * message)
protectedvirtual

Handles choose role button click messages.

Parameters
messagePointer to the button click message
Returns
Message handling result

Processes clicking the choose role button, typically returning to the role selection screen from gameplay.

◆ handleSimulationStateMessage()

virtual DtVreMessageResult makVre::DtEngagedState::handleSimulationStateMessage ( DtVreMessage * msg)
protectedvirtual

Handles simulation state update messages.

Parameters
msgPointer to the simulation state message
Returns
Message handling result

Processes simulation state updates, particularly tracking the role-driving state that can force the current player station to be recreated or switched.

◆ handleVrfSetEmbarkMessage()

virtual DtVreMessageResult makVre::DtEngagedState::handleVrfSetEmbarkMessage ( DtVreMessage * msg)
protectedvirtual

Intercepts player-initiated embark/disembark requests.

Parameters
msgPointer to the VrfSetEmbarkMessage
Returns
Message handling result

Handles VrfSetEmbarkMessage to trigger immediate role transitions for player-initiated embark/disembark, bypassing the SimulationStateMessage polling delay. Falls back to handleSimulationStateMessage for cases where the role cannot be determined from the embark message alone, or for VRF-initiated embarkation changes.

◆ elementRemoved()

void makVre::DtEngagedState::elementRemoved ( makVrv::DtElementID elementId)
protected

Handles entity element removal signals.

Parameters
elementIdID of the removed element

Callback for EntityResolver signals when elements are removed. Used to detect when the player's controlled entity is removed from the simulation, which requires disengagement.

◆ handleSessionPlayState()

virtual DtVreMessageResult makVre::DtEngagedState::handleSessionPlayState ( DtVreMessage * message)
protectedvirtual

Handles session play state messages.

Parameters
messagePointer to the play state message
Returns
Message handling result

Processes messages about changes to the session's play state (playing/paused), updating UI and control systems accordingly.

◆ handleModalState()

virtual DtVreMessageResult makVre::DtEngagedState::handleModalState ( DtVreMessage * message)
protectedvirtual

Handles modal dialog state messages.

Parameters
messagePointer to the modal state message
Returns
Message handling result

Processes messages about modal dialogs opening or closing, adjusting gameplay controls and input handling accordingly.

◆ handleVrfRewind()

virtual DtVreMessageResult makVre::DtEngagedState::handleVrfRewind ( DtVreMessage * message)
protectedvirtual

Handles VR-Forces simulation rewind messages.

Parameters
messagePointer to the VrfRewindMessage
Returns
Message handling result (HANDLED)

Processes rewind requests from VR-Forces, transitioning the player back to the role selection state. The rewind message is copied and passed as state arguments to allow the choose role state to clean up and reset appropriately.

◆ updatePlayerControlsState()

virtual void makVre::DtEngagedState::updatePlayerControlsState ( )
protectedvirtual

Updates the state of player controls.

Enables or disables player controls based on current application state, such as whether the simulation is playing, paused, or a modal dialog is open. This ensures that controls are only active when appropriate.

◆ isPlayerLoadInProgress()

bool makVre::DtEngagedState::isPlayerLoadInProgress ( ) const
protected

Checks whether a player load is pending or active.

Covers both the interval after a load is queued and the time that LOADING_PLAYER_STATE is present in the state stack.

◆ loadPlayer()

void makVre::DtEngagedState::loadPlayer ( const DtEntityIdentifier & entityId,
const std::string & stationName,
LoadPlayerRequestMessage::LoadPolicy loadPolicy = LoadPlayerRequestMessage::LoadPolicy_PreserveExisting,
const DtEntityIdentifier & destroyEntityId = DtEntityIdentifier::nullId(),
const std::string & destroyStationName = std::string(),
bool isEmbarkation = false,
bool isEmbarkationTransition = false )
protected

Pushes LOADING_PLAYER_STATE on top to create or resume a player station.

Parameters
entityIdThe entity identifier to load the player station for
stationNameThe station/role name to load
loadPolicyControls whether existing player stations are preserved (embarkation) or replaced (authoritative role reassignment).
destroyEntityIdEntity whose player station should be destroyed before the new station is created. Null means no targeted destruction.
destroyStationNameStation name of the player to destroy.
isEmbarkationTrue when the load was triggered by an embarkation event. Passed through to LoadPlayerRequestMessage so ownership acquisition retains the base entity while loading an embarked-host role.
isEmbarkationTransitionTrue when the load follows an authoritative embark or disembark update. LOADING_PLAYER_STATE skips its stale-state embark probe but retains its normal settle window.

Sets myLoadingPlayer, packages the entity/station into args, and pushes LOADING_PLAYER_STATE. When loading completes, onExposed clears the flag.

References makVre::LoadPlayerRequestMessage::LoadPolicy_PreserveExisting.

◆ resolveDestroyTarget()

void makVre::DtEngagedState::resolveDestroyTarget ( const DtEntityIdentifier & targetEntity,
const std::string & targetStation,
DtEntityIdentifier & outDestroyEntity,
std::string & outDestroyStation )
protected

Determines which player station should be destroyed when loading a new one.

Compares the target load against the current player stack. If an active embarked-host station (not the base player) exists and differs from the target, it is returned as the destroy target. Used by processEmbarkationChange and other callers to centralise the destroy-target decision.

Parameters
targetEntityEntity for the station being loaded
targetStationStation/role name being loaded
[out]outDestroyEntityEntity whose station should be destroyed (nullId if none)
[out]outDestroyStationStation name to destroy (empty if none)

◆ processEmbarkationChange()

void makVre::DtEngagedState::processEmbarkationChange ( const DtEntityIdentifier & newHost,
const std::string & newRole )
protected

Unified handler for embarkation, disembarkation, and role switches.

Called by both handleSimulationStateMessage and handleVrfSetEmbarkMessage after they determine the new (host, role) pair. Updates tracking state, resolves which station to destroy, restores base display settings on disembark, and calls loadPlayer.

Parameters
newHostHost entity (nullId for disembark)
newRoleRole name (empty for disembark)

◆ resolveEmbarkedRoleFromSlot()

std::string makVre::DtEngagedState::resolveEmbarkedRoleFromSlot ( const VrfSetEmbarkMessage * embarkMsg)
protected

Resolves the player-station role for a VrfSetEmbarkMessage slot.

Looks up the parent host's entity type via the entity resolver, then consults the player-creation palette to find a role matching the slot name (preferred) or slot type. Returns an empty string if the slot info is insufficient to determine a role; callers should fall back to waiting for the next SimulationStateMessage.

Parameters
embarkMsgSource message; its parent entity ID and slot name/type are read.
Returns
The resolved role name, or empty string if unresolved.

◆ syncEmbarkationTrackingFromActivePlayer()

void makVre::DtEngagedState::syncEmbarkationTrackingFromActivePlayer ( )
protected

Synchronises embarkation tracking with the active player station.

Called from onExposed after LOADING_PLAYER_STATE pops. When a chained embarked-host load has occurred, the base player (index 0) and active player differ; in that case the active player's identity is mirrored into myEmbarkedHost/myEmbarkedRole and myBasePlayerIsInvisible is set so the next SimulationStateMessage does not see a stale mismatch and trigger a redundant processEmbarkationChange. When base == active (no embarkation), the tracking fields are cleared.

Member Data Documentation

◆ myPersistentNotification

std::shared_ptr<DtVreHeaderFooterUI> makVre::DtEngagedState::myPersistentNotification
protected

Persistent notification displayed during gameplay.

◆ myIsPlaying

bool makVre::DtEngagedState::myIsPlaying
protected

Flag indicating whether the simulation is currently playing.

◆ myIsModalOpen

bool makVre::DtEngagedState::myIsModalOpen
protected

Flag indicating whether a modal dialog is currently open.

◆ myEntityRemovedConnection

boost::signals2::connection makVre::DtEngagedState::myEntityRemovedConnection
protected

Connection to the entity removed signal.

◆ myBaseEntityId

DtEntityIdentifier makVre::DtEngagedState::myBaseEntityId
protected

These fields record the human player's original role assignment. They are restored after disembark and updated by handleAssignRolePlayer when the server authoritatively reassigns the entity.

Entity identifier of the human player's original assignment

◆ myBaseStationName

std::string makVre::DtEngagedState::myBaseStationName
protected

Station (role) name of the human player's original assignment.

◆ myBaseDisplayLayout

std::string makVre::DtEngagedState::myBaseDisplayLayout
protected

Display layout of the human player's original assignment.

◆ myBaseSpectatorMode

bool makVre::DtEngagedState::myBaseSpectatorMode
protected

Whether the human player was originally in spectator mode.

◆ myEmbarkedRole

std::string makVre::DtEngagedState::myEmbarkedRole
protected

These fields track the current embarkation state reported by VRF. They are a layered override on top of the base identity — the human player's identity is preserved in the base fields above.

Role name assigned to the player through embarkation

◆ myEmbarkedHost

DtEntityIdentifier makVre::DtEngagedState::myEmbarkedHost
protected

Entity identifier of the embarkation host.

◆ myBasePlayerIsInvisible

bool makVre::DtEngagedState::myBasePlayerIsInvisible
protected

Whether the base player entity is invisible (notional embarkation slot)

◆ myLoadingPlayer

bool makVre::DtEngagedState::myLoadingPlayer
protected

True after a player load has been requested and before loading completes.

Used with LOADING_PLAYER_STATE stack membership by isPlayerLoadInProgress() to prevent duplicate load requests while the state transition is pending.

◆ myAutoRunPending

bool makVre::DtEngagedState::myAutoRunPending
protected

True until the first onExposed after onEnter (for auto-run in hosted sessions)


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