|
VR-Engage
2.3
|
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>
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 |
| makVre::DtEngagedState::DtEngagedState | ( | DtPlayerStationApp & | app | ) |
Constructor.
| app | Reference to the player station application |
Creates a new engaged state associated with the given application.
References makVre::DtPlayerStationState::app().
|
overridevirtual |
Virtual destructor.
Ensures proper cleanup of the engaged state resources.
|
overridevirtual |
Called when the state is entered.
| args | Pointer 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.
|
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.
|
overridevirtual |
Updates the state each frame.
| dt | Time 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.
|
overridevirtual |
Called when the state becomes the topmost state again.
| args | Pointer 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.
|
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.
|
virtual |
Checks if the simulation is currently playing.
Reports whether the simulation is currently in a playing state or if it's paused. This affects how inputs are processed.
|
virtual |
Handles escape key press messages.
| message | Pointer to the key press message |
Processes escape key presses, typically bringing up the pause menu or other options during gameplay.
|
virtual |
Handles back button click messages.
| message | Pointer to the button click message |
Processes back button clicks, typically navigating back to a previous screen or opening the pause menu during gameplay.
| QString makVre::DtEngagedState::buildEngagedTitle | ( | ) | const |
Builds the header title for the engaged state.
|
protectedvirtual |
Message handlers for role assignment.
Handles role assignment messages
| message | Pointer to the role assignment message |
Processes messages relating to assigning roles to players.
|
protectedvirtual |
Handles role unassignment messages.
| message | Pointer to the role unassignment message |
Processes messages relating to removing players from roles.
|
protectedvirtual |
Handles entity removal messages.
| message | Pointer to the entity removal message |
Processes messages relating to entities being removed from the simulation, which may require disengaging if the player's entity is removed.
|
protectedvirtual |
Handles choose role button click messages.
| message | Pointer to the button click message |
Processes clicking the choose role button, typically returning to the role selection screen from gameplay.
|
protectedvirtual |
Handles simulation state update messages.
| msg | Pointer to the simulation state message |
Processes simulation state updates, particularly tracking the role-driving state that can force the current player station to be recreated or switched.
|
protectedvirtual |
Intercepts player-initiated embark/disembark requests.
| msg | Pointer to the VrfSetEmbarkMessage |
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.
|
protected |
Handles entity element removal signals.
| elementId | ID 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.
|
protectedvirtual |
Handles session play state messages.
| message | Pointer to the play state message |
Processes messages about changes to the session's play state (playing/paused), updating UI and control systems accordingly.
|
protectedvirtual |
Handles modal dialog state messages.
| message | Pointer to the modal state message |
Processes messages about modal dialogs opening or closing, adjusting gameplay controls and input handling accordingly.
|
protectedvirtual |
Handles VR-Forces simulation rewind messages.
| message | Pointer to the VrfRewindMessage |
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.
|
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.
|
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.
|
protected |
Pushes LOADING_PLAYER_STATE on top to create or resume a player station.
| entityId | The entity identifier to load the player station for |
| stationName | The station/role name to load |
| loadPolicy | Controls whether existing player stations are preserved (embarkation) or replaced (authoritative role reassignment). |
| destroyEntityId | Entity whose player station should be destroyed before the new station is created. Null means no targeted destruction. |
| destroyStationName | Station name of the player to destroy. |
| isEmbarkation | True 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. |
| isEmbarkationTransition | True 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.
|
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.
| targetEntity | Entity for the station being loaded | |
| targetStation | Station/role name being loaded | |
| [out] | outDestroyEntity | Entity whose station should be destroyed (nullId if none) |
| [out] | outDestroyStation | Station name to destroy (empty if none) |
|
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.
| newHost | Host entity (nullId for disembark) |
| newRole | Role name (empty for disembark) |
|
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.
| embarkMsg | Source message; its parent entity ID and slot name/type are read. |
|
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.
|
protected |
Persistent notification displayed during gameplay.
|
protected |
Flag indicating whether the simulation is currently playing.
|
protected |
Flag indicating whether a modal dialog is currently open.
|
protected |
Connection to the entity removed signal.
|
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
|
protected |
Station (role) name of the human player's original assignment.
|
protected |
Display layout of the human player's original assignment.
|
protected |
Whether the human player was originally in spectator mode.
|
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
|
protected |
Entity identifier of the embarkation host.
|
protected |
Whether the base player entity is invisible (notional embarkation slot)
|
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.
|
protected |
True until the first onExposed after onEnter (for auto-run in hosted sessions)