Updated Items
Started to create item stacks and fix item not dissapearing bug
This commit is contained in:
parent
cc9384a9c1
commit
7199ee76a3
BIN
Content/Blueprints/Items/ItemsInWorld/BP_BuffPlacedItem.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/ItemsInWorld/BP_BuffPlacedItem.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
Binary file not shown.
@ -40,10 +40,11 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
||||
BaseItem->StoredItems = this;
|
||||
BaseItem->World = GetWorld();
|
||||
Items.Add(BaseItem);
|
||||
BaseItem->ItemID++;
|
||||
BaseItem->SubItemID++;
|
||||
UE_LOG(LogTemp, Display, TEXT("ITEM HAS BEEN ADDED"));
|
||||
//log the itemid
|
||||
UE_LOG(LogTemp, Display, TEXT("ITEM ID: %d"), BaseItem->ItemID);
|
||||
UE_LOG(LogTemp, Display, TEXT("SUBITEM ID: %d"), BaseItem->SubItemID);
|
||||
|
||||
//Refreshes the inventory
|
||||
OnInventoryUpdated.Broadcast();
|
||||
@ -59,7 +60,14 @@ bool UInventoryComponent::Remove(class UBaseItem* BaseItem)
|
||||
UE_LOG(LogTemp, Display, TEXT("ItEM HAS BEEN REMOVED"));
|
||||
BaseItem->StoredItems = nullptr;
|
||||
BaseItem->World = nullptr;
|
||||
Items.RemoveSingle(BaseItem);
|
||||
if(BaseItem->SubItemID < Items.Num())
|
||||
{
|
||||
Items.RemoveSingle(BaseItem);
|
||||
BaseItem->SubItemID --;
|
||||
UE_LOG(LogTemp, Display, TEXT("ItemRemoved"));
|
||||
UE_LOG(LogTemp, Display, TEXT("SUBITEM ID: %d"), BaseItem->SubItemID);
|
||||
}
|
||||
//Items.RemoveSingle(BaseItem);
|
||||
OnInventoryUpdated.Broadcast(); // Updates UI
|
||||
return true;
|
||||
}
|
||||
|
@ -55,6 +55,9 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Item")
|
||||
int ItemID;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Item")
|
||||
int SubItemID;
|
||||
|
||||
//reference to the UInventoryComponent script
|
||||
UPROPERTY()
|
||||
|
@ -10,6 +10,7 @@
|
||||
UEatableItems::UEatableItems()
|
||||
{
|
||||
ItemID;
|
||||
SubItemID;
|
||||
}
|
||||
|
||||
void UEatableItems::Use(ATempCharacter* Character)
|
||||
|
Loading…
Reference in New Issue
Block a user