VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtPlayerStation Class Reference

Detailed Description

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:

  • Components that provide specific functionality
  • Connectors that handle communication with simulation protocols
  • Input mappings that translate user actions to simulation commands
  • Menu configurations for role-specific UI elements

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.

Warning
Not thread safe. Used only in the display engine's main render thread.

#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 DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () 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 DtPlayerStationAppapp () 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

DtPlayerStationAppmyApp
 
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
 

Member Typedef Documentation

◆ ComponentList

Type definition for a list of player components.

◆ ConnectorNameList

using makVre::DtPlayerStation::ConnectorNameList = std::vector<std::string>

Type definition for a list of connector names.

Constructor & Destructor Documentation

◆ DtPlayerStation()

makVre::DtPlayerStation::DtPlayerStation ( DtPlayerStationApp * app,
DtInitTable playerDefinition,
DtEntityIdentifier attachTo,
std::string stationName,
std::string displayLayout )

Constructor for a player station.

Parameters
appPointer to the player station application
playerDefinitionTable containing the role definition
attachToID of the entity this station will control
stationNameName of the chosen role
displayLayoutName of the display layout to use

Creates a new player station instance when a role is engaged. This happens when:

  • A user clicks Engage from the Choose Role menu
  • The station is configured to auto-engage at startup
  • A secondary role is created when an entity embarks in a host slot

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

Warning
DtPlayerStation instances should only be created using DtPlayerStationApp::createPlayerStation and destroyed using DtPlayerStationApp::destroyPlayerStation.
See also
DtPlayerStationApp::createPlayerStation

References app(), displayLayout(), and stationName().

◆ ~DtPlayerStation()

virtual makVre::DtPlayerStation::~DtPlayerStation ( )
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.

Member Function Documentation

◆ init()

virtual bool makVre::DtPlayerStation::init ( )
virtual

Initializes the player station.

Returns
True if all components initialized successfully, false otherwise

Performs all required setup to create a functional role:

  • Instantiates all components defined in the role definition
  • Requests connectors to be started
  • Registers message handlers
  • Calls init() and postInit() on all components

This method is called when initially engaging this role or when returning to this role from an embarked role.

◆ tick()

virtual void makVre::DtPlayerStation::tick ( double dt)
virtual

Updates the player station.

Parameters
dtSeconds elapsed since the previous tick

Called once per display engine frame to update the player station. Updates all components and processes any pending operations.

◆ shutdown()

virtual void makVre::DtPlayerStation::shutdown ( )
virtual

Shuts down the player station.

Performs teardown of all setup done during initialization:

  • Destroys all components
  • Requests connectors to be stopped
  • Unregisters message handlers

Called when disengaging from this role, or when suspending this role temporarily when embarking into a different role slot.

◆ debugPlayer()

virtual void makVre::DtPlayerStation::debugPlayer ( )
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.

◆ playerAttributeStore() [1/2]

virtual DtAttributeHandle & makVre::DtPlayerStation::playerAttributeStore ( )
virtual

Gets the player attribute store.

Returns
Reference to the attribute store

The attribute store contains player/role data shared between components.

◆ playerAttributeStore() [2/2]

virtual const DtAttributeHandle & makVre::DtPlayerStation::playerAttributeStore ( ) const
virtual

Gets the player attribute store (const version)

Returns
Const reference to the attribute store

References findComponent(), and findComponents().

◆ findComponent()

template<typename COMP_TYPE>
COMP_TYPE * makVre::DtPlayerStation::findComponent ( const std::string & name = "")

Finds a component by type and optional name.

Template Parameters
COMP_TYPEThe component type to find
Parameters
nameOptional name to match (empty to match by type only)
Returns
Pointer to the found component, or NULL if not found

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

◆ findComponents()

template<typename COMP_TYPE>
std::vector< COMP_TYPE * > makVre::DtPlayerStation::findComponents ( )

Finds all components of a specific type.

Template Parameters
COMP_TYPEThe component type to find
Returns
Vector of pointers to matching components

Returns a list of all components that match the specified template type.

References myComponents.

Referenced by playerAttributeStore().

◆ connectors()

virtual ConnectorNameList makVre::DtPlayerStation::connectors ( DtConnector::DtConnectorType connectionType)
virtual

Gets the list of connectors by type.

Parameters
connectionTypeThe type of connectors to retrieve
Returns
List of connector names for the specified type

Returns a list of connectors belonging to this role with the ConnectorType protocol suffix appended to each name.

◆ app()

virtual DtPlayerStationApp * makVre::DtPlayerStation::app ( ) const
virtual

Gets the player station application.

Returns
Pointer to the 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().

◆ de()

virtual makVrv::DtDe * makVre::DtPlayerStation::de ( ) const
virtual

Gets the display engine.

Returns
Pointer to 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.

◆ elementId()

virtual makVrv::DtElementID makVre::DtPlayerStation::elementId ( ) const
virtual

Gets the element ID for the controlled entity.

Returns
Element ID of the controlled entity

Returns the DtElementID associated with the entity that this player station controls in the display engine.

◆ entityId()

virtual const DtEntityIdentifier & makVre::DtPlayerStation::entityId ( ) const
virtual

Gets the entity ID for the controlled entity.

Returns
Reference to the entity identifier

Returns the DtEntityIdentifier of the entity that this player station controls.

◆ entityType()

virtual const DtEntityType & makVre::DtPlayerStation::entityType ( ) const
virtual

Gets the entity type for the controlled entity.

Returns
Reference to the entity type

Returns the DtEntityType of the entity that this player station controls.

◆ stationName()

virtual std::string makVre::DtPlayerStation::stationName ( ) const
virtual

Gets the name of the role.

Returns
String containing the station name

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

◆ displayLayout()

virtual std::string makVre::DtPlayerStation::displayLayout ( ) const
virtual

Gets the display layout name.

Returns
String containing 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().

◆ roles()

virtual std::vector< std::string > makVre::DtPlayerStation::roles ( ) const
virtual

Gets the list of joystick function groups.

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

◆ isActive()

virtual bool makVre::DtPlayerStation::isActive ( ) const
virtual
Returns
true unless the Role has been suspended in the case of an emplicit engagement of an embarked Role. If the player embarks in a role slot, the active primary PlayerStation is supsneded and a new secondary PlayerStation instance is created for the embarked Role.

◆ isShuttingDown()

virtual bool makVre::DtPlayerStation::isShuttingDown ( ) const
virtual
Returns
True after shutdown has been called and remains True until the PlayerStation instance is either destroyed or re-initialized by calling init again.

◆ definition()

virtual DtInitTable makVre::DtPlayerStation::definition ( ) const
virtual
Returns
the lua config table defining the Connector, Component, and Menu configuration for this Role. This is the final configuration for this Role, after filtering and merging the associated Display Layout configuration. This table is built when the user engages a role and before the DtPlayerStation instance is created. It should not change thereafter.

◆ handleSimulationStateMessage()

virtual DtVreMessageResult makVre::DtPlayerStation::handleSimulationStateMessage ( makVre::DtVreMessage * msg)
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".

◆ initializeMenus()

virtual bool makVre::DtPlayerStation::initializeMenus ( )
protectedvirtual

Called from init. Calls initializeMenus on the DtActionMenuUpdater Component, if present, passing in the menuConfig table from the role definition.

◆ initializeComponents()

virtual bool makVre::DtPlayerStation::initializeComponents ( )
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.

◆ postInitializeComponents()

virtual bool makVre::DtPlayerStation::postInitializeComponents ( )
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.

Member Data Documentation

◆ myApp

DtPlayerStationApp* makVre::DtPlayerStation::myApp
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.

◆ myPlayerDefinition

DtInitTable makVre::DtPlayerStation::myPlayerDefinition
protected

◆ myElementId

makVrv::DtElementID makVre::DtPlayerStation::myElementId
protected

◆ myEntityId

DtEntityIdentifier makVre::DtPlayerStation::myEntityId
protected

◆ myEntityType

DtEntityType makVre::DtPlayerStation::myEntityType
protected

◆ myForceType

DtForceType makVre::DtPlayerStation::myForceType
protected

◆ myRoles

std::vector<std::string> makVre::DtPlayerStation::myRoles
protected

◆ myStationName

std::string makVre::DtPlayerStation::myStationName
protected

◆ myDisplayLayout

std::string makVre::DtPlayerStation::myDisplayLayout
protected

◆ myAttributeStore

DtAttributeHandle makVre::DtPlayerStation::myAttributeStore
protected

◆ myComponents

ComponentList makVre::DtPlayerStation::myComponents
protected

Referenced by findComponent(), and findComponents().

◆ myConnectorNames

ConnectorNameList makVre::DtPlayerStation::myConnectorNames
protected

◆ myActive

bool makVre::DtPlayerStation::myActive
protected

◆ myShuttingDown

bool makVre::DtPlayerStation::myShuttingDown
protected

◆ myDe

makVrv::DtDe* makVre::DtPlayerStation::myDe
protected

◆ myDebugAttributeTraceChecks

std::map<unsigned long long, bool[4]> makVre::DtPlayerStation::myDebugAttributeTraceChecks
protected

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