diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 97bbe387..b47528cf 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -12,6 +12,7 @@ #include "GameFramework/CharacterMovementComponent.h" #include "Kismet/GameplayStatics.h" #include "GameFramework/MovementComponent.h" +#include "Inventory/InventoryComponent.h" ////////////////////////////////////////////////////////////////////////// @@ -486,3 +487,16 @@ bool AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf NewGad } return true; } + +void AEndlessVendettaCharacter::UpdateInventorySize(int Cols, int Rows) +{ + UInventoryComponent* Inventory = Cast(GetComponentByClass(UInventoryComponent::StaticClass())); + if (IsValid(Inventory)) + { + Inventory->UpdateInventorySize(Cols, Rows); + } + else + { + UE_LOG(LogTemp, Warning, TEXT("No Vaild Inventory")); + } +} diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index 258c5c21..a20cde35 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -194,4 +194,7 @@ public: // Returns true if successfully changed to a new gadget, can fail if the target gadget to replace is being used bool UpdateGadgetType(TSubclassOf NewGadgetClass); + + UFUNCTION(Exec) + void UpdateInventorySize(int Cols, int Rows); }; diff --git a/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.cpp b/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.cpp index 2d09885f..8f08b362 100644 --- a/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.cpp @@ -23,7 +23,6 @@ void UInventoryComponent::InitializeComponent() ItemToPickup = nullptr; } - // Called when the game starts void UInventoryComponent::BeginPlay() { @@ -181,11 +180,12 @@ void UInventoryComponent::SpawnItem(UBaseItem* Item, FVector Location) { } -void UInventoryComponent::UpdateInventorySize_Implementation(const int _Columns, const int _Rows) +void UInventoryComponent::UpdateInventorySize(const int _Columns, const int _Rows) { Columns = _Columns; Rows = _Rows; InventoryItems.SetNum(Columns * Rows); + OnInventorySizeUpdated.Broadcast(); } bool UInventoryComponent::IsTileValid(const FInventoryTile InventoryTile) const diff --git a/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.h b/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.h index 813a181b..124d0de0 100644 --- a/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.h +++ b/EndlessVendetta/Source/EndlessVendetta/Inventory/InventoryComponent.h @@ -38,6 +38,9 @@ public: DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryUpdated); UPROPERTY(BlueprintAssignable, Category="Inventory") FOnInventoryUpdated OnInventoryUpdated; + DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventorySizeUpdated); + UPROPERTY(BlueprintAssignable, Category = "Inventory") + FOnInventorySizeUpdated OnInventorySizeUpdated; UFUNCTION(BlueprintCallable, Category="Inventory") bool AddItem(class UBaseItem* Item); @@ -60,9 +63,8 @@ public: void RemoveItem(class UBaseItem* Item); UFUNCTION(BlueprintCallable, Category="Inventory") void SpawnItem(class UBaseItem* Item, FVector Location); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Exec, Category = "Inventory") + UFUNCTION(BlueprintCallable, Category = "Inventory") void UpdateInventorySize(const int _Columns, const int _Rows); - virtual void UpdateInventorySize_Implementation(const int _Columns, const int _Rows); private: bool IsTileValid(const FInventoryTile InventoryTile) const;