VR-Engage  2.2
Loading...
Searching...
No Matches
extendedStateLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file extendedStateLogic.h
7//! \brief Defines the DtExtendedStateLogic component for managing extended state attributes.
8//!
9//! This component allows for the dynamic addition of state attributes beyond the standard set,
10//! supporting various data types and custom properties for simulation monitoring and control.
11//!
12//! \ingroup vreCommonComponents
13
14#pragma once
15
18
19#include <string>
20#include <vector>
21
22namespace makVre
23{
24
26{
27//! \ingroup RoleConfigParams
28//! \defgroup ExtendedStateLogicRoleParams Extended State Logic Role Parameters
29//! \roleInherits{PlayerComponentRoleParams}
30//! Configuration Options for extended state logic component.
31//! @{
32
33//! \vreRoleParam{extendedState,table,{},extendedStateLogic,Table containing definitions for extended state attributes with name and type fields.}
34constexpr const char* extendedState = "extendedState";
35
36//! \vreRoleParam{stateProperties,table,{},extendedStateLogic,Table containing definitions for state properties with name and type fields.}
37constexpr const char* stateProperties = "stateProperties";
38
39//! @}
40} // namespace ExtendedStateLogicConfig
41
42//! \brief Forward declaration of the initialization table class
43class DtInitTable;
44
45//! \brief Type identifier for DtExtendedStateLogic component
46constexpr const char* DtExtendedStateLogicType = "DtExtendedStateLogic";
47
48//! \brief Component for managing extended state attributes beyond the standard set
49//!
50//! The DtExtendedStateLogic component provides functionality to dynamically add custom
51//! state attributes to an entity. These attributes can be configured in Lua and support
52//! various data types (int, float, double, string, bool, ammoClipMap).
53//!
54//! This component is particularly useful for simulation monitoring and sharing state
55//! information that isn't covered by the standard state attributes. It will send an
56//! ExtendedStateMonitorInitMessage to notify the system of these additional attributes.
58{
59public:
60 //! \brief Constructor for DtExtendedStateLogic
61 //!
62 //! Initializes the component with the name "DtExtendedStateLogic".
64
65 //! \brief Virtual destructor for DtExtendedStateLogic
66 virtual ~DtExtendedStateLogic() override;
67
68 //! \brief Initializes the component with configuration from Lua
69 //!
70 //! Processes the "extendedState" and "stateProperties" sections from the configuration,
71 //! creating state attributes based on their specifications. For each attribute defined,
72 //! the component will:
73 //! - Add the attribute to the player's attribute store
74 //! - Send an ExtendedStateMonitorInitMessage to register the attribute with the system
75 //!
76 //! \param player Pointer to the player station this component belongs to
77 //! \param config Configuration table containing attribute definitions
78 //! \return True if initialization succeeds, false otherwise
80
81 //! \brief Updates the component state (empty implementation)
82 //!
83 //! This method is called each frame but currently has no implementation.
84 //!
85 //! \param dt Delta time in seconds since the last tick
86 virtual void tick(double dt) override;
87
88 //! \brief Shuts down the component
89 //!
90 //! Sends an ExtendedStateMonitorInitMessage with a null entity ID to
91 //! deregister the extended state attributes.
92 virtual void shutdown() override;
93
94 //! \brief Returns the type identifier for this component
95 //! \return The type string for DtExtendedStateLogic
96 virtual const char* type() const override;
97
98protected:
99 //! \brief Adds custom attributes to the player's attribute store
100 //!
101 //! Creates attributes in the player's attribute store based on the provided names
102 //! and types. Supports the following data types:
103 //! - int: Initialized to 0
104 //! - float: Initialized to 0.0f
105 //! - double: Initialized to 0.0
106 //! - string: Initialized to "not set"
107 //! - bool: Initialized to false
108 //! - ammoClipMap: Special case that requires no initialization
109 //!
110 //! \param names Vector of attribute names to add
111 //! \param types Vector of attribute types corresponding to the names
112 void addAdditionalAttributesToState(std::vector<std::string>& names, std::vector<std::string>& types);
113};
114} // namespace makVre
virtual const char * type() const override
Returns the type identifier for this component.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the component with configuration from Lua.
virtual void shutdown() override
Shuts down the component.
void addAdditionalAttributesToState(std::vector< std::string > &names, std::vector< std::string > &types)
Adds custom attributes to the player's attribute store.
virtual ~DtExtendedStateLogic() override
Virtual destructor for DtExtendedStateLogic.
virtual void tick(double dt) override
Updates the component state (empty implementation)
DtExtendedStateLogic()
Constructor for DtExtendedStateLogic.
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
constexpr const char * stateProperties
Definition extendedStateLogic.h:37
constexpr const char * extendedState
Definition extendedStateLogic.h:34
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition extendedStateLogic.h:26
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtExtendedStateLogicType
Type identifier for DtExtendedStateLogic component.
Definition extendedStateLogic.h:46
Defines the DtPlayerComponent base class for VR-Engage role components.