This commit is contained in:
Ji Yoon Rhee 2024-09-10 10:46:13 +09:00
parent eeaf691a1a
commit cf526110b3
13 changed files with 54 additions and 24 deletions

Binary file not shown.

Binary file not shown.

BIN
hwanyoung2/Content/Hwanyoung/UI/Images/HUD_cooking.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
hwanyoung2/Content/Hwanyoung/UI/Images/HUD_crafting.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -18,7 +18,18 @@ public:
//unique ID of item that is being used to create the item
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ComponentID;
FName ItemAID;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ItemBID;
//unique ID of item that is being used to create the item
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ItemCID;
//unique ID of item that is being used to create the item
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ItemDID;
//unique ID of the item that gets created
UPROPERTY(EditAnywhere, BlueprintReadWrite)
@ -28,12 +39,20 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemA;
//
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemB;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemC;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemD;
bool operator==(const FCraftingInfo& OtherItem) const {
return ComponentID == OtherItem.ComponentID;
return ItemAID == OtherItem.ItemAID
&& ItemBID == OtherItem.ItemBID
&& ItemCID == OtherItem.ItemCID
&& ItemDID == OtherItem.ItemDID;
}

View File

@ -39,13 +39,18 @@ bool AHYPlayerCharacController::AddItemToInventoryByID(FName ID)
return false;
}
void AHYPlayerCharacController::CraftItem(FInventoryItem ItemA, FInventoryItem ItemB)
void AHYPlayerCharacController::CraftItem(FInventoryItem ItemA, FInventoryItem ItemB, FInventoryItem ItemC, FInventoryItem ItemD)
{
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);
for (auto Combination : ItemB.CraftCombinations) {
if (Combination.ItemAID == ItemA.ItemID
&& Combination.ItemBID == ItemB.ItemID
&& Combination.ItemCID == ItemC.ItemID
&& Combination.ItemDID == ItemD.ItemID) {
if (Combination.bDestroyItemA) Inventory.RemoveSingle(ItemA);
if (Combination.bDestroyItemB) Inventory.RemoveSingle(ItemB);
if (Combination.bDestroyItemC) Inventory.RemoveSingle(ItemC);
if (Combination.bDestroyItemD) Inventory.RemoveSingle(ItemD);
AddItemToInventoryByID(Combination.ProductID);
ReloadCraftUI();
}
}

View File

@ -38,7 +38,7 @@ public:
bool AddItemToInventoryByID(FName ID);
UFUNCTION(BlueprintCallable, Category = "Utils")
void CraftItem(FInventoryItem ItemA, FInventoryItem ItemB);
void CraftItem(FInventoryItem ItemA, FInventoryItem ItemB, FInventoryItem ItemC, FInventoryItem ItemD);
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
class AHYInteractableActor* CurrentInteractable;