|
VR-Engage
2.3
|
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>
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 |
| makVre::DtLoadingPlayerState::DtLoadingPlayerState | ( | DtPlayerStationApp & | app | ) |
Constructor.
| app | Reference to the player station application |
References makVre::DtPlayerStationState::app().
Referenced by DtLoadingPlayerState(), and operator=().
|
overridevirtual |
Virtual destructor.
|
delete |
Deleted copy constructor.
References DtLoadingPlayerState().
|
delete |
Deleted assignment operator.
References DtLoadingPlayerState().
|
overridevirtual |
Called when the state is entered.
| args | Pointer 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.
|
overridevirtual |
Called when the state is exited.
Removes any registered message handlers and hides the loading overlay.
Reimplemented from makVre::DtPlayerStationState.
|
overridevirtual |
Updates the state each frame.
| dt | Time 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.
|
protectedvirtual |
Advances to the next phase.
| nextPhase | The phase to advance to |
|
protectedvirtual |
Handles failure by transitioning back to CHOOSE_ROLE_STATE.
| reason | Human-readable description of the failure |
|
protectedvirtual |
Handles the ownership transfer response message.
| message | Pointer to the ownership transfer response message |
|
protectedvirtual |
Consumes escape key presses during loading.
| message | Pointer to the escape key message |
Swallows escape key events while the load-player sequence is in progress, preventing the user from navigating away during initialization.
|
protectedvirtual |
Sends an ownership acquire request for the current entity.
|
protectedvirtual |
Updates the loading overlay status text.
| text | The translatable status text to display |
|
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.
|
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.
|
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.
|
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.
|
protected |
Current phase of the loading sequence.
|
protected |
Remaining time in seconds before the overall timeout fires.
|
staticconstexprprotected |
Default timeout duration in seconds.
|
protected |
Request ID for the pending ownership acquire request.
|
protected |
Whether the CreateStation phase has been executed this entry.
|
protected |
Pointer to the loading overlay page (not owned, stored in attribute store)
|
protected |
Whether the fade-out animation has been started in the Complete phase.
|
protected |
Accumulated tick count in the PostReadyDelay phase.
|
protected |
Number of ticks spent in the current phase.
|
protected |
Whether the current phase has completed its one-time work.
|
protected |
Last status text set on the loading page, used to avoid redundant updates.
|
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
|
protected |
Resolved embarked-host role name detected during loading.
|
protected |
True after chainEmbarkationLoad() has run — prevents infinite loop.
|
protected |
Whether this load was triggered by an embarkation (set via LoadPlayerRequestMessage)
|
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.
|
protected |
Whether the ownership transfer handler is currently registered.
|
protected |
Accumulated wall-clock seconds spent in the EmbarkProbe phase.
|
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
|
protected |
Station name of the player station to destroy before creating the new one.
|
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.