VR-Engage  2.3
Loading...
Searching...
No Matches
vreEmbarkationController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreEmbarkationController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for managing entity embarkation and disembarkation
9//!
10//! This file defines the DtVreEmbarkationController class which extends the base
11//! embarkation controller with VRE-specific functionality. It manages entity
12//! embarkation and disembarkation operations, with fixes for VRF bugs such as
13//! lifeforms staying in sitting posture while moving to egress points.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
18#include "vreVrfModel/vreSimComponent.h"
19
21
22#include <vrfmodel/embarkationController.h>
23
24class DtHumanStateRepository;
25
26namespace makVre
27{
28//! \brief Type identifier for the VRE embarkation controller component
29const char DtVreEmbarkationControllerType[] = "vre-embarkation-controller";
30
31//! \brief Controller for managing entity embarkation and disembarkation
32//!
33//! DtVreEmbarkationController extends the base embarkation controller with
34//! VRE-specific functionality. It manages the embarkation and disembarkation
35//! of entities into and out of vehicles or other carrier entities. This controller
36//! includes fixes for VRF bugs such as lifeforms staying in sitting posture while
37//! moving to egress points, and adds additional capabilities for weapon state
38//! management during embarkation operations.
39class VREVRFMODEL_DLL DtVreEmbarkationController : public DtVreSimComponent<DtEmbarkationController>
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 embarkation controller component with the specified parameters.
50 DtVreEmbarkationController(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 embarkation controller component,
56 //! including any signal connections.
57 virtual ~DtVreEmbarkationController() override;
58
59 //! \brief Gets the type identifier for this component
60 //! \return String identifying the component type (DtVreEmbarkationControllerType)
61 //!
62 //! Implements the DtSimComponent::type() method to return the
63 //! type identifier for this component.
64 virtual const char* type() const override;
65
66 //! \brief Factory method to create a new instance of this component
67 //! \param name The name for the new component
68 //! \param owner The local object that will own this component
69 //! \param simManager The simulation services manager
70 //! \param desc Optional component descriptor
71 //! \param parentRegistry Optional parent registry for reader/writer functionality
72 //! \return Pointer to the newly created component
73 //!
74 //! Static factory method used by the component creation system to instantiate
75 //! new instances of this component type.
76 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
77 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
78
79protected:
80 //! \brief Updates the controller state each simulation frame
81 //!
82 //! Checks for slot position changes, updates postures during embarkation
83 //! and disembarkation, and fixes the VRF bug where lifeforms stay sitting
84 //! while moving to egress points.
85 virtual void tick() override;
86
87 // VRE NOTE: A preFirstTickInit() override that restored the embarked slot
88 // animation after scenario load was removed when rebasing on VR-Forces
89 // r292798; the base class now handles it in setupExistingConditions().
90
91 //! \brief Initializes the embarkation controller
92 //! \return True if initialization is successful, false otherwise
93 //!
94 //! Overridden to register callback for object deleted signals, which
95 //! are needed to properly handle cases where the carrier entity is deleted
96 //! while this entity is embarked.
97 virtual bool init() override;
98
99 //! \brief Handles embarkation information receipt and clearance to embark
100 //! \param embarkInfo Pointer to embarkation information for the target slot
101 //!
102 //! Called when embarkation information has been received and the entity
103 //! has been cleared to embark. Overridden to provide VRE-specific handling
104 //! of embarkation operations, including weapon state management.
105 virtual void completeEmbarkationInformationRequest(const DtIfEmbarkationInformation* embarkInfo) override;
106
107 //! \brief Handles disembarkation information receipt and clearance to disembark
108 //! \param disembarkInfo Pointer to disembarkation information for the egress point
109 //!
110 //! Called when disembarkation information has been received and the entity
111 //! has been cleared to disembark. Overridden to provide VRE-specific handling
112 //! of disembarkation operations, including restoring cached weapon states.
113 virtual void completeDisembarkationInformationRequest(const DtIfEmbarkationInformation* disembarkInfo) override;
114
115 //! \brief Provides a fallback disembarkation position
116 //! \return Vector containing the fallback offload point coordinates
117 //!
118 //! Overridden to offer a better fallback disembarkation position when
119 //! the normal disembarkation process cannot determine a suitable egress point.
120 //! This improves the reliability of the disembarkation process.
121 virtual DtVector fallbackOffloadPoint() override;
122
123 //! \brief Updates lifeform appearance and animation when embarked
124 //! \param slotNum The embarkation slot number
125 //! \param animationHintName Animation hint for the embarked state
126 //!
127 //! Overridden to include weapon state management from slot appearance
128 //! settings. Ensures the correct appearance and animation when an entity
129 //! is embarked in a vehicle or other carrier entity.
130 virtual void updateLifeformEmbarkedAppearanceAndAnimation(int slotNum, const DtString& animationHintName) override;
131
132 //! \brief Caches the current weapon state before embarkation
133 //!
134 //! Stores the current weapon state and hand item information before
135 //! embarkation, so it can be restored later when the entity disembarks.
136 //! This ensures continuity of equipment across embarkation operations.
137 virtual void cacheWeaponState();
138
139 //! \brief Restores the cached weapon state after disembarkation
140 //!
141 //! Restores the previously cached weapon state and hand item after
142 //! disembarkation. This ensures the entity returns to its proper equipped
143 //! state after leaving a vehicle or other carrier entity.
144 virtual void restoreWeaponState();
145
146 //! \brief Handles simulation object deletion events
147 //! \param simObject Reference to the simulation object being deleted
148 //!
149 //! If the deleted object is the entity this entity is currently embarked on,
150 //! this method restores the posture, weapon status, and clears the embarkation slot.
151 //! This ensures proper cleanup when carrier entities are removed from the simulation.
152 virtual void processSimObjectDeleted(DtSimObjectReference simObject);
153
154 //! \brief Pointer to the VRE embarkation process state repository
155 //!
156 //! References the VRE-specific embarkation PSR which adds slotPoint to watch
157 //! for entity leaving slot position and free slot. This extended PSR provides
158 //! additional capabilities beyond the base embarkation PSR.
160
161 //! \brief Cached weapon state from before embarkation
162 //!
163 //! Stores the entity's weapon state (DIS appearance) before embarkation
164 //! so it can be restored after disembarkation (addresses issue VRE-1220).
166
167 //! \brief Cached hand item from before embarkation
168 //!
169 //! Stores the type of weapon being held before embarkation so it can
170 //! be restored after disembarkation. This ensures weapon continuity.
171 DtString myHandItem;
172
173 //! \brief Flag indicating whether weapon state is cached
174 //!
175 //! When true, indicates that weapon state has been cached and can be
176 //! restored during disembarkation. Controls when the cached state is restored.
178
179 //! \brief Flag indicating whether entity is in its embarkation slot
180 //!
181 //! When true, indicates that the entity has reached its assigned slot position.
182 //! Used to detect when the entity leaves the slot, which may require cleanup actions.
184
185 //! \brief Connection for simulation object deleted events
186 //!
187 //! Manages the connection to simulation object deleted events, which is used
188 //! to handle cleanup when carrier entities are removed from the simulation.
189 boost::signals2::scoped_connection mySimObjectDeletedConnection;
190
191private:
192 //! \brief Default constructor (not implemented)
193 //!
194 //! Default constructor is private and not implemented to prevent
195 //! creation of instances without proper initialization.
197
198 //! \brief Copy constructor (not implemented)
199 //!
200 //! Copy constructor is private and not implemented to prevent
201 //! copy construction.
203
204 //! \brief Assignment operator (not implemented)
205 //! \return Reference to this object
206 //!
207 //! Assignment operator is private and not implemented to prevent assignment.
209};
210
211} // namespace makVre
virtual void completeDisembarkationInformationRequest(const DtIfEmbarkationInformation *disembarkInfo) override
Handles disembarkation information receipt and clearance to disembark.
bool myWeaponStateCached
Flag indicating whether weapon state is cached.
Definition vreEmbarkationController.h:177
virtual void restoreWeaponState()
Restores the cached weapon state after disembarkation.
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.
const DtVreEmbarkationController & operator=(const DtVreEmbarkationController &orig)
Assignment operator (not implemented)
virtual void updateLifeformEmbarkedAppearanceAndAnimation(int slotNum, const DtString &animationHintName) override
Updates lifeform appearance and animation when embarked.
virtual DtVector fallbackOffloadPoint() override
Provides a fallback disembarkation position.
virtual const char * type() const override
Gets the type identifier for this component.
DtVreEmbarkationController()
Default constructor (not implemented)
virtual ~DtVreEmbarkationController() override
Virtual destructor.
DtVreEmbarkationController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
DtVreEmbarkationController(const DtVreEmbarkationController &orig)
Copy constructor (not implemented)
virtual bool init() override
Initializes the embarkation controller.
virtual void processSimObjectDeleted(DtSimObjectReference simObject)
Handles simulation object deletion events.
DtString myHandItem
Cached hand item from before embarkation.
Definition vreEmbarkationController.h:171
boost::signals2::scoped_connection mySimObjectDeletedConnection
Connection for simulation object deleted events.
Definition vreEmbarkationController.h:189
bool myAmInSlotPosition
Flag indicating whether entity is in its embarkation slot.
Definition vreEmbarkationController.h:183
DtVreVrfEmbarkationPSR * myVreEmbarkPSR
Pointer to the VRE embarkation process state repository.
Definition vreEmbarkationController.h:159
virtual void cacheWeaponState()
Caches the current weapon state before embarkation.
DtWeaponState myUnembarkedWeaponState
Cached weapon state from before embarkation.
Definition vreEmbarkationController.h:165
virtual void completeEmbarkationInformationRequest(const DtIfEmbarkationInformation *embarkInfo) override
Handles embarkation information receipt and clearance to embark.
virtual void tick() override
Updates the controller state each simulation frame.
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:63
Extended embarkation process state repository for VREngage.
Definition vreVrfEmbarkationPSR.h:32
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
!
Definition glsVreMessageUtil.h:50
const char DtVreEmbarkationControllerType[]
Type identifier for the VRE embarkation controller component.
Definition vreEmbarkationController.h:29
Embarkation process state repository for VREngage.