FLimenInventorySlot
Overview
FLimenInventorySlot is a data structure used to define and manage individual slots within an inventory. It includes properties for the slot's name and allowed item classes, as well as comparison operators for equality checks.
Properties
Type | Name | Access | Description |
|---|---|---|---|
FName | SlotName | EditAnywhere, BlueprintReadOnly | The name of the inventory slot. |
TArray<TObjectPtr > | AllowedClasses | EditAnywhere, BlueprintReadOnly | A list of item classes that are allowed to be placed in this slot. |
Functions
Return Type | Signature | Description |
|---|---|---|
bool | operator==(const FLimenInventorySlot& Other) const | Compares two |
bool | operator==(const FName& InSlotName) const | Compares an |
ULimenSlotInventoryComponent
Overview
ULimenSlotInventoryComponent is an actor component that implements the ILimenInventory interface. It manages a set of inventory slots and handles item operations such as adding, removing, and updating items. The component also supports replication for networked games.
Properties
Type | Name | Access | Description |
|---|---|---|---|
TSet | Slots | EditAnywhere, BlueprintReadOnly | A set of inventory slots that define the structure of the inventory. |
FLimenReplicatedInventorySlotsArray | ReplicatedSlots | Replicated | A replicated array of inventory slots used for network synchronization. |
Functions
Return Type | Signature | Description |
|---|---|---|
FSlotUpdate | OnSlotItemUpdated | Multicast delegate triggered when an item is updated in a slot. |
FSlotUpdate | OnSlotCreated | Multicast delegate triggered when a new slot is created. |
FSlotUpdate | OnSlotRemoved | Multicast delegate triggered when a slot is removed. |
FLimenInventorySlot& | FindOrAddSlot(const FName& SlotName) | Finds an existing slot or adds a new one if it doesn't exist. |
void | RemoveSlot(const FName& SlotName) | Removes the specified slot from the inventory. |
void | DynamicAddSlot(const FName SlotName) | Adds a new slot dynamically during gameplay, requiring authority and being called after BeginPlay. |
void | DynamicRemoveSlot(const FName SlotName) | Removes a slot dynamically during gameplay, requiring authority and being called after BeginPlay. |
bool | DoesSlotExist(const FName& SlotName) const | Checks if the specified slot exists in the inventory. |
bool | AddItem(const FName& SlotName, const TScriptInterface< ILimenSlotInventoryItem >& Item) | Adds an item to the specified slot if it's compatible and not already occupied. |
bool | GetItem(const TScriptInterface< ILimenSlotInventoryItem >& Item) | Retrieves an item from its current slot and removes it. |
TScriptInterface< ILimenSlotInventoryItem > | GetItemFromSlot(const FName& SlotName) | Retrieves an item from the specified slot and removes it. |
template T* GetItemFromSlot(const FName& SlotName) | Retrieves an item of a specific type from the specified slot and removes it. | |
template TScriptInterface GetItemInterfaceFromSlot(const FName& SlotName) | Retrieves an item interface of a specific type from the specified slot and removes it. | |
TScriptInterface< ILimenSlotInventoryItem > | PeekItemFromSlot(FName SlotName) const | Retrieves an item from the specified slot without removing it. |
template T* PeekItemFromSlot(const FName& SlotName) | Retrieves an item of a specific type from the specified slot without removing it. | |
template TScriptInterface PeekItemInterfaceFromSlot(const FName& SlotName) | Retrieves an item interface of a specific type from the specified slot without removing it. |
Usage & Implementation Notes
Threading Constraints: This component should be used on the game thread only.
Replication Requirements: The
ReplicatedSlotsproperty is marked for replication to ensure that inventory changes are synchronized across networked clients.Memory Lifetime Management: Ensure that items added to slots have proper lifetime management, especially in networked environments where objects may need to be replicated and destroyed.