// 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 StatusEffectClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_HealOverTime")); HealOverTimeStatusEffect = StatusEffectClassFinder.Class; } void UEatableItems::Use(ATempCharacter* Character) { if (Character) { if (isHealingItem) { if (Character->Health < 100) { UStatusSystem* StatusSystem = Character->FindComponentByClass(); StatusSystem->AddStatusEffect(NewObject(Character, HealOverTimeStatusEffect)); Character->Inventory->RemoveItem(this); } else if (Character->Health >= 100) { UE_LOG(LogTemp, Display, TEXT("Health is full")); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, 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 (isProbertiumType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->ProbertiumResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Probertium eaten")); TurnBaseCombat->ProbertiumResource += 5; Character->Inventory->RemoveItem(this); } } if (isEisType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->EisResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Eis eaten")); TurnBaseCombat->EisResource += 5; Character->Inventory->RemoveItem(this); } } if (isAzosType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->AzosResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Azos eaten")); TurnBaseCombat->AzosResource += 5; Character->Inventory->RemoveItem(this); } } if (isIroquoidType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->IroquoidResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Iroq eaten")); TurnBaseCombat->IroquoidResource += 5; Character->Inventory->RemoveItem(this); } } } }