ULimenGridInventoryComponent
Overview
ULimenGridInventoryComponent is an actor component that implements the ILimenInventory interface. It provides functionality to manage items in a grid layout, including adding, moving, and retrieving items. The component uses a nested cell structure to efficiently manage item placement and stacking.
Properties
Type | Name | Access | Description |
|---|---|---|---|
TObjectPtr< ULimenGridItemDatabase > | ItemDatabase | EditAnywhere, BlueprintReadOnly | Reference to the grid item database containing definitions for all items. |
FIntVector2 | Size | EditAnywhere, BlueprintReadOnly | The dimensions of the inventory grid (width and height). |
Functions
Return Type | Signature | Description |
|---|---|---|
void | BeginPlay() | Initializes the component when the owning actor is spawned. |
FInventoryUpdate& | GetOnInventoryUpdated() | Returns a delegate for inventory updates. |
FInventoryUpdate& | GetOnInventoryRefreshed() | Returns a delegate for inventory refreshes. |
FInventoryItemUpdate& | GetOnItemFailedToAdd() | Returns a delegate for failed item additions. |
FInventoryItemUpdate& | GetOnItemAdded() | Returns a delegate for successful item additions. |
FInventoryItemUpdate& | GetOnItemRemoved() | Returns a delegate for item removals. |
FInventoryItemUpdate& | GetOnItemUpdated() | Returns a delegate for item updates. |
bool | CanPutItemAt(const ALimenItemBase* Item, const FIntVector2& Coordinates) const | Checks if an item can be placed at the specified coordinates. |
bool | CanPutStackAt(const TArray< ALimenItemBase *>& Items, const FIntVector2& Coordinates) const | Checks if a stack of items can be placed at the specified coordinates. |
bool | CanPutStackAt(const TArray<TWeakObjectPtr< ALimenItemBase >>& Items, const FIntVector2& Coordinates) const | Checks if a stack of items can be placed at the specified coordinates. |
void | AddItem(ALimenItemBase* Item, const FIntVector2& Coordinates) | Adds an item to the inventory at the specified coordinates. |
bool | AddItem(ALimenItemBase* Item) | Attempts to add an item to any valid location in the inventory. |
void | AddItems(TArray< ALimenItemBase *>& Items, const FIntVector2& Coordinates) | Adds a stack of items to the inventory at the specified coordinates. |
void | MoveItem(ALimenItemBase* Item, const FIntVector2& NewCoordinates) | Moves an item from its current location to a new location. |
void | MoveItemStack(const FIntVector2& From, const FIntVector2& To) | Moves a stack of items from one location to another. |
GetItem(const FIntVector2& Coordinates) | Retrieves an item at the specified coordinates. | |
TArray< ALimenItemBase *> | GetItemStack(const FIntVector2& Coordinates) | Retrieves all items in a stack starting at the specified coordinates. |
void | GetItem(const ALimenItemBase* Item) | Retrieves the coordinates of an item in the inventory. |
TArray< ALimenItemBase *> | PeekItems(const FIntVector2& Coordinates) const | Peeks at the items at the specified coordinates without removing them. |
TArray< ALimenItemBase *> | PeekItems(const TSubclassOf< ALimenItemBase >& Class) const | Retrieves all items of a specific class in the inventory. |
bool | ContainsItem(const ALimenItemBase* Item) const | Checks if an item is present in the inventory. |
FIntVector2 | GetItemCoordinates(const ALimenItemBase* Item) const | Retrieves the coordinates of an item in the inventory. |
FIntVector2 | GetSize() const | Returns the dimensions of the inventory grid. |
GetItemDatabase() const | Returns a reference to the grid item database. | |
const FGridInventoryCell* | GetCell(const FIntVector2& Coordinates) const | Retrieves the cell at the specified coordinates. |
Usage & Implementation Notes
Threading Constraints: This component is not thread-safe and should only be accessed from the game thread.
Replication Requirements: No replication is required for this component as it operates on a local actor's inventory.
Memory Lifetime Management: The component manages memory for items through weak pointers, ensuring that items are not prematurely destroyed if they are no longer referenced by the inventory.
Initialization Dependencies: The
ItemDatabaseproperty must be set before using any functionality of the component.