VR-Engage  2.2
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 () override
 
virtual void onStacked () override
 
virtual bool isPlaying () const
 
virtual DtVreMessageResult handleEscKey (DtVreMessage *message)
 
virtual DtVreMessageResult handleBackButtonClicked (DtVreMessage *message)
 
- Public Member Functions inherited from makVre::DtPlayerStationState
 DtPlayerStationState (DtPlayerStationApp &app, std::string stateType)
 
virtual ~DtPlayerStationState ()
 
 DtPlayerStationState (const DtPlayerStationState &)=delete
 
DtPlayerStationStateoperator= (const DtPlayerStationState &)=delete
 
virtual void onEnter ()
 
virtual void onExposed (const DtPlayerStationStateArgs *args)
 
bool active () const
 
bool exposed () const
 
bool exiting () const
 
bool stacking () const
 
const std::string & stateType () const
 
DtPlayerStationAppapp () const
 

Protected Member Functions

virtual DtVreMessageResult handleSimulationStateMessage (makVre::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 ()
 
virtual void updatePlayersForEmbarkationChange ()
 
virtual bool startPlayerStation ()
 
virtual bool startPlayerStation (const DtEntityIdentifier &entityId, const std::string &station)
 
virtual void activateWindowFocus ()
 
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< DtPlayerStationPersistentNotificationmyPersistentNotification
 
bool myIsPlaying
 
bool myIsModalOpen
 
boost::signals2::connection myEntityRemovedConnection
 
std::string myBasePlayerEmbarkedRole
 
DtEntityIdentifier myBasePlayerHost
 
bool myBasePlayerIsInvisible
 
bool myOhMySomethingHasChanged
 
- Protected Attributes inherited from makVre::DtPlayerStationState
DtPlayerStationAppmyApp
 

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.

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 ( )
overridevirtual

Called when the state becomes the topmost state again.

Restores gameplay functionality when this state is exposed after another state (like a menu) has been popped from the stack.

Reimplemented from makVre::DtPlayerStationState.

Reimplemented in makVre::DtExtendedEngagedState.

◆ 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.

◆ 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 ( makVre::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 changes to embarkation status that might affect the player's entity.

◆ 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.

◆ updatePlayersForEmbarkationChange()

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

Updates player state after embarkation changes.

Called when embarkation status changes, such as when getting in or out of a vehicle, to update UI and control systems accordingly.

◆ startPlayerStation() [1/2]

virtual bool makVre::DtEngagedState::startPlayerStation ( )
protectedvirtual

Starts the player station with default settings.

Returns
True if startup was successful, false otherwise

Initializes the player station for the current entity and role using the default station configuration.

◆ startPlayerStation() [2/2]

virtual bool makVre::DtEngagedState::startPlayerStation ( const DtEntityIdentifier & entityId,
const std::string & station )
protectedvirtual

Starts the player station with specific entity and station.

Parameters
entityIdIdentifier of the entity to control
stationName of the station or role to use
Returns
True if startup was successful, false otherwise

Initializes the player station for a specific entity and role, typically used when switching entities or roles during gameplay.

◆ activateWindowFocus()

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

Ensures the application window has focus before engaging.

Checks if the application currently has active focus, and if not, attempts to activate and raise the main window. This is called before creating a player station to ensure that entity control logic has the correct focus state for activating mouse control.

Note
Uses Qt window activation methods to bring the window to front
See also
startPlayerStation()

Member Data Documentation

◆ myPersistentNotification

std::shared_ptr<DtPlayerStationPersistentNotification> 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.

◆ myBasePlayerEmbarkedRole

std::string makVre::DtEngagedState::myBasePlayerEmbarkedRole
protected

Role name for embarked player.

◆ myBasePlayerHost

DtEntityIdentifier makVre::DtEngagedState::myBasePlayerHost
protected

Entity identifier of the host entity for embarked player.

◆ myBasePlayerIsInvisible

bool makVre::DtEngagedState::myBasePlayerIsInvisible
protected

Flag indicating whether the player entity is invisible.

◆ myOhMySomethingHasChanged

bool makVre::DtEngagedState::myOhMySomethingHasChanged
protected

Flag indicating that the entity state has changed.


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