VR-Engage  2.2
Loading...
Searching...
No Matches
humanControlLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file humanControlLogic.h
7//! \brief Defines DtHumanControlLogic for managing human entity controls and interactions
8//! \ingroup vreHumanFrontend
9
10#pragma once
11
13
17
18#include <vrvCore/DtUniqueID.h>
19
20#include <matrix/vlVector.h>
21
22#include <vector>
23#include <matrix/vlVector.inl> // for DtVector64::DtVector64, DtVector64::operator=
24#include <vlpi/entityIdentifier.inl> // for DtEntityIdentifier::DtEntityIdentifier, DtEntityIdentifier::operator=
25#include <vlpi/entityType.h> // for DtEntityType
26#include <xstring> // for string, basic_string
27
28namespace makVrv
29{
30//! \brief Forward declaration of the observer class
31class DtObserver;
32} // namespace makVrv
33
34namespace makVre
35{
36//! \brief Forward declaration of the human input logic class
38
39//! \brief Forward declaration of the initialization table class
40class DtInitTable;
41
42//! \brief Forward declaration of the weapon resource logic class
44
45//! \brief Forward declaration of the Qt quick overlay class
47
48//! \brief Forward declaration of the human virtual reality logic class
50
52{
53//! \ingroup RoleConfigParams
54//! \defgroup HumanControlLogicRoleParams Human Control Logic Role Parameters
55//! \roleInherits{EntityControlLogicRoleParams}
56//! Configuration Options for humanControlLogic role.
57//! @{
58
59//! \vreRoleParam{aimMultiplier,double,0.46666667,humanControlLogic,Movement speed multiplier when aiming weapons.}
60constexpr const char* aimMultiplier = "aimMultiplier";
61
62//! \vreRoleParam{aimingErrorCalcDistanceToTarget,double,1.0,humanControlLogic,Target distance in meters used for aiming error calculations.}
63constexpr const char* aimingErrorCalcDistanceToTarget = "aimingErrorCalcDistanceToTarget";
64
65//! \vreRoleParam{aimingErrorCalcMaxSpread,double,0.0,humanControlLogic,Maximum aiming spread in inches for error calculations.}
66constexpr const char* aimingErrorCalcMaxSpread = "aimingErrorCalcMaxSpread";
67
68//! \vreRoleParam{aimingImprovementPercent,double,1.0,humanControlLogic,Percentage value (0-1) for general aiming improvement.}
69constexpr const char* aimingImprovementPercent = "aimingImprovementPercent";
70
71//! \vreRoleParam{binocularsInputMultiplier,double,0.5,humanControlLogic,Input sensitivity multiplier when using binoculars.}
72constexpr const char* binocularsInputMultiplier = "binocularsInputMultiplier";
73
74//! \vreRoleParam{compassUnits,string,"Degrees",humanControlLogic,Units for compass display ("Degrees" or "NATO-MIL").}
75constexpr const char* compassUnits = "compassUnits";
76
77//! \vreRoleParam{invertPitchInput,bool,false,humanControlLogic,Whether to invert pitch input controls.}
78constexpr const char* invertPitchInput = "invertPitchInput";
79
80//! \vreRoleParam{isAllowedThirdPersonView,bool,false,humanControlLogic,Whether third-person view mode is allowed.}
81constexpr const char* isAllowedThirdPersonView = "isAllowedThirdPersonView";
82
83//! \vreRoleParam{joystickSensitivity,double,3.0,humanControlLogic,Sensitivity multiplier for joystick input.}
84constexpr const char* joystickSensitivity = "joystickSensitivity";
85
86//! \vreRoleParam{moveDelays,table,{},humanControlLogic,Table of posture change animation delays and timing.}
87constexpr const char* moveDelays = "moveDelays";
88
89//! \vreRoleParam{moveLockedPostures,table,{},humanControlLogic,Table of postures that prevent movement.}
90constexpr const char* moveLockedPostures = "moveLockedPostures";
91
92//! \vreRoleParam{postureSequence,table,{},humanControlLogic,Table defining the sequence of available postures.}
93constexpr const char* postureSequence = "postureSequence";
94
95//! \vreRoleParam{proneAimingImprovementPercent,double,1.0,humanControlLogic,Percentage value (0-1) for aiming improvement when prone.}
96constexpr const char* proneAimingImprovementPercent = "proneAimingImprovementPercent";
97
98//! \vreRoleParam{raiseGunOnAttach,bool,false,humanControlLogic,Whether to automatically raise weapon when attaching to entity.}
99constexpr const char* raiseGunOnAttach = "raiseGunOnAttach";
100
101//! \vreRoleParam{requiredAimingErrorPercent,double,0.0,humanControlLogic,Required percentage value (0-1) for aiming error calculations.}
102constexpr const char* requiredAimingErrorPercent = "requiredAimingErrorPercent";
103
104//! \vreRoleParam{runMultiplier,double,0.77777778,humanControlLogic,Movement speed multiplier when running.}
105constexpr const char* runMultiplier = "runMultiplier";
106
107//! \vreRoleParam{showCompass,bool,false,humanControlLogic,Whether to display the compass in the interface.}
108constexpr const char* showCompass = "showCompass";
109
110//! \vreRoleParam{sprintBackwardMultiplier,double,1.2,humanControlLogic,Movement speed multiplier when sprinting backward.}
111constexpr const char* sprintBackwardMultiplier = "sprintBackwardMultiplier";
112
113//! \vreRoleParam{sprintMultiplier,double,1.555556,humanControlLogic,Movement speed multiplier when sprinting forward.}
114constexpr const char* sprintMultiplier = "sprintMultiplier";
115
116//! \vreRoleParam{walkMultiplier,double,0.3,humanControlLogic,Movement speed multiplier when walking.}
117constexpr const char* walkMultiplier = "walkMultiplier";
118
119//! \vreRoleParam{weaponLockedPostures,table,{},humanControlLogic,Table of postures that prevent weapon usage.}
120constexpr const char* weaponLockedPostures = "weaponLockedPostures";
121
122//! \vreRoleParam{weaponLockedWhenMovingPostures,table,{},humanControlLogic,Table of postures that prevent weapon usage when moving.}
123constexpr const char* weaponLockedWhenMovingPostures = "weaponLockedWhenMovingPostures";
124
125//! @}
126} // namespace HumanControlLogicConfig
127
128//! \brief Type identifier for DtHumanControlLogic component
129constexpr const char* DtHumanControlLogicType = "DtHumanControlLogic";
130
131//! \brief Control logic component for the human entity
132//!
133//! DtHumanControlLogic manages user inputs and control actions for the human entity,
134//! including movement, posture changes, weapon handling, and special actions like
135//! using equipment or interacting with the environment. It translates input commands
136//! into entity state changes and simulation actions.
138{
139public:
140 //! \brief Friend class declaration to allow VR logic access to protected members
142
143 //! \brief Enumeration of posture transition directions
145 POSTURE_UP, //!< Transitioning to a more upright posture
146 POSTURE_DOWN //!< Transitioning to a more prone posture
147 };
148
149 //! \brief Enumeration of compass unit types
151 DEGREES = 0, //!< Compass units in degrees (0-360)
152 NATO_MIL //!< Compass units in NATO mils (0-6400)
153 };
154
155 //! \brief Default constructor
157
158 //! \brief Virtual destructor
159 virtual ~DtHumanControlLogic() override;
160
161 //! \brief Initializes the human control logic
162 //! \param player Pointer to the player station
163 //! \param config Configuration settings for initialization
164 //! \return True if initialization was successful, false otherwise
165 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
166
167 //! \brief Performs post-initialization setup
168 //! \return True if post-initialization was successful, false otherwise
169 virtual bool postInitialize() override;
170
171 //! \brief Updates control logic for the current frame
172 //! \param dt Delta time since the last frame in seconds
173 virtual void tick(double dt) override;
174
175 //! \brief Cleans up resources when the component is being shut down
176 virtual void shutdown() override;
177
178 //! \brief Returns the component type identifier
179 //! \return The component type string
180 virtual const char* type() const override;
181
182 //! \brief Handles aim input
183 //! \param val Input value in the range [-1.0, 1.0]
184 virtual void aim(double val);
185
186 //! \brief Set a temporary movement lockout
187 //!
188 //! Set time in seconds during which player cannot move; set 0 to clear.
189 void setMoveLockTime(double seconds);
190
191 //! \brief Add time to a temporary movement lockout
192 //!
193 //! Add time in seconds during which player cannot move
194 void addMoveLockTime(double seconds);
195
196 //! \brief Handles forward/backward movement input
197 //! \param val Input value in the range [-1.0, 1.0], where positive is forward
198 virtual void move(double val);
199
200 //! \brief Handles left/right movement input
201 //! \param val Input value in the range [-1.0, 1.0], where positive is right
202 virtual void strafe(double val);
203 //! \brief Handles pitch (up/down looking) input
204 //! \param val Input value in the range [-1.0, 1.0], where positive is down
205 //! \param mouseInput Flag indicating if input is from mouse
206 //!
207 //! Handles pitch input, applies value scaling, and sends pitch joystick command when not gazing.
208 virtual void pitch(double val, bool mouseInput = false);
209
210 //! \brief Handles yaw (left/right looking) input
211 //! \param val Input value in the range [-1.0, 1.0], where positive is right
212 //! \param mouseInput Flag indicating if input is from mouse
213 //!
214 //! Handles yaw input, applies value scaling, and sends yaw joystick command when not gazing.
215 virtual void yaw(double val, bool mouseInput = false);
216 //! \brief Sets the pitch angle directly
217 //! \param pitch Pitch angle in degrees
218 virtual void setPitch(double pitch);
219
220 //! \brief Sets the yaw angle directly
221 //! \param yaw Yaw angle in degrees
222 virtual void setYaw(double yaw);
223
224 //! \brief Simulates yaw movement over time
225 //! \param dt Delta time since the last frame in seconds
226 virtual void simulateYaw(double dt);
227
228 //! \brief Simulates pitch movement over time
229 //! \param dt Delta time since the last frame in seconds
230 virtual void simulatePitch(double dt);
231
232 //! \brief Sets the current pitch angle for VR input
233 //! \param pitch Pitch angle in degrees
234 //! \note VRE-3178 remove once we support proper VR input
235 virtual void setCurrentPitch(double pitch);
236
237 //! \brief Sets the current heading angle for VR input
238 //! \param yaw Yaw angle in degrees
239 //! \note VRE-3178 remove once we support proper VR input
240 virtual void setCurrentHeading(double yaw);
241 //! \brief Turns the entity's head to look up/down
242 //!
243 //! Updates the gazePitch attribute according to the processed pitch input (myPitch).
244 virtual void gazePitch();
245
246 //! \brief Turns the entity's head to look left/right
247 //!
248 //! Updates the gazeYaw attribute according to the processed yaw input (myYaw).
249 virtual void gazeYaw();
250
251 //! \brief Gets the desired posture for the human entity
252 //! \return The current desired posture
254
255 //! \brief Sets the entity posture
256 //! \param val Input value, typically 1.0 for activation
257 //! \param posture Target posture to transition to
258 //! \param postureTransition Direction of posture transition
259 virtual void setPosture(double val, HumanPosture posture, DtPostureTransition postureTransition);
260
261 //! \brief Selects a posture based on the current state
262 //! \param val Input value, typically 1.0 for activation
263 virtual void postureSelect(double val);
264
265 //! \brief Transitions to a more upright posture
266 //! \param val Input value, typically 1.0 for activation
267 virtual void postureUp(double val);
268
269 //! \brief Transitions to a more prone posture
270 //! \param val Input value, typically 1.0 for activation
271 virtual void postureDown(double val);
272
273 //! \brief Transitions to standing posture
274 //! \param val Input value, typically 1.0 for activation
275 virtual void standUp(double val);
276
277 //! \brief Transitions to prone posture
278 //! \param val Input value, typically 1.0 for activation
279 virtual void goProne(double val);
280
281 //! \brief Transitions to kneeling posture
282 //! \param val Input value, typically 1.0 for activation
283 virtual void kneel(double val);
284
285 //! \brief Toggles binoculars equipment
286 //! \param val Input value, typically 1.0 for activation
287 virtual void toggleBinoculars(double val);
288
289 //! \brief Initiates weapon reload
290 //! \param val Input value, typically 1.0 for activation
291 virtual void reload(double val);
292
293 //! \brief Fires the current weapon
294 //! \param val Input value, typically 1.0 for activation
295 virtual void fire(double val);
296
297 //! \brief Toggles free look mode
298 //! \param val Input value, typically 1.0 for activation
299 virtual void freeLook(double val);
300
301 //! \brief Toggles the observer attachment mode
302 //! \param val Input value, typically 1.0 for activation
303 virtual void toggleObserverAttachMode(double val);
304
305 //! \brief Sets the observer attachment mode directly
306 //! \param mode The observer attachment mode to set
308
309 //! \brief Activates sprint movement
310 //! \param val Input value, typically 1.0 for activation
311 virtual void sprint(double val);
312
313 //! \brief Activates walk movement
314 //! \param val Input value, typically 1.0 for activation
315 virtual void walk(double val);
316
317 //! \brief Toggles flashlight on/off
318 //! \param val Input value, typically 1.0 for activation
319 virtual void toggleFlashlight(double val);
320
321 //! \brief Adjusts flashlight pitch upward
322 //! \param val Input value, typically 1.0 for activation
323 virtual void flashlightPitchUp(double val);
324
325 //! \brief Adjusts flashlight pitch downward
326 //! \param val Input value, typically 1.0 for activation
327 virtual void flashlightPitchDown(double val);
328
329 //! \brief Adjusts flashlight yaw leftward
330 //! \param val Input value, typically 1.0 for activation
331 virtual void flashlightYawLeft(double val);
332
333 //! \brief Adjusts flashlight yaw rightward
334 //! \param val Input value, typically 1.0 for activation
335 virtual void flashlightYawRight(double val);
336
337 //! \brief Handles first stage trigger input for weapons
338 //! \param val Input value, typically 1.0 for activation
339 virtual void firstStageTrigger(double val);
340
341 //! \brief Toggles the compass display
342 //! \param val Input value, typically 1.0 for activation
343 //!
344 //! Toggles the value of the makVre::DtState attribute "compass".
345 virtual void toggleCompass(double val);
346
347 //! \brief Toggles between compass unit types
348 //! \param val Input value, typically 1.0 for activation
349 virtual void toggleCompassUnits(double val);
350
351 //! \brief Sets the compass units directly
352 //! \param units The compass units to use
353 virtual void setCompassUnits(enum DtCompassUnits units);
354
355 //! \brief Toggles between true and magnetic north references
356 //! \param val Input value, typically 1.0 for activation
357 virtual void toggleNorthReference(double val);
358
359 //! \brief Toggles night vision goggles
360 //! \param val Input value, typically 1.0 for activation
361 virtual void toggleNVG(double val);
362
363 //! \brief Zooms in binoculars or toggles binoculars if not active
364 //! \param val Input value, typically 1.0 for activation
365 virtual void zoomInToggleBinoculars(double val);
366
367 //! \brief Zooms out binoculars or toggles binoculars if not active
368 //! \param val Input value, typically 1.0 for activation
369 virtual void zoomOutToggleBinoculars(double val);
370
371 //! \brief Toggles weapon stowed state
372 //! \param val Input value, typically 1.0 for activation
373 virtual void toggleWeaponStowed(double val);
374
375 //! \brief Toggles weapon down state
376 //! \param val Input value, typically 1.0 for activation
377 virtual void toggleWeaponDown(double val);
378
379 //! \brief Toggles HUD visibility
380 //! \param val Input value, typically 1.0 for activation
381 //!
382 //! Toggles value of state attribute "showHUD".
383 virtual void toggleHUD(double val);
384
385 //! \brief Puts the weapon in down position
386 virtual void weaponDown();
387
388 //! \brief Stows the current weapon
389 //! \param stow True to stow the weapon, false otherwise
390 virtual void weaponStow(bool stow);
391
392 //! \brief Brings the weapon to ready position
393 virtual void weaponUp();
394
395 //! \brief Cycles through weapon states (ready, down, stowed)
396 //! \param val Input value, typically 1.0 for activation
397 //!
398 //! Toggles current "attackMode" extended state data, representing
399 //! current attack mode of the launcher, top attack ("top-attack") or direct attack ("direct-attack").
400 virtual void cycleWeaponState(double val);
401
402 // Toggle current "attackMode" extended state data, representing
403 // current attack mode of the launcher, top attack ("top-attack") or direct attack ("direct-attack").
404 virtual void toggleMissileAttackMode(double val);
405
406 //! \brief Cycles through weapons or puts current weapon down
407 //! \param press True if button is pressed, false if released
408 //!
409 //! Cycles through available weapons if weapon is already in ready position,
410 //! or puts the current weapon down if in ready position and not cycling.
411 virtual void weaponCycleOrDown(bool press);
412
413 //! \brief Selects the next weapon in the inventory
414 //! \param val Input value, typically 1.0 for activation
415 //!
416 //! Cycles to the next available weapon in the entity's inventory.
417 virtual void nextWeapon(double val);
418
419 //! \brief Selects a specific weapon by index
420 //! \param index The index of the weapon to select
421 //!
422 //! Selects a specific weapon from the entity's inventory based on its index.
423 virtual void selectWeapon(int index);
424
425 //! \brief Manipulates a terrain element
426 //! \param element The terrain element to manipulate
427 //! \param action The action to perform on the element
428 //!
429 //! Performs an action on a terrain element, such as opening a door,
430 //! toggling a light switch, or operating other interactive objects.
432
433 //! \brief Toggles the left parachute control line
434 //! \param val Input value, typically 1.0 for activation
435 //!
436 //! Controls the left steering of a parachute when deployed,
437 //! causing the entity to turn left when in the air.
438 virtual void parachuteLeftToggle(double val);
439
440 //! \brief Toggles the right parachute control line
441 //! \param val Input value, typically 1.0 for activation
442 //!
443 //! Controls the right steering of a parachute when deployed,
444 //! causing the entity to turn right when in the air.
445 virtual void parachuteRightToggle(double val);
446
447 //! \brief Deploys the parachute
448 //! \param val Input value, typically 1.0 for activation
449 //!
450 //! Deploys the entity's parachute when falling, allowing for
451 //! controlled descent and safe landing.
452 virtual void parachuteDeploy(double val);
453
454 //! \brief Sets the laser designation code
455 //! \param val The four-digit laser code to set
456 //!
457 //! Sets the laser designation code used for guiding laser-guided munitions.
458 //! This code must match the code set on the munition for proper guidance.
459 virtual void setLaserCode(int val);
460
461 //! \brief Plays a DI-Guy animation action on the entity
462 //! \param diguyAction The name of the DI-Guy action to play
463 //! \param duration The duration of the animation in seconds (0 for default duration)
464 //!
465 //! Sends a VrfTaskAnimationMessage to the entity, instructing it to play the specified
466 //! DI-Guy animation action, such as waving, saluting, or other gestures and movements.
467 virtual void playDiguyAction(const std::string& diguyAction, double duration = 0);
468
469 //! \brief Plays a DI-Guy gesture on the entity
470 //! \param diguyGesture The name of the DI-Guy gesture to play
471 //!
472 //! Sends a VrfTaskGestureMessage to the entity, instructing it to play the specified
473 //! DI-Guy gesture, typically used for facial expressions and minor movements.
474 virtual void playDiguyGesture(const std::string diguyGesture);
475
476 //! \brief Sends a joystick command to a specific entity
477 //! \param id The entity identifier of the target entity
478 //! \param functionGroup The function group of the command
479 //! \param function The specific function to trigger
480 //! \param val The input value for the function
481 //! \param repeat Whether the command should be repeated (default: false)
482 //!
483 //! Sends a joystick command message to the specified entity, allowing
484 //! control of its functions via simulated joystick input.
485 virtual void sendJoystickCommand(const DtEntityIdentifier& id, const std::string& functionGroup,
486 const std::string& function, double val, bool repeat = false);
487
488 //! \brief Sends a joystick command to the controlled entity
489 //! \param functionGroup The function group of the command
490 //! \param function The specific function to trigger
491 //! \param val The input value for the function
492 //! \param repeat Whether the command should be repeated (default: false)
493 //!
494 //! Sends a joystick command message to the entity controlled by this logic component,
495 //! allowing control of its functions via simulated joystick input.
497 const std::string& functionGroup, const std::string& function, double val, bool repeat = false);
498 //! \brief Forwards a joystick command to controlled drones
499 //!
500 //! Helper comment for the sendJoystickCommand methods, indicating that they
501 //! can be used to forward commands to drones being controlled by the entity.
502
503 //! \brief Resets the entity to its initial state
504 //! \param value Input value, typically 1.0 for activation
505 //!
506 //! Resets the entity to its initial state, including position, orientation, and equipment.
507 //! This overrides the base class implementation to handle human-specific reset behavior.
508 virtual void reset(float value) override;
509
510 //! \brief Resets the entity state without changing position
511 //! \param value Input value, typically 1.0 for activation
512 //!
513 //! Resets the entity to its initial state but maintains its current position in the world.
514 //! This is useful for resetting health, equipment, or other attributes without teleporting.
515 virtual void resetInPlace(float value) override;
516
517 //! \brief Updates the DI-Guy hand item based on current state
518 //!
519 //! Updates the item held in the entity's hands based on the current weapon
520 //! or equipment selection. This affects the visual appearance of the entity.
521 virtual void updateDiGuyHandItem();
522
523 //! \brief Zooms in the weapon scope or optics
524 //! \param val Input value, typically 1.0 for activation
525 //!
526 //! Increases the zoom level of the currently equipped weapon's scope or optics,
527 //! providing a closer view of distant targets.
528 void zoomInScope(double val);
529
530 //! \brief Zooms out the weapon scope or optics
531 //! \param val Input value, typically 1.0 for activation
532 //!
533 //! Decreases the zoom level of the currently equipped weapon's scope or optics,
534 //! providing a wider field of view.
535 void zoomOutScope(double val);
536
537 //! \brief Converts a posture string to a HumanPosture enum value
538 //! \param posture String representation of the posture
539 //! \return The corresponding HumanPosture enum value
540 //!
541 //! Converts a string representation of a posture (e.g., "Standing", "Kneeling", "Prone")
542 //! to the corresponding HumanPosture enumeration value.
543 virtual HumanPosture postureFromString(const std::string& posture) const;
544
545 //! \brief Converts a HumanPosture enum value to a string
546 //! \param posture The HumanPosture enum value to convert
547 //! \return String representation of the posture
548 //!
549 //! Converts a HumanPosture enumeration value to its string representation
550 //! (e.g., "Standing", "Kneeling", "Prone").
551 virtual std::string stringForPosture(const HumanPosture posture) const;
552
553protected:
554 //! \brief Checks if the entity is dead
555 //! \return True if the entity is dead, false otherwise
556 //!
557 //! Determines whether the entity is currently dead based on its health value
558 //! and appearance bits. Used to disable certain controls when the entity is dead.
559 bool isDead();
560
561 //! \brief Checks if the player can control the entity
562 //! \return True if the player can control the entity, false otherwise
563 //!
564 //! Determines whether player input should be allowed to control the entity
565 //! based on the current state, such as health, posture, and other conditions.
567
568 //! \brief Checks if the entity is in the air
569 //! \return True if the entity is airborne, false otherwise
570 //!
571 //! Determines whether the entity is currently in the air, such as when
572 //! jumping, falling, or parachuting. Affects available controls and animations.
574
575 //! \brief Checks if the entity is aiming a launcher
576 //! \return True if aiming a launcher, false otherwise
577 //!
578 //! Determines whether the entity is currently carrying a shoulder-mounted
579 //! launcher or using a tripod-mounted launcher. Affects aiming behavior,
580 //! movement restrictions, and available actions.
581 bool isAimingLauncher() const;
582
583 //! \brief Sets whether mouse control is enabled
584 //! \param enabled True to enable mouse control, false to disable it
585 //!
586 //! Overrides the base class implementation to handle additional setup
587 //! related to mouse pitch control for human entities.
588 virtual void setMouseControlEnabled(bool enabled) override;
589
590 //! \brief Handles simulation state messages
591 //! \param msg Pointer to the simulation state message
592 //! \return Message result indicating how the message was handled
593 //!
594 //! Processes messages containing updates to the simulation state,
595 //! such as entity positions, orientations, and other dynamic attributes.
597
598 //! \brief Handles view mode change messages
599 //! \param msg Pointer to the view mode message
600 //! \return Message result indicating how the message was handled
601 //!
602 //! Processes messages that change the view mode, such as switching
603 //! between first-person and third-person perspectives.
605
606 //! \brief Handles application focus update messages
607 //! \param msg Pointer to the focus update message
608 //! \return Message result indicating how the message was handled
609 //!
610 //! Processes messages about application focus changes. Used to disable
611 //! walking when the application loses focus, preventing stuck movement
612 //! when the ALT key release event is missed.
614
615 //! \brief Handles session play state messages
616 //! \param msg Pointer to the session play state message
617 //! \return Message result indicating how the message was handled
618 //!
619 //! Processes messages about changes to the simulation play state
620 //! (running, paused, or stopped) and updates entity controls accordingly.
622
623 //! \brief Handles changes to the current state
624 //! \param state The new state string
625 //!
626 //! Called when the current state changes. Provides faster response
627 //! than waiting for a message-based notification (see VRE-2775).
628 //! Updates controls based on the new state.
629 virtual void onCurrentStateChanged(std::string state);
630
631 //! \brief Handles changes to the launcher element ID
632 //! \param launcherId The new launcher element ID
633 //!
634 //! Called when the "launcherElementId" attribute changes. Calls setupExternalLauncher
635 //! when a valid launcher ID is set, or teardownExternalLauncher when the ID is cleared.
636 //! This enables or disables launcher-specific functionality and UI elements.
637 virtual void onLauncherIdChanged(makVrv::DtElementID launcherId);
638
639 //! \brief Determines posture from appearance bits
640 //! \param entityType The entity type
641 //! \param appearanceBits The appearance bits from the entity
642 //! \return The human posture derived from appearance bits
643 //!
644 //! Extracts the current posture (standing, kneeling, prone) from the
645 //! entity's appearance bits, which encode visual state information.
646 virtual HumanPosture getPostureFromAppearance(const DtEntityType& entityType, unsigned int appearanceBits);
647
648 //! \brief Gets the currently equipped item
649 //! \return The currently active equipment type
650 //!
651 //! Determines what equipment the entity is currently using, such as
652 //! binoculars, NVGs, or weapons, based on attribute values.
654
655 //! \brief Gets the entity's health from appearance bits
656 //! \return Health value between 0.0 (dead) and 1.0 (full health)
657 //!
658 //! Extracts the current health value from the entity's appearance bits,
659 //! which include damage and injury state information.
660 virtual double getHealthFromAppearance();
661
662 //! \brief Initializes the posture-to-string mapping tables
663 //!
664 //! Sets up bidirectional mappings between HumanPosture enum values and
665 //! their string representations. Called during initialization.
666 virtual void initPostureStringMaps();
667
668 //! \brief Maps a posture enum to a string representation
669 //! \param posture The HumanPosture enum value to map
670 //! \param postureString The string representation to associate with the posture
671 //!
672 //! Adds an entry to the bidirectional mapping tables between posture
673 //! enum values and their string representations.
674 virtual void mapPostureToString(const HumanPosture posture, const std::string& postureString);
675
676 //! \brief Fires the currently equipped gun
677 //!
678 //! Handles the logic for firing a gun-type weapon, including ammunition
679 //! tracking, recoil effects, and sending the appropriate messages to the
680 //! simulation to create projectiles and effects.
681 virtual void fireGun();
682
683 //! \brief Fires the currently equipped launcher
684 //!
685 //! Handles the logic for firing a launcher-type weapon, such as rocket
686 //! launchers or missile systems, including tracking ammunition and
687 //! sending the appropriate messages to the simulation.
688 virtual void fireLauncher();
689
690 //! \brief Throws a grenade
691 //!
692 //! Handles the logic for throwing a grenade, including tracking inventory,
693 //! animation timing, and sending the appropriate messages to the simulation
694 //! to create the grenade entity.
695 virtual void throwGrenade();
696
697 //! \brief Sets up an external launcher
698 //!
699 //! Configures the control logic for using an external launcher, such as a
700 //! tripod-mounted weapon system. Sets up appropriate UI elements, control
701 //! mappings, and attribute listeners.
702 virtual void setupExternalLauncher();
703
704 //! \brief Tears down an external launcher
705 //!
706 //! Removes the configuration for an external launcher when the entity stops
707 //! using it. Cleans up UI elements, control mappings, and attribute listeners.
709
710 //! \brief Starts laser designation
711 //!
712 //! Activates the laser designator for targeting laser-guided munitions.
713 //! Sets up the necessary attributes and tracking for the laser spot.
714 virtual void startLasing();
715
716 //! \brief Updates the laser designation state
717 //!
718 //! Updates the position and state of the active laser designation spot.
719 //! Called periodically when laser designation is active.
720 virtual void updateLasingState();
721
722 //! \brief Stops laser designation
723 //!
724 //! Deactivates the laser designator and cleans up associated resources.
725 //! Removes the laser spot from the simulation.
726 virtual void stopLasing();
727
728 //! \brief Disables certain features while parachuting
729 //!
730 //! Disables features and controls that should not be available while
731 //! the entity is using a parachute, such as weapon handling or posture changes.
733
734 //! \brief Updates the weapon ready state
735 //!
736 //! Updates the state of the currently equipped weapon based on entity
737 //! attributes and conditions. Determines whether the weapon should be
738 //! ready for use or put away.
739 virtual void updateWeaponReady();
740
741 //! \brief Computes the current aiming error
742 //!
743 //! Calculates the current aiming error based on factors like posture,
744 //! movement, fatigue, and weapon type. This error affects weapon accuracy
745 //! and is used to scale the reticle in the human overlay. Must be updated
746 //! every frame for accurate visual feedback.
747 virtual void computeAimingError();
748
749 //! \brief Adds a random offset to the input aim orientation
750 //! \param aimingOrientation The aiming orientation to which the error is added
751 //!
752 //! Takes an aim orientation from the player and adds a random degree of offset
753 //! between myRequiredAimingErrorPercent and the max error determined by
754 //! computeAimingError().
755 virtual void addRandomAimingError(DtTaitBryan& aimingOrientation);
756
757 //! \brief Determines if movement should be allowed
758 //! \return True if movement should be allowed, false otherwise
759 //!
760 //! Checks various conditions to determine if the entity should be
761 //! allowed to move, such as health, posture restrictions, and current actions.
762 virtual bool shouldAllowMovement();
763
764 //! \brief Returns the velocity of the player ownship entity
765 //!
766 //! Velocity is relative to the host if embarked, otherwise i
767 DtVector32 walkingVelocity();
768
769 //! \brief Updates the move lock state
770 //!
771 //! Updates the move lock state based on current posture and conditions.
772 //! Move lock prevents the entity from moving in certain situations.
774
775 //! \brief Checks if the entity is currently moving
776 //! \return True if the entity is moving, false otherwise
777 //!
778 //! Determines whether the entity is currently in motion based on
779 //! movement inputs and velocity.
780 bool isMoving();
781
782 //! \brief Initializes the weapon index
783 //!
784 //! Sets up the initial weapon index based on the entity's configuration
785 //! and available weapons. Called during initialization.
787
788 //! \brief Sets the weapon stowed state
789 //! \param stowed True to stow the weapon, false otherwise
790 //!
791 //! Updates the weapon stowed state and related attributes.
792 //! A stowed weapon is put away completely (e.g., on the back).
793 void setWeaponStowed(bool stowed);
794
795 //! \brief Sets the weapon down state
796 //! \param down True to put the weapon down, false to bring it up
797 //!
798 //! Updates the weapon down state and related attributes.
799 //! A down weapon is lowered but still in hand (e.g., at low ready).
800 void setWeaponDown(bool down);
801
802 //! \brief Sets the weapon state directly
803 //! \param state The weapon state value to set
804 //!
805 //! Sets the weapon state directly to a specific value, bypassing
806 //! the individual stowed/down state setters.
807 void setWeaponState(int state);
808
809 //! \brief Gets the current ammunition count
810 //! \return The current ammunition count for the active weapon
811 //!
812 //! Retrieves the current ammunition count for the active weapon
813 //! from the appropriate attribute.
815
816 //! \brief Sets the gaze pitch attribute
817 //! \param pitch The pitch angle in degrees
818 //!
819 //! Updates the gazePitch attribute, which controls the up/down
820 //! orientation of the entity's head for looking.
821 void setGazePitch(double pitch);
822
823 //! \brief Sets the gaze yaw attribute
824 //! \param yaw The yaw angle in degrees
825 //!
826 //! Updates the gazeYaw attribute, which controls the left/right
827 //! orientation of the entity's head for looking.
828 void setGazeYaw(double yaw);
829
830 //! \brief Checks if third-person view is allowed
831 //! \return True if third-person view is allowed, false otherwise
832 //!
833 //! Determines if the entity is allowed to switch to third-person view
834 //! based on configuration settings in human.lua.
835 virtual bool thirdPersonAllowed();
836
837 // Commented out callback methods preserved for reference
838 // void onDiguyItemChanged(std::string);
839 // void onCanSwitchWeaponsChanged(bool);
840
841 //! \brief Handles changes to the weapon list
842 //! \param weaponList Vector of weapon names available to the entity
843 //!
844 //! Called when the list of available weapons changes. Updates the
845 //! weapon selection UI and related controls.
846 void onWeaponListChanged(const DtAttributeHandle& weaponList);
847
848 //! \brief Handles changes to the ammunition count
849 //! \param weaponResourceHandle The new ammunition count
850 //!
851 //! Called when the ammunition count for the current weapon changes.
852 //! Updates UI elements and manages weapon state if out of ammunition.
853 void onAmmoCountChanged(const DtAttributeHandle& weaponResourceHandle);
854
855 //! \brief Current ammunition resource attribute name
856 //!
857 //! Stores the name of the attribute currently being monitored for ammunition count.
860
861 //! \brief Handles changes to the sprinting state
862 //! \param sprinting True if the entity is sprinting, false otherwise
863 //!
864 //! Called when the sprinting state changes. Updates movement speed
865 //! modifiers and related attributes.
866 void onSprintingChanged(bool sprinting);
867
868 //! \brief Handles changes to the backward movement state
869 //! \param movingBackward True if the entity is moving backward, false otherwise
870 //!
871 //! Called when the backward movement state changes. Updates movement
872 //! speed modifiers and other movement-related attributes.
873 void onMovingBackwardChanged(bool movingBackward);
874
875 //! \brief Handles changes to the walking state
876 //! \param walking True if the entity is walking (vs running), false otherwise
877 //!
878 //! Called when the walking state changes. Updates movement speed
879 //! modifiers and related attributes.
880 void onWalkingChanged(bool walking);
881
882 //! \brief Handles changes to the aiming state
883 //! \param aiming True if the entity is aiming, false otherwise
884 //!
885 //! Called when the aiming state changes. Updates movement restrictions,
886 //! accuracy modifiers, and weapon handling attributes.
887 void onAimingChanged(bool aiming);
888
889 //! \brief Handles changes to the weapon index
890 //! \param weaponIndex The new weapon index
891 //!
892 //! Called when the selected weapon changes. Updates UI elements,
893 //! ammunition tracking, and weapon-related attributes.
894 void onWeaponIndexChanged(int weaponIndex);
895
896 //! \brief Handles changes to the posture
897 //! \param posture The new posture
898 //!
899 //! Called when the entity's posture changes. Updates movement restrictions,
900 //! accuracy modifiers, and other posture-dependent attributes.
902
903 //! \brief Handles changes to the movement capability
904 //! \param canMove True if the entity can move, false otherwise
905 //!
906 //! Called when the entity's ability to move changes. Updates movement
907 //! controls and related UI elements.
908 void onCanMoveChanged(bool canMove);
909
910 //! \brief Handles changes to the health
911 //! \param health The new health value
912 //!
913 //! Called when the entity's health changes. Updates UI elements,
914 //! movement capabilities, and other health-dependent attributes.
915 void onHealthChanged(double health);
916
917 //! \brief Handles changes to the active equipment
918 //! \param equipment The new active equipment
919 //!
920 //! Called when the entity's active equipment changes. Updates UI elements,
921 //! control modes, and equipment-dependent attributes.
923
924 //! \brief Handles changes to the binoculars state
925 //! \param usingBinoculars True if binoculars are in use, false otherwise
926 //!
927 //! Called when the entity's binoculars usage state changes. Updates
928 //! view settings, input sensitivity, and related UI elements.
929 void onBinocularsChanged(bool usingBinoculars);
930
931 //! \brief Handles changes to the forward controls state
932 //! \param forwardControls True if forward controls are enabled, false otherwise
933 //!
934 //! Called when the entity's forward controls state changes. Updates
935 //! control mappings and related UI elements.
936 void onForwardControlsChanged(bool forwardControls);
937
938 //! \brief Handles changes to the weapon state
939 //! \param weaponState The new weapon state
940 //!
941 //! Called when the entity's weapon state changes (ready, down, stowed).
942 //! Updates UI elements, control modes, and weapon-dependent attributes.
943 void onWeaponStateChanged(int weaponState);
944
945 //! \brief Handles changes to the DI-Guy action
946 //! \param action The new DI-Guy action name
947 //!
948 //! Called when the entity's DI-Guy animation action changes. Updates
949 //! control restrictions and other animation-dependent attributes.
950 void onDiGuyActionChanged(std::string action);
951
952 //! \brief Shows a QML overlay by name
953 //! \param name Name of the QML overlay to show
954 //!
955 //! Activates and displays a named QML overlay, such as a weapon scope
956 //! or other specialized UI element.
957 void showQmlOverlay(const std::string& name);
958
959 //! \brief Determines if gaze should be enabled
960 //! \param pitch True to check pitch gaze, false to check yaw gaze
961 //! \return True if gaze should be enabled, false otherwise
962 //!
963 //! Returns whether pitch/yaw gaze should be enabled according to the entity state
964 //! (e.g. weapon/launcher state, freelook/climbing enabled state, spectator observer attach mode).
965 bool shouldEnableGaze(bool pitch) const;
966
967 //! \brief Handles gaze input and updates attributes
968 //! \param pitch True to handle pitch gaze, false to handle yaw gaze
969 //! \return True if gaze is enabled and input handled, false otherwise
970 //!
971 //! Checks if gaze should be enabled and sets the useGazePitch/Yaw attribute accordingly.
972 //! Returns whether the gaze input was handled.
974
975 //! \brief Handles changes to the firepower health
976 //! \param newFirepowerHealthValue The new firepower health value
977 //!
978 //! Called when the entity's firepower health changes. This affects
979 //! aiming accuracy and weapon handling capabilities.
980 virtual void firepowerHealthChangeCallback(int newFirepowerHealthValue);
981
982 //! \brief Handles changes to the fatigue level
983 //! \param newFatigueValue The new fatigue value
984 //!
985 //! Called when the entity's fatigue level changes. This affects
986 //! movement speed, aiming accuracy, and other performance attributes.
987 virtual void fatigueChangeCallback(float newFatigueValue);
988
989 //! \brief Handles changes to the percent of max speed
990 //! \param newPercentOfMaxSpeedValue The new percent of max speed value
991 //!
992 //! Called when the entity's percent of maximum speed changes. This affects
993 //! movement capabilities and is modified by fatigue and other factors.
994 virtual void percentOfMaxSpeedChangeCallback(float newPercentOfMaxSpeedValue);
995
996protected:
997 //! \brief Weapon resource logic component
998 //!
999 //! Manages weapon resources such as ammunition and available weapons.
1001
1003
1004 //! \brief Pointer to the associated observer
1005 //!
1006 //! Provides access to view-related functionality for the entity.
1007 makVrv::DtObserver* myObserver;
1008
1009 //! \brief Human input logic component
1010 //!
1011 //! Handles input processing specific to human entities.
1013
1014 //! \brief Flag for inverting pitch input
1015 //!
1016 //! When true, pitch input is inverted (up becomes down and vice versa).
1018
1019 //! \brief Multiplier for sprint movement speed
1020 //!
1021 //! Scales forward movement speed when sprinting forward.
1023
1024 //! \brief Multiplier for backward sprint movement speed
1025 //!
1026 //! Scales backward movement speed when sprinting backward.
1028
1029 //! \brief Multiplier for running movement speed
1030 //!
1031 //! Scales movement speed when running (the default movement mode).
1033
1034 //! \brief Multiplier for walking movement speed
1035 //!
1036 //! Scales movement speed when in walking mode (slower than running).
1038
1039 //! \brief Multiplier for aiming movement speed
1040 //!
1041 //! Scales movement speed when aiming a weapon (typically slower).
1043
1044 //! \brief Last forward/backward movement input value
1045 //!
1046 //! Stores the most recent forward/backward movement input value.
1048
1049 //! \brief Last left/right strafe input value
1050 //!
1051 //! Stores the most recent left/right strafe input value.
1053
1054 //! \brief Map from posture enum to string representation
1055 //!
1056 //! Bidirectional mapping between posture enum values and their string representations.
1057 std::map<HumanPosture, std::string> myPostureToString;
1058
1059 //! \brief Map from string representation to posture enum
1060 //!
1061 //! Bidirectional mapping between string representations and posture enum values.
1062 std::map<std::string, HumanPosture> myStringToPosture;
1063
1064 //! \brief Sequence of postures for cycling
1065 //!
1066 //! Defines the order in which postures are cycled through when using posture cycling commands.
1067 std::vector<HumanPosture> myPostureSequence;
1068
1069 //! \brief Map from posture to sequence index
1070 //!
1071 //! Maps each posture to its index in the posture sequence for quick lookup.
1072 std::map<HumanPosture, int> myPostureSequenceIndex;
1073
1074 //! \brief Structure defining restrictions for each posture
1076 {
1077 //! \brief Default constructor initializing all restrictions to false
1079 : moveLocked(false)
1080 , weaponLocked(false)
1081 , weaponLockedWhenMoving(false)
1082 {
1083 }
1084
1085 //! \brief Whether movement is locked in this posture
1087
1088 //! \brief Whether weapon use is locked in this posture
1090
1091 //! \brief Whether weapon use is locked while moving in this posture
1093 };
1094
1095 //! \brief Map of posture restrictions for each posture
1096 //!
1097 //! Defines movement and weapon usage restrictions for each posture type.
1098 std::map<HumanPosture, PostureRestrictions> myPostureRestrictions;
1099
1100 //! \brief Map of animation transition timing for each posture
1101 //!
1102 //! Stores the delay times (in seconds) for transitioning into and out of each posture.
1103 //! The first value is the delay when transitioning into the posture,
1104 //! and the second value is the delay when transitioning out of the posture.
1105 std::map<HumanPosture, std::pair<double /* delay into */, double /* out of */>> myPostureAnimationWaitTimes;
1106
1107 //! \brief Last posture transition direction
1108 //!
1109 //! Stores the direction of the last posture transition (up or down).
1111
1112 //! \brief Expected posture after transition completes
1113 //!
1114 //! The posture that the entity is transitioning to or expected to reach.
1116
1117 //! \brief Desired posture requested by user input
1118 //!
1119 //! The posture that was requested through user input, which may differ
1120 //! from the expected posture during transitions.
1122
1123 //! \brief Last stable posture
1124 //!
1125 //! The last fully-established posture before any current transition.
1127
1128 //! \brief Timeout for posture command processing
1129 //!
1130 //! Time remaining (in seconds) before a posture command expires if not completed.
1132
1133 //! \brief Posture animation wait timer
1134 //!
1135 //! Time remaining (in seconds) to wait for the current posture animation to complete.
1137
1138 //! \brief Timed move lock time remaining
1139 //!
1140 //! Time in seconds remaining in temporary movement lockout.
1141 double myMoveLockTimer = 0.0;
1142
1143 //! \brief Move lock active flag
1144 //!
1145 //! Indicates whether movement is currently locked due to posture constraints
1146 //! or other restrictions.
1148
1149 //! \brief Target weapon state to transition to
1150 //!
1151 //! The weapon state that the entity is transitioning to after any delays.
1153
1154 //! \brief Flag indicating grenade throw request
1155 //!
1156 //! When true, indicates that a grenade throw has been requested and is pending.
1158
1159 //! \brief Timer for delayed weapon state changes
1160 //!
1161 //! Time remaining (in seconds) before a delayed weapon state change occurs.
1163
1164 //! \brief Joystick input sensitivity multiplier
1165 //!
1166 //! Controls the sensitivity of joystick inputs for movement and aiming.
1168
1169 //! \brief Current fatigue level
1170 //!
1171 //! Stores the current fatigue value, which affects aiming accuracy and movement speed.
1172 //! Higher values indicate greater fatigue and worse performance.
1174
1175 //! \brief Current firepower health value
1176 //!
1177 //! Stores the current firepower health value, which affects aiming accuracy.
1178 //! Lower values indicate degraded weapon handling capability.
1180
1181 //! \brief Current percentage of maximum movement speed
1182 //!
1183 //! Represents the current percentage of maximum speed available to the entity.
1184 //! Decreases as fatigue increases, limiting maximum movement speed.
1186
1187 //! \brief Maximum aiming error in radians
1188 //!
1189 //! The maximum half-angle of aiming error in radians. This is typically negative
1190 //! to produce the full spread of possible aiming error.
1192
1193 //! \brief Current aiming error as a percentage of maximum
1194 //!
1195 //! The current aiming error expressed as a percentage of the maximum possible error.
1196 //! Affected by posture, movement, fatigue, and other factors.
1198
1199 //! \brief Minimum required aiming error percentage
1200 //!
1201 //! The minimum error percentage that is always applied to ensure some spread
1202 //! in shots, preventing unrealistically perfect accuracy.
1204
1205 //! \brief Aiming improvement percentage in prone position
1206 //!
1207 //! The percentage by which aiming accuracy improves when in the prone position.
1208 //! This reduces the effective aiming error.
1210
1211 //! \brief Aiming improvement percentage when aiming
1212 //!
1213 //! The percentage by which aiming accuracy improves when using the weapon's
1214 //! aiming capability (e.g., iron sights, optics).
1216
1217 //! \brief Current entity heading in degrees
1218 //!
1219 //! The current heading (yaw) angle of the entity in world space, in degrees.
1221
1222 //! \brief Current entity pitch in degrees
1223 //!
1224 //! The current pitch angle of the entity in world space, in degrees.
1226
1227 //! \brief Yaw rate in degrees per second
1228 //!
1229 //! The rate at which the entity's yaw angle changes when turning, in degrees per second.
1231
1232 //! \brief Pitch rate in degrees per second
1233 //!
1234 //! The rate at which the entity's pitch angle changes when looking up/down, in degrees per second.
1236
1237 //! \brief Turning rate modifier
1238 //!
1239 //! A modifier applied to the turning rate under various conditions.
1241
1242 //! \brief Current input-driven yaw offset
1243 //!
1244 //! The current yaw offset resulting from user input, relative to the entity's base orientation.
1245 double myYaw;
1246
1247 //! \brief Current input-driven pitch offset
1248 //!
1249 //! The current pitch offset resulting from user input, relative to the entity's base orientation.
1250 double myPitch;
1251
1252 //! \brief Flag indicating heading initialization
1253 //!
1254 //! When true, indicates that the entity's heading has been initialized.
1256
1257 //! \brief Flag to force orientation update
1258 //!
1259 //! When true, forces an update to the entity's orientation even if other conditions
1260 //! would normally prevent it. Temporary solution for VR input (VRE-3178).
1262
1263 //! \brief Flag for sending gaze angles
1264 //!
1265 //! When true, enables sending of gaze angle updates to the entity.
1267
1268 //! \brief Flag for two-stage fire mode
1269 //!
1270 //! When true, indicates that the current weapon uses a two-stage firing process,
1271 //! such as missile launchers with target lock before firing.
1273
1274 //! \brief Current laser designation target location
1275 //!
1276 //! The world position of the current laser designation target point.
1278
1279 //! \brief Input sensitivity multiplier when using binoculars
1280 //!
1281 //! Scales joystick and mouse pitch/yaw inputs while using binoculars.
1282 //! Corresponds to lua configuration variable "binocularsInputMultiplier".
1283 //! Defaults to 0.5 to provide finer control while using binoculars.
1285
1286 //! \brief Cached observer attach mode before menu state
1287 //!
1288 //! Stores the observer attach mode at the time we enter the menu state.
1289 //! Used to restore the observer attach mode upon exiting menu state
1290 //! (while in the menu state, we force third person mode).
1292
1293 //! \brief Cached compass visibility state before menu state
1294 //!
1295 //! Stores whether the compass was visible at the time we enter the menu state.
1296 //! Used to restore the compass visibility when exiting the menu state.
1298
1299 //! \brief Currently active scope overlay
1300 //!
1301 //! The DtQtQuickOverlay scope currently in use. It may or may not be null
1302 //! over the lifetime of a player. For example, with shoulder mounted launchers,
1303 //! there may be a valid pointer when the launcher is raised, but once lowered,
1304 //! the pointer will be set to null again.
1306};
1307} // namespace makVre
Scoped attribute change callback wrapper.
Definition attributeCallback.h:86
Handle class for safe access to attributes.
Definition attributeHandle.h:30
Type-specific handle class for attributes.
Definition attributeHandle.h:181
DtEntityControlLogic()
Constructor.
bool myInvertPitch
Flag for inverting pitch input.
Definition humanControlLogic.h:1017
virtual void fireGun()
Fires the currently equipped gun.
enum DtCompassUnits { DEGREES=0, NATO_MIL } DtCompassUnits
Enumeration of compass unit types.
Definition humanControlLogic.h:150
virtual void playDiguyGesture(const std::string diguyGesture)
Plays a DI-Guy gesture on the entity.
virtual void nextWeapon(double val)
Selects the next weapon in the inventory.
double myJoystickSensitivity
Joystick input sensitivity multiplier.
Definition humanControlLogic.h:1167
std::map< std::string, HumanPosture > myStringToPosture
Map from string representation to posture enum.
Definition humanControlLogic.h:1062
virtual void setCurrentPitch(double pitch)
Sets the current pitch angle for VR input.
virtual void teardownExternalLauncher()
Tears down an external launcher.
double myPostureCommandTimeout
Timeout for posture command processing.
Definition humanControlLogic.h:1131
enum DtPostureTransition { POSTURE_UP, POSTURE_DOWN } DtPostureTransition
Enumeration of posture transition directions.
Definition humanControlLogic.h:144
virtual HumanPosture desiredPosture() const
Gets the desired posture for the human entity.
virtual void stopLasing()
Stops laser designation.
void zoomInScope(double val)
Zooms in the weapon scope or optics.
void onWeaponIndexChanged(int weaponIndex)
Handles changes to the weapon index.
virtual void updateDiGuyHandItem()
Updates the DI-Guy hand item based on current state.
virtual void weaponStow(bool stow)
Stows the current weapon.
float myFatigue
Current fatigue level.
Definition humanControlLogic.h:1173
virtual void flashlightPitchUp(double val)
Adjusts flashlight pitch upward.
DtPostureTransition myLastPostureTransition
Last posture transition direction.
Definition humanControlLogic.h:1110
virtual void setCurrentHeading(double yaw)
Sets the current heading angle for VR input.
virtual makVre::DtVreMessageResult handleSessionPlayState(makVre::DtVreMessage *msg)
Handles session play state messages.
virtual void toggleFlashlight(double val)
Toggles flashlight on/off.
virtual std::string stringForPosture(const HumanPosture posture) const
Converts a HumanPosture enum value to a string.
virtual void walk(double val)
Activates walk movement.
double myLastMoveValue
Last forward/backward movement input value.
Definition humanControlLogic.h:1047
virtual void freeLook(double val)
Toggles free look mode.
bool myMoveLockActive
Move lock active flag.
Definition humanControlLogic.h:1147
bool mySendGazeAngles
Flag for sending gaze angles.
Definition humanControlLogic.h:1266
virtual void firstStageTrigger(double val)
Handles first stage trigger input for weapons.
virtual void selectWeapon(int index)
Selects a specific weapon by index.
virtual void kneel(double val)
Transitions to kneeling posture.
virtual Equipment getCurrentEquipment()
Gets the currently equipped item.
double myYaw
Current input-driven yaw offset.
Definition humanControlLogic.h:1245
DtAttributeHandleType< std::vector< std::string > > myWeaponList
Definition humanControlLogic.h:1002
virtual void reload(double val)
Initiates weapon reload.
void onAmmoCountChanged(const DtAttributeHandle &weaponResourceHandle)
Handles changes to the ammunition count.
virtual void weaponUp()
Brings the weapon to ready position.
int myEventualWeaponState
Target weapon state to transition to.
Definition humanControlLogic.h:1152
virtual HumanPosture getPostureFromAppearance(const DtEntityType &entityType, unsigned int appearanceBits)
Determines posture from appearance bits.
virtual void toggleNVG(double val)
Toggles night vision goggles.
void onWalkingChanged(bool walking)
Handles changes to the walking state.
virtual void parachuteRightToggle(double val)
Toggles the right parachute control line.
virtual void strafe(double val)
Handles left/right movement input.
virtual void toggleCompassUnits(double val)
Toggles between compass unit types.
virtual void shutdown() override
Cleans up resources when the component is being shut down.
virtual makVre::DtVreMessageResult handleSimState(makVre::DtVreMessage *msg) override
Handles simulation state messages.
DtHumanInputLogic * myHumanInputLogic
Human input logic component.
Definition humanControlLogic.h:1012
virtual void updateWeaponReady()
Updates the weapon ready state.
double mySprintBackwardMultiplier
Multiplier for backward sprint movement speed.
Definition humanControlLogic.h:1027
void onWeaponStateChanged(int weaponState)
Handles changes to the weapon state.
std::map< HumanPosture, std::pair< double, double > > myPostureAnimationWaitTimes
Map of animation transition timing for each posture.
Definition humanControlLogic.h:1105
void onSprintingChanged(bool sprinting)
Handles changes to the sprinting state.
virtual void zoomInToggleBinoculars(double val)
Zooms in binoculars or toggles binoculars if not active.
virtual void flashlightPitchDown(double val)
Adjusts flashlight pitch downward.
bool isAimingLauncher() const
Checks if the entity is aiming a launcher.
virtual void toggleHUD(double val)
Toggles HUD visibility.
DtVector myLasingLocation
Current laser designation target location.
Definition humanControlLogic.h:1277
bool isDead()
Checks if the entity is dead.
virtual void toggleMissileAttackMode(double val)
virtual void setObserverAttachMode(ObserverAttachMode mode)
Sets the observer attachment mode directly.
double getCurrentAmmo()
Gets the current ammunition count.
void addMoveLockTime(double seconds)
Add time to a temporary movement lockout.
bool isMoving()
Checks if the entity is currently moving.
bool myInitializedHeading
Flag indicating heading initialization.
Definition humanControlLogic.h:1255
virtual void simulatePitch(double dt)
Simulates pitch movement over time.
virtual void flashlightYawLeft(double val)
Adjusts flashlight yaw leftward.
void zoomOutScope(double val)
Zooms out the weapon scope or optics.
void setWeaponStowed(bool stowed)
Sets the weapon stowed state.
double myMoveLockTimer
Timed move lock time remaining.
Definition humanControlLogic.h:1141
virtual void resetInPlace(float value) override
Resets the entity state without changing position.
bool isAirborne()
Checks if the entity is in the air.
void onBinocularsChanged(bool usingBinoculars)
Handles changes to the binoculars state.
virtual void postureDown(double val)
Transitions to a more prone posture.
bool myForceOrientationUpdate
Flag to force orientation update.
Definition humanControlLogic.h:1261
HumanPosture myDesiredPosture
Desired posture requested by user input.
Definition humanControlLogic.h:1121
HumanPosture myExpectedPosture
Expected posture after transition completes.
Definition humanControlLogic.h:1115
double myCurrentPitch
Current entity pitch in degrees.
Definition humanControlLogic.h:1225
virtual void yaw(double val, bool mouseInput=false)
Handles yaw (left/right looking) input.
virtual void gazeYaw()
Turns the entity's head to look left/right.
virtual void setPitch(double pitch)
Sets the pitch angle directly.
virtual void toggleWeaponDown(double val)
Toggles weapon down state.
double myLastStrafeValue
Last left/right strafe input value.
Definition humanControlLogic.h:1052
virtual void cycleWeaponState(double val)
Cycles through weapon states (ready, down, stowed)
void onHealthChanged(double health)
Handles changes to the health.
DtAttributeChangeCallback myCurrentAmmoResourceAttributeCallback
Definition humanControlLogic.h:859
virtual bool thirdPersonAllowed()
Checks if third-person view is allowed.
double mySprintMultiplier
Multiplier for sprint movement speed.
Definition humanControlLogic.h:1022
virtual void reset(float value) override
Forwards a joystick command to controlled drones.
double myTurningRate
Turning rate modifier.
Definition humanControlLogic.h:1240
virtual bool shouldAllowMovement()
Determines if movement should be allowed.
DtQtQuickOverlay * myActiveScopeOverlay
Currently active scope overlay.
Definition humanControlLogic.h:1305
virtual void parachuteDeploy(double val)
Deploys the parachute.
std::vector< HumanPosture > myPostureSequence
Sequence of postures for cycling.
Definition humanControlLogic.h:1067
virtual void playDiguyAction(const std::string &diguyAction, double duration=0)
Plays a DI-Guy animation action on the entity.
double myRunMultiplier
Multiplier for running movement speed.
Definition humanControlLogic.h:1032
void setGazePitch(double pitch)
Sets the gaze pitch attribute.
double myPitchingRate
Pitch rate in degrees per second.
Definition humanControlLogic.h:1235
double myPostureAnimationWait
Posture animation wait timer.
Definition humanControlLogic.h:1136
virtual void mapPostureToString(const HumanPosture posture, const std::string &postureString)
Maps a posture enum to a string representation.
DtVector32 walkingVelocity()
Returns the velocity of the player ownship entity.
virtual void toggleWeaponStowed(double val)
Toggles weapon stowed state.
virtual void fire(double val)
Fires the current weapon.
virtual void gazePitch()
Turns the entity's head to look up/down.
void setWeaponState(int state)
Sets the weapon state directly.
bool myTwoStageFire
Flag for two-stage fire mode.
Definition humanControlLogic.h:1272
virtual const char * type() const override
Returns the component type identifier.
makVrv::DtObserver * myObserver
Pointer to the associated observer.
Definition humanControlLogic.h:1007
virtual void setYaw(double yaw)
Sets the yaw angle directly.
DtWeaponResourceLogic * myWeaponResourceLogic
Weapon resource logic component.
Definition humanControlLogic.h:1000
virtual void onCurrentStateChanged(std::string state)
Handles changes to the current state.
virtual void postureUp(double val)
Transitions to a more upright posture.
double myPitch
Current input-driven pitch offset.
Definition humanControlLogic.h:1250
virtual void standUp(double val)
Transitions to standing posture.
virtual void weaponCycleOrDown(bool press)
Cycles through weapons or puts current weapon down.
double myProneAimingImprovementPercent
Aiming improvement percentage in prone position.
Definition humanControlLogic.h:1209
virtual void zoomOutToggleBinoculars(double val)
Zooms out binoculars or toggles binoculars if not active.
virtual void toggleObserverAttachMode(double val)
Toggles the observer attachment mode.
virtual void toggleCompass(double val)
Toggles the compass display.
virtual void initPostureStringMaps()
Initializes the posture-to-string mapping tables.
double myUsingBinocularsInputMultiplier
Input sensitivity multiplier when using binoculars.
Definition humanControlLogic.h:1284
virtual void flashlightYawRight(double val)
Adjusts flashlight yaw rightward.
DtAttributeHandle myCurrentResourceHandle
Current ammunition resource attribute name.
Definition humanControlLogic.h:858
bool myWantThrowGrenade
Flag indicating grenade throw request.
Definition humanControlLogic.h:1157
virtual makVre::DtVreMessageResult handleViewModeMessage(makVre::DtVreMessage *msg)
Handles view mode change messages.
HumanPosture myLastPosture
Last stable posture.
Definition humanControlLogic.h:1126
double myDelayedToggleWeaponDownTimer
Timer for delayed weapon state changes.
Definition humanControlLogic.h:1162
void onAimingChanged(bool aiming)
Handles changes to the aiming state.
virtual void computeAimingError()
Computes the current aiming error.
virtual void updateLasingState()
Updates the laser designation state.
std::map< HumanPosture, std::string > myPostureToString
Map from posture enum to string representation.
Definition humanControlLogic.h:1057
DtHumanControlLogic()
Default constructor.
virtual void fatigueChangeCallback(float newFatigueValue)
Handles changes to the fatigue level.
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the human control logic.
void initWeaponIndex()
Initializes the weapon index.
int myFirepowerHealth
Current firepower health value.
Definition humanControlLogic.h:1179
void setGazeYaw(double yaw)
Sets the gaze yaw attribute.
double myAimMultiplier
Multiplier for aiming movement speed.
Definition humanControlLogic.h:1042
virtual void aim(double val)
Handles aim input.
std::map< HumanPosture, int > myPostureSequenceIndex
Map from posture to sequence index.
Definition humanControlLogic.h:1072
virtual void setCompassUnits(enum DtCompassUnits units)
Sets the compass units directly.
virtual void addRandomAimingError(DtTaitBryan &aimingOrientation)
Adds a random offset to the input aim orientation.
virtual void postureSelect(double val)
Selects a posture based on the current state.
std::map< HumanPosture, PostureRestrictions > myPostureRestrictions
Map of posture restrictions for each posture.
Definition humanControlLogic.h:1098
virtual void setLaserCode(int val)
Sets the laser designation code.
bool myCachedShowCompass
Cached compass visibility state before menu state.
Definition humanControlLogic.h:1297
virtual void fireLauncher()
Fires the currently equipped launcher.
virtual double getHealthFromAppearance()
Gets the entity's health from appearance bits.
virtual void pitch(double val, bool mouseInput=false)
Handles pitch (up/down looking) input.
double myRequiredAimingErrorPercent
Minimum required aiming error percentage.
Definition humanControlLogic.h:1203
void showQmlOverlay(const std::string &name)
Shows a QML overlay by name.
virtual void weaponDown()
Puts the weapon in down position.
virtual void sendJoystickCommand(const std::string &functionGroup, const std::string &function, double val, bool repeat=false)
Sends a joystick command to the controlled entity.
virtual void setPosture(double val, HumanPosture posture, DtPostureTransition postureTransition)
Sets the entity posture.
void onMovingBackwardChanged(bool movingBackward)
Handles changes to the backward movement state.
double myYawRate
Yaw rate in degrees per second.
Definition humanControlLogic.h:1230
virtual void firepowerHealthChangeCallback(int newFirepowerHealthValue)
Handles changes to the firepower health.
ObserverAttachMode myCachedObserverAttachMode
Cached observer attach mode before menu state.
Definition humanControlLogic.h:1291
double myMaxAimingError
Maximum aiming error in radians.
Definition humanControlLogic.h:1191
void updateMoveLock()
Updates the move lock state.
virtual void setMouseControlEnabled(bool enabled) override
Sets whether mouse control is enabled.
virtual HumanPosture postureFromString(const std::string &posture) const
Converts a posture string to a HumanPosture enum value.
virtual void sprint(double val)
Activates sprint movement.
float myPercentOfMaxSpeed
Current percentage of maximum movement speed.
Definition humanControlLogic.h:1185
bool shouldEnableGaze(bool pitch) const
Determines if gaze should be enabled.
void setMoveLockTime(double seconds)
Set a temporary movement lockout.
double myAimingImprovementPercent
Aiming improvement percentage when aiming.
Definition humanControlLogic.h:1215
virtual ~DtHumanControlLogic() override
Virtual destructor.
virtual void setupExternalLauncher()
Sets up an external launcher.
virtual void tick(double dt) override
Updates control logic for the current frame.
void onCanMoveChanged(bool canMove)
Handles changes to the movement capability.
bool playerCanControl()
Checks if the player can control the entity.
virtual void onLauncherIdChanged(makVrv::DtElementID launcherId)
Handles changes to the launcher element ID.
virtual void toggleNorthReference(double val)
Toggles between true and magnetic north references.
void onWeaponListChanged(const DtAttributeHandle &weaponList)
Handles changes to the weapon list.
virtual void sendJoystickCommand(const DtEntityIdentifier &id, const std::string &functionGroup, const std::string &function, double val, bool repeat=false)
Sends a joystick command to a specific entity.
double myCurrentHeading
Current entity heading in degrees.
Definition humanControlLogic.h:1220
void onEquipmentChanged(Equipment equipment)
Handles changes to the active equipment.
virtual void move(double val)
Handles forward/backward movement input.
double myWalkMultiplier
Multiplier for walking movement speed.
Definition humanControlLogic.h:1037
virtual void manipulateTerrainElement(TerrainElement element, TerrainAction action)
Manipulates a terrain element.
bool handleGazeInput(bool pitch)
Handles gaze input and updates attributes.
void onForwardControlsChanged(bool forwardControls)
Handles changes to the forward controls state.
virtual void toggleBinoculars(double val)
Toggles binoculars equipment.
virtual void startLasing()
Starts laser designation.
virtual makVre::DtVreMessageResult handleAppFocusUpdate(makVre::DtVreMessage *msg)
Handles application focus update messages.
virtual void percentOfMaxSpeedChangeCallback(float newPercentOfMaxSpeedValue)
Handles changes to the percent of max speed.
virtual void disableFeaturesWhileParachuting()
Disables certain features while parachuting.
virtual void simulateYaw(double dt)
Simulates yaw movement over time.
virtual void goProne(double val)
Transitions to prone posture.
friend class DtHumanVirtualRealityLogic
Friend class declaration to allow VR logic access to protected members.
Definition humanControlLogic.h:141
virtual void parachuteLeftToggle(double val)
Toggles the left parachute control line.
virtual void throwGrenade()
Throws a grenade.
void onPostureChanged(HumanPosture posture)
Handles changes to the posture.
void setWeaponDown(bool down)
Sets the weapon down state.
double myAimingErrorPercent
Current aiming error as a percentage of maximum.
Definition humanControlLogic.h:1197
void onDiGuyActionChanged(std::string action)
Handles changes to the DI-Guy action.
virtual bool postInitialize() override
Performs post-initialization setup.
Input logic component for the human role.
Definition humanInputLogic.h:27
Virtual reality logic component for the human role.
Definition humanVirtualRealityLogic.h:83
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
virtual const std::string & name()
Gets the component name.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
A component that manages Qt Quick overlays for rendering 2D UI elements on top of 3D graphics.
Definition qtQuickOverlay.h:76
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Component for managing weapon resources, equipment, and related state attributes.
Definition weaponResourceLogic.h:45
Defines the logic for controlling entities in VR-Engage.
constexpr const char * joystickSensitivity
Definition humanControlLogic.h:84
constexpr const char * weaponLockedWhenMovingPostures
Definition humanControlLogic.h:123
constexpr const char * invertPitchInput
Definition humanControlLogic.h:78
constexpr const char * raiseGunOnAttach
Definition humanControlLogic.h:99
constexpr const char * weaponLockedPostures
Definition humanControlLogic.h:120
constexpr const char * aimingErrorCalcDistanceToTarget
Definition humanControlLogic.h:63
constexpr const char * requiredAimingErrorPercent
Definition humanControlLogic.h:102
constexpr const char * compassUnits
Definition humanControlLogic.h:75
constexpr const char * isAllowedThirdPersonView
Definition humanControlLogic.h:81
constexpr const char * moveLockedPostures
Definition humanControlLogic.h:90
constexpr const char * binocularsInputMultiplier
Definition humanControlLogic.h:72
constexpr const char * moveDelays
Definition humanControlLogic.h:87
constexpr const char * showCompass
Definition humanControlLogic.h:108
constexpr const char * proneAimingImprovementPercent
Definition humanControlLogic.h:96
constexpr const char * aimingImprovementPercent
Definition humanControlLogic.h:69
constexpr const char * sprintMultiplier
Definition humanControlLogic.h:114
constexpr const char * sprintBackwardMultiplier
Definition humanControlLogic.h:111
constexpr const char * walkMultiplier
Definition humanControlLogic.h:117
constexpr const char * aimingErrorCalcMaxSpread
Definition humanControlLogic.h:66
constexpr const char * aimMultiplier
Definition humanControlLogic.h:60
constexpr const char * postureSequence
Definition humanControlLogic.h:93
constexpr const char * runMultiplier
Definition humanControlLogic.h:105
Defines export macros for the Human Frontend library.
#define HUMAN_DLL
Definition export.h:19
Definition humanControlLogic.h:52
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
ObserverAttachMode
Enumeration of camera/observer attachment offsets.
Definition stateDefines.h:44
HumanPosture
Enumeration of human posture states.
Definition stateDefines.h:30
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
TerrainAction
Enumeration of actions that can be performed on terrain elements.
Definition stateDefines.h:94
constexpr const char * DtHumanControlLogicType
Type identifier for DtHumanControlLogic component.
Definition humanControlLogic.h:129
Equipment
Enumeration of equipment types that can be held or used.
Definition stateDefines.h:55
TerrainElement
Enumeration of interactive terrain elements.
Definition stateDefines.h:85
Definition appLauncherComponent.h:28
Common enumeration definitions used throughout the VREngage system.
bool weaponLocked
Whether weapon use is locked in this posture.
Definition humanControlLogic.h:1089
bool weaponLockedWhenMoving
Whether weapon use is locked while moving in this posture.
Definition humanControlLogic.h:1092
PostureRestrictions()
Default constructor initializing all restrictions to false.
Definition humanControlLogic.h:1078
bool moveLocked
Whether movement is locked in this posture.
Definition humanControlLogic.h:1086
Defines the base class for all VREngage messages.