Overhauled Items

Gave every single item a unique ID so no matter the item the ID will always be different
This commit is contained in:
MH261677 2022-11-29 14:15:20 +00:00
parent 3360ea2031
commit f52ea5efb8
7 changed files with 20 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -40,8 +40,12 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
BaseItem->StoredItems = this;
BaseItem->World = GetWorld();
Items.Add(BaseItem);
BaseItem->ItemID++;
UE_LOG(LogTemp, Display, TEXT("ITEM HAS BEEN ADDED"));
//Update UI
//log the itemid
UE_LOG(LogTemp, Display, TEXT("ITEM ID: %d"), BaseItem->ItemID);
//Refreshes the inventory
OnInventoryUpdated.Broadcast();
return true;

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Items/EatableItems.h"
#include "InventoryComponent.generated.h"
//OUR DELEGATE IS CALLED FONINVENTORYUPDATED
@ -33,6 +34,9 @@ public:
UPROPERTY(EditDefaultsOnly, Category= "Inventory")
int32 MaxItemSlots;
UPROPERTY(EditDefaultsOnly, Category = "Inventory")
int MaxItemStack;
UPROPERTY(BlueprintAssignable, Category= "Inventory")
FOnInventoryUpdated OnInventoryUpdated; //This is our delegate
@ -41,4 +45,5 @@ public:
UFUNCTION(BlueprintCallable, Category= "Inventory")
class UBaseItem* GetItem(int Index);
};

View File

@ -53,6 +53,9 @@ public:
UPROPERTY(EditAnywhere, Category = "Item")
bool isDamageBuffItem;
UPROPERTY(EditAnywhere, Category = "Item")
int ItemID;
//reference to the UInventoryComponent script
UPROPERTY()
class UInventoryComponent* StoredItems;

View File

@ -9,7 +9,7 @@
UEatableItems::UEatableItems()
{
ItemID;
}
void UEatableItems::Use(ATempCharacter* Character)