diff --git a/Content/Blueprints/Status_UI/StatusIcon.uasset b/Content/Blueprints/Status_UI/StatusIcon.uasset index 1095e3f..74e0964 100644 --- a/Content/Blueprints/Status_UI/StatusIcon.uasset +++ b/Content/Blueprints/Status_UI/StatusIcon.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ddfcf5e3a69889d633124e3ec44154648315efe9c84ceec1733053c32faf2f7 -size 26198 +oid sha256:a911529b7d90b0795d916aa06b7e43b3a488abce5af21ccd7bb79f2a3d4f1354 +size 26496 diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index 0263e9a..9a0b867 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -16,26 +16,23 @@ UEatableItems::UEatableItems() void UEatableItems::Use(ATempCharacter* Character) { - if(Character) + if (Character) { - if(isHealingItem) + if (isHealingItem) { if (Character->Health < 100) { - /*Character->Health += 10; - UE_LOG(LogTemp, Display, TEXT("Healed")); - Character->Inventory->RemoveItem(this);*/ - UStatusSystem* StatusSystem = Character->FindComponentByClass(); - StatusSystem->AddStatusEffect(NewObject(this, HealOverTimeStatusEffect)); + StatusSystem->AddStatusEffect(NewObject(Character, HealOverTimeStatusEffect)); + Character->Inventory->RemoveItem(this); } else if (Character->Health >= 100) { UE_LOG(LogTemp, Display, TEXT("Health is full")); } } - - if(isDamageBuffItem) + + if (isDamageBuffItem) { // need to add the damage buff functionality here UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); @@ -57,4 +54,3 @@ void UEatableItems::Use(ATempCharacter* Character) } } } - diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp index 97e825f..55112bd 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp @@ -5,17 +5,18 @@ #include "StatusSystem.h" #include "Kismet/GameplayStatics.h" +#include "Components/TextBlock.h" -void UStatusEffect::Invoke(AActor* Character, float TimeOfExpiry) +void UStatusEffect::Invoke(AActor* Character, float TimeOfInit) { - GetWorld()->GetTimerManager().SetTimer(ExpiryTimerHandle, [this, Character, TimeOfExpiry] { CheckForExpiry(TimeOfExpiry, Character); }, 1, true, 0); + GetWorld()->GetTimerManager().SetTimer(ExpiryTimerHandle, [this, Character, TimeOfInit] { CheckForExpiry(TimeOfInit, Character); }, 1, true, 0); } void UStatusEffect::OnExpiry(AActor* Character) { GetWorld()->GetTimerManager().ClearTimer(ExpiryTimerHandle); UStatusSystem* StatusSystem = Cast(Character->GetComponentByClass(UStatusSystem::StaticClass())); - if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return; + if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return; StatusSystem->GetActiveStatusEffect(this).StatusIcon->RemoveFromParent(); StatusSystem->RemoveStatusEffect(this); } @@ -26,4 +27,8 @@ void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character) { OnExpiry(Character); } + UStatusSystem* StatusSystem = Cast(Character->GetComponentByClass(UStatusSystem::StaticClass())); + if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return; + UTextBlock* StatusText = Cast(StatusSystem->GetActiveStatusEffect(this).StatusIcon->GetWidgetFromName(TEXT("DurationText"))); + StatusText->SetText(FText::FromString(FString::FromInt(TimeOfExpiry - UGameplayStatics::GetRealTimeSeconds(GetWorld())))); } diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h index 253dd7b..6e0435f 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h @@ -5,7 +5,6 @@ #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "StatusEffect.h" -#include "Components/TextBlock.h" #include "Components/WrapBox.h" #include "StatusSystem.generated.h"