Is it possible? I’m currently trying to create custom structures that I can use for an inventory system. This is an attempt at not having to spawn an actor in the world for every object that requires one and so that I can keep the inventory as a data structure.
Here are the examples of what I’m trying to do:
USTRUCT(BlueprintType)
struct FItemStack {
GENERATED_USTRUCT_BODY()
AActor * item;
float stack;
FItemStack() {}
FItemStack(AActor * add_item, float add_stack) {
item = add_item;
stack = add_stack;
}
};
USTRUCT(BlueprintType)
struct FInventory {
GENERATED_USTRUCT_BODY()
TArray<FItemStack> Items;
int32 total_space;
// UFUNCTION HERE
int32 getMaxSlots() { return total_space; }
void setMaxSlots(int32 slots) { total_space = slots; }
FItemStack & getItemAtIndex(int32 index) { return Items[index]; }
int32 addItemToInventory(AActor * add_item, float add_stack) {
Items.Add(FItemStack(add_item, add_stack));
}
void removeItemFromInventory(AActor * remove_item, float remove_stack) {
}
FInventory() {}
};