|
VR-Engage
2.2
|
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>
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 DtPlayerStation & | player () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () 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 |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
| makVre::DtEntityControlLogic::DtEntityControlLogic | ( | ) |
Constructor.
| type | Type identifier for the component |
Creates a new entity control logic component with the specified type. The default type is "DtEntityControlLogic".
|
overridevirtual |
Virtual destructor.
Ensures proper cleanup of entity control resources.
|
overridevirtual |
Initializes the entity control logic.
| player | Pointer to the player station this component belongs to |
| config | Configuration table with initialization parameters |
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().
|
overridevirtual |
Performs post-initialization setup.
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.
|
overridevirtual |
Updates the entity control logic each frame.
| dt | Time 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.
|
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.
|
overridevirtual |
Returns the component type identifier.
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.
|
virtual |
Message handlers.
Handles simulation state update messages
| msg | Pointer to the simulation state message |
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.
|
virtual |
Handles general state messages.
| message | Pointer to the state message |
Processes various state-related messages that affect entity control.
|
virtual |
Handles reset messages.
| message | Pointer to the reset message |
Processes messages requesting an entity reset, either in place or to a default position/state.
|
virtual |
Sets extended data for an entity.
| key | Key identifier for the data being set |
| value | Value to set for the specified key |
| entity | Entity 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).
|
virtual |
Entity reset methods.
Resets the entity to its default state
| val | Input 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.
|
virtual |
Resets the entity while maintaining its current position.
| val | Input 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.
|
virtual |
Mouse control methods.
Toggles mouse control mode on/off
| val | Input value (typically 1.0 for pressed actions) |
Toggles between mouse control being enabled and disabled. This is typically triggered by a user input action.
|
virtual |
Enables mouse control mode.
| val | Input value (typically 1.0 for pressed actions) |
Explicitly enables mouse control without toggling. This is typically triggered by a user input action.
|
virtual |
Handles application focus change messages.
| message | Pointer to the focus message |
Processes messages about application focus changes, which may affect how input control works (e.g., disabling control when the application loses focus).
|
virtual |
Sets whether mouse control is enabled.
| enabled | True 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.
|
virtual |
Checks if mouse control is currently enabled.
Determines whether mouse input is currently being used for entity control.
|
virtual |
Checks if mouse control support is allowed.
Determines whether mouse control is allowed for the current entity or mode. Some entity types or control modes may not support mouse control.
|
virtual |
Sets whether mouse control support is allowed.
| enable | True 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.
|
virtual |
Gets the joystick function groups.
Retrieves the list of joystick function groups used by this entity controller. These groups organize joystick input mappings by function.
|
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.
|
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.
|
protected |
List of joystick function groups used by this controller.
|
protected |
Input logic handler for common controls.
Manages input mappings and action handlers for general entity control.
|
protected |
Name of the input configuration file.
Identifies the configuration file containing input mappings for this controller.
|
protected |
Flag indicating whether mouse control is currently enabled.
|
protected |
Flag indicating whether mouse control is allowed for the current entity/mode.