Update Inventory to Update Size During Runtime
This commit is contained in:
parent
75c1976ec4
commit
81c9df4940
@ -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<AGadgetBase> NewGad
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::UpdateInventorySize(int Cols, int Rows)
|
||||
{
|
||||
UInventoryComponent* Inventory = Cast<UInventoryComponent>(GetComponentByClass(UInventoryComponent::StaticClass()));
|
||||
if (IsValid(Inventory))
|
||||
{
|
||||
Inventory->UpdateInventorySize(Cols, Rows);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("No Vaild Inventory"));
|
||||
}
|
||||
}
|
||||
|
@ -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<AGadgetBase> NewGadgetClass);
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void UpdateInventorySize(int Cols, int Rows);
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user