Add Blueprint-accessible GetAbilityCostValues to UGMCAbility#11
Conversation
Added a helper function to easily retrieve and map the attribute costs associated with an ability. Functionality: Iterates through the AbilityCost effect CDO to extract the modifiers. Returns: A TMap<FGameplayTag, float> that maps attribute tags directly to their exact modifier values. Use Case: Simplifies querying and accessing ability costs for UI display and Blueprint logic.
WalkthroughThis PR adds a new Blueprint-pure accessor method ChangesAbility Cost Values Accessor
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)Source/GMCAbilitySystem/Private/Ability/GMCAbility.cppSource/GMCAbilitySystem/Private/Ability/GMCAbility.cpp:1:13: fatal error: 'Ability/GMCAbility.h' file not found ... [truncated 1164 characters] ... "-internal-isystem" "/usr/local/include" "-internal-isystem" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Source/GMCAbilitySystem/Private/Ability/GMCAbility.cpp (1)
147-159: 💤 Low valueConsider defensive handling for potential duplicate AttributeTags.
The current implementation uses
CostMap.Add(), which will assert in development builds if the sameAttributeTagappears multiple times in theModifiersarray. While duplicate tags are likely a data configuration error, usingCostMap.Emplace()or checkingContains()before adding would make the code more resilient.🛡️ Optional: Make duplicate key handling explicit
for (const FGMCAttributeModifier& Modifier : EffectCDO->EffectData.Modifiers) { - CostMap.Add(Modifier.AttributeTag, Modifier.GetValue()); + CostMap.Emplace(Modifier.AttributeTag, Modifier.GetValue()); }Or to accumulate values from duplicate tags:
for (const FGMCAttributeModifier& Modifier : EffectCDO->EffectData.Modifiers) { - CostMap.Add(Modifier.AttributeTag, Modifier.GetValue()); + float& Value = CostMap.FindOrAdd(Modifier.AttributeTag, 0.0f); + Value += Modifier.GetValue(); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Source/GMCAbilitySystem/Private/Ability/GMCAbility.cpp` around lines 147 - 159, The GetAbilityCostValues function currently uses CostMap.Add(Modifier.AttributeTag, Modifier.GetValue()) which will assert on duplicate AttributeTags; update UGMCAbility::GetAbilityCostValues to handle duplicates defensively by either using CostMap.Emplace(Modifier.AttributeTag, Modifier.GetValue()) after checking !CostMap.Contains(Modifier.AttributeTag), or explicitly accumulate values when duplicates are valid (e.g., if CostMap.Contains(AttributeTag) then sum Modifier.GetValue() into existing entry), referencing AbilityCost, UGMCAbilityEffect, FGMCAttributeModifier and CostMap in your changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Source/GMCAbilitySystem/Private/Ability/GMCAbility.cpp`:
- Around line 147-159: The GetAbilityCostValues function currently uses
CostMap.Add(Modifier.AttributeTag, Modifier.GetValue()) which will assert on
duplicate AttributeTags; update UGMCAbility::GetAbilityCostValues to handle
duplicates defensively by either using CostMap.Emplace(Modifier.AttributeTag,
Modifier.GetValue()) after checking !CostMap.Contains(Modifier.AttributeTag), or
explicitly accumulate values when duplicates are valid (e.g., if
CostMap.Contains(AttributeTag) then sum Modifier.GetValue() into existing
entry), referencing AbilityCost, UGMCAbilityEffect, FGMCAttributeModifier and
CostMap in your changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8b77e5da-1802-4728-adf0-01936851b4b3
📒 Files selected for processing (2)
Source/GMCAbilitySystem/Private/Ability/GMCAbility.cppSource/GMCAbilitySystem/Public/Ability/GMCAbility.h
|
May want to change Add to FindOrAdd if there are duplicate tags. |
Added a helper function to easily retrieve and map the attribute costs associated with an ability.
Functionality: Iterates through the AbilityCost effect CDO to extract the modifiers.
Returns: A TMap<FGameplayTag, float> that maps attribute tags directly to their exact modifier values.
Use Case: Simplifies querying and accessing ability costs for UI display and Blueprint logic.
Summary by CodeRabbit
GetAbilityCostValues()method to retrieve cost values for abilities. Available in both Blueprints and code, the method returns a map of attribute tags with their associated cost values configured for each ability.