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

Detailed Description

DtChooseRoleState represents the application state where users can select existing entities to control or create new entities. It manages the UI interactions, entity creation, and transitions to the engaged state.

#include <chooseRoleState.h>

Inheritance diagram for makVre::DtChooseRoleState:
[legend]

Classes

struct  AttachToEntity
 
struct  EntityDefinition
 
struct  StationDefinition
 

Public Member Functions

 DtChooseRoleState (DtPlayerStationApp &app)
 
virtual ~DtChooseRoleState () override
 
virtual void onEnter (const DtPlayerStationStateArgs *args) override
 
virtual void onExit () override
 
virtual void tick (double dt) override
 
virtual void onExposed () override
 
virtual void onStacked () override
 
virtual const DtEntityType & getNewEntityType ()
 
virtual const DtEntityIdentifier & getCreatedOwnshipEntity () const
 
virtual makVrv::DtElementID getCreatedOwnshipElement () const
 
virtual void playStation (const std::string &role, const DtEntityIdentifier &entityId=DtEntityIdentifier::nullId(), const std::string &displayLayout="")
 
virtual void play (bool asSpectator=false)
 
virtual DtVreMessageResult handleAssignRolePlayer (DtVreMessage *message)
 
virtual void setObserverViewsPanelVisible (bool visible)
 
virtual void setCreatingOwnship (bool newNotExisting)
 
virtual void setNewEntityName (const std::string &name)
 
virtual void setNewEntityType (const DtEntityType &type)
 
virtual void setNewEntityForce (const DtForceType &force)
 
virtual void setNewEntityLocation (const DtVector &location)
 
virtual void setNewEntityLocationAtAltitude (const DtVector &location, double altitude)
 
virtual void setNewEntityClamp (bool clamp)
 
virtual void setNewEntityHeading (const double headingInDegrees)
 
virtual void setNewEntityPitch (const double pitch)
 
virtual void setNewEntityEmbarkedOn (const DtEntityIdentifier &host, const DtVector &offset)
 
- Public Member Functions inherited from makVre::DtPlayerStationState
 DtPlayerStationState (DtPlayerStationApp &app, std::string stateType)
 
virtual ~DtPlayerStationState ()
 
 DtPlayerStationState (const DtPlayerStationState &)=delete
 
DtPlayerStationStateoperator= (const DtPlayerStationState &)=delete
 
virtual void onEnter ()
 
virtual void onExposed (const DtPlayerStationStateArgs *args)
 
bool active () const
 
bool exposed () const
 
bool exiting () const
 
bool stacking () const
 
const std::string & stateType () const
 
DtPlayerStationAppapp () const
 

Protected Types

enum  DirtyBits {
  DirtyName = 1 << 0 , DirtyType = 1 << 1 , DirtyForce = 1 << 2 , DirtyPosition = 1 << 3 ,
  DirtyHeading = 1 << 4 , DirtyPitch = 1 << 5 , DirtyRoll = 1 << 6
}
 

Protected Member Functions

virtual void setUIVisibility (bool visible)
 
virtual void resetEntityPanel ()
 
virtual std::string getDisplayLayout (const StationDefinition &station) const
 
virtual bool verifyEntityDefinition (EntityDefinition const &def, QString *error=NULL) const
 
virtual bool verifyStationDefinition (StationDefinition const &def, QString *error=NULL) const
 
virtual DtVreMessageResult handleNewOwnshipCreated (DtVreMessage *message)
 
virtual DtVreMessageResult handleEntityRealized (DtVreMessage *message)
 
virtual DtVreMessageResult handleApplicationMode (makVre::DtVreMessage *message)
 
virtual DtVreMessageResult handleEscKey (DtVreMessage *msg)
 
virtual DtVreMessageResult handleBackButtonClicked (DtVreMessage *msg)
 
virtual DtVreMessageResult handleChooseRoleButtonClicked (DtVreMessage *msg)
 
virtual DtVreMessageResult handleVrfRewind (DtVreMessage *msg)
 
virtual void createNewEntity ()
 
virtual bool updateNewEntity ()
 
virtual void destroyNewEntity ()
 
virtual bool haveNewRealizedOwnshipEntity () const
 
virtual void onNewOwnshipRealized ()
 
- 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

bool myWantNewEntity
 
bool myAwaitingNewRealizedEntity
 
bool myHaveNewEntity
 
EntityDefinition myNewEntityDef
 
StationDefinition myStationDef
 
DtEntityIdentifier myHostId
 
DtVector myHostOffset
 
int myDirtyBits
 
DtChooseRolePanelmyEntityPanel
 
std::shared_ptr< DtVreChooseRolePagemyChooseRolePage
 
std::shared_ptr< AttachToEntitymyAttachToEntity
 
- Protected Attributes inherited from makVre::DtPlayerStationState
DtPlayerStationAppmyApp
 

Member Enumeration Documentation

◆ DirtyBits

Flags indicating which entity properties have changed.

Used to track which properties of the entity definition have been modified and need to be updated in the simulation.

Enumerator
DirtyName 

Entity name has changed.

DirtyType 

Entity type has changed.

DirtyForce 

Entity force type has changed.

DirtyPosition 

Entity position has changed.

DirtyHeading 

Entity heading has changed.

DirtyPitch 

Entity pitch has changed.

DirtyRoll 

Entity roll has changed.

Constructor & Destructor Documentation

◆ DtChooseRoleState()

makVre::DtChooseRoleState::DtChooseRoleState ( DtPlayerStationApp & app)

Constructor.

Parameters
appReference to the player station application

Creates a new role selection state associated with the given application.

References makVre::DtPlayerStationState::app().

◆ ~DtChooseRoleState()

virtual makVre::DtChooseRoleState::~DtChooseRoleState ( )
overridevirtual

Virtual destructor.

Ensures proper cleanup of the role selection state resources.

Member Function Documentation

◆ onEnter()

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

Called when the state is entered.

Parameters
argsPointer to arguments from the previous state

Sets up the role selection UI and observer views, registers message handlers, and initializes the state's data structures. This is called when the player first enters the role selection state.

Reimplemented from makVre::DtPlayerStationState.

◆ onExit()

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

Called when the state is exited.

Cleans up resources, hides UI elements, and unregisters message handlers. This is called when the player leaves the role selection state.

Reimplemented from makVre::DtPlayerStationState.

◆ tick()

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

Updates the state each frame.

Parameters
dtTime in seconds since the last update

Handles per-frame processing, such as updating entity status, managing user interactions, and handling deferred operations.

Reimplemented from makVre::DtPlayerStationState.

◆ onExposed()

virtual void makVre::DtChooseRoleState::onExposed ( )
overridevirtual

Called when the state becomes the topmost state again.

Restores UI visibility and updates the panel when this state is exposed after another state has been popped from the stack.

Reimplemented from makVre::DtPlayerStationState.

◆ onStacked()

virtual void makVre::DtChooseRoleState::onStacked ( )
overridevirtual

Called when another state is pushed on top of this one.

Hides UI elements and pauses processing while this state is covered by another state on the stack.

Reimplemented from makVre::DtPlayerStationState.

◆ setCreatingOwnship()

virtual void makVre::DtChooseRoleState::setCreatingOwnship ( bool newNotExisting)
virtual

Entity creation methods.

Sets whether a new entity should be created

Parameters
newNotExistingTrue to create a new entity, false to use an existing one

Determines whether the player will create a new entity or control an existing one.

◆ setNewEntityName()

virtual void makVre::DtChooseRoleState::setNewEntityName ( const std::string & name)
virtual

Sets the name for a new entity.

Parameters
nameName to assign to the new entity

Sets the display name for the entity being created.

◆ setNewEntityType()

virtual void makVre::DtChooseRoleState::setNewEntityType ( const DtEntityType & type)
virtual

Sets the type for a new entity.

Parameters
typeType identifier for the new entity

Sets the type of entity to create (e.g., aircraft, vehicle, infantry).

◆ setNewEntityForce()

virtual void makVre::DtChooseRoleState::setNewEntityForce ( const DtForceType & force)
virtual

Sets the force type for a new entity.

Parameters
forceForce type for the new entity (friendly, hostile, etc.)

Sets the force affiliation for the entity being created.

◆ setNewEntityLocation()

virtual void makVre::DtChooseRoleState::setNewEntityLocation ( const DtVector & location)
virtual

Sets the location for a new entity.

Parameters
location3D position for the new entity (at ground level)

Sets the ground location where the entity will be created.

◆ setNewEntityLocationAtAltitude()

virtual void makVre::DtChooseRoleState::setNewEntityLocationAtAltitude ( const DtVector & location,
double altitude )
virtual

Sets the location and altitude for a new entity.

Parameters
location3D position for the new entity (ground reference)
altitudeHeight above ground in meters

Sets both the ground position and altitude for the entity being created.

◆ setNewEntityClamp()

virtual void makVre::DtChooseRoleState::setNewEntityClamp ( bool clamp)
virtual

Sets whether the entity should be clamped to terrain.

Parameters
clampTrue to clamp to terrain, false otherwise

Determines whether the entity should be constrained to follow terrain contours.

◆ setNewEntityHeading()

virtual void makVre::DtChooseRoleState::setNewEntityHeading ( const double headingInDegrees)
virtual

Sets the heading for a new entity.

Parameters
headingInDegreesHeading in degrees (0-360, clockwise from north)

Sets the initial heading for the entity being created. This assumes the location has already been set.

◆ setNewEntityPitch()

virtual void makVre::DtChooseRoleState::setNewEntityPitch ( const double pitch)
virtual

Sets the pitch for a new entity.

Parameters
pitchPitch angle in degrees

Sets the initial pitch angle for the entity being created.

◆ setNewEntityEmbarkedOn()

virtual void makVre::DtChooseRoleState::setNewEntityEmbarkedOn ( const DtEntityIdentifier & host,
const DtVector & offset )
virtual

Sets a parent entity for embarking.

Parameters
hostEntity identifier of the host/parent entity
offsetRelative offset from the host entity's position

Specifies that the new entity should be created as embarked on another entity.

◆ getNewEntityType()

virtual const DtEntityType & makVre::DtChooseRoleState::getNewEntityType ( )
inlinevirtual

Gets the type of the entity being created.

Returns
Reference to the entity type

Retrieves the entity type that has been set for creation.

References myNewEntityDef.

◆ getCreatedOwnshipEntity()

virtual const DtEntityIdentifier & makVre::DtChooseRoleState::getCreatedOwnshipEntity ( ) const
virtual

Gets the identifier of the created entity.

Returns
Reference to the entity identifier

Retrieves the unique identifier of the entity that was created. Only valid after entity creation is complete.

◆ getCreatedOwnshipElement()

virtual makVrv::DtElementID makVre::DtChooseRoleState::getCreatedOwnshipElement ( ) const
virtual

Gets the element ID of the created entity.

Returns
Element ID in the display engine

Retrieves the display engine element ID for the created entity. Only valid after entity creation is complete.

◆ playStation()

virtual void makVre::DtChooseRoleState::playStation ( const std::string & role,
const DtEntityIdentifier & entityId = DtEntityIdentifier::nullId(),
const std::string & displayLayout = "" )
virtual

Updates the player station with role information.

Parameters
roleName of the role to play
entityIdIdentifier of the entity to control (null for new entities)
displayLayoutName of the display layout to use

Sets up the player station with the selected role, entity, and display layout in preparation for transitioning to the engaged state.

◆ play()

virtual void makVre::DtChooseRoleState::play ( bool asSpectator = false)
virtual

Initiates engagement with the selected entity.

Parameters
asSpectatorTrue to engage as a spectator, false as a controller

Transitions from the role selection state to the engaged state, starting gameplay with the selected entity and role.

◆ handleAssignRolePlayer()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleAssignRolePlayer ( DtVreMessage * message)
virtual

Handles role assignment messages.

Parameters
messagePointer to the role assignment message
Returns
Message handling result

Processes messages related to assigning roles to players, which may come from network or local sources.

◆ setObserverViewsPanelVisible()

virtual void makVre::DtChooseRoleState::setObserverViewsPanelVisible ( bool visible)
virtual

Controls visibility of the observer views panel.

Parameters
visibleTrue to show the panel, false to hide it

Shows or hides the observer views panel that provides alternative viewpoints of the simulated environment.

◆ setUIVisibility()

virtual void makVre::DtChooseRoleState::setUIVisibility ( bool visible)
protectedvirtual

Controls visibility of the UI components.

Parameters
visibleTrue to show UI elements, false to hide them

Manages the visibility of the choose role page and entity panel components. Used when entering/exiting the state or when stacked/exposed.

◆ resetEntityPanel()

virtual void makVre::DtChooseRoleState::resetEntityPanel ( )
protectedvirtual

Resets the entity panel to its default state.

Clears all selections and inputs in the entity panel, preparing it for a fresh interaction.

◆ handleNewOwnshipCreated()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleNewOwnshipCreated ( DtVreMessage * message)
protectedvirtual

Message handlers.

Handles messages about newly created ownship entities

Parameters
messagePointer to the message about the new entity
Returns
Message handling result

◆ handleEntityRealized()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleEntityRealized ( DtVreMessage * message)
protectedvirtual

Handles messages about entities being realized in the simulation.

Parameters
messagePointer to the entity realization message
Returns
Message handling result

◆ handleApplicationMode()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleApplicationMode ( makVre::DtVreMessage * message)
protectedvirtual

Handles messages about application mode changes.

Parameters
messagePointer to the application mode message
Returns
Message handling result

◆ handleEscKey()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleEscKey ( DtVreMessage * msg)
protectedvirtual

Handles escape key press messages.

Parameters
msgPointer to the key press message
Returns
Message handling result

◆ handleBackButtonClicked()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleBackButtonClicked ( DtVreMessage * msg)
protectedvirtual

Handles back button click messages.

Parameters
msgPointer to the button click message
Returns
Message handling result

◆ handleChooseRoleButtonClicked()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleChooseRoleButtonClicked ( DtVreMessage * msg)
protectedvirtual

Handles choose role button click messages.

Parameters
msgPointer to the button click message
Returns
Message handling result

◆ handleVrfRewind()

virtual DtVreMessageResult makVre::DtChooseRoleState::handleVrfRewind ( DtVreMessage * msg)
protectedvirtual

Handles VRF rewind messages.

Parameters
msgPointer to the rewind message
Returns
Message handling result

◆ createNewEntity()

virtual void makVre::DtChooseRoleState::createNewEntity ( )
protectedvirtual

Entity management methods.

Creates a new entity in the simulation

Uses the information in myNewEntityDef to create a new entity in the simulation and start tracking its realization.

◆ updateNewEntity()

virtual bool makVre::DtChooseRoleState::updateNewEntity ( )
protectedvirtual

Updates an existing new entity.

Returns
True if the update was successful, false otherwise

Applies changes from myNewEntityDef to the entity that is currently being created or modified.

◆ destroyNewEntity()

virtual void makVre::DtChooseRoleState::destroyNewEntity ( )
protectedvirtual

Destroys a new entity that was being created.

Removes the entity that was being created from the simulation. Typically called when canceling entity creation or during cleanup.

◆ haveNewRealizedOwnshipEntity()

virtual bool makVre::DtChooseRoleState::haveNewRealizedOwnshipEntity ( ) const
protectedvirtual

Checks if a new ownship entity has been realized.

Returns
True if the entity exists and is ready, false otherwise

Determines whether a newly created entity has been fully realized in the simulation and is ready for interaction.

◆ onNewOwnshipRealized()

virtual void makVre::DtChooseRoleState::onNewOwnshipRealized ( )
protectedvirtual

Called when a new ownship entity is realized.

Handles the completion of entity creation, transitioning to the next step in the engagement process.

◆ getDisplayLayout()

virtual std::string makVre::DtChooseRoleState::getDisplayLayout ( const StationDefinition & station) const
protectedvirtual

Gets the display layout for a station.

Parameters
stationStation definition to get layout for
Returns
Name of the display layout to use

Determines the appropriate display layout for the given station, using defaults if necessary.

◆ verifyEntityDefinition()

virtual bool makVre::DtChooseRoleState::verifyEntityDefinition ( EntityDefinition const & def,
QString * error = NULL ) const
protectedvirtual

Validates an entity definition.

Parameters
defEntity definition to validate
errorOptional pointer to receive error message
Returns
True if the definition is valid, false otherwise

Checks whether an entity definition contains all the required information to create a valid entity.

◆ verifyStationDefinition()

virtual bool makVre::DtChooseRoleState::verifyStationDefinition ( StationDefinition const & def,
QString * error = NULL ) const
protectedvirtual

Validates a station definition.

Parameters
defStation definition to validate
errorOptional pointer to receive error message
Returns
True if the definition is valid, false otherwise

Checks whether a station definition contains all the required information to set up a player station.

Member Data Documentation

◆ myWantNewEntity

bool makVre::DtChooseRoleState::myWantNewEntity
protected

Flag indicating whether to create a new entity.

◆ myAwaitingNewRealizedEntity

bool makVre::DtChooseRoleState::myAwaitingNewRealizedEntity
protected

Flag indicating that entity creation is in progress.

◆ myHaveNewEntity

bool makVre::DtChooseRoleState::myHaveNewEntity
protected

Flag indicating that a new entity has been created.

◆ myNewEntityDef

EntityDefinition makVre::DtChooseRoleState::myNewEntityDef
protected

Definition of the entity to create.

Referenced by getNewEntityType().

◆ myStationDef

StationDefinition makVre::DtChooseRoleState::myStationDef
protected

Definition of the station to set up.

◆ myHostId

DtEntityIdentifier makVre::DtChooseRoleState::myHostId
protected

Identifier of the host entity for embarking.

◆ myHostOffset

DtVector makVre::DtChooseRoleState::myHostOffset
protected

Offset from the host entity for embarking.

◆ myDirtyBits

int makVre::DtChooseRoleState::myDirtyBits
protected

Bitmap of dirty flags for the entity definition.

◆ myEntityPanel

DtChooseRolePanel* makVre::DtChooseRoleState::myEntityPanel
protected

Pointer to the entity selection panel UI.

◆ myChooseRolePage

std::shared_ptr<DtVreChooseRolePage> makVre::DtChooseRoleState::myChooseRolePage
protected

Shared pointer to the role selection page.

◆ myAttachToEntity

std::shared_ptr<AttachToEntity> makVre::DtChooseRoleState::myAttachToEntity
protected

Shared pointer to the entity attachment configuration.


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