VR-Engage  2.2
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 VRF message interface class
31
32//! \brief Forward declaration of the simulation message class
33class DtSimMessage;
34
35
36namespace makVre
37{
38//! \brief Connector for handling weapon fire events in the simulation
39//!
40//! DtWeaponFireConnector processes weapon fire interactions from VR-Link and
41//! translates them to VREngage fire messages. It also handles caching of fire
42//! interactions when necessary entity information is not yet available.
44{
45public:
46 //! \brief Default constructor
47 //!
48 //! Initializes the connector with name "WeaponFire"
50
51 //! \brief Virtual destructor
52 virtual ~DtWeaponFireConnector() override;
53
54 //! \brief Installs the weapon fire connector with the application and connection
55 //! \param app Pointer to the player station application
56 //! \param connection Pointer to the protocol-specific VR-Link connection
57 //!
58 //! Calls the base class implementation, registers the fire callback,
59 //! and retrieves the reflected entity list from the application
60 virtual void install(
61 DtPlayerStationApp* app, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection) override;
62
63 //! \brief Performs periodic processing of pending fire interactions
64 //!
65 //! Checks if any pending fire interactions are ready to send or have timed out,
66 //! and processes them accordingly
67 virtual void tick() override;
68
69 //! \brief Shuts down the weapon fire connector
70 //!
71 //! Removes the fire callback from the connection
72 virtual void shutdown() override;
73
74 //! \brief Handles an incoming fire interaction
75 //! \param fire Pointer to the fire interaction to process
76 //!
77 //! Either sends the fire message immediately if all necessary entity information
78 //! is available, or caches it for later processing
79 void handleFireMessage(DtFireInteraction* fire);
80
81protected:
82 //! \brief Finds the entity identifier for a global object designator
83 //! \param globalId The global object designator to look up
84 //! \return The entity identifier if found, or nullId if not found
85 //!
86 //! Looks up an entity in the reflected entity list by its global object designator
87 DtEntityIdentifier findEntityId(const DtGlobalObjectDesignator& globalId);
88
89 //! \brief Determines if a fire interaction is ready to be sent
90 //! \param fire Pointer to the fire interaction to check
91 //! \return True if the interaction is ready to send, false otherwise
92 //!
93 //! Makes sure that the firing entity and munition entity (if specified)
94 //! have been discovered in the simulation
95 bool fireMessageReadyToSend(DtFireInteraction* fire);
96
97 //! \brief Sends a fire message for a fire interaction
98 //! \param fire Pointer to the fire interaction to send
99 //!
100 //! Creates and queues a fire message with the information from the fire interaction
101 void sendFireMessage(DtFireInteraction* fire);
102
103protected:
104 //! \brief Pointer to the reflected entity list
105 //!
106 //! Used to look up entities by their global object designators
107 DtReflectedEntityList* myReflectedEntityList;
108
109 //! \brief Type alias for pending fire interactions
110 //!
111 //! Each pair contains the timestamp when the interaction was received
112 //! and a pointer to the fire interaction
113 using PendingFireInteractions = std::vector<std::pair<double, DtFireInteraction*>>;
114
115 //! \brief Cached fire interactions
116 //!
117 //! These interactions are delayed until the firing entity and munition entity
118 //! have been discovered in the simulation
120};
121} // namespace makVre
Interface for handling VR-Forces message interactions in the VREngage framework.
Definition vreVrfMessageInterface.h:31
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:54
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
DtEntityIdentifier findEntityId(const DtGlobalObjectDesignator &globalId)
Finds the entity identifier for a global object designator.
std::vector< std::pair< double, DtFireInteraction * > > PendingFireInteractions
Type alias for pending fire interactions.
Definition weaponFireConnector.h:113
virtual void install(DtPlayerStationApp *app, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection) override
Installs the weapon fire connector with the application and connection.
virtual ~DtWeaponFireConnector() override
Virtual destructor.
virtual void tick() override
Performs periodic processing of pending fire interactions.
DtWeaponFireConnector()
Default constructor.
PendingFireInteractions myPendingFireInteractions
Cached fire interactions.
Definition weaponFireConnector.h:119
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:107
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
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
Defines the base DtSimEventConnector class for VREngage simulation events.