VR-Engage  2.2
Loading...
Searching...
No Matches
humanHandWeaponSwitchController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file humanHandWeaponSwitchController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller that manages handheld weapon switching for human entities
9//!
10//! This file defines the DtVreHumanHandWeaponSwitchController which manages enabling
11//! and disabling secondary weapons for human entities. It addresses compatibility
12//! issues with multiple weapons in VRF by disabling secondary weapons when VRF
13//! is in control and enabling them when VR Engage is in control.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
19#include <vrfobjcore/simComponent.h>
20#include <vrfobjcore/componentSystem.h>
21
22namespace makVre
23{
24//! \brief Type identifier for the human handheld weapon switch controller component
25const char DtVreHumanHandWeaponSwitchControllerType[] = "handheld-weapon-switcher-controller";
26
27//! \brief Controller for managing secondary weapons on human entities
28//!
29//! DtVreHumanHandWeaponSwitchController manages the enabling and disabling of secondary
30//! weapons on human entities. Due to handling limitations in the current version of VRF
31//! with multiple weapons, this controller disables secondary weapons when VRF is in
32//! control of the entity and enables them when VR Engage is in control.
33//!
34//! This ensures proper weapon handling while maintaining compatibility between
35//! VRF and VR Engage control modes.
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 Optional component descriptor
63 //! \param parentRegistry Optional parent registry for reader/writer functionality
64 //!
65 //! Creates a new human handheld weapon switch controller component with the specified parameters.
66 DtVreHumanHandWeaponSwitchController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
67 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
68
69 //! \brief Initializes weapon system references before the first tick
70 //!
71 //! Identifies all weapon systems in the entity by checking for "aimable-weapon"
72 //! in the system category. Excludes the first weapon system and stores references
73 //! to any additional weapon systems found. These secondary weapons will be managed
74 //! based on control state changes.
75 virtual void preFirstTickInit() override;
76
77 //! \brief Virtual destructor
78 //!
79 //! Cleans up resources used by the human handheld weapon switch controller component.
81
82 //! \brief Updates weapon system states each simulation frame
83 //!
84 //! Checks whether the entity is player-controlled each frame. When control state changes,
85 //! enables or disables secondary weapon systems accordingly. Secondary weapons are enabled
86 //! when under VR Engage control and disabled when under VRF control.
87 virtual void tick() override;
88
89 //! \brief Gets the type identifier for this component
90 //! \return String identifying the component type (DtVreHumanHandWeaponSwitchControllerType)
91 //!
92 //! Implements the DtSimComponent::type() method to return the
93 //! type identifier for this component.
94 virtual const char* type() const override;
95
96 //! \brief Factory method to create a new instance of this component
97 //! \param name The name for the new component
98 //! \param owner The local object that will own this component
99 //! \param simManager The simulation services manager
100 //! \param desc Component descriptor with configuration parameters
101 //! \param parentRegistry Optional parent registry for reader/writer functionality
102 //! \return Pointer to the newly created component
103 //!
104 //! Static factory method used by the component creation system to instantiate
105 //! new instances of this component type.
106 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
107 DtComponentDescriptor* desc, DtReaderWriterRegistry* parentRegistry);
108
109protected:
110 //! \brief Collects references to secondary weapon systems
111 //!
112 //! Scans through all component systems in the entity and identifies those with
113 //! the "aimable-weapon" category. Excludes the first weapon system found (primary weapon)
114 //! and adds any others to mySystemList for management. In most cases, the secondary
115 //! weapon will be a pistol or other sidearm.
117
118protected:
119 //! \brief List of secondary weapon systems to be managed
120 //!
121 //! Contains pointers to all secondary weapon systems (all but the first)
122 //! that have the "aimable-weapon" category.
123 std::vector<DtComponentSystem*> mySystemList;
124
125 //! \brief Previous player control state
126 //!
127 //! Tracks whether the entity was player-controlled in the previous frame,
128 //! used to detect transitions between control states.
130};
131} // namespace makVre
void collectHandheldWeaponSystems()
Collects references to secondary weapon systems.
bool myWasPlayerControlled
Previous player control state.
Definition humanHandWeaponSwitchController.h:129
const DtVreHumanHandWeaponSwitchController & operator=(const DtVreHumanHandWeaponSwitchController &orig)
Assignment operator (not implemented)
DtVreHumanHandWeaponSwitchController(const DtVreHumanHandWeaponSwitchController &orig)
Copy constructor (not implemented)
DtVreHumanHandWeaponSwitchController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
Factory method to create a new instance of this component.
virtual void tick() override
Updates weapon system states each simulation frame.
virtual ~DtVreHumanHandWeaponSwitchController() override
Virtual destructor.
std::vector< DtComponentSystem * > mySystemList
List of secondary weapon systems to be managed.
Definition humanHandWeaponSwitchController.h:123
DtVreHumanHandWeaponSwitchController()
Default constructor (not implemented)
virtual void preFirstTickInit() override
Initializes weapon system references before the first tick.
virtual const char * type() const override
Gets the type identifier for this component.
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
const char DtVreHumanHandWeaponSwitchControllerType[]
Type identifier for the human handheld weapon switch controller component.
Definition humanHandWeaponSwitchController.h:25
Base template class for VR-Engage simulation components.