VR-Engage  2.2
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 //! \brief Performs initialization before the first simulation tick
88 //!
89 //! Sets up initial states and caches references to required components
90 //! before the simulation begins. This includes setting up the VRE-specific
91 //! embarkation process state repository.
92 virtual void preFirstTickInit() override;
93
94 //! \brief Initializes the embarkation controller
95 //! \return True if initialization is successful, false otherwise
96 //!
97 //! Overridden to register callback for object deleted signals, which
98 //! are needed to properly handle cases where the carrier entity is deleted
99 //! while this entity is embarked.
100 virtual bool init() override;
101
102 //! \brief Handles embarkation information receipt and clearance to embark
103 //! \param embarkInfo Pointer to embarkation information for the target slot
104 //!
105 //! Called when embarkation information has been received and the entity
106 //! has been cleared to embark. Overridden to provide VRE-specific handling
107 //! of embarkation operations, including weapon state management.
108 virtual void completeEmbarkationInformationRequest(const DtIfEmbarkationInformation* embarkInfo) override;
109
110 //! \brief Handles disembarkation information receipt and clearance to disembark
111 //! \param disembarkInfo Pointer to disembarkation information for the egress point
112 //!
113 //! Called when disembarkation information has been received and the entity
114 //! has been cleared to disembark. Overridden to provide VRE-specific handling
115 //! of disembarkation operations, including restoring cached weapon states.
116 virtual void completeDisembarkationInformationRequest(const DtIfEmbarkationInformation* disembarkInfo) override;
117
118 //! \brief Provides a fallback disembarkation position
119 //! \return Vector containing the fallback offload point coordinates
120 //!
121 //! Overridden to offer a better fallback disembarkation position when
122 //! the normal disembarkation process cannot determine a suitable egress point.
123 //! This improves the reliability of the disembarkation process.
124 virtual DtVector fallbackOffloadPoint() override;
125
126 //! \brief Updates lifeform appearance and animation when embarked
127 //! \param slotNum The embarkation slot number
128 //! \param animationHintName Animation hint for the embarked state
129 //!
130 //! Overridden to include weapon state management from slot appearance
131 //! settings. Ensures the correct appearance and animation when an entity
132 //! is embarked in a vehicle or other carrier entity.
133 virtual void updateLifeformEmbarkedAppearanceAndAnimation(int slotNum, const DtString& animationHintName) override;
134
135 //! \brief Caches the current weapon state before embarkation
136 //!
137 //! Stores the current weapon state and hand item information before
138 //! embarkation, so it can be restored later when the entity disembarks.
139 //! This ensures continuity of equipment across embarkation operations.
140 virtual void cacheWeaponState();
141
142 //! \brief Restores the cached weapon state after disembarkation
143 //!
144 //! Restores the previously cached weapon state and hand item after
145 //! disembarkation. This ensures the entity returns to its proper equipped
146 //! state after leaving a vehicle or other carrier entity.
147 virtual void restoreWeaponState();
148
149 //! \brief Handles simulation object deletion events
150 //! \param simObject Reference to the simulation object being deleted
151 //!
152 //! If the deleted object is the entity this entity is currently embarked on,
153 //! this method restores the posture, weapon status, and clears the embarkation slot.
154 //! This ensures proper cleanup when carrier entities are removed from the simulation.
155 virtual void processSimObjectDeleted(DtSimObjectReference simObject);
156
157 //! \brief Pointer to the VRE embarkation process state repository
158 //!
159 //! References the VRE-specific embarkation PSR which adds slotPoint to watch
160 //! for entity leaving slot position and free slot. This extended PSR provides
161 //! additional capabilities beyond the base embarkation PSR.
163
164 //! \brief Cached weapon state from before embarkation
165 //!
166 //! Stores the entity's weapon state (DIS appearance) before embarkation
167 //! so it can be restored after disembarkation (addresses issue VRE-1220).
169
170 //! \brief Cached hand item from before embarkation
171 //!
172 //! Stores the type of weapon being held before embarkation so it can
173 //! be restored after disembarkation. This ensures weapon continuity.
174 DtString myHandItem;
175
176 //! \brief Flag indicating whether weapon state is cached
177 //!
178 //! When true, indicates that weapon state has been cached and can be
179 //! restored during disembarkation. Controls when the cached state is restored.
181
182 //! \brief Flag indicating whether entity is in its embarkation slot
183 //!
184 //! When true, indicates that the entity has reached its assigned slot position.
185 //! Used to detect when the entity leaves the slot, which may require cleanup actions.
187
188 //! \brief Connection for simulation object deleted events
189 //!
190 //! Manages the connection to simulation object deleted events, which is used
191 //! to handle cleanup when carrier entities are removed from the simulation.
192 boost::signals2::scoped_connection mySimObjectDeletedConnection;
193
194private:
195 //! \brief Default constructor (not implemented)
196 //!
197 //! Default constructor is private and not implemented to prevent
198 //! creation of instances without proper initialization.
200
201 //! \brief Copy constructor (not implemented)
202 //!
203 //! Copy constructor is private and not implemented to prevent
204 //! copy construction.
206
207 //! \brief Assignment operator (not implemented)
208 //! \return Reference to this object
209 //!
210 //! Assignment operator is private and not implemented to prevent assignment.
212};
213
214} // 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:180
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:174
boost::signals2::scoped_connection mySimObjectDeletedConnection
Connection for simulation object deleted events.
Definition vreEmbarkationController.h:192
bool myAmInSlotPosition
Flag indicating whether entity is in its embarkation slot.
Definition vreEmbarkationController.h:186
DtVreVrfEmbarkationPSR * myVreEmbarkPSR
Pointer to the VRE embarkation process state repository.
Definition vreEmbarkationController.h:162
virtual void cacheWeaponState()
Caches the current weapon state before embarkation.
DtWeaponState myUnembarkedWeaponState
Cached weapon state from before embarkation.
Definition vreEmbarkationController.h:168
virtual void preFirstTickInit() override
Performs initialization before the first simulation tick.
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:54
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
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtVreEmbarkationControllerType[]
Type identifier for the VRE embarkation controller component.
Definition vreEmbarkationController.h:29
Embarkation process state repository for VREngage.