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 "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "GameFramework/MovementComponent.h"
|
#include "GameFramework/MovementComponent.h"
|
||||||
|
#include "Inventory/InventoryComponent.h"
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -486,3 +487,16 @@ bool AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf<AGadgetBase> NewGad
|
|||||||
}
|
}
|
||||||
return true;
|
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
|
// 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);
|
bool UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass);
|
||||||
|
|
||||||
|
UFUNCTION(Exec)
|
||||||
|
void UpdateInventorySize(int Cols, int Rows);
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,6 @@ void UInventoryComponent::InitializeComponent()
|
|||||||
ItemToPickup = nullptr;
|
ItemToPickup = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
void UInventoryComponent::BeginPlay()
|
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;
|
Columns = _Columns;
|
||||||
Rows = _Rows;
|
Rows = _Rows;
|
||||||
InventoryItems.SetNum(Columns * Rows);
|
InventoryItems.SetNum(Columns * Rows);
|
||||||
|
OnInventorySizeUpdated.Broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UInventoryComponent::IsTileValid(const FInventoryTile InventoryTile) const
|
bool UInventoryComponent::IsTileValid(const FInventoryTile InventoryTile) const
|
||||||
|
@ -38,6 +38,9 @@ public:
|
|||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryUpdated);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryUpdated);
|
||||||
UPROPERTY(BlueprintAssignable, Category="Inventory")
|
UPROPERTY(BlueprintAssignable, Category="Inventory")
|
||||||
FOnInventoryUpdated OnInventoryUpdated;
|
FOnInventoryUpdated OnInventoryUpdated;
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventorySizeUpdated);
|
||||||
|
UPROPERTY(BlueprintAssignable, Category = "Inventory")
|
||||||
|
FOnInventorySizeUpdated OnInventorySizeUpdated;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Inventory")
|
UFUNCTION(BlueprintCallable, Category="Inventory")
|
||||||
bool AddItem(class UBaseItem* Item);
|
bool AddItem(class UBaseItem* Item);
|
||||||
@ -60,9 +63,8 @@ public:
|
|||||||
void RemoveItem(class UBaseItem* Item);
|
void RemoveItem(class UBaseItem* Item);
|
||||||
UFUNCTION(BlueprintCallable, Category="Inventory")
|
UFUNCTION(BlueprintCallable, Category="Inventory")
|
||||||
void SpawnItem(class UBaseItem* Item, FVector Location);
|
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);
|
void UpdateInventorySize(const int _Columns, const int _Rows);
|
||||||
virtual void UpdateInventorySize_Implementation(const int _Columns, const int _Rows);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsTileValid(const FInventoryTile InventoryTile) const;
|
bool IsTileValid(const FInventoryTile InventoryTile) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user