VR-Engage  2.2
Loading...
Searching...
No Matches
DtLightsSirensControlLogic Class Reference

Detailed Description

DtLightsSirensControlLogic allows toggling of emergency lights and sirens on vehicles. It maintains the state of various light types and sirens, handles menu actions for toggling them, and updates their states based on player inputs.

#include <lightsSirensControlLogic.h>

Inheritance diagram for DtLightsSirensControlLogic:
[legend]

Public Member Functions

 DtLightsSirensControlLogic ()
 
virtual ~DtLightsSirensControlLogic () override
 
virtual bool initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual void toggleSiren (const std::string &sirenName)
 
virtual void toggleLight (const std::string &lightName)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual bool postInitialize ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Types

using LightMap = std::map<std::string, int>
 

Protected Member Functions

virtual makVre::DtVreMessageResult handleMenuMessage (makVre::DtVreMessage *msg)
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

LightMap myLightMap
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Member Typedef Documentation

◆ LightMap

using DtLightsSirensControlLogic::LightMap = std::map<std::string, int>
protected

Type definition for mapping light names to their light type IDs.

Constructor & Destructor Documentation

◆ DtLightsSirensControlLogic()

DtLightsSirensControlLogic::DtLightsSirensControlLogic ( )

Constructor for DtLightsSirensControlLogic.

Initializes the component with default values

◆ ~DtLightsSirensControlLogic()

virtual DtLightsSirensControlLogic::~DtLightsSirensControlLogic ( )
overridevirtual

Virtual destructor for DtLightsSirensControlLogic.

Member Function Documentation

◆ initialize()

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

Initializes the lights and sirens control component.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing lights and sirens settings
Returns
True if initialization succeeded, false otherwise

Configures the available lights and sirens from the configuration table, initializes state attributes, and sets up message handlers for menu actions

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ tick()

virtual void DtLightsSirensControlLogic::tick ( double dt)
overridevirtual

Called every frame to update lights and sirens states.

Parameters
dtDelta time since the last frame in seconds

Updates player attributes for all configured lights based on the entity's current appearance and light states

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void DtLightsSirensControlLogic::shutdown ( )
overridevirtual

Shuts down the lights and sirens control component.

Removes message handlers and performs cleanup operations

Reimplemented from makVre::DtPlayerComponent.

◆ type()

virtual const char * DtLightsSirensControlLogic::type ( ) const
overridevirtual

Returns the component type identifier.

Returns
The component type string

Implements makVre::DtPlayerComponent.

◆ toggleSiren()

virtual void DtLightsSirensControlLogic::toggleSiren ( const std::string & sirenName)
virtual

Toggles the state of a specific siren.

Parameters
sirenNameName of the siren to toggle

Inverts the current state of the specified siren and updates the corresponding player attribute

◆ toggleLight()

virtual void DtLightsSirensControlLogic::toggleLight ( const std::string & lightName)
virtual

Toggles the state of a specific light.

Parameters
lightNameName of the light to toggle

Inverts the current state of the specified light, updates the corresponding player attribute, and sends a VrfSetLightStateMessage to update the visual appearance of the vehicle

◆ handleMenuMessage()

virtual makVre::DtVreMessageResult DtLightsSirensControlLogic::handleMenuMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Handles menu action messages for lights and sirens.

Parameters
msgThe message to handle
Returns
Message handling result indicating if the message was handled

Processes "toggleSiren" and "toggleLights" menu actions with a parameter indicating which specific light or siren to toggle

Member Data Documentation

◆ myLightMap

LightMap DtLightsSirensControlLogic::myLightMap
protected

Map associating light names with their corresponding light type IDs.

Maps configuration-defined light names (e.g., "headlights", "brake_lights") to their corresponding DtLightType enumeration values


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