Updated EatableItems to Add Status Effects
This commit is contained in:
parent
37deb51b5f
commit
88323e4ea6
BIN
Content/Blueprints/StatusEffects/BP_HealOverTime.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/StatusEffects/BP_HealOverTime.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/Mat_BungeeMan_Rubber.uasset
(Stored with Git LFS)
BIN
Content/BungeeMan/Mat_BungeeMan_Rubber.uasset
(Stored with Git LFS)
Binary file not shown.
@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
||||||
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||||
|
#include "the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h"
|
||||||
|
|
||||||
|
|
||||||
UEatableItems::UEatableItems()
|
UEatableItems::UEatableItems()
|
||||||
{
|
{
|
||||||
|
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_HealOverTime"));
|
||||||
|
HealOverTimeStatusEffect = StatusEffectClassFinder.Class;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEatableItems::Use(ATempCharacter* Character)
|
void UEatableItems::Use(ATempCharacter* Character)
|
||||||
@ -20,9 +22,12 @@ void UEatableItems::Use(ATempCharacter* Character)
|
|||||||
{
|
{
|
||||||
if (Character->Health < 100)
|
if (Character->Health < 100)
|
||||||
{
|
{
|
||||||
Character->Health += 10;
|
/*Character->Health += 10;
|
||||||
UE_LOG(LogTemp, Display, TEXT("Healed"));
|
UE_LOG(LogTemp, Display, TEXT("Healed"));
|
||||||
Character->Inventory->RemoveItem(this);
|
Character->Inventory->RemoveItem(this);*/
|
||||||
|
|
||||||
|
UStatusSystem* StatusSystem = Cast<UStatusSystem>(Character);
|
||||||
|
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(this, HealOverTimeStatusEffect));
|
||||||
}
|
}
|
||||||
else if (Character->Health >= 100)
|
else if (Character->Health >= 100)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "BaseItem.h"
|
#include "BaseItem.h"
|
||||||
#include "the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h"
|
#include "the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h"
|
||||||
|
#include "the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h"
|
||||||
#include "EatableItems.generated.h"
|
#include "EatableItems.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +21,8 @@ class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void Use(class ATempCharacter* Character) override;
|
virtual void Use(class ATempCharacter* Character) override;
|
||||||
|
UPROPERTY()
|
||||||
|
TSubclassOf<UStatusEffect> HealOverTimeStatusEffect;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCo
|
|||||||
|
|
||||||
void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float DurationMultiplier)
|
void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float DurationMultiplier)
|
||||||
{
|
{
|
||||||
FActiveStatusEffect NewStatusEffect;
|
FActiveStatusEffect NewStatusEffect{};
|
||||||
NewStatusEffect.StatusEffect = StatusEffect;
|
NewStatusEffect.StatusEffect = StatusEffect;
|
||||||
NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());
|
NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());
|
||||||
NewStatusEffect.TimeTillExpiry = UGameplayStatics::GetRealTimeSeconds(GetWorld()) + StatusEffect->BaseDuration * DurationMultiplier;
|
NewStatusEffect.TimeTillExpiry = UGameplayStatics::GetRealTimeSeconds(GetWorld()) + StatusEffect->BaseDuration * DurationMultiplier;
|
||||||
|
Loading…
Reference in New Issue
Block a user