VR-Engage  2.3
Loading...
Searching...
No Matches
weaponFireConnector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file weaponFireConnector.h
7//! \brief Defines the DtWeaponFireConnector class for handling weapon fire events
8//!
9//! This connector processes weapon fire events in the simulation, translating
10//! between VR-Link fire interactions and VREngage fire messages.
11
12#pragma once
13
14#include "export.h"
15
17
18#include <vl/fireInteraction.h>
19
20//! \brief Forward declaration of the exercise connection class
21class DtExerciseConn;
22
23//! \brief Forward declaration of the reflected entity list class
24class DtReflectedEntityList;
25
26//! \brief Forward declaration of the entity publisher class
27class DtEntityPublisher;
28
29//! \brief Forward declaration of the simulation message class
30class DtSimMessage;
31
32
33namespace makVre
34{
35//! \brief Connector for handling weapon fire events in the simulation
36//!
37//! DtWeaponFireConnector processes weapon fire interactions from VR-Link and
38//! translates them to VREngage fire messages. It also handles caching of fire
39//! interactions when necessary entity information is not yet available.
41{
42public:
43 //! \brief Default constructor
44 //!
45 //! Initializes the connector with name "WeaponFire"
47
48 //! \brief Virtual destructor
49 virtual ~DtWeaponFireConnector() override;
50
51 //! \brief Installs the weapon fire connector with a VR-Link connection.
52 //!
53 //! \param connection Non-owning pointer to the protocol-specific VR-Link connection.
54 //!
55 //! Calls the base class implementation, registers the fire callback,
56 //! and retrieves the reflected entity list from the global App attribute tree.
57 virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection) override;
58
59 //! \brief Performs periodic processing of pending fire interactions
60 //!
61 //! Checks if any pending fire interactions are ready to send or have timed out,
62 //! and processes them accordingly
63 //!
64 //! \param dt The elapsed time in seconds since the last tick
65 virtual void tick(double dt) override;
66
67 //! \brief Shuts down the weapon fire connector
68 //!
69 //! Removes the fire callback from the connection
70 virtual void shutdown() override;
71
72 //! \brief Handles an incoming fire interaction
73 //! \param fire Pointer to the fire interaction to process
74 //!
75 //! Either sends the fire message immediately if all necessary entity information
76 //! is available, or caches it for later processing
77 void handleFireMessage(DtFireInteraction* fire);
78
79protected:
80 //! \brief Finds the entity identifier for a global object designator
81 //! \param globalId The global object designator to look up
82 //! \return The entity identifier if found, or nullId if not found
83 //!
84 //! Looks up an entity in the reflected entity list by its global object designator
85 DtEntityIdentifier findEntityId(const DtGlobalObjectDesignator& globalId);
86
87 //! \brief Determines if a fire interaction is ready to be sent
88 //! \param fire Pointer to the fire interaction to check
89 //! \return True if the interaction is ready to send, false otherwise
90 //!
91 //! Makes sure that the firing entity and munition entity (if specified)
92 //! have been discovered in the simulation
93 bool fireMessageReadyToSend(DtFireInteraction* fire);
94
95 //! \brief Sends a fire message for a fire interaction
96 //! \param fire Pointer to the fire interaction to send
97 //!
98 //! Creates and queues a fire message with the information from the fire interaction
99 void sendFireMessage(DtFireInteraction* fire);
100
101protected:
102 //! \brief Pointer to the reflected entity list
103 //!
104 //! Used to look up entities by their global object designators
105 DtReflectedEntityList* myReflectedEntityList;
106
107 //! \brief Type alias for pending fire interactions
108 //!
109 //! Each pair contains the timestamp when the interaction was received
110 //! and a pointer to the fire interaction
111 using PendingFireInteractions = std::vector<std::pair<double, DtFireInteraction*>>;
112
113 //! \brief Cached fire interactions
114 //!
115 //! These interactions are delayed until the firing entity and munition entity
116 //! have been discovered in the simulation
118};
119} // namespace makVre
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:53
DtEntityIdentifier findEntityId(const DtGlobalObjectDesignator &globalId)
Finds the entity identifier for a global object designator.
virtual void tick(double dt) override
Performs periodic processing of pending fire interactions.
std::vector< std::pair< double, DtFireInteraction * > > PendingFireInteractions
Type alias for pending fire interactions.
Definition weaponFireConnector.h:111
virtual ~DtWeaponFireConnector() override
Virtual destructor.
DtWeaponFireConnector()
Default constructor.
virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection) override
Installs the weapon fire connector with a VR-Link connection.
PendingFireInteractions myPendingFireInteractions
Cached fire interactions.
Definition weaponFireConnector.h:117
void sendFireMessage(DtFireInteraction *fire)
Sends a fire message for a fire interaction.
bool fireMessageReadyToSend(DtFireInteraction *fire)
Determines if a fire interaction is ready to be sent.
DtReflectedEntityList * myReflectedEntityList
Pointer to the reflected entity list.
Definition weaponFireConnector.h:105
void handleFireMessage(DtFireInteraction *fire)
Handles an incoming fire interaction.
virtual void shutdown() override
Shuts down the weapon fire connector.
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
!
Definition glsVreMessageUtil.h:50
Defines the base DtSimEventConnector class for VREngage simulation events.