From 564f2a80cd3bfcb666a48109dd9e317f14738998 Mon Sep 17 00:00:00 2001 From: Ji Yoon Rhee Date: Tue, 17 Sep 2024 00:05:53 +0900 Subject: [PATCH] crafting system is fully functional --- .../Character/NPC/BP_NPCControllerBase.uasset | 3 ++ .../NPC/BehaviorTree/BB_NPCBase.uasset | 3 ++ .../NPC/BehaviorTree/BT_NPCBase.uasset | 3 ++ .../E_NPCBehaviorStateBase.uasset | 3 ++ .../BP_HYPlayerCharacController.uasset | 4 +-- .../ItemBP/ChildrenItemBP/BP_TeaCup.uasset | 3 ++ .../Interactables/ItemDataTable.uasset | 4 +-- .../Content/Hwanyoung/Levels/Spring.umap | 4 +-- .../Crafting_HUD/BP_CookingHUDWidget.uasset | 4 +-- .../Crafting_HUD/BP_CraftingHUDWidget.uasset | 4 +-- .../Crafting_HUD/BP_CraftingItemSlot.uasset | 4 +-- .../BP_InventoryHUDWidget.uasset | 4 +-- .../BP_InventoryItemToolTip.uasset | 4 +-- .../UI/Player_HUD/WG_PlayerHUD.uasset | 4 +-- .../5/5T/WBIWIME71FMAJC5DG8LPM0.uasset | 3 ++ .../D/SO/DVS50SZGH8WN6RAKBQRMQR.uasset | 3 ++ .../hwanyoung2/HYPlayerCharacController.cpp | 35 +++++++++++++++++-- .../hwanyoung2/HYPlayerCharacController.h | 6 +++- hwanyoung2/Source/hwanyoung2/InventoryItem.h | 6 ++++ 19 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 hwanyoung2/Content/Hwanyoung/Character/NPC/BP_NPCControllerBase.uasset create mode 100644 hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BB_NPCBase.uasset create mode 100644 hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BT_NPCBase.uasset create mode 100644 hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/E_NPCBehaviorStateBase.uasset create mode 100644 hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/ItemBP/ChildrenItemBP/BP_TeaCup.uasset create mode 100644 hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/5/5T/WBIWIME71FMAJC5DG8LPM0.uasset create mode 100644 hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/D/SO/DVS50SZGH8WN6RAKBQRMQR.uasset diff --git a/hwanyoung2/Content/Hwanyoung/Character/NPC/BP_NPCControllerBase.uasset b/hwanyoung2/Content/Hwanyoung/Character/NPC/BP_NPCControllerBase.uasset new file mode 100644 index 00000000..c0b75e44 --- /dev/null +++ b/hwanyoung2/Content/Hwanyoung/Character/NPC/BP_NPCControllerBase.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81309d9157d1dfe4f86da473938400d504c7c9f00875b007ddaba94e2739979e +size 67716 diff --git a/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BB_NPCBase.uasset b/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BB_NPCBase.uasset new file mode 100644 index 00000000..82fedb81 --- /dev/null +++ b/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BB_NPCBase.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d29a8e3c6ee5d00b1392cb8d124663045446f312b7e3a044507f727d5843da34 +size 2871 diff --git a/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BT_NPCBase.uasset b/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BT_NPCBase.uasset new file mode 100644 index 00000000..b4bcd3da --- /dev/null +++ b/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/BT_NPCBase.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c90b049a1e75e6568ed6a7dc272b017ea9f4be32a0d3915748a82d76551e4612 +size 13597 diff --git a/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/E_NPCBehaviorStateBase.uasset b/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/E_NPCBehaviorStateBase.uasset new file mode 100644 index 00000000..0fc1003e --- /dev/null +++ b/hwanyoung2/Content/Hwanyoung/Character/NPC/BehaviorTree/E_NPCBehaviorStateBase.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cf5f4327ea741cab315d7e330a025e1b7b70bb5dcc04837bd25b8b274cc5532 +size 3721 diff --git a/hwanyoung2/Content/Hwanyoung/Character/PlayerCharacter/BP_HYPlayerCharacController.uasset b/hwanyoung2/Content/Hwanyoung/Character/PlayerCharacter/BP_HYPlayerCharacController.uasset index 52753062..69e35d3a 100644 --- a/hwanyoung2/Content/Hwanyoung/Character/PlayerCharacter/BP_HYPlayerCharacController.uasset +++ b/hwanyoung2/Content/Hwanyoung/Character/PlayerCharacter/BP_HYPlayerCharacController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92dee415c8ef928b43a063c491666192eee236e70ca56f313316e9c56bce7e51 -size 201452 +oid sha256:0ebfd128b89a2f70c0c1b6176a63036d7053fccb8adb9d6c1e976855bde12e92 +size 201870 diff --git a/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/ItemBP/ChildrenItemBP/BP_TeaCup.uasset b/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/ItemBP/ChildrenItemBP/BP_TeaCup.uasset new file mode 100644 index 00000000..9d00bcdb --- /dev/null +++ b/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/ItemBP/ChildrenItemBP/BP_TeaCup.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f28a45940a7d36db4671aa4e1dbee6ec985ef9807e415a74b362a646d837fb1 +size 41483 diff --git a/hwanyoung2/Content/Hwanyoung/Interactables/ItemDataTable.uasset b/hwanyoung2/Content/Hwanyoung/Interactables/ItemDataTable.uasset index 467d4f68..445b99e0 100644 --- a/hwanyoung2/Content/Hwanyoung/Interactables/ItemDataTable.uasset +++ b/hwanyoung2/Content/Hwanyoung/Interactables/ItemDataTable.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13c9c5bd8311aba659acd275c84b9bc885a929dee646be08afcce84f28587703 -size 14555 +oid sha256:2235548b49c40bc461d9e9cbfc6a8f22ab749cf6ad0c2fbf3d4196b2d7ad82b6 +size 16966 diff --git a/hwanyoung2/Content/Hwanyoung/Levels/Spring.umap b/hwanyoung2/Content/Hwanyoung/Levels/Spring.umap index 1ed20a82..1bdf5b10 100644 --- a/hwanyoung2/Content/Hwanyoung/Levels/Spring.umap +++ b/hwanyoung2/Content/Hwanyoung/Levels/Spring.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:67e82a93f640c7b0e162d7e8cb7d3ba5c410e515b4d0df69feffd196849e5833 -size 2146970 +oid sha256:c8516fb86064fd9adc994d141629cb9d70c1ffeceb5afc6603f4927e98b52046 +size 2154278 diff --git a/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CookingHUDWidget.uasset b/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CookingHUDWidget.uasset index fa0398a0..2f88d439 100644 --- a/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CookingHUDWidget.uasset +++ b/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CookingHUDWidget.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3dd32cf5a354c0af6f8eae6acbe7d88081a513cdeb8b533c74939a71d6ec9d77 -size 118503 +oid sha256:5dfaeea4ae1abd3d130400536daaaeb62006c2f724d0ddfd72e19d1ef000d800 +size 115734 diff --git a/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingHUDWidget.uasset b/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingHUDWidget.uasset index 8a962c2f..7308d766 100644 --- a/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingHUDWidget.uasset +++ b/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingHUDWidget.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e83ff9a7cbc1745ccff6e3bc11ad34f93488cd2d8c9fbef1e0f7ccb09a7a2e0a -size 170448 +oid sha256:9f8e6f27194bfac3b1e12eb77e880be36d1669f186bfd7720d20ef991becb0d7 +size 183097 diff --git a/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingItemSlot.uasset b/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingItemSlot.uasset index 747f3148..cf83dbda 100644 --- a/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingItemSlot.uasset +++ b/hwanyoung2/Content/Hwanyoung/UI/Crafting_HUD/BP_CraftingItemSlot.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b6a750d9846d1c3dac7fed946d7813c3b932644254b61eee6c283770c69e480a -size 168518 +oid sha256:8da15d789017885c8958f1beace9f0da3000245ecaca8d6aa10e6d4d94333838 +size 129563 diff --git a/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryHUDWidget.uasset b/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryHUDWidget.uasset index fd7a80dc..c339ef26 100644 --- a/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryHUDWidget.uasset +++ b/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryHUDWidget.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:00f80198f1c2543e4cdffbaaca9aa80924625d6561c4042449512339e52eea3b -size 102868 +oid sha256:8e139f2abfc226c65693502ac1b7a80fd4c59fb3caf273d0a2d46a9aaa868211 +size 103180 diff --git a/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryItemToolTip.uasset b/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryItemToolTip.uasset index 1ce43383..e4a50faa 100644 --- a/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryItemToolTip.uasset +++ b/hwanyoung2/Content/Hwanyoung/UI/Inventory_HUD/BP_InventoryItemToolTip.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d520a6d2d650cf1cb40a6f86acf06a93a4c46a5bd1ac5636a5b01dfedec2210a -size 91603 +oid sha256:ed4649dd8db9cb839d4de2b505a464d27c803e115226e22ad8ca260b51450af8 +size 91470 diff --git a/hwanyoung2/Content/Hwanyoung/UI/Player_HUD/WG_PlayerHUD.uasset b/hwanyoung2/Content/Hwanyoung/UI/Player_HUD/WG_PlayerHUD.uasset index b3da4888..0a413c30 100644 --- a/hwanyoung2/Content/Hwanyoung/UI/Player_HUD/WG_PlayerHUD.uasset +++ b/hwanyoung2/Content/Hwanyoung/UI/Player_HUD/WG_PlayerHUD.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a71b263669b89695e8c18cff0dd63e3a08fcd5ec8326f5ddd56b79f3e46b83a -size 96441 +oid sha256:cac2ff7447703500f1237f4806799b4d1c8e835ffdbbd07939ec8754c03a8e50 +size 96194 diff --git a/hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/5/5T/WBIWIME71FMAJC5DG8LPM0.uasset b/hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/5/5T/WBIWIME71FMAJC5DG8LPM0.uasset new file mode 100644 index 00000000..b910942f --- /dev/null +++ b/hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/5/5T/WBIWIME71FMAJC5DG8LPM0.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fabb32336b61b6fbce00db8bb853ad1bb74945ce341a0876d0df5db4ef344442 +size 3763 diff --git a/hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/D/SO/DVS50SZGH8WN6RAKBQRMQR.uasset b/hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/D/SO/DVS50SZGH8WN6RAKBQRMQR.uasset new file mode 100644 index 00000000..e91633d7 --- /dev/null +++ b/hwanyoung2/Content/__ExternalActors__/ThirdPerson/Maps/ThirdPersonMap/D/SO/DVS50SZGH8WN6RAKBQRMQR.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99225b72dff1ac101963f4786e5e0d5b8b0d2a2671f8d6ec13bccce36a23ccf3 +size 3726 diff --git a/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.cpp b/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.cpp index 55f06544..64fa83be 100644 --- a/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.cpp +++ b/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.cpp @@ -39,9 +39,9 @@ bool AHYPlayerCharacController::AddItemToInventoryByID(FName ID) return false; } -void AHYPlayerCharacController::CraftItem(FInventoryItem ItemA, FInventoryItem ItemB, FInventoryItem ItemC, FInventoryItem ItemD) +void AHYPlayerCharacController::CraftItem(FInventoryItem ItemA) { - for (auto Combination : ItemB.CraftCombinations) { + /*for (auto Combination : ItemB.CraftCombinations) { if (Combination.ItemAID == ItemA.ItemID && Combination.ItemBID == ItemB.ItemID && Combination.ItemCID == ItemC.ItemID @@ -53,7 +53,38 @@ void AHYPlayerCharacController::CraftItem(FInventoryItem ItemA, FInventoryItem I AddItemToInventoryByID(Combination.ProductID); ReloadCraftUI(); } + }*/ + + int32 NumOfCraftingItems = CraftingItems.Num(); + bool bIsValidComb; + bIsValidComb = false; + if (NumOfCraftingItems < 2 || NumOfCraftingItems > 4) { return; } + + AHYGameStateBase* gameState = Cast(GetWorld()->GetGameState()); + UDataTable* itemDB = gameState->GetItemDatabase(); + + for (auto Combination : ItemA.CraftCombinations) { + if (CraftingItems.Contains(Combination.ItemBID) && NumOfCraftingItems >= 2) { + if (Combination.bDestroyItemB) Inventory.RemoveSingle(*itemDB->FindRow(Combination.ItemBID, "")); + bIsValidComb = bIsValidComb || true; + } + if (CraftingItems.Contains(Combination.ItemCID) && NumOfCraftingItems >= 3) { + if (Combination.bDestroyItemC) Inventory.RemoveSingle(*itemDB->FindRow(Combination.ItemCID, "")); + bIsValidComb = bIsValidComb && true; + } + if (CraftingItems.Contains(Combination.ItemDID) && NumOfCraftingItems == 4) { + if (Combination.bDestroyItemD) Inventory.RemoveSingle(*itemDB->FindRow(Combination.ItemDID, "")); + bIsValidComb = bIsValidComb && true; + } + if (bIsValidComb) { + if (Combination.bDestroyItemA) Inventory.RemoveSingle(ItemA); + AddItemToInventoryByID(Combination.ProductID); + ReloadCraftUI(); + return; + } + else continue; } + } void AHYPlayerCharacController::Interact() diff --git a/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.h b/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.h index d4ebcfb4..2f17c36c 100644 --- a/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.h +++ b/hwanyoung2/Source/hwanyoung2/HYPlayerCharacController.h @@ -38,7 +38,7 @@ public: bool AddItemToInventoryByID(FName ID); UFUNCTION(BlueprintCallable, Category = "Utils") - void CraftItem(FInventoryItem ItemA, FInventoryItem ItemB, FInventoryItem ItemC, FInventoryItem ItemD); + void CraftItem(FInventoryItem ItemA); UPROPERTY(BlueprintReadWrite, VisibleAnywhere) class AHYInteractableActor* CurrentInteractable; @@ -55,6 +55,10 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 Currency; + + UPROPERTY(VisibleAnywhere, BlueprintReadWrite) + TSet CraftingItems; + //interacts with the Interactable objects UFUNCTION(BlueprintCallable, Category = "Utils") void Interact(); diff --git a/hwanyoung2/Source/hwanyoung2/InventoryItem.h b/hwanyoung2/Source/hwanyoung2/InventoryItem.h index c9f14748..6201e1b0 100644 --- a/hwanyoung2/Source/hwanyoung2/InventoryItem.h +++ b/hwanyoung2/Source/hwanyoung2/InventoryItem.h @@ -62,4 +62,10 @@ public: bool operator==(const FInventoryItem& OtherItem) const { return ItemID == OtherItem.ItemID; } + + friend uint32 GetTypeHash(const FInventoryItem& InventoryItem) { + + return HashCombine(GetTypeHash(InventoryItem.ItemID), InventoryItem.ItemValue); + + } }; \ No newline at end of file