the player can pick up consumable items and use items for different effects; needs optimization in player character base BP class

This commit is contained in:
Ji Yoon Rhee
2024-08-27 14:29:55 +09:00
parent e8cacbe1c7
commit 682231dd0f
470 changed files with 1400 additions and 44 deletions

View File

@ -0,0 +1,8 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYConsumableItem.h"
AHYConsumableItem::AHYConsumableItem()
{
}

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "HYManualPickUp.h"
#include "HYConsumableItem.generated.h"
/**
*
*/
UCLASS()
class HWANYOUNG2_API AHYConsumableItem : public AHYManualPickUp
{
GENERATED_BODY()
public:
AHYConsumableItem();
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Pick up and consume")
void OnUsed(APlayerController* Controller);
};

View File

@ -39,6 +39,18 @@ bool AHYPlayerCharacController::AddItemToInventoryByID(FName ID)
return false;
}
void AHYPlayerCharacController::CraftItem(FInventoryItem ItemA, FInventoryItem ItemB)
{
for (auto Pair : ItemB.CraftCombinations) {
if (Pair.ComponentID == ItemA.ItemID) {
if (Pair.bDestroyItemA) Inventory.RemoveSingle(ItemA);
if (Pair.bDestroyItemB) Inventory.RemoveSingle(ItemB);
AddItemToInventoryByID(Pair.ProductID);
ReloadCraftUI();
}
}
}
void AHYPlayerCharacController::Interact()
{
if (CurrentInteractable) CurrentInteractable->Interact(this);

View File

@ -25,12 +25,18 @@ public:
UFUNCTION(BlueprintImplementableEvent)
void ReloadInventory();
UFUNCTION(BlueprintImplementableEvent)
void ReloadCraftUI();
UFUNCTION(BlueprintCallable, Category = "Utils")
int32 GetInventoryWeight();
UFUNCTION(BlueprintCallable, Category = "Utils")
bool AddItemToInventoryByID(FName ID);
UFUNCTION(BlueprintCallable, Category = "Utils")
void CraftItem(FInventoryItem ItemA, FInventoryItem ItemB);
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
class AHYInteractableActor* CurrentInteractable;