VR-Engage  2.2
Loading...
Searching...
No Matches
vehicleOccupantUpdater.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file vehicleOccupantUpdater.h
7//! \brief Component for managing vehicle occupant visibility when a player assumes a driver role
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
15
16namespace makVrv
17{
18class DtDe;
19class DtObserver;
20} // namespace makVrv
21
22namespace makVre
23{
24//! \brief Type identifier for DtVehicleOccupantUpdater component
25constexpr const char* DtVehicleOccupantUpdaterType = "DtVehicleOccupantUpdater";
26
27//! \brief Component that manages vehicle occupant visibility during player engagement
28//!
29//! DtVehicleOccupantUpdater manages the visibility of vehicle occupant models (visual-only
30//! representations of drivers in vehicles) when a player assumes a driver role. It caches the
31//! current occupant visibility state when a player first takes control and restores that state
32//! when the player relinquishes control. During player control, the component ensures the
33//! occupant is visible to external observers while hiding it locally for the player to
34//! prevent visual obstructions.
35
37{
38public:
39 //! \brief Constructor for DtVehicleOccupantUpdater
40 //!
41 //! Initializes the component with default state values
43
44 //! \brief Virtual destructor for DtVehicleOccupantUpdater
45 virtual ~DtVehicleOccupantUpdater() override;
46
47 //! \brief Initializes the vehicle occupant updater component
48 //! \param player Pointer to the player station this component belongs to
49 //! \param config Configuration table containing component settings
50 //! \return True if initialization succeeded, false otherwise
51 //!
52 //! Determines whether the player is an implicit driver (directly controlling a vehicle)
53 //! versus an embarked driver (a human player that entered a vehicle)
54 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
55
56 //! \brief Called every frame to update the occupant visibility state
57 //! \param dt Delta time since the last frame in seconds
58 //!
59 //! If the player is an implicit driver, this function waits until it can detect the
60 //! "HideOccupants" state. Once detected, it performs the following actions once:
61 //! - Caches the initial occupant visibility state
62 //! - Shows the driver occupant externally (to other observers)
63 //! - Hides the driver occupant model locally (for the player's view)
64 virtual void tick(double dt) override;
65
66 //! \brief Shuts down the vehicle occupant updater component
67 //!
68 //! Restores the driver occupant model locally and resets the published
69 //! "HideOccupants" state of the vehicle to its original value
70 virtual void shutdown() override;
71
72 //! \brief Returns the type identifier for this component
73 //! \return The type string for DtVehicleOccupantUpdater
74 virtual const char* type() const override;
75
76protected:
77 //! \brief Makes the driver occupant visible to external observers
78 //!
79 //! Sends an internal message indicating that the driver occupant for the
80 //! vehicle should be visible. This ensures that other simulators and
81 //! observers will see the driver model in the vehicle.
83
84 //! \brief Makes the driver occupant visible to external observers
85 //!
86 //! Sends an internal message indicating that the driver occupant for the
87 //! vehicle should be hidden. This ensures that other simulators and
88 //! observers will hide the driver model in the vehicle.
90
91 //! \brief Hides the driver occupant model in the local view
92 //!
93 //! Sends a message to hide the occupant model locally, preventing it from
94 //! obstructing the player's view while driving
96
97 //! \brief Shows the driver occupant model in the local view
98 //!
99 //! Sends a message to make the occupant model visible locally,
100 //! typically called during shutdown to restore the original state
102
103 //! \brief Saves the original occupant visibility state
104 //!
105 //! Reads and caches the initial "HideOccupants" attribute value
106 //! to allow proper restoration during shutdown
107 virtual void cacheOccupantState();
108
109 //! \brief Restores the original occupant visibility state
110 //!
111 //! Sends an internal message to reset the vehicle's occupant visibility
112 //! to match the cached value from before player engagement
113 virtual void restoreOccupantState();
114
115 //! \brief Flag indicating if player is directly controlling the vehicle (not embarked)
117
118 //! \brief Flag indicating if the initial occupant state has been cached
120
121 //! \brief The initial value of the HideOccupants attribute
123
124 //! \brief Pointer to the observer being used by this component
125 makVrv::DtObserver* myObserver;
126};
127} // namespace makVre
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
DtPlayerComponent()
Constructor.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
virtual void showDriverOccupantLocally()
Shows the driver occupant model in the local view.
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the vehicle occupant updater component.
bool myPlayerIsImplicitDriver
Flag indicating if player is directly controlling the vehicle (not embarked)
Definition vehicleOccupantUpdater.h:116
bool myCachedOccupantState
Flag indicating if the initial occupant state has been cached.
Definition vehicleOccupantUpdater.h:119
virtual void hideDriverOccupantLocally()
Hides the driver occupant model in the local view.
virtual void restoreOccupantState()
Restores the original occupant visibility state.
makVrv::DtObserver * myObserver
Pointer to the observer being used by this component.
Definition vehicleOccupantUpdater.h:125
DtVehicleOccupantUpdater()
Constructor for DtVehicleOccupantUpdater.
virtual void showDriverOccupantExternally()
Makes the driver occupant visible to external observers.
virtual void shutdown() override
Shuts down the vehicle occupant updater component.
virtual void cacheOccupantState()
Saves the original occupant visibility state.
bool myInitialHideOccupantsState
The initial value of the HideOccupants attribute.
Definition vehicleOccupantUpdater.h:122
virtual const char * type() const override
Returns the type identifier for this component.
virtual void hideDriverOccupantExternally()
Makes the driver occupant visible to external observers.
virtual void tick(double dt) override
Called every frame to update the occupant visibility state.
virtual ~DtVehicleOccupantUpdater() override
Virtual destructor for DtVehicleOccupantUpdater.
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtVehicleOccupantUpdaterType
Type identifier for DtVehicleOccupantUpdater component.
Definition vehicleOccupantUpdater.h:25
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.