|
VR-Engage
2.3
|
DtPlayerStation manages all aspects of a user's engagement with a simulation entity. It is responsible for handling user input, presenting the appropriate views, and controlling the entity according to the selected role.
Each instance is configured with a role definition that specifies:
The class maintains an attribute store for data sharing between components and manages the lifecycle of all component instances.
This class may be referred to as a Role, Station, or Player in different contexts.
#include <playerStation.h>
Public Types | |
| using | ComponentList = std::vector<DtPlayerComponent*> |
| using | ConnectorNameList = std::vector<std::string> |
Public Member Functions | |
| DtPlayerStation (DtPlayerStationApp *app, DtInitTable playerDefinition, DtEntityIdentifier attachTo, std::string stationName, std::string displayLayout) | |
| virtual | ~DtPlayerStation () |
| virtual bool | preInit () |
| virtual bool | initializeComponents () |
| virtual bool | postInitializeComponents () |
| virtual bool | initializeMenus () |
| virtual bool | finishInit () |
| virtual void | tick (double dt) |
| virtual void | shutdown () |
| virtual void | takeVreControl (const std::string &stationNameOverride="") |
| virtual void | releaseVreControl (const std::string &stationNameOverride="") |
| virtual void | debugPlayer () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () const |
| virtual const DtAttributeHandle & | ownshipState () const |
| template<typename COMP_TYPE> | |
| COMP_TYPE * | findComponent (const std::string &name="") |
| template<typename COMP_TYPE> | |
| std::vector< COMP_TYPE * > | findComponents () |
| virtual ConnectorNameList | connectors (DtConnector::DtConnectorType connectionType) |
| virtual DtPlayerStationApp * | app () const |
| virtual makVrv::DtDe * | de () const |
| virtual makVrv::DtElementID | elementId () const |
| virtual const DtEntityIdentifier & | entityId () const |
| virtual const DtEntityType & | entityType () const |
| virtual std::string | stationName () const |
| virtual std::string | displayLayout () const |
| virtual std::vector< std::string > | roleTypes () const |
| virtual bool | isActive () const |
| virtual bool | isShuttingDown () const |
| virtual DtInitTable | definition () const |
| virtual void | tickUnreadyComponents (double dt) |
| virtual bool | allComponentsReady () const |
| virtual bool | anyComponentFailed () const |
Protected Member Functions | |
| virtual DtVreMessageResult | handleSimulationStateMessage (makVre::DtVreMessage *msg) |
Protected Attributes | |
| DtPlayerStationApp * | myApp |
| DtInitTable | myPlayerDefinition |
| makVrv::DtElementID | myElementId |
| DtEntityIdentifier | myEntityId |
| DtEntityType | myEntityType |
| DtForceType | myForceType |
| std::vector< std::string > | myRoleTypes |
| std::string | myStationName |
| std::string | myDisplayLayout |
| DtAttributeHandle | myAttributeStore |
| const DtAttributeHandle | myOwnshipState |
| ComponentList | myComponents |
| ConnectorNameList | myConnectorNames |
| bool | myActive |
| bool | myShuttingDown |
| makVrv::DtDe * | myDe |
| bool | myAnyComponentFailed = false |
| bool | myAllComponentsReady = false |
| bool | myFullyInitialized = false |
| std::map< size_t, bool[4]> | myDebugAttributeTraceChecks |
| using makVre::DtPlayerStation::ComponentList = std::vector<DtPlayerComponent*> |
Type definition for a list of player components.
| using makVre::DtPlayerStation::ConnectorNameList = std::vector<std::string> |
Type definition for a list of connector names.
| makVre::DtPlayerStation::DtPlayerStation | ( | DtPlayerStationApp * | app, |
| DtInitTable | playerDefinition, | ||
| DtEntityIdentifier | attachTo, | ||
| std::string | stationName, | ||
| std::string | displayLayout ) |
Constructor for a player station.
| app | Pointer to the player station application |
| playerDefinition | Table containing the role definition |
| attachTo | ID of the entity this station will control |
| stationName | Name of the chosen role |
| displayLayout | Name of the display layout to use |
Creates a new player station instance when a role is engaged. This happens when:
The playerDefinition parameter contains the complete role configuration, which is assembled by merging the role definition from the .lua file, overrides from the .entity file, and display layout-specific settings. The stationName parameter identifies the chosen role from those available for the entity type. Available roles are defined in the .entity file, with each role specifying a .lua file containing its definition.
Role configuration files are located in the vre-roles-dir folder as defined in the .sms file (default: "data/simulationModelSets/VR-Engage/roles").
The displayLayout parameter specifies which layout to use with the chosen role. Roles can support multiple layouts that arrange views differently. Some roles only support a single layout, often called "default".
References app(), displayLayout(), and stationName().
|
virtual |
Destructor for a player station.
If this instance was created as a secondary role as a result of the primary ownship embarking in a role slot, then this secondary instance is destroyed when the primary ownship leaves that slot. If this instance is a primary role, then this instance is destroyed either when the VR-Engage app is closed, or when the user returns to the Choose Role panel.
|
virtual |
Pre-initialization: validation, attribute setup, and state flags.
Validates the entity, element, type, and role definition. Sets up initial attributes in the attribute store and resets internal state flags. Must be called before initializeComponents().
|
virtual |
Instantiates all components in the role definition and calls initialize() on each.
Called after preInit(). Creates component instances via the component factory and invokes initialize() with the per-component config table.
|
virtual |
Calls postInitialize() on all components.
Called after initializeComponents(). Gives each component a chance to perform setup that depends on peer components being initialized.
|
virtual |
Initializes menus via the DtActionMenuUpdater component.
Called after postInitializeComponents(). Passes the menuConfig table from the role definition to the action menu updater component.
|
virtual |
Post-pipeline finalization: connectors, PlayerCreatedMessage.
Sets up connectors, sends the PlayerCreatedMessage, and performs any remaining post-menu-init work. Must be called after initializeMenus().
|
virtual |
Updates the player station.
| dt | Seconds elapsed since the previous tick |
Called once per display engine frame to update the player station. Updates all components and processes any pending operations.
|
virtual |
Shuts down the player station.
Performs teardown of all setup done during initialization:
Called when disengaging from this role, or when suspending this role temporarily when embarking into a different role slot.
|
virtual |
Acquires VR-Engage role control for this station.
Queues a VrfSetVreControlledMessage that marks this station's role types as controlled. Does not queue a request for spectators, stations without role types, or meta roles. The optional override lets a sub-role report control using its owning station's name.
| stationNameOverride | Station name to include in the control request. Uses stationName() when empty. |
DtLoadingPlayerState calls this method when initialization reaches its Complete phase. Override this method when a specialized station needs a different role-acquisition operation.
|
virtual |
Releases VR-Engage role control for this station.
Called by DtPlayerStationApp immediately before permanently deleting a station. Shutdown preserves role occupancy so a suspended station remains engaged while another station is active. Does not queue a request for stations without role types or meta roles. The optional override lets a sub-role release control using its owning station's name.
| stationNameOverride | Station name to include in the release request. Uses stationName() when empty. |
Override this method when a specialized station needs a different role-release operation.
|
virtual |
Provides debugging information.
Invoked from the ImGui debug menu system to populate the Player tab of the Shift-F4 debug menu. Displays component status, attribute values, and other diagnostic information about the player station.
|
virtual |
Gets the player attribute store.
The attribute store contains player/role data shared between components.
|
virtual |
Gets the player attribute store (const version)
|
virtual |
Gets the ownship state attribute handle.
References findComponent(), and findComponents().
| COMP_TYPE * makVre::DtPlayerStation::findComponent | ( | const std::string & | name = "" | ) |
Finds a component by type and optional name.
| COMP_TYPE | The component type to find |
| name | Optional name to match (empty to match by type only) |
Returns the first component that matches the template type. If a name is provided, both the type and name must match to find the component.
References myComponents.
Referenced by ownshipState().
| std::vector< COMP_TYPE * > makVre::DtPlayerStation::findComponents | ( | ) |
Finds all components of a specific type.
| COMP_TYPE | The component type to find |
Returns a list of all components that match the specified template type.
References myComponents.
Referenced by ownshipState().
|
virtual |
Gets the list of connectors by type.
| connectionType | The type of connectors to retrieve |
Returns a list of connectors belonging to this role with the ConnectorType protocol suffix appended to each name.
|
virtual |
Gets the player station application.
Returns a pointer to the VR-Engage DtPlayerStationApp singleton. This pointer is provided in the constructor and saved for convenience. It should never be null and should remain valid for the life of this class.
Referenced by DtPlayerStation().
|
virtual |
Gets the display engine.
Returns a pointer to the VR-Vantage DtDe singleton. This pointer is obtained from app() during construction and saved for convenience. It should never be null and should remain valid for the life of this class.
|
virtual |
Gets the element ID for the controlled entity.
Returns the DtElementID associated with the entity that this player station controls in the display engine.
|
virtual |
Gets the entity ID for the controlled entity.
Returns the DtEntityIdentifier of the entity that this player station controls.
|
virtual |
Gets the entity type for the controlled entity.
Returns the DtEntityType of the entity that this player station controls.
|
virtual |
Gets the name of the role.
Returns the name of the role that this player station represents. This name is provided in the constructor and saved for reference. It should not change during the life of the player station.
Referenced by DtPlayerStation().
|
virtual |
Gets the display layout name.
Returns the name of the display layout chosen when the role was engaged. This is provided in the constructor and saved for reference. It should not change during the life of the player station.
Referenced by DtPlayerStation().
|
virtual |
Gets the list of joystick function groups.
Returns a list of joystick function groups that this station will control. Used internally with the VR-Forces Remote Control joystick API. This list is defined by the "roleTypes" table in the Role definition. Note that these strings do not correspond to "Roles" as the term is generally used elsewhere, meaning a PlayerStation definition or instance.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Calls finalizeInitTick(dt) on every component where componentReady() is false.
For each unready component, calls finalizeInitTick(dt). The component itself is responsible for setting myComponentReady = true when returning Ready. If finalizeInitTick() returns Failed, records the failure (queryable via anyComponentFailed()).
Called by LOADING_PLAYER_STATE during its ComponentReadiness phase.
| dt | Time in seconds since the last tick |
|
virtual |
Returns true when every component reports componentReady() == true.
Used by LOADING_PLAYER_STATE to determine when to advance from the ComponentReadiness phase to Complete.
|
virtual |
Returns true if any component's most recent finalizeInitTick() returned Failed.
Used by LOADING_PLAYER_STATE to detect unrecoverable initialization failures and abort back to CHOOSE_ROLE_STATE.
|
protectedvirtual |
Handler for the SimulationStateMessage for this station's ownship entity. This function is used only to cache initial state values of the ownship entity from the first message receied after engagement. This handler is then unregistered. The initial state values are saved in the AttributeStore as: <DtEntityType> "entityType" <DtVector> "InitialPosition" <DtTaitBryan> "InitialOrientation" <DtEntityIdentifier> "InitialParent".
|
protected |
Writes name, type, and value of each attribute in Attribute Store to a human-readable string. Returns vector of these strings, one per attribute. Used by debugPlayer to write the data in the Attribute Store to the F4 menu or log file.
Pointer to DtPlayerStationApp singleton that created and owns this DtPlayerStation instance. This should never be null.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by findComponent(), and findComponents().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Set to true if any component's finalizeInitTick() returns Failed.
Reset in preInit(). Checked by LOADING_PLAYER_STATE via anyComponentFailed().
|
mutableprotected |
Cached result of allComponentsReady().
Once all components report ready, this is set to true so subsequent calls avoid iterating the entire component list every tick. Reset in preInit(). Mutable because allComponentsReady() is const and this is a pure cache of the iteration result.
|
protected |
True once the full init pipeline (preInit through finishInit) has completed. Prevents tick() from running on a partially built station.
Reset in preInit(), set in finishInit().
|
protected |