C++ Inventory Helper
CanStoreItem
-
This function check if we can store an item in an inventory
-
Can it called by Blueprint: YES
-
Blueprint type: Pure
Function
static bool CanStoreItem(UFGInventoryComponent* Inventory, int InvIndex, TSubclassOf<UFGItemDescriptor> ItemClass, int Amount = 1);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want to store the item(s) |
int InvIndex |
Index of the slot where we want to store the items |
TSubclassOf<UFGItemDescriptor> ItemClass |
Class of the Item what we want to store |
int Amount |
Amount of the items we want to store |
Output | Description |
---|---|
bool Return |
Can we store the amount of item in the inventory |
StoreItemAmountInInventory
-
This function can Store an Item in an Inventory
-
Can it called by Blueprint: YES
-
Blueprint type: Callable
Function
static void StoreItemAmountInInventory(UFGInventoryComponent* inventory, int InvIndex, TSubclassOf<UFGItemDescriptor> itemClass, int amount = 1);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want to store the item(s) |
int InvIndex |
Index of the slot where we want to store the items |
TSubclassOf<UFGItemDescriptor> ItemClass |
Class of the Item what we want to store |
int Amount |
Amount of the items we want to store |
StoreItemStackInInventory
-
This function can Store a Stack in an Inventory
-
Can it called by Blueprint: YES
-
Blueprint type: Callable
Function
static void StoreItemStackInInventory(UFGInventoryComponent* inventory, int InvIndex, FInventoryStack ItemStack);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want to store the item(s) |
int InvIndex |
Index of the slot where we want to store the items |
FInventoryStack ItemStack |
Stack of an item what we want to store |
AddItemsInInventory
-
This function can Store Items in an Inventory (not using Slot Indexes)
-
Can it called by Blueprint: YES
-
Blueprint type: Callable
Function
static void AddItemsInInventory(UFGInventoryComponent* inventory, TSubclassOf<UFGItemDescriptor> itemClass, int Amount = 1);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want to store the item(s) |
TSubclassOf<UFGItemDescriptor> ItemClass |
Class of the Item what we want to store |
int Amount |
Amount of the items we want to store |
GatherRefundFromInventory
-
Filter the target inventory for solid items and add them into
out_refund
.
I use this in building classes for custom inventory’s to get the refund on dismantle. (Example)
Header:
virtual void GetDismantleRefund_Implementation(TArray<FInventoryStack>& out_refund) const override;
CPP:
void AYourClass::GetDismantleRefund_Implementation(TArray<FInventoryStack>& out_refund) const
{
Super::GetDismantleRefund_Implementation(out_refund);
UKBFLCppInventoryHelper::GatherRefundFromInventory(GetSecondOutputInventory(), out_refund);
}
-
Can it called by Blueprint: NO
PushPipe
-
Push the fluid to the pipe (can be use in FactoryTick is also recommend)
-
Can it called by Blueprint: No
-
Example:
void AYourClass::Factory_Tick(float dt)
{
Super::Factory_Tick(dt);
if(HasAuthority()) {
UKBFLCppInventoryHelper::PushPipe(GetInventory(), 0, dt, YourItemClass, PipeConnection, 300);
UKBFLCppInventoryHelper::PushPipe(GetInventory(), 0, dt, {YourItemClass1, YourItemClass2}, PipeConnection, 300);
}
}
Function
static void PushPipe(UFGInventoryComponent* Inventory, int InventoryIndex, float dt, UFGPipeConnectionFactory* PipeOutput, int PushAmount = 200);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want handle this Connection |
int InvIndex |
Index of the slot where we want to push |
float dt |
DeltaTime form tick |
UFGPipeConnectionFactory* PipeOutput |
Pipe connection for output the fluid |
int PushAmount |
Amount that should max output |
PullPipe
-
With this function can we pull items from a pipe (can be use in FactoryTick is also recommend)
-
Can it called by Blueprint: No
-
Example:
void AYourClass::Factory_Tick(float dt)
{
Super::Factory_Tick(dt);
if(HasAuthority()) {
UKBFLCppInventoryHelper::PullPipe(GetInventory(), 0, dt, YourItemClass, PipeConnection, 300);
UKBFLCppInventoryHelper::PullPipe(GetInventory(), 0, dt, {YourItemClass1, YourItemClass2}, PipeConnection, 300);
}
}
Function
static void PullPipe(UFGInventoryComponent* Inventory, int InventoryIndex, float dt, TSubclassOf<UFGItemDescriptor> AllowedItem, UFGPipeConnectionFactory* PipeInputComp, int PullAmount = 200);
static void PullPipe(UFGInventoryComponent* Inventory, int InventoryIndex, float dt, TArray<TSubclassOf<UFGItemDescriptor>> AllowedItem, UFGPipeConnectionFactory* PipeInputComp, int PullAmount = 200);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want handle this Connection |
int InvIndex |
Index of the slot where we want to push |
float dt |
DeltaTime form tick |
TSubclassOf<UFGItemDescriptor> AllowedItem TArray<TSubclassOf<UFGItemDescriptor>> AllowedItem |
Item or Items (allow Array here too) that allow to grab |
UFGPipeConnectionFactory* PipeOutput |
Pipe connection for input and pull the fluid |
int PushAmount |
Amount that should max output |
PullBelt
-
With this function can we pull items from a belt (can be use in FactoryTick is also recommend)
-
Can it called by Blueprint: No
-
Example:
void AYourClass::Factory_Tick(float dt)
{
Super::Factory_Tick(dt);
if(HasAuthority()) {
UKBFLCppInventoryHelper::PullBelt(GetInventory(), 0, dt, YourItemClass, BeltConnection);
UKBFLCppInventoryHelper::PullBelt(GetInventory(), 0, dt, {YourItemClass1, YourItemClass2}, BeltConnection);
}
}
Function
static void PullBelt(UFGInventoryComponent* Inventory, int InventoryIndex, float dt, TSubclassOf<UFGItemDescriptor> AllowedItem, UFGFactoryConnectionComponent* BeltInput);
static void PullBelt(UFGInventoryComponent* Inventory, int InventoryIndex, float dt, TArray<TSubclassOf<UFGItemDescriptor>> AllowedItem, UFGFactoryConnectionComponent* BeltInput);
Input | Description |
---|---|
UFGInventoryComponent* Inventory |
Inventory where we want handle this Connection |
int InvIndex |
Index of the slot where we want to push |
float dt |
DeltaTime form tick |
TSubclassOf<UFGItemDescriptor> AllowedItem TArray<TSubclassOf<UFGItemDescriptor>> AllowedItem |
Item or Items (allow Array here to) that allow to grab |
UFGFactoryConnectionComponent* BeltInput |
Pipe connection for input and pull the item |