This one has me stumped. Looking for a little guidance!!
In header file:
USTRUCT(BlueprintType)
struct FStatValue
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 MinValue = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 CurrentValue = 100;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 MaxValue = 100;
};
TMap<EStat, FStatValue> TStats;
UFUNCTION(BlueprintCallable, Category = "Stat Manager")
void SetStat(EStat Stat, int32 NewValue, bool Update);
Next I have in my CPP:
void UF3CMasterStatManager::SetStat(EStat Stat, int32 NewValue, bool Update)
{
FStatValue* FS = TStats.Find(Stat);
if (FS != nullptr)
{
FS->CurrentValue = NewValue;
if (FS->CurrentValue < FS->MinValue)
{
UE_LOG(LogTemp, Warning, TEXT("MinValue Override in Uf3CMasterStatManger::ModifyStat"));
FS->CurrentValue = FS->MinValue;
}
else if (FS->CurrentValue > FS->MaxValue)
{
FS->CurrentValue = FS->MaxValue;
}
//FS->CurrentValue = FMath::Clamp(NewValue, int32(FS->MinValue), int32(FS->MaxValue));
// If the call asked to update the stat (in child for display purposes)
if (Update)
{
UpdateStat(Stat);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("MasterStatManager: Set Stat Find returned NULLPTR."));
}
}
I exploded the Clamp (which is commented out) to see what was actually happening. I set a breakpoint on the UE_LOG line inside the IF. The MinValue is coming back as 512, or 440 or 600 sometimes. and sometimes 0! I scanned all my logic and nowhere do I even attempt to update the default value for MinValue. So it should always be 0.