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

Detailed Description

DtLoadingPlayerState replaces the monolithic startup that previously happened inside DtEngagedState::onEnter(). It shows a loading overlay, walks through initialization phases, polls component readiness via finalizeInitTick(), broadcasts PlayerStationCreationStatusMessage at each phase transition, and then transitions to ENGAGED_STATE. On failure or timeout it transitions back to CHOOSE_ROLE_STATE with an error notification.

Take-control is no longer sent by this state. Instead, DtEntityControlLogic listens for the PlayerStationCreationStatusMessage and sends VrfTakeControlOf when it receives the ComponentsReady phase.

#include <loadingPlayerState.h>

Inheritance diagram for makVre::DtLoadingPlayerState:
[legend]

Public Member Functions

 DtLoadingPlayerState (DtPlayerStationApp &app)
 
virtual ~DtLoadingPlayerState () override
 
 DtLoadingPlayerState (const DtLoadingPlayerState &)=delete
 
DtLoadingPlayerState & operator= (const DtLoadingPlayerState &)=delete
 
virtual void onEnter (const DtPlayerStationStateArgs *args) override
 
virtual void onExit () override
 
virtual void tick (double dt) override
 
- 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 onStacked ()
 
virtual void onExposed (const DtPlayerStationStateArgs *args)
 
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 void advanceToPhase (DtLoadPhase nextPhase)
 
virtual void fail (const std::string &reason)
 
virtual DtVreMessageResult handleOwnershipTransferResponse (DtVreMessage *message)
 
virtual DtVreMessageResult handleEscKey (DtVreMessage *message)
 
virtual void sendOwnershipAcquireRequest ()
 
virtual void setLoadingText (const QString &text)
 
void beginLoadCycle ()
 
void resetPhaseStateForNewCycle ()
 
virtual DtVreMessageResult handleEmbarkationDetected (DtVreMessage *message)
 
virtual void chainEmbarkationLoad ()
 
- 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

DtLoadPhase myCurrentPhase
 
double myTimeoutRemaining
 
unsigned long long myPendingOwnershipRequestId
 
bool myStationCreated
 
DtVreLoadingPlayerPage * myLoadingPlayerPage
 
bool myFadeOutStarted
 
int myPostReadyTicksElapsed
 
int myPhaseTickCount
 
bool myPhaseWorkDone
 
QString myLastLoadingText
 
DtEntityIdentifier myDetectedEmbarkHost
 
std::string myDetectedEmbarkRole
 
bool myEmbarkChainCompleted
 
bool myIsEmbarkationLoad
 
bool myIsEmbarkationTransition
 
bool myOwnershipHandlerRegistered
 
double myEmbarkProbeWaitSeconds
 
DtEntityIdentifier myDestroyEntityId
 
std::string myDestroyStationName
 
LoadPlayerRequestMessage::LoadPolicy myLoadPolicy
 
- Protected Attributes inherited from makVre::DtPlayerStationState
DtPlayerStationApp & myApp
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtVreMessageHandlerGroup myMessageHandlers
 

Static Protected Attributes

static constexpr double theDefaultTimeout = 30.0
 

Constructor & Destructor Documentation

◆ DtLoadingPlayerState() [1/2]

makVre::DtLoadingPlayerState::DtLoadingPlayerState ( DtPlayerStationApp & app)

Constructor.

Parameters
appReference to the player station application

References makVre::DtPlayerStationState::app().

Referenced by DtLoadingPlayerState(), and operator=().

◆ ~DtLoadingPlayerState()

virtual makVre::DtLoadingPlayerState::~DtLoadingPlayerState ( )
overridevirtual

Virtual destructor.

◆ DtLoadingPlayerState() [2/2]

makVre::DtLoadingPlayerState::DtLoadingPlayerState ( const DtLoadingPlayerState & )
delete

Deleted copy constructor.

References DtLoadingPlayerState().

Member Function Documentation

◆ operator=()

DtLoadingPlayerState & makVre::DtLoadingPlayerState::operator= ( const DtLoadingPlayerState & )
delete

Deleted assignment operator.

References DtLoadingPlayerState().

◆ onEnter()

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

Called when the state is entered.

Parameters
argsPointer to arguments from the previous state

Starts the loading sequence. If ownership transfer is needed the state enters the OwnershipAcquire phase; otherwise it advances directly to CreateStation. The overall timeout timer starts here.

Reimplemented from makVre::DtPlayerStationState.

◆ onExit()

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

Called when the state is exited.

Removes any registered message handlers and hides the loading overlay.

Reimplemented from makVre::DtPlayerStationState.

◆ tick()

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

Updates the state each frame.

Parameters
dtTime in seconds since the last update

Drives the phase state machine. Each phase performs its work and either advances to the next phase or stays in the current phase waiting for an asynchronous result (ownership response or component readiness).

Reimplemented from makVre::DtPlayerStationState.

◆ advanceToPhase()

virtual void makVre::DtLoadingPlayerState::advanceToPhase ( DtLoadPhase nextPhase)
protectedvirtual

Advances to the next phase.

Parameters
nextPhaseThe phase to advance to

◆ fail()

virtual void makVre::DtLoadingPlayerState::fail ( const std::string & reason)
protectedvirtual

Handles failure by transitioning back to CHOOSE_ROLE_STATE.

Parameters
reasonHuman-readable description of the failure

◆ handleOwnershipTransferResponse()

virtual DtVreMessageResult makVre::DtLoadingPlayerState::handleOwnershipTransferResponse ( DtVreMessage * message)
protectedvirtual

Handles the ownership transfer response message.

Parameters
messagePointer to the ownership transfer response message
Returns
Message handling result

◆ handleEscKey()

virtual DtVreMessageResult makVre::DtLoadingPlayerState::handleEscKey ( DtVreMessage * message)
protectedvirtual

Consumes escape key presses during loading.

Parameters
messagePointer to the escape key message
Returns
EATEN to prevent the key from reaching other handlers

Swallows escape key events while the load-player sequence is in progress, preventing the user from navigating away during initialization.

◆ sendOwnershipAcquireRequest()

virtual void makVre::DtLoadingPlayerState::sendOwnershipAcquireRequest ( )
protectedvirtual

Sends an ownership acquire request for the current entity.

◆ setLoadingText()

virtual void makVre::DtLoadingPlayerState::setLoadingText ( const QString & text)
protectedvirtual

Updates the loading overlay status text.

Parameters
textThe translatable status text to display

◆ beginLoadCycle()

void makVre::DtLoadingPlayerState::beginLoadCycle ( )
protected

Checks ownership requirements and advances to the correct initial phase.

Shared entry point for both initial loads (onEnter) and embarkation chains (chainEmbarkationLoad). Evaluates ownership transfer settings for the current entity/role, registers the response handler if needed, and advances to either OwnershipAcquire or CreateStation.

◆ resetPhaseStateForNewCycle()

void makVre::DtLoadingPlayerState::resetPhaseStateForNewCycle ( )
protected

Resets the per-load-cycle phase tracking fields.

Used by both onEnter() (initial entry) and chainEmbarkationLoad() (re-entry for a chained embarked-host load) to ensure the phase state machine starts from a clean slate. Does NOT touch the overall timeout budget (myTimeoutRemaining) — chained loads intentionally inherit the remaining time so a stuck embarked-host load can't mask a stuck base load.

◆ handleEmbarkationDetected()

virtual DtVreMessageResult makVre::DtLoadingPlayerState::handleEmbarkationDetected ( DtVreMessage * message)
protectedvirtual

Handles EmbarkationDetectedMessage from DtEngagedState.

DtEngagedState analyses SimulationStateMessage and forwards the pre-resolved embarkation result here. This handler records the host and role so the EmbarkProbe phase can chain a second load for the embarkation host before popping.

◆ chainEmbarkationLoad()

virtual void makVre::DtLoadingPlayerState::chainEmbarkationLoad ( )
protectedvirtual

Restarts the loading pipeline for an embarked-host role.

Called from the EmbarkProbe phase when DtEngagedState detected that the base entity is already embarked. Resets the phase machine back to CreateStation (or OwnershipAcquire) so the embarked-host player station is created on top of the base human.

Member Data Documentation

◆ myCurrentPhase

DtLoadPhase makVre::DtLoadingPlayerState::myCurrentPhase
protected

Current phase of the loading sequence.

◆ myTimeoutRemaining

double makVre::DtLoadingPlayerState::myTimeoutRemaining
protected

Remaining time in seconds before the overall timeout fires.

◆ theDefaultTimeout

double makVre::DtLoadingPlayerState::theDefaultTimeout = 30.0
staticconstexprprotected

Default timeout duration in seconds.

◆ myPendingOwnershipRequestId

unsigned long long makVre::DtLoadingPlayerState::myPendingOwnershipRequestId
protected

Request ID for the pending ownership acquire request.

◆ myStationCreated

bool makVre::DtLoadingPlayerState::myStationCreated
protected

Whether the CreateStation phase has been executed this entry.

◆ myLoadingPlayerPage

DtVreLoadingPlayerPage* makVre::DtLoadingPlayerState::myLoadingPlayerPage
protected

Pointer to the loading overlay page (not owned, stored in attribute store)

◆ myFadeOutStarted

bool makVre::DtLoadingPlayerState::myFadeOutStarted
protected

Whether the fade-out animation has been started in the Complete phase.

◆ myPostReadyTicksElapsed

int makVre::DtLoadingPlayerState::myPostReadyTicksElapsed
protected

Accumulated tick count in the PostReadyDelay phase.

◆ myPhaseTickCount

int makVre::DtLoadingPlayerState::myPhaseTickCount
protected

Number of ticks spent in the current phase.

◆ myPhaseWorkDone

bool makVre::DtLoadingPlayerState::myPhaseWorkDone
protected

Whether the current phase has completed its one-time work.

◆ myLastLoadingText

QString makVre::DtLoadingPlayerState::myLastLoadingText
protected

Last status text set on the loading page, used to avoid redundant updates.

◆ myDetectedEmbarkHost

DtEntityIdentifier makVre::DtLoadingPlayerState::myDetectedEmbarkHost
protected

DtEngagedState analyses SimulationStateMessage and forwards pre-resolved results via EmbarkationDetectedMessage. These fields record that result so the EmbarkProbe phase can chain a second load for the embarked-host role.

Host entity detected via EmbarkationDetectedMessage during loading

◆ myDetectedEmbarkRole

std::string makVre::DtLoadingPlayerState::myDetectedEmbarkRole
protected

Resolved embarked-host role name detected during loading.

◆ myEmbarkChainCompleted

bool makVre::DtLoadingPlayerState::myEmbarkChainCompleted
protected

True after chainEmbarkationLoad() has run — prevents infinite loop.

◆ myIsEmbarkationLoad

bool makVre::DtLoadingPlayerState::myIsEmbarkationLoad
protected

Whether this load was triggered by an embarkation (set via LoadPlayerRequestMessage)

◆ myIsEmbarkationTransition

bool makVre::DtLoadingPlayerState::myIsEmbarkationTransition
protected

Whether this load follows an authoritative embark or disembark update.

Such loads already have a known target role. The EmbarkProbe phase retains its settle window but does not request a possibly stale simulation state.

◆ myOwnershipHandlerRegistered

bool makVre::DtLoadingPlayerState::myOwnershipHandlerRegistered
protected

Whether the ownership transfer handler is currently registered.

◆ myEmbarkProbeWaitSeconds

double makVre::DtLoadingPlayerState::myEmbarkProbeWaitSeconds
protected

Accumulated wall-clock seconds spent in the EmbarkProbe phase.

◆ myDestroyEntityId

DtEntityIdentifier makVre::DtLoadingPlayerState::myDestroyEntityId
protected

When set, the CreateStation phase destroys this specific player station before creating the new one. This allows surgical cleanup (e.g., destroy the previous embarked host during role switch) without nuking suspended stations like the base human player.

Entity of the player station to destroy before creating the new one

◆ myDestroyStationName

std::string makVre::DtLoadingPlayerState::myDestroyStationName
protected

Station name of the player station to destroy before creating the new one.

◆ myLoadPolicy

LoadPlayerRequestMessage::LoadPolicy makVre::DtLoadingPlayerState::myLoadPolicy
protected

Load policy read from the LoadPlayerRequestMessage on entry.

When LoadPolicy_ReplaceExisting, the preparation phase calls app().clearPlayers() before ownership acquisition to remove stale role assignments before their simulations are restarted. The policy is then reset to LoadPolicy_PreserveExisting so any chained embarkation loads use targeted destruction instead.


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