mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
CogEngine: Fix crash when the CogEngine data asset is not present
Fix cheat colors always overriding the user color
This commit is contained in:
@@ -16,13 +16,20 @@ void FCogEngineWindow_Cheats::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window can be used to apply cheats to the selected actor (by default). "
|
||||
"The cheats can be configured in the '%s' data asset. "
|
||||
"When clicking a cheat button, press:\n"
|
||||
" [CTRL] to apply the cheat to controlled actor\n"
|
||||
" [ALT] to apply the cheat to the allies of the selected actor\n"
|
||||
" [SHIFT] to apply the cheat to the enemies of the selected actor\n"
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
|
||||
);
|
||||
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
ImGui::Text("Create a DataAsset child of 'CogEngineDataAsset' to configure the cheats. ");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("The cheats can be configured in the '%s' data asset. ", StringCast<ANSICHAR>(*GetNameSafe(Asset.Get())).Get());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -436,6 +443,9 @@ void FCogEngineWindow_Cheats::RequestCheat(ACogEngineReplicator& Replicator, AAc
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& CheatName, const bool OnlyPersistentCheats)
|
||||
{
|
||||
if (Asset == nullptr)
|
||||
{ return nullptr; }
|
||||
|
||||
for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories)
|
||||
{
|
||||
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentCheats)
|
||||
@@ -447,9 +457,7 @@ const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& C
|
||||
}
|
||||
|
||||
if (OnlyPersistentCheats)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
{ continue; }
|
||||
|
||||
for (const FCogEngineCheat& Cheat : CheatCategory.InstantCheats)
|
||||
{
|
||||
@@ -458,8 +466,6 @@ const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& C
|
||||
return &Cheat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
+1
-2
@@ -110,6 +110,5 @@ bool UCogAbilityCheat_Execution_ActivateAbility::GetColor(const FCogWindow& InCa
|
||||
const UCogAbilityConfig_Alignment* Config = InCallingWindow.GetConfig<UCogAbilityConfig_Alignment>();
|
||||
const UCogAbilityDataAsset* Asset = InCallingWindow.GetAsset<UCogAbilityDataAsset>();
|
||||
|
||||
OutColor = Config->GetAbilityColor(Asset, *GameplayAbility);
|
||||
return true;
|
||||
return Config->GetAbilityColor(Asset, *GameplayAbility, OutColor);
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,6 +7,7 @@
|
||||
#include "CogAbilityConfig_Alignment.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindow.h"
|
||||
#include "MeshPaintVisualize.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityCheat_Execution_ApplyEffect::Execute_Implementation(const UObject* WorldContextObject, const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
@@ -106,6 +107,5 @@ bool UCogAbilityCheat_Execution_ApplyEffect::GetColor(const FCogWindow& InCallin
|
||||
const UCogAbilityConfig_Alignment* Config = InCallingWindow.GetConfig<UCogAbilityConfig_Alignment>();
|
||||
const UCogAbilityDataAsset* Asset = InCallingWindow.GetAsset<UCogAbilityDataAsset>();
|
||||
|
||||
OutColor = Config->GetEffectColor(Asset, *GameplayEffect);
|
||||
return true;
|
||||
return Config->GetEffectColor(Asset, *GameplayEffect, OutColor);
|
||||
}
|
||||
|
||||
@@ -24,35 +24,55 @@ FVector4f UCogAbilityConfig_Alignment::GetAttributeColor(const UAbilitySystemCom
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FVector4f UCogAbilityConfig_Alignment::GetAbilityColor(const UCogAbilityDataAsset* Asset, const UGameplayAbility& Ability) const
|
||||
bool UCogAbilityConfig_Alignment::GetAbilityColor(const UCogAbilityDataAsset* Asset, const UGameplayAbility& Ability, FLinearColor& OutColor) const
|
||||
{
|
||||
if (Asset == nullptr)
|
||||
{ return NeutralColor; }
|
||||
{
|
||||
OutColor = NeutralColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
const FGameplayTagContainer& Tags = Ability.GetAssetTags();
|
||||
if (Tags.HasTag(Asset->NegativeAbilityTag))
|
||||
{ return NegativeColor; }
|
||||
{
|
||||
OutColor = NegativeColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Tags.HasTag(Asset->PositiveAbilityTag))
|
||||
{ return PositiveColor; }
|
||||
{
|
||||
OutColor = PositiveColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NeutralColor;
|
||||
OutColor = NeutralColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FVector4f UCogAbilityConfig_Alignment::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) const
|
||||
bool UCogAbilityConfig_Alignment::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect, FLinearColor& OutColor) const
|
||||
{
|
||||
if (Asset == nullptr)
|
||||
{ return NeutralColor; }
|
||||
{
|
||||
OutColor = NeutralColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
const FGameplayTagContainer& Tags = Effect.GetAssetTags();
|
||||
if (Tags.HasTag(Asset->NegativeEffectTag))
|
||||
{ return NegativeColor; }
|
||||
{
|
||||
OutColor = NegativeColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Tags.HasTag(Asset->PositiveEffectTag))
|
||||
{ return PositiveColor; }
|
||||
{
|
||||
OutColor = PositiveColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NeutralColor;
|
||||
OutColor = NeutralColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -192,7 +192,9 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectColor(Asset, Effect)));
|
||||
FLinearColor Color;
|
||||
AlignmentConfig->GetEffectColor(Asset, Effect, Color);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Color));
|
||||
|
||||
if (ImGui::Selectable(EffectName.Get(), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
|
||||
@@ -23,13 +23,13 @@ public:
|
||||
|
||||
FVector4f GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const;
|
||||
|
||||
FVector4f GetAbilityColor(const UCogAbilityDataAsset* Asset, const UGameplayAbility& Ability) const;
|
||||
bool GetAbilityColor(const UCogAbilityDataAsset* Asset, const UGameplayAbility& Ability, FLinearColor& OutColor) const;
|
||||
|
||||
FVector4f GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const;
|
||||
|
||||
FVector4f GetEffectModifierColor(float ModifierValue, EGameplayModOp::Type ModifierOp, float BaseValue) const;
|
||||
|
||||
FVector4f GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) const;
|
||||
bool GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect, FLinearColor& OutColor) const;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector4f PositiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f);
|
||||
|
||||
Reference in New Issue
Block a user