61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "EatableItems.h"
|
|
|
|
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
|
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
|
#include "the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h"
|
|
|
|
|
|
UEatableItems::UEatableItems()
|
|
{
|
|
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_HealOverTime"));
|
|
HealOverTimeStatusEffect = StatusEffectClassFinder.Class;
|
|
}
|
|
|
|
void UEatableItems::Use(ATempCharacter* Character)
|
|
{
|
|
if(Character)
|
|
{
|
|
if(isHealingItem)
|
|
{
|
|
if (Character->Health < 100)
|
|
{
|
|
/*Character->Health += 10;
|
|
UE_LOG(LogTemp, Display, TEXT("Healed"));
|
|
Character->Inventory->RemoveItem(this);*/
|
|
|
|
UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
|
|
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(this, HealOverTimeStatusEffect));
|
|
}
|
|
else if (Character->Health >= 100)
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Health is full"));
|
|
}
|
|
}
|
|
|
|
if(isDamageBuffItem)
|
|
{
|
|
// need to add the damage buff functionality here
|
|
UE_LOG(LogTemp, Display, TEXT("Damage Buffed"));
|
|
Character->Inventory->RemoveItem(this);
|
|
}
|
|
|
|
if (isAmmoItemType)
|
|
{
|
|
TurnBaseCombat = GetWorld()->GetGameState<ATurnBaseCombatV2>();
|
|
if (TurnBaseCombat->IronResource > 10)
|
|
{
|
|
TurnBaseCombat->IronResource += 5;
|
|
}
|
|
if (TurnBaseCombat->SulfurResource > 10)
|
|
{
|
|
TurnBaseCombat->SulfurResource += 5;
|
|
}
|
|
Character->Inventory->RemoveItem(this);
|
|
}
|
|
}
|
|
}
|
|
|