|
VR-Engage
2.2
|
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 | init () |
| virtual void | tick (double dt) |
| virtual void | shutdown () |
| virtual void | debugPlayer () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () 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 > | roles () const |
| virtual bool | isActive () const |
| virtual bool | isShuttingDown () const |
| virtual DtInitTable | definition () const |
Protected Member Functions | |
| virtual DtVreMessageResult | handleSimulationStateMessage (makVre::DtVreMessage *msg) |
| virtual bool | initializeMenus () |
| virtual bool | initializeComponents () |
| virtual bool | postInitializeComponents () |
Protected Attributes | |
| DtPlayerStationApp * | myApp |
| DtInitTable | myPlayerDefinition |
| makVrv::DtElementID | myElementId |
| DtEntityIdentifier | myEntityId |
| DtEntityType | myEntityType |
| DtForceType | myForceType |
| std::vector< std::string > | myRoles |
| std::string | myStationName |
| std::string | myDisplayLayout |
| DtAttributeHandle | myAttributeStore |
| ComponentList | myComponents |
| ConnectorNameList | myConnectorNames |
| bool | myActive |
| bool | myShuttingDown |
| makVrv::DtDe * | myDe |
| std::map< unsigned long long, 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 |
Initializes the player station.
Performs all required setup to create a functional role:
This method is called when initially engaging this role or when returning to this role from an embarked role.
|
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 |
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)
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 playerAttributeStore().
| 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 playerAttributeStore().
|
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 "roles" 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 |
|
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".
|
protectedvirtual |
Called from init. Calls initializeMenus on the DtActionMenuUpdater Component, if present, passing in the menuConfig table from the role definition.
|
protectedvirtual |
Called from init. Instantiates all components in the role definition and invokes their init function. Returns true if all components return true from component init.
|
protectedvirtual |
Called from init. Invokes postInit function on all components. Called only after and if initializeComponents has returned true. Returns true if all components return true from postInit.
|
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 |
Referenced by findComponent(), and findComponents().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |