save/load souls, inventory items

This commit is contained in:
sharon2pan 2024-09-10 00:07:47 -04:00
parent eeaf691a1a
commit 6ec77ff202
22 changed files with 70 additions and 40 deletions

Binary file not shown.

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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 //unique ID of item that is being used to create the item
UPROPERTY(EditAnywhere, BlueprintReadWrite) 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 //unique ID of the item that gets created
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
@ -28,12 +39,20 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemA; bool bDestroyItemA;
//
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemB; bool bDestroyItemB;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemC;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyItemD;
bool operator==(const FCraftingInfo& OtherItem) const { 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; 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) { for (auto Combination : ItemB.CraftCombinations) {
if (Pair.ComponentID == ItemA.ItemID) { if (Combination.ItemAID == ItemA.ItemID
if (Pair.bDestroyItemA) Inventory.RemoveSingle(ItemA); && Combination.ItemBID == ItemB.ItemID
if (Pair.bDestroyItemB) Inventory.RemoveSingle(ItemB); && Combination.ItemCID == ItemC.ItemID
AddItemToInventoryByID(Pair.ProductID); && 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(); ReloadCraftUI();
} }
} }

View File

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