VR-Engage  2.2
Loading...
Searching...
No Matches
vreLasingController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreLasingController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for laser designation functionality
9//!
10//! This file defines the DtVreLasingController class which extends the base
11//! lasing controller to support VR-Engage specific laser designation features.
12//! It sets a state property "HasLaser" defined in human and aircraft platform files,
13//! allowing the VRE player menu to show laser designation options.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
19
21
22#include <vrfmodel/lasingController.h>
23
24//! \brief Derived laser controller with VR-Engage specific functionality
25//!
26//! This controller extends the base lasing controller and sets a state property - "HasLaser"
27//! that is defined in the Human and flying aircraft sysdef platform files. By doing so,
28//! the VR-Engage player menu will know that it should show the laser designation options.
29//! It is connected to GUI definitions in sensorOperator.lua & human.lua, and is designed for
30//! use with the Set_Lase_Location lua task set.
31namespace makVre
32{
33//! \brief Type identifier for the VRE lasing controller component
34const char DtVreLasingControllerType[] = "vre-laser-controller";
35
37{
38private:
39 //! \brief Default constructor (not implemented)
40 //!
41 //! Default constructor is private and not implemented to prevent
42 //! creation of instances without proper initialization.
44
45 //! \brief Copy constructor (not implemented)
46 //!
47 //! Copy constructor is private and not implemented to prevent
48 //! copy construction.
50
51 //! \brief Assignment operator (not implemented)
52 //! \return Reference to this object
53 //!
54 //! Assignment operator is private and not implemented to prevent assignment.
56
57public:
58 //! \brief Constructor
59 //! \param name The name of this component
60 //! \param owner The local object that owns this component
61 //! \param simManager The simulation services manager
62 //! \param desc Component descriptor with configuration parameters
63 //! \param parentRegistry Optional parent registry for reader/writer functionality
64 //!
65 //! Creates a new lasing controller component with the specified parameters.
66 DtVreLasingController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
67 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
68
69 //! \brief Virtual destructor
70 //!
71 //! Cleans up resources used by the lasing controller component.
72 virtual ~DtVreLasingController() override;
73
74 //! \brief Gets the type identifier for this component
75 //! \return String identifying the component type (DtVreLasingControllerType)
76 //!
77 //! Implements the DtSimComponent::type() method to return the
78 //! type identifier for this component.
79 virtual const char* type() const override;
80
81 //! \brief Performs initialization before the first simulation tick
82 //!
83 //! Gets initial laser designator code from the Process State Repository (PSR)
84 //! and copies it to the state property "laserCode". This ensures that the
85 //! GUI displays the correct laser code when the simulation starts.
86 virtual void preFirstTickInit() override;
87
88 //! \brief Updates the controller state each simulation frame
89 //!
90 //! Processes lasing operations during each simulation frame. This includes
91 //! updating laser position, checking line of sight conditions, and managing
92 //! the lasing state based on player inputs.
93 virtual void tick() override;
94
95 //! \brief Initializes the lasing controller
96 //! \return True if initialization is successful, false otherwise
97 //!
98 //! Sets the state property named "HasLaser" to True. This property is defined
99 //! in the platform sysdef file under state-data and is used by the VR-Engage menu
100 //! system to determine whether to show laser designation options in the user interface.
101 virtual bool init() override;
102
103 //! \brief Factory method to create a new instance of this component
104 //! \param name The name for the new component
105 //! \param owner The local object that will own this component
106 //! \param simManager The simulation services manager
107 //! \param desc Optional component descriptor
108 //! \param parentRegistry Optional parent registry for reader/writer functionality
109 //! \return Pointer to the newly created component
110 //!
111 //! Static factory method used by the component creation system to instantiate
112 //! new instances of this component type.
113 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
114 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
115
116 //! \brief Callback for entity restoration events
117 //! \param msg The message containing restoration information
118 //! \param usrData User data pointer, typically pointing to the instance of this class
119 //!
120 //! Static callback function invoked when an entity is restored. This function forwards
121 //! the message to the instance's processSetRestore method to reinitialize state properties.
122 static void setRestoreCallback(DtSimMessage* msg, void* usrData);
123
124protected:
125 //! \brief Handles messages to start lasing at a specific location
126 //! \param msg The message containing lasing parameters
127 //! \return Message processing result indicating success or failure
128 //!
129 //! Processes StartLasingLocation messages, which activate the laser designator
130 //! at a specified location. This allows the entity to designate targets for
131 //! laser-guided weapons.
133
134 //! \brief Handles messages to stop lasing
135 //! \param msg The message containing stop lasing request
136 //! \return Message processing result indicating success or failure
137 //!
138 //! Processes StopLasingLocation messages, which deactivate the laser designator.
139 //! This turns off the laser and stops target designation.
141
142 //! \brief Handles messages to set a new lasing location
143 //! \param msg The message containing new lasing location parameters
144 //! \return Message processing result indicating success or failure
145 //!
146 //! Processes SetLasingLocation messages, which update the location
147 //! at which the laser designator is pointing. This allows for tracking
148 //! moving targets or switching designation to a new target.
150
151 //! \brief Processes entity restoration messages
152 //! \param msg The message containing restoration information
153 //!
154 //! Reinitializes the state property "HasLaser" when a set restore operation
155 //! is executed. This ensures that the entity's laser capabilities are properly
156 //! restored after entity restoration, allowing the VR-Engage menu to correctly
157 //! display laser options.
158 virtual void processSetRestore(DtSimMessage* msg);
159
160 //! \brief Processes laser code change requests
161 //! \param msg The message containing the new laser code
162 //!
163 //! Sets the state property for laser code based on the message contents,
164 //! so the updated code can be reflected in the GUI. This allows users to
165 //! change laser codes through the user interface, ensuring that laser-guided
166 //! weapons are properly configured for the selected code.
167 virtual void processSetLaserCodeRequestMessage(DtSimMessage* msg) override;
168
169 //! \brief Determines if the controller has line of sight to a target
170 //! \param target Reference to the target object
171 //! \param reason Output parameter that will contain the reason for line of sight failure
172 //! \return True if line of sight exists, false otherwise
173 //!
174 //! Checks whether the laser controller has line of sight with the specified target.
175 //! Overridden to demote an excessive warning in the console (changed from DtWarn to
176 //! DtVerbose level). The actual line of sight calculation functionality remains
177 //! unchanged from the base class implementation.
178 virtual bool lineOfSight(DtSimObjectReference target, DtString& reason) override;
179
180 //! \brief Flag indicating whether the player is currently lasing
181 //!
182 //! When true, indicates that the player has activated the laser designator
183 //! and is currently designating a target. This state affects various controller
184 //! behaviors including message handling and visual effects.
186};
187} // namespace makVre
virtual makVre::DtVreMessageResult handleStartLasingLocation(makVre::DtVreMessage *msg)
Handles messages to start lasing at a specific location.
virtual void processSetLaserCodeRequestMessage(DtSimMessage *msg) override
Processes laser code change requests.
virtual makVre::DtVreMessageResult handleSetLasingLocation(makVre::DtVreMessage *msg)
Handles messages to set a new lasing location.
const DtVreLasingController & operator=(const DtVreLasingController &orig)
Assignment operator (not implemented)
virtual void preFirstTickInit() override
Performs initialization before the first simulation tick.
virtual makVre::DtVreMessageResult handleStopLasingLocation(makVre::DtVreMessage *msg)
Handles messages to stop lasing.
static void setRestoreCallback(DtSimMessage *msg, void *usrData)
Callback for entity restoration events.
DtVreLasingController(const DtVreLasingController &orig)
Copy constructor (not implemented)
virtual void tick() override
Updates the controller state each simulation frame.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
bool myPlayerIsLasing
Flag indicating whether the player is currently lasing.
Definition vreLasingController.h:185
virtual void processSetRestore(DtSimMessage *msg)
Processes entity restoration messages.
DtVreLasingController()
Default constructor (not implemented)
virtual const char * type() const override
Gets the type identifier for this component.
virtual bool init() override
Initializes the lasing controller.
DtVreLasingController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual bool lineOfSight(DtSimObjectReference target, DtString &reason) override
Determines if the controller has line of sight to a target.
virtual ~DtVreLasingController() override
Virtual destructor.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
const char DtVreLasingControllerType[]
Type identifier for the VRE lasing controller component.
Definition vreLasingController.h:34
Defines the base class for all VREngage messages.
Base template class for VR-Engage simulation components.