VR-Engage  2.3
Loading...
Searching...
No Matches
vreLauncherController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies, Inc.
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreLauncherController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for missile launcher systems
9//!
10//! This file defines the DtVreLauncherController class which extends
11//! the base launcher controller to add VR-Engage specific functionality,
12//! including equipment status tracking and resource management.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
18
19#include <vrfmodel/launcherController.h>
20
22
23class DtSimResource;
24
25namespace makVre
26{
27//! \brief Type identifier for the VRE launcher controller component
28const char* DtVreLauncherControllerType = "vre-missile-launcher-controller";
29
31
32//! \brief Controller for missile launcher systems with equipment status tracking
33//!
34//! DtVreLauncherController extends the base launcher controller to add
35//! equipment status monitoring functionality. It tracks the state of
36//! associated equipment resources and updates weapon availability based
37//! on the equipment status. This allows for disabling missile systems
38//! when the associated equipment is damaged or unavailable.
39class VREVRFMODEL_DLL DtVreLauncherController : public DtVreSimComponent<DtLauncherController>
40{
41public:
42 //! \brief Constructor
43 //! \param name The name of this component
44 //! \param owner The local object that owns this component
45 //! \param simManager The simulation services manager
46 //! \param desc Component descriptor with configuration parameters
47 //! \param parentRegistry Optional parent registry for reader/writer functionality
48 //!
49 //! Creates a new launcher controller component with the specified parameters.
50 DtVreLauncherController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
51 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
52
53 //! \brief Virtual destructor
54 //!
55 //! Cleans up resources used by the launcher controller component.
56 virtual ~DtVreLauncherController() override;
57
58 //! \brief Default constructor (deleted)
59 //!
60 //! Default constructor is deleted to prevent creation of instances
61 //! without proper initialization.
63
64 //! \brief Copy constructor (deleted)
65 //!
66 //! Copy constructor is deleted to prevent copy construction.
68
69 //! \brief Assignment operator (deleted)
70 //! \return Reference to this object
71 //!
72 //! Assignment operator is deleted to prevent assignment.
74
75 //! \brief Gets the type identifier for this component
76 //! \return String identifying the component type (DtVreLauncherControllerType)
77 //!
78 //! Implements the DtSimComponent::type() method to return the
79 //! type identifier for this component.
80 virtual const char* type() const override;
81
82 //! \brief Updates the controller state each simulation frame
83 //!
84 //! Checks myEquipmentResource. If it's null, attempts to look it up and cache it,
85 //! which will happen after a reset. If myEquipmentResource is non-null, updates
86 //! the DtWeaponComponentInterface::DT_WEAPON_DISABLED flag based on whether or not
87 //! the value of this resource is non-zero. This allows the weapon system to be
88 //! disabled when the associated equipment is damaged or unavailable.
89 virtual void tick() override;
90
91 //! \brief Factory method to create a new instance of this component
92 //! \param name The name for the new component
93 //! \param owner The local object that will own this component
94 //! \param simManager The simulation services manager
95 //! \param desc Optional component descriptor
96 //! \param parentRegistry Optional parent registry for reader/writer functionality
97 //! \return Pointer to the newly created component
98 //!
99 //! Static factory method used by the component creation system to instantiate
100 //! new instances of this component type.
101 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
102 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
103
104 //! \brief Handles component restoration
105 //!
106 //! Called whenever a component is restored from a saved state.
107 //! Sets myEquipmentResource to null, forcing it to be looked up
108 //! again on the next tick. This ensures proper initialization
109 //! after scenario restoration.
110 virtual void onRestore() override;
111
112protected:
113 //! \brief Performs initialization before the first simulation tick
114 //!
115 //! Initializes the myMissileSimObjectFacadeMap and performs other
116 //! one-time initialization tasks that must be completed before the
117 //! first simulation tick occurs.
118 virtual void preFirstTickInit() override;
119
120 //! \brief Detaches the missile so another one can be fired.
122
123protected:
124 //! \brief Pointer to the equipment resource being monitored
125 //!
126 //! Stores a reference to the equipment resource that affects the availability
127 //! of this launcher system. When this resource value becomes zero (indicating
128 //! damaged or unavailable equipment), the launcher is disabled.
129 DtSimResource* myEquipmentResource;
130
131private:
132 //! \brief Looks up the appropriate equipment resource
133 //! \return Pointer to the equipment resource, or nullptr if not found
134 //!
135 //! Searches for and returns a pointer to the equipment resource that
136 //! affects this launcher's availability. This method is called when
137 //! the resource pointer is null, typically after initialization or reset.
138 virtual DtSimResource* lookupEquipmentResource();
139};
140} // namespace makVre
virtual void onRestore() override
Handles component restoration.
virtual void tick() override
Updates the controller state each simulation frame.
virtual void preFirstTickInit() override
Performs initialization before the first simulation tick.
virtual DtVreMessageResult handleDetachMissile(DtVreMessage *msg)
Detaches the missile so another one can be fired.
virtual DtSimResource * lookupEquipmentResource()
Looks up the appropriate equipment resource.
const DtVreLauncherController & operator=(const DtVreLauncherController &orig)=delete
Assignment operator (deleted)
virtual const char * type() const override
Gets the type identifier for this component.
DtVreLauncherController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual ~DtVreLauncherController() override
Virtual destructor.
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.
DtVreLauncherController(const DtVreLauncherController &orig)=delete
Copy constructor (deleted)
DtVreLauncherController()=delete
Default constructor (deleted)
DtSimResource * myEquipmentResource
Pointer to the equipment resource being monitored.
Definition vreLauncherController.h:129
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:63
Weapon controller descriptor for VREngage.
Definition vreWeaponControllerDescriptor.h:35
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
const char * DtVreLauncherControllerType
Type identifier for the VRE launcher controller component.
Definition vreLauncherController.h:28
Defines the base class for all VREngage messages.
Base template class for VR-Engage simulation components.