VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtEntityControlLogic Class Reference

Detailed Description

DtEntityControlLogic is responsible for translating user input into entity control commands and managing the state of player-controlled entities. It handles input mapping for different control modes (mouse, joystick, etc.), entity state synchronization, and specific control operations like reset.

This component serves as the primary interface between user input and entity behavior in the simulation.

#include <entityControlLogic.h>

Inheritance diagram for makVre::DtEntityControlLogic:
[legend]

Public Member Functions

 DtEntityControlLogic ()
 
virtual ~DtEntityControlLogic () override
 
virtual bool initialize (DtPlayerStation *player, DtInitTable &config) override
 
virtual bool postInitialize () override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual void setMouseControlEnabled (bool enabled)
 
virtual bool isMouseControlEnabled ()
 
virtual bool isMouseControlSupportAllowed () const
 
virtual void setMouseControlSupportAllowed (bool enable)
 
virtual const std::vector< std::string > & joystickGroups () const
 
virtual void sendJoystickCommand (const DtEntityIdentifier &id, const std::string &functionGroup, const std::string &function, double val, bool repeat=false)
 
virtual makVre::DtVreMessageResult handleSimState (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleReset (makVre::DtVreMessage *message)
 
virtual makVre::DtVreMessageResult handleCreationStatus (makVre::DtVreMessage *message)
 
virtual void reset (float val)
 
virtual void resetInPlace (float val)
 
virtual void toggleMouseControl (float val)
 
virtual void enableMouseControl (float val)
 
virtual makVre::DtVreMessageResult handleFocusMessage (makVre::DtVreMessage *message)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
bool componentReady () const
 
void setComponentReady (bool ready)
 
virtual DtInitTickStatus finalizeInitTick (double dt)
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStation & player ()
 
virtual DtAttributeHandle & playerAttributeStore ()
 
virtual const DtAttributeHandle & playerAttributeStore () const
 
virtual const DtAttributeHandle & ownshipState () const
 
virtual void setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId())
 

Protected Member Functions

bool requiresControl () const
 
bool isAirborne () const
 
void showNotification (const QString &text, double duration)
 
virtual void takeControlOfPlayerEntity ()
 
virtual void releaseControlOfPlayerEntity ()
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

std::vector< std::string > myJoystickFunctionGroups
 
DtInputLogic myCommonInputLogic
 
std::string myInputConfigFile
 
bool myMouseControlEnabled
 
bool myMouseControlSupportAllowed
 
DtAttributeHandle myOwnshipAttr
 
DtAttributeHandleType< bool > myEmbarkedAttr
 
DtAttributeHandleType< DtEntityIdentifier > myEmbarkedHostAttr
 
DtAttributeHandleType< DtEntityType > myEmbarkedHostTypeAttr
 
DtAttributeHandleType< std::string > myEmbarkedHostMarkingAttr
 
DtAttributeHandleType< bool > myEmbarkedOnAircraftAttr
 
DtAttributeHandleType< std::string > myEmbarkedInSlotAttr
 
DtAttributeHandleType< unsigned int > myAppearanceAttr
 
DtAttributeHandleType< DtVector > myPositionAttr
 
DtAttributeHandleType< DtTaitBryan > myOrientationAttr
 
DtAttributeHandleType< double > mySpeedAttr
 
DtAttributeHandleType< DtVector32 > myVelocityAttr
 
DtAttributeHandleType< DtVector32 > myAccelerationAttr
 
DtAttributeHandleType< DtVector32 > myRotVelAttr
 
DtAttributeHandleType< DtEntityType > myEntityTypeAttr
 
DtAttributeHandleType< DtVector32 > myRelativeVelocityAttr
 
DtAttributeHandleType< DtDamageState > myDamageStateAttr
 
DtAttributeHandleType< int > mySimStateUpdateIndexAttr
 
DtAttributeHandleType< bool > myHideOccupantsAttr
 
- Protected Attributes inherited from makVre::DtPlayerComponent
bool myComponentReady = true
 
std::string myName
 
DtInitTable myConfig
 
DtPlayerStation * myPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolver * myResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtVreMessageHandlerGroup myMessageHandlers
 

Constructor & Destructor Documentation

◆ DtEntityControlLogic()

makVre::DtEntityControlLogic::DtEntityControlLogic ( )

Constructor.

Parameters
typeType identifier for the component

Creates a new entity control logic component with the specified type. The default type is "DtEntityControlLogic".

◆ ~DtEntityControlLogic()

virtual makVre::DtEntityControlLogic::~DtEntityControlLogic ( )
overridevirtual

Virtual destructor.

Ensures proper cleanup of entity control resources.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtEntityControlLogic::initialize ( DtPlayerStation * player,
DtInitTable & config )
overridevirtual

Initializes the entity control logic.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table with initialization parameters
Returns
True if initialization was successful, false otherwise

Initializes the entity control component with the specified player station and configuration. Registers message handlers and sets up input mappings.

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in DtVehicleBlinkerControlLogic, makVre::DtCommanderControlLogic, makVre::DtCommanderHatchControlLogic, makVre::DtDriverControlLogic, makVre::DtDroneControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtLauncherControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, makVre::DtTowingControlLogic, and makVre::DtZoomControl.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

virtual bool makVre::DtEntityControlLogic::postInitialize ( )
overridevirtual

Performs post-initialization setup.

Returns
True if post-initialization was successful, false otherwise

Completes initialization tasks that require other components to be already initialized. This typically includes setting up connections to other components and starting entity control.

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in makVre::DtCommanderControlLogic, makVre::DtCommanderHatchControlLogic, makVre::DtDroneControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, and makVre::DtPilotSimLogic.

◆ tick()

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

Updates the entity control logic each frame.

Parameters
dtTime in seconds since the last update

Handles per-frame updates for entity control, including processing input and updating entity states. This is called once per frame.

Implements makVre::DtPlayerComponent.

Reimplemented in makVre::DtCommanderControlLogic, makVre::DtCommanderHatchControlLogic, makVre::DtDriverControlLogic, makVre::DtDroneControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtLauncherControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, and makVre::DtTowingControlLogic.

◆ shutdown()

virtual void makVre::DtEntityControlLogic::shutdown ( )
overridevirtual

Shuts down the entity control logic.

Cleans up resources, disconnects from input handlers, and releases joystick function-group control. Role occupancy remains until the player station is permanently destroyed.

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in makVre::DtCommanderControlLogic, makVre::DtCommanderHatchControlLogic, makVre::DtDriverControlLogic, makVre::DtDroneControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtLauncherControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, makVre::DtTowingControlLogic, and makVre::DtZoomControl.

◆ type()

virtual const char * makVre::DtEntityControlLogic::type ( ) const
overridevirtual

Returns the component type identifier.

Returns
String identifier for this component type

Returns the type identifier string for this component, which is used by the VR-Engage framework for component identification and management. The returned value matches DtEntityControlLogicType.

Implements makVre::DtPlayerComponent.

Reimplemented in DtVehicleBlinkerControlLogic, makVre::DtCommanderControlLogic, makVre::DtCommanderHatchControlLogic, makVre::DtDriverControlLogic, makVre::DtDroneControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtLauncherControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, makVre::DtTowingControlLogic, and makVre::DtZoomControl.

◆ handleSimState()

virtual makVre::DtVreMessageResult makVre::DtEntityControlLogic::handleSimState ( makVre::DtVreMessage * msg)
virtual

Message handlers.

Handles simulation state update messages

Parameters
msgPointer to the simulation state message
Returns
Message handling result

Processes simulation state messages, updating the component's understanding of the current entity state in the simulation.

Reimplemented in makVre::DtDroneControlLogic, makVre::DtHumanControlLogic, and makVre::DtPilotSimLogic.

◆ handleReset()

virtual makVre::DtVreMessageResult makVre::DtEntityControlLogic::handleReset ( makVre::DtVreMessage * message)
virtual

Handles reset messages.

Parameters
messagePointer to the reset message
Returns
Message handling result

Processes messages requesting an entity reset, either in place or to a default position/state.

◆ handleCreationStatus()

virtual makVre::DtVreMessageResult makVre::DtEntityControlLogic::handleCreationStatus ( makVre::DtVreMessage * message)
virtual

Handles player station creation status messages.

Parameters
messagePointer to the creation status message
Returns
Message handling result

When the current phase reaches ComponentsReady, this handler calls takeControlOfPlayerEntity() and then removes itself. This replaces the previous direct call in postInitialize().

◆ reset()

virtual void makVre::DtEntityControlLogic::reset ( float val)
virtual

Entity reset methods.

Resets the entity to its default state

Parameters
valInput value (typically 1.0 for pressed actions)

Resets the player's entity to its default position and state. This is typically triggered by a user input action.

Reimplemented in makVre::DtHumanControlLogic, and makVre::DtPilotSimLogic.

◆ resetInPlace()

virtual void makVre::DtEntityControlLogic::resetInPlace ( float val)
virtual

Resets the entity while maintaining its current position.

Parameters
valInput value (typically 1.0 for pressed actions)

Resets the player's entity to its default state except for position, which remains unchanged. Useful for clearing problems without relocating.

Reimplemented in makVre::DtHumanControlLogic, and makVre::DtPilotSimLogic.

◆ toggleMouseControl()

virtual void makVre::DtEntityControlLogic::toggleMouseControl ( float val)
virtual

Mouse control methods.

Toggles mouse control mode on/off

Parameters
valInput value (typically 1.0 for pressed actions)

Toggles between mouse control being enabled and disabled. This is typically triggered by a user input action.

◆ enableMouseControl()

virtual void makVre::DtEntityControlLogic::enableMouseControl ( float val)
virtual

Enables mouse control mode.

Parameters
valInput value (typically 1.0 for pressed actions)

Explicitly enables mouse control without toggling. This is typically triggered by a user input action.

◆ handleFocusMessage()

virtual makVre::DtVreMessageResult makVre::DtEntityControlLogic::handleFocusMessage ( makVre::DtVreMessage * message)
virtual

Handles application focus change messages.

Parameters
messagePointer to the focus message
Returns
Message handling result

Processes messages about application focus changes, which may affect how input control works (e.g., disabling control when the application loses focus).

◆ setMouseControlEnabled()

virtual void makVre::DtEntityControlLogic::setMouseControlEnabled ( bool enabled)
virtual

Sets whether mouse control is enabled.

Parameters
enabledTrue to enable mouse control, false to disable it

Controls whether mouse input is used for entity control. When disabled, other input methods like joystick may still work.

Reimplemented in makVre::DtHumanControlLogic.

◆ isMouseControlEnabled()

virtual bool makVre::DtEntityControlLogic::isMouseControlEnabled ( )
virtual

Checks if mouse control is currently enabled.

Returns
True if mouse control is enabled, false otherwise

Determines whether mouse input is currently being used for entity control.

◆ isMouseControlSupportAllowed()

virtual bool makVre::DtEntityControlLogic::isMouseControlSupportAllowed ( ) const
virtual

Checks if mouse control support is allowed.

Returns
True if mouse control is allowed, false if explicitly disallowed

Determines whether mouse control is allowed for the current entity or mode. Some entity types or control modes may not support mouse control.

◆ setMouseControlSupportAllowed()

virtual void makVre::DtEntityControlLogic::setMouseControlSupportAllowed ( bool enable)
virtual

Sets whether mouse control support is allowed.

Parameters
enableTrue to allow mouse control, false to disallow it

Controls whether mouse control is allowed as an option for the current entity or mode. This affects whether mouse control can be enabled at all.

◆ joystickGroups()

virtual const std::vector< std::string > & makVre::DtEntityControlLogic::joystickGroups ( ) const
virtual

Gets the joystick function groups.

Returns
Reference to the vector of joystick function group names

Retrieves the list of joystick function groups used by this entity controller. These groups organize joystick input mappings by function.

◆ sendJoystickCommand()

virtual void makVre::DtEntityControlLogic::sendJoystickCommand ( const DtEntityIdentifier & id,
const std::string & functionGroup,
const std::string & function,
double val,
bool repeat = false )
virtual

Sends a joystick command to a controlled entity.

Reimplemented in makVre::DtHumanControlLogic.

◆ requiresControl()

bool makVre::DtEntityControlLogic::requiresControl ( ) const
protected

Returns true if the player is not a spectator and health > 0.

◆ isAirborne()

bool makVre::DtEntityControlLogic::isAirborne ( ) const
protected

Returns true if posture attribute is JUMPING or PARACHUTING.

◆ showNotification()

void makVre::DtEntityControlLogic::showNotification ( const QString & text,
double duration )
protected

Displays a temporary notification via the player app.

◆ takeControlOfPlayerEntity()

virtual void makVre::DtEntityControlLogic::takeControlOfPlayerEntity ( )
protectedvirtual

Takes control of the player's entity.

Establishes control over the player's assigned entity, enabling input to affect the entity's state and behavior. Typically called during initialization or when a new entity is assigned.

◆ releaseControlOfPlayerEntity()

virtual void makVre::DtEntityControlLogic::releaseControlOfPlayerEntity ( )
protectedvirtual

Releases joystick control of the player's entity.

Relinquishes joystick function groups for the player's assigned entity, preventing further input from affecting the entity. Role occupancy is released by the player station destructor.

Member Data Documentation

◆ myJoystickFunctionGroups

std::vector<std::string> makVre::DtEntityControlLogic::myJoystickFunctionGroups
protected

List of joystick function groups used by this controller.

◆ myCommonInputLogic

DtInputLogic makVre::DtEntityControlLogic::myCommonInputLogic
protected

Input logic handler for common controls.

Manages input mappings and action handlers for general entity control.

◆ myInputConfigFile

std::string makVre::DtEntityControlLogic::myInputConfigFile
protected

Name of the input configuration file.

Identifies the configuration file containing input mappings for this controller.

◆ myMouseControlEnabled

bool makVre::DtEntityControlLogic::myMouseControlEnabled
protected

Flag indicating whether mouse control is currently enabled.

◆ myMouseControlSupportAllowed

bool makVre::DtEntityControlLogic::myMouseControlSupportAllowed
protected

Flag indicating whether mouse control is allowed for the current entity/mode.

◆ myOwnshipAttr

DtAttributeHandle makVre::DtEntityControlLogic::myOwnshipAttr
protected

Handle root for ownship attributes.

Attribute Store Keyownship

◆ myEmbarkedAttr

DtAttributeHandleType<bool> makVre::DtEntityControlLogic::myEmbarkedAttr
protected

Handle for embarked state.

Attribute Store Keyownship.embarked

◆ myEmbarkedHostAttr

DtAttributeHandleType<DtEntityIdentifier> makVre::DtEntityControlLogic::myEmbarkedHostAttr
protected

Handle for embarked host entity identifier.

Attribute Store Keyownship.embarked.host

◆ myEmbarkedHostTypeAttr

DtAttributeHandleType<DtEntityType> makVre::DtEntityControlLogic::myEmbarkedHostTypeAttr
protected

Handle for embarked host entity type.

Attribute Store Keyownship.embarked.hostType

◆ myEmbarkedHostMarkingAttr

DtAttributeHandleType<std::string> makVre::DtEntityControlLogic::myEmbarkedHostMarkingAttr
protected

Handle for embarked host marking text.

Attribute Store Keyownship.embarked.hostMarking

◆ myEmbarkedOnAircraftAttr

DtAttributeHandleType<bool> makVre::DtEntityControlLogic::myEmbarkedOnAircraftAttr
protected

Handle indicating whether ownship is embarked on an aircraft.

Attribute Store Keyownship.embarked.embarkedOnAircraft

◆ myEmbarkedInSlotAttr

DtAttributeHandleType<std::string> makVre::DtEntityControlLogic::myEmbarkedInSlotAttr
protected

Handle for embarked slot name.

Attribute Store Keyownship.embarked.embarkedInSlot

◆ myAppearanceAttr

DtAttributeHandleType<unsigned int> makVre::DtEntityControlLogic::myAppearanceAttr
protected

Handle for ownship appearance bits.

Attribute Store Keyownship.appearance

◆ myPositionAttr

DtAttributeHandleType<DtVector> makVre::DtEntityControlLogic::myPositionAttr
protected

Handle for ownship world position.

Attribute Store Keyownship.position

◆ myOrientationAttr

DtAttributeHandleType<DtTaitBryan> makVre::DtEntityControlLogic::myOrientationAttr
protected

Handle for ownship world orientation.

Attribute Store Keyownship.orientation

◆ mySpeedAttr

DtAttributeHandleType<double> makVre::DtEntityControlLogic::mySpeedAttr
protected

Handle for ownship speed magnitude.

Attribute Store Keyownship.speed

◆ myVelocityAttr

DtAttributeHandleType<DtVector32> makVre::DtEntityControlLogic::myVelocityAttr
protected

Handle for ownship world velocity.

Attribute Store Keyownship.velocity

◆ myAccelerationAttr

DtAttributeHandleType<DtVector32> makVre::DtEntityControlLogic::myAccelerationAttr
protected

Handle for ownship world acceleration.

Attribute Store Keyownship.acceleration

◆ myRotVelAttr

DtAttributeHandleType<DtVector32> makVre::DtEntityControlLogic::myRotVelAttr
protected

Handle for ownship rotational velocity.

Attribute Store Keyownship.rotationVelocity

◆ myEntityTypeAttr

DtAttributeHandleType<DtEntityType> makVre::DtEntityControlLogic::myEntityTypeAttr
protected

Handle for ownship entity type.

Attribute Store Keyownship.entityType

◆ myRelativeVelocityAttr

DtAttributeHandleType<DtVector32> makVre::DtEntityControlLogic::myRelativeVelocityAttr
protected

Handle for ownship relative velocity.

Attribute Store Keyownship.relativeVelocity

◆ myDamageStateAttr

DtAttributeHandleType<DtDamageState> makVre::DtEntityControlLogic::myDamageStateAttr
protected

Handle for ownship damage state.

Attribute Store Keyownship.damageState

◆ mySimStateUpdateIndexAttr

DtAttributeHandleType<int> makVre::DtEntityControlLogic::mySimStateUpdateIndexAttr
protected

Handle for simulation state update index.

Attribute Store KeysimStateUpdateIndex

◆ myHideOccupantsAttr

DtAttributeHandleType<bool> makVre::DtEntityControlLogic::myHideOccupantsAttr
protected

Handle indicating whether occupants should be hidden.

Attribute Store KeyHideOccupants

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