VR-Engage  2.2
Loading...
Searching...
No Matches
friendlyUnitLogic.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file friendlyUnitLogic.h
7//! \brief Defines the DtFriendlyUnitsLogic component for tracking friendly units in the simulation.
8//!
9//! This component listens for EntityFriendlyUnitsMessages and maintains a list of friendly units
10//! that can be accessed via state attributes. This is particularly useful for command roles
11//! that need to know what friendly units are available for tasking.
12//!
13//! \ingroup vreCommonComponents
14
15#pragma once
16
18
21
22
23namespace makVre
24{
25//! \brief Type identifier for DtFriendlyUnitsLogic component
26constexpr const char* DtFriendlyUnitsLogicType = "DtFriendlyUnitsLogic";
27
28//! \brief Component for tracking friendly units in the simulation
29//!
30//! The DtFriendlyUnitsLogic listens for EntityFriendlyUnitsMessages and maintains
31//! a list of friendly units via state attributes. When a message is received, the component
32//! updates the "subordinateList" and "taskableEntities" state attributes with the
33//! list of friendly units and a flag indicating whether any are available, respectively.
34//!
35//! This component is particularly useful in command roles where it's important to know
36//! what friendly units can be tasked or interacted with.
38{
39public:
40 //! \brief Constructor for DtFriendlyUnitsLogic
41 //!
42 //! Initializes the component with the name "DtFriendlyUnitsLogic".
44
45 //! \brief Virtual destructor for DtFriendlyUnitsLogic
46 virtual ~DtFriendlyUnitsLogic() override;
47
48 //! \brief Initializes the component with configuration from Lua
49 //!
50 //! Sets up a message handler for EntityFriendlyUnitsMessages.
51 //!
52 //! \param player Pointer to the player station this component belongs to
53 //! \param config Configuration table containing initialization parameters
54 //! \return True if initialization succeeds
55 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
56
57 //! \brief Performs post-initialization setup
58 //!
59 //! Currently just returns true as there's no additional setup needed.
60 //!
61 //! \return True, indicating successful post-initialization
62 virtual bool postInitialize() override;
63
64 //! \brief Updates the component state (empty implementation)
65 //!
66 //! This method is called each frame but currently has no implementation.
67 //!
68 //! \param dt Delta time in seconds since the last tick
69 virtual void tick(double dt) override;
70
71 //! \brief Shuts down the component
72 //!
73 //! Removes the EntityFriendlyUnitsMessage handler.
74 virtual void shutdown() override;
75
76 //! \brief Returns the type identifier for this component
77 //! \return The type string for DtFriendlyUnitsLogic
78 virtual const char* type() const override;
79
80protected:
81 //! \brief Initializes state attributes (empty implementation)
82 //!
83 //! This method is reserved for initializing state attributes, but currently
84 //! has an empty implementation with commented-out code for potential future use.
85 virtual void initializeStateAttributes() override;
86
87 //! \brief Handles messages about friendly units
88 //!
89 //! Processes EntityFriendlyUnitsMessages by extracting the list of friendly units
90 //! and updating the "subordinateList" and "taskableEntities" state attributes.
91 //!
92 //! \param msg The message to process
93 //! \return HANDLED if the message was processed successfully, IGNORED otherwise
95
96 // Commented out attributes for future use
97 //! \brief Pointer to the subordinate list attribute (commented out)
98 // DtAttribute<std::vector<std::string>>* mySubordinateListAttr;
99
100 //! \brief Pointer to the taskable entities flag attribute (commented out)
101 // DtAttribute<bool>* myTaskableEntitiesAttr;
102};
103
104} // namespace makVre
virtual void tick(double dt) override
Updates the component state (empty implementation)
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the component with configuration from Lua.
virtual const char * type() const override
Returns the type identifier for this component.
virtual bool postInitialize() override
Performs post-initialization setup.
DtVreMessageResult handleFriendlyUnitsMessage(DtVreMessage *msg)
Handles messages about friendly units.
DtFriendlyUnitsLogic()
Constructor for DtFriendlyUnitsLogic.
virtual ~DtFriendlyUnitsLogic() override
Virtual destructor for DtFriendlyUnitsLogic.
virtual void shutdown() override
Shuts down the component.
virtual void initializeStateAttributes() override
Initializes state attributes (empty implementation)
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
DtPlayerComponent()
Constructor.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtFriendlyUnitsLogicType
Type identifier for DtFriendlyUnitsLogic component.
Definition friendlyUnitLogic.h:26
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the DtPlayerComponent base class for VR-Engage role components.
Defines the base class for all VREngage messages.