diff --git a/Content/Blueprints/BP_HealingJellyItem.uasset b/Content/Blueprints/BP_HealingJellyItem.uasset index f66b6a9..06702c4 100644 --- a/Content/Blueprints/BP_HealingJellyItem.uasset +++ b/Content/Blueprints/BP_HealingJellyItem.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f9bb81fd6a904d7139d83d81f2d8fbecf448eda7710959bfa2a32faf2e2eee72 -size 29888 +oid sha256:8bde496e61be34dbd75c08fee0b9ad7fff9751158af26fc77f5bae97167cc2e1 +size 31249 diff --git a/Content/Blueprints/BP_Interaction.uasset b/Content/Blueprints/BP_Interaction.uasset index dcb91cb..6a6fb20 100644 --- a/Content/Blueprints/BP_Interaction.uasset +++ b/Content/Blueprints/BP_Interaction.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42db740853a281bd78c277e9281ab2af4bdf9d0ee834045782e066ee782e9e67 -size 27990 +oid sha256:e31f123a59603938d430a7a585aef68184c0c01501f4c9952ac523ff1455c2dc +size 26551 diff --git a/Content/Blueprints/BP_MyTempCharacter.uasset b/Content/Blueprints/BP_MyTempCharacter.uasset index 585dc7f..6bab0dc 100644 --- a/Content/Blueprints/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c720b55a9e91e62f991279ef9d043ef8e41e3282b1b1c640ddb46dd4c8efc543 -size 53356 +oid sha256:58b898c8869c0539a2cee866134a992678874e84fc45085a2fdb8d26b9e35b1c +size 52636 diff --git a/Content/Blueprints/Items/BP_HealingJelly.uasset b/Content/Blueprints/Items/BP_HealingJelly.uasset index 65677e7..85e397d 100644 --- a/Content/Blueprints/Items/BP_HealingJelly.uasset +++ b/Content/Blueprints/Items/BP_HealingJelly.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79844600695e0e7790cb68584c0c58f21af18a8872904ccd645f1ec3108da22d +oid sha256:228d6db7c136bd371aa3b3333cd81dbea3d396a0df920eb88f521520af3438e7 size 6681 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index 6a6e864..2abd349 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:085eef600d9d08558738acea97402875c1b986649999de674e98be2749afe503 -size 24931 +oid sha256:0cf793b6df5bd19e78d63cd14065a8b98fc78f7093ec18b1d127597c8295b329 +size 25103 diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp index 30156e9..a5a1a9f 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -25,30 +25,32 @@ void UInventoryComponent::BeginPlay() for(auto & BaseItem : DefaultItems) { AddItem(BaseItem); - } -} - + } +} + bool UInventoryComponent::AddItem(class UBaseItem* BaseItem) { //if the items is over the maxinventoryslots then it wont add the item if (Items.Num() >= MaxItemSlots || !BaseItem) { + UE_LOG(LogTemp, Display, TEXT("THERE ARE MORE ITEMS THAN THE INVENTORY SLOTS")); return false; } BaseItem->StoredItems = this; BaseItem->World = GetWorld(); Items.Add(BaseItem); - + UE_LOG(LogTemp, Display, TEXT("ITEM HAS BEEN ADDED")); //Update UI OnInventoryUpdated.Broadcast(); return true; } -bool UInventoryComponent::Remove(UBaseItem* BaseItem) +bool UInventoryComponent::Remove(class UBaseItem* BaseItem) { if(BaseItem) { + UE_LOG(LogTemp, Display, TEXT("ItEM HAS BEEN REMOVED")); BaseItem->StoredItems = nullptr; BaseItem->World = nullptr; Items.RemoveSingle(BaseItem); @@ -58,3 +60,8 @@ bool UInventoryComponent::Remove(UBaseItem* BaseItem) return false; } +UBaseItem* UInventoryComponent::GetItem(int32 Index) +{ + return Items[Index]; +} + diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h index d2fbb5a..bcfead2 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h @@ -36,6 +36,9 @@ public: UPROPERTY(BlueprintAssignable, Category= "Inventory") FOnInventoryUpdated OnInventoryUpdated; //This is our delegate - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Items") + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category= "Items") TArray Items; // The items currently in the inventory + + UFUNCTION(BlueprintCallable, Category= "Inventory") + class UBaseItem* GetItem(int32 Index); }; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 6171a59..07a7ae2 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -1,6 +1,8 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "TempCharacter.h" + +#include "IDetailTreeNode.h" #include "Blueprint/UserWidget.h" #include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" @@ -82,9 +84,11 @@ void ATempCharacter::LineTraceLogic() if(GoldBalance >= 100) { GoldBalance -= 100; + Inventory->AddItem(OutHit.GetActor()->FindComponentByClass()->GetItem(0)); + //Inventory->AddItem(Cast(OutHit.GetActor())); + //Inventory->AddItem(OutHit.GetActor()->Get("HealingJelly")); UE_LOG(LogTemp, Display, TEXT("Item Purchased")); - // UInventoryComponent* tempInventory = GetOwner()->FindComponentByClass(); - // tempInventory->AddItem(ItemToBuy); + } if(GoldBalance <= 0) { diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 4760f2c..b3f30c7 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -54,6 +54,6 @@ public: UFUNCTION(BlueprintCallable, Category= "Items") void BuyItem(class UBaseItem* BuyItem); - // UPROPERTY(EditAnywhere, Category= "Items") - // UBaseItem ItemToBuy; + UPROPERTY(EditAnywhere, Category= "Items") + UBaseItem* ItemToBuy; };