VR-Engage  2.2
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 setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId())
 
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 makVre::DtVreMessageResult handleSimState (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleStateMessages (makVre::DtVreMessage *message)
 
virtual makVre::DtVreMessageResult handleReset (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 ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Member Functions

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
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

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::DtDeployableObjectsSimLogic, makVre::DtDriverControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, 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::DtDeployableObjectsSimLogic, makVre::DtGunnerControlLogic, and makVre::DtHumanControlLogic.

◆ 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::DtDeployableObjectsSimLogic, makVre::DtDriverControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtPilotSimLogic, and makVre::DtSpectatorSimLogic.

◆ shutdown()

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

Shuts down the entity control logic.

Cleans up resources, disconnects from input handlers, and releases control of entities. Called when the player station is shutting down.

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in makVre::DtCommanderControlLogic, makVre::DtCommanderHatchControlLogic, makVre::DtDeployableObjectsSimLogic, makVre::DtDriverControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, 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::DtDeployableObjectsSimLogic, makVre::DtDriverControlLogic, makVre::DtGunnerControlLogic, makVre::DtHumanControlLogic, makVre::DtPilotSimLogic, makVre::DtSpectatorSimLogic, 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::DtDeployableObjectsSimLogic, makVre::DtHumanControlLogic, and makVre::DtPilotSimLogic.

◆ handleStateMessages()

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

Handles general state messages.

Parameters
messagePointer to the state message
Returns
Message handling result

Processes various state-related messages that affect entity control.

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

◆ setExtendedData()

virtual void makVre::DtEntityControlLogic::setExtendedData ( const std::string & key,
const std::string & value,
DtEntityIdentifier entity = DtEntityIdentifier::nullId() )
virtual

Sets extended data for an entity.

Parameters
keyKey identifier for the data being set
valueValue to set for the specified key
entityEntity identifier to set data for (defaults to ownship entity)

Sets extended data values for an entity, typically used for custom properties or state information that isn't part of the standard entity state. If no entity is specified, applies to the player's own entity (ownship).

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

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

◆ 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 control of the player's entity.

Relinquishes control over the player's assigned entity, preventing further input from affecting the entity. Typically called during shutdown or when changing entities.

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.


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