I’m working on inventoy system in c++ and I have a question. How to store information with Actor using separate class but it should looks like a struct property in editor (just expandable like it was component). I want somthing like this:
class InventoryItemInfo : public UObject
{
UPROPERTY()
FString Name;
UPROPERTY()
int32 Count;
UPROPERTY()
UClass* Class;//used to spawn Actor when drop it from the inventory
}
class SwordItemInfo : public InventoryItemInfo
{
UPROPERTY()
int32 DamageMin;
UPROPERTY()
int32 DamageMax;
}
class InventoryItem : public AActor
{
UPROPERTY()
InventoryItemInfo* m_info;//how to get this property
}
class Sword : public InventoryItem
{
Sword()
{
m_info = NewObject<FInvItemData>(SwordItemInfo);
}
}
class APlayerCharacter : public ACharacter
{
TArray<InventoryItemInfo*> m_inventoryItems;
}
How to get m_info edit in editor if it was a non pointer property?
Or may be how organize classes in another way. The main point is to destroy inventory item Actor when player picked it up but to store its inventory information.
Thanks!
which then appears as an multi-element array entry in the Blueprint derived from the class that calls out the TArray definition. I use this TArray in my Load/SaveGame class directly.
I had originally set mine up with a single inventory, but decided my needs for Weapons were too different for Items and then split it out further for a specialized array that I called “WeaponAttachments”, again too different from the other two to be convenient in my code. So I ended up with three different arrays by the time I was done with it. I also wanted to save frequently, and felt that saving Weapons separately from Items might be less noticeable to the player.