Add the removal of an active gameplay effect

This commit is contained in:
Arnaud Jamin
2025-01-06 02:03:07 -05:00
parent 00b6dd65bc
commit 78508fda24
2 changed files with 10 additions and 3 deletions
@@ -85,7 +85,7 @@ void FCogAbilityWindow_Effects::RenderContent()
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Effects::RenderEffectsTable()
{
const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
if (AbilitySystemComponent == nullptr)
{
ImGui::TextDisabled("Selection has no ability system component");
@@ -170,7 +170,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable()
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected)
void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected)
{
const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
if (ActiveEffectPtr == nullptr)
@@ -238,6 +238,13 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
}
ImGui::CloseCurrentPopup();
}
if (ImGui::Button("Remove"))
{
AbilitySystemComponent.RemoveActiveGameplayEffect(ActiveHandle);
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
@@ -38,7 +38,7 @@ protected:
virtual void RenderEffectsTable();
virtual void RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected);
virtual void RenderEffectRow(UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected);
virtual void RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect);