@@ -32,143 +32,159 @@ class COMPONENTDYNAMICATTRIBUTES_API UActorCDA : public UActorComponent
3232 UActorCDA ();
3333
3434 // Array of data assets used to initialize attributes.
35- UPROPERTY (EditAnywhere, BlueprintReadWrite, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
36- TArray<TObjectPtr<UAttributesDataAssetCDA>> AttributesData ;
35+ UPROPERTY (EditAnywhere, BlueprintReadWrite, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
36+ TArray<TObjectPtr<UAttributesDataAssetCDA>> RegisteredAttributeAssets ;
3737
3838 // Runtime attribute storage for fast iteration.
39- UPROPERTY (VisibleAnywhere, BlueprintReadOnly, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
39+ UPROPERTY (VisibleAnywhere, BlueprintReadOnly, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
4040 TArray<FAttributeRuntimeDataCDA> Attributes;
4141
4242 // Index lookup for attributes by gameplay tag.
43- UPROPERTY (VisibleAnywhere, BlueprintReadOnly, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
43+ UPROPERTY (VisibleAnywhere, BlueprintReadOnly, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
4444 TMap<FGameplayTag, int32> AttributeIndex;
4545
4646 // Event broadcast when an attribute's value changes.
47- UPROPERTY (BlueprintAssignable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
47+ UPROPERTY (BlueprintAssignable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
4848 FOnAttributeChangedCDA OnAttributeChangedCDA;
4949
5050 /* *
5151 * Get the runtime data for an attribute.
52- * @param Tag The gameplay tag of the attribute.
53- * @return The attribute's runtime data, or default if not found.
52+ *
53+ * @param Tag The gameplay tag of the attribute
54+ * @return The attribute's runtime data, or a default-initialized struct if not found
5455 */
55- UFUNCTION (BlueprintPure, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
56+ UFUNCTION (BlueprintPure, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
5657 FAttributeRuntimeDataCDA GetAttribute (FGameplayTag Tag);
5758
5859 /* *
5960 * Get only the current value of an attribute.
60- * @param Tag The gameplay tag of the attribute.
61- * @return The current value, or 0.0f if not found.
61+ *
62+ * @param Tag The gameplay tag of the attribute
63+ * @return The current value, or 0.0f if the attribute was not found
6264 */
63- UFUNCTION (BlueprintPure, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
65+ UFUNCTION (BlueprintPure, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
6466 float GetCurrentValue (FGameplayTag Tag);
6567
6668 /* *
67- * Set an attribute's runtime data.
68- * @param Tag The gameplay tag of the attribute.
69- * @param NewAttribute The new runtime data to set.
69+ * Register an attribute's runtime data.
70+ *
71+ * @param Tag The gameplay tag of the attribute
72+ * @param NewAttribute The runtime data to register or replace
7073 */
71- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
72- void SetAttribute (FGameplayTag Tag, const FAttributeRuntimeDataCDA& NewAttribute);
74+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
75+ void RegisterAttribute (FGameplayTag Tag, const FAttributeRuntimeDataCDA& NewAttribute);
7376
7477 /* *
75- * Check if an attribute exists.
76- * @param Tag The gameplay tag of the attribute.
77- * @return True if the attribute exists.
78+ * Check if an attribute exists in runtime storage.
79+ *
80+ * @param Tag The gameplay tag of the attribute
81+ * @return true if the attribute exists
7882 */
79- UFUNCTION (BlueprintPure, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
83+ UFUNCTION (BlueprintPure, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
8084 bool HasAttribute (FGameplayTag Tag) const ;
8185
8286 /* *
83- * Remove an attribute.
84- * @param Tag The gameplay tag of the attribute.
87+ * Remove an attribute from runtime storage.
88+ *
89+ * @param Tag The gameplay tag of the attribute to remove
8590 */
86- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
91+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
8792 void RemoveAttribute (FGameplayTag Tag);
8893
89- // Remove all attributes.
90- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
94+ /* *
95+ * Remove all attributes from runtime storage.
96+ */
97+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
9198 void RemoveAllAttributes ();
9299
93100 /* *
94101 * Edit an attribute's current value with an operation.
95- * @param Tag The gameplay tag of the attribute.
96- * @param Operation The operation to perform.
97- * @param Value The value to apply.
102+ *
103+ * @param Tag The gameplay tag of the attribute
104+ * @param Operation The operation to perform
105+ * @param Value The value to apply
98106 */
99- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
107+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
100108 void EditCurrentValue (FGameplayTag Tag, EAttributeOperationCDA Operation, float Value);
101109
102110 /* *
103111 * Edit an attribute's base value with an operation.
104- * @param Tag The gameplay tag of the attribute.
105- * @param Operation The operation to perform.
106- * @param Value The value to apply.
112+ *
113+ * @param Tag The gameplay tag of the attribute
114+ * @param Operation The operation to perform
115+ * @param Value The value to apply
107116 */
108- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
117+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
109118 void EditBaseValue (FGameplayTag Tag, EAttributeOperationCDA Operation, float Value);
110119
111120 /* *
112121 * Edit an attribute's minimum value with an operation.
113- * @param Tag The gameplay tag of the attribute.
114- * @param Operation The operation to perform.
115- * @param Value The value to apply.
122+ *
123+ * @param Tag The gameplay tag of the attribute
124+ * @param Operation The operation to perform
125+ * @param Value The value to apply
116126 */
117- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
127+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
118128 void EditMinValue (FGameplayTag Tag, EAttributeOperationCDA Operation, float Value);
119129
120130 /* *
121131 * Edit an attribute's maximum value with an operation.
122- * @param Tag The gameplay tag of the attribute.
123- * @param Operation The operation to perform.
124- * @param Value The value to apply.
132+ *
133+ * @param Tag The gameplay tag of the attribute
134+ * @param Operation The operation to perform
135+ * @param Value The value to apply
125136 */
126- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
137+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
127138 void EditMaxValue (FGameplayTag Tag, EAttributeOperationCDA Operation, float Value);
128139
129140 /* *
130141 * Add a modifier to an attribute.
131- * @param Tag The gameplay tag of the attribute.
132- * @param Modifier The modifier to add.
142+ *
143+ * @param Tag The gameplay tag of the attribute
144+ * @param Modifier The modifier to add
133145 */
134- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
146+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
135147 void AddModifier (FGameplayTag Tag, const FAttributeModifierCDA& Modifier);
136148
137149 /* *
138150 * Remove a specific modifier from an attribute.
139- * @param Tag The gameplay tag of the attribute.
140- * @param Modifier The modifier to remove.
141- * @return True if the modifier was found and removed.
151+ *
152+ * @param Tag The gameplay tag of the attribute
153+ * @param Modifier The modifier to remove
154+ * @return true if the modifier was found and removed
142155 */
143- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
156+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
144157 bool RemoveModifier (FGameplayTag Tag, const FAttributeModifierCDA& Modifier);
145158
146159 /* *
147- * Remove all modifiers from a source.
148- * @param Source The source tag of modifiers to remove.
160+ * Remove all modifiers originating from a specific source tag.
161+ *
162+ * @param Source The source tag whose modifiers will be removed
149163 */
150- UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
164+ UFUNCTION (BlueprintCallable, Category = " Dynamic Attributes CDA " , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
151165 void RemoveModifiersFromSource (FGameplayTag Source);
152166
153167 /* *
154168 * Get an attribute's base, min, and max values from its level table.
155- * @param Tag The gameplay tag of the attribute.
156- * @param Level The level to query.
157- * @param OutBaseValue The base value at the specified level.
158- * @param OutMinValue The minimum value at the specified level.
159- * @param OutMaxValue The maximum value at the specified level.
160- * @return True if the row was found.
161- */
162- UFUNCTION (BlueprintPure, Category = " Dynamic Attributes | Scaling" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
169+ *
170+ * @param Tag The gameplay tag of the attribute
171+ * @param Level The level to query
172+ * @param OutBaseValue The base value at the specified level (output)
173+ * @param OutMinValue The minimum value at the specified level (output)
174+ * @param OutMaxValue The maximum value at the specified level (output)
175+ * @return true if the row was found in the level table
176+ */
177+ UFUNCTION (BlueprintPure, Category = " Dynamic Attributes CDA | Scaling" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
163178 bool GetAttributeValuesFromLevelTable (FGameplayTag Tag, int32 Level, float & OutBaseValue, float & OutMinValue, float & OutMaxValue) const ;
164179
165180 /* *
166181 * Get an attribute's value from its curve table.
167- * @param Tag The gameplay tag of the attribute.
168- * @param Level The level to evaluate.
169- * @return The interpolated value at the specified level.
182+ *
183+ * @param Tag The gameplay tag of the attribute
184+ * @param Level The level to evaluate
185+ * @return The interpolated value at the specified level
170186 */
171- UFUNCTION (BlueprintPure, Category = " Dynamic Attributes | Scaling" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
187+ UFUNCTION (BlueprintPure, Category = " Dynamic Attributes CDA | Scaling" , meta = (Keywords = " CDA, Component Dynamic Attributes" ))
172188 float GetAttributeValueFromCurve (FGameplayTag Tag, int32 Level) const ;
173189
174190protected:
@@ -179,31 +195,72 @@ class COMPONENTDYNAMICATTRIBUTES_API UActorCDA : public UActorComponent
179195 virtual void InitializeComponent () override ;
180196
181197private:
182- // Initialize attributes from data assets.
198+ /* *
199+ * Initialize attributes from configured data assets and prepare runtime storage.
200+ * Called from component initialization path.
201+ */
183202 void InitializeAttributes ();
184203
185- // Try to get the index of an attribute by tag.
204+ /* *
205+ * Try to get the index of an attribute by tag.
206+ *
207+ * @param Tag The attribute gameplay tag to look up
208+ * @param OutIndex Output index if found
209+ * @return true if the attribute exists in runtime storage
210+ */
186211 bool TryGetAttributeIndex (FGameplayTag Tag, int32& OutIndex) const ;
187212
188- // Get the definition of an attribute.
213+ /* *
214+ * Get the definition of an attribute from cached definitions.
215+ *
216+ * @param Tag The attribute gameplay tag
217+ * @return Pointer to the definition or nullptr if not found
218+ */
189219 const FAttributeDefinitionCDA* GetAttributeDefinition (FGameplayTag Tag) const ;
190220
191- // Add an attribute definition.
221+ /* *
222+ * Add an attribute definition to the internal definition table.
223+ *
224+ * @param Definition Definition to add
225+ */
192226 void AddAttributeDefinition (const FAttributeDefinitionCDA& Definition);
193227
194- // Remove an attribute by index.
228+ /* *
229+ * Remove an attribute by its runtime index.
230+ *
231+ * @param Index Index of the attribute to remove
232+ */
195233 void RemoveAttributeByIndex (int32 Index);
196234
197- // Recalculate an attribute if needed.
235+ /* *
236+ * Recalculate an attribute's derived values if needed.
237+ *
238+ * @param Tag Attribute gameplay tag
239+ * @param Index Runtime index of the attribute to recalc
240+ */
198241 void RecalculateAttributeIfNeeded (FGameplayTag Tag, int32 Index);
199242
200- // Apply an operation to a float value.
243+ /* *
244+ * Apply an operation (add, multiply, set, etc.) to a float target value.
245+ *
246+ * @param TargetValue Value to modify (in/out)
247+ * @param Operation Operation to perform
248+ * @param Value Operand value for the operation
249+ */
201250 void ApplyOperation (float & TargetValue, EAttributeOperationCDA Operation, float Value) const ;
202251
203- // Broadcast value change if different.
252+ /* *
253+ * Broadcast value change if the value actually changed.
254+ *
255+ * @param Tag Attribute tag
256+ * @param OldValue Previous value
257+ * @param NewValue New calculated value
258+ */
204259 void BroadcastIfValueChanged (FGameplayTag Tag, float OldValue, float NewValue);
205260
206- // Storage for attribute definitions.
261+ /* *
262+ * Storage for attribute definitions used to initialize runtime attributes.
263+ */
207264 UPROPERTY ()
208265 TArray<FAttributeDefinitionCDA> AttributeDefinitions;
209266
0 commit comments