Templates for inventory and containers
IFP features two different types of templates;
Inventory template - This is a data asset that simply hosts an array of
ContainerSettings. A inventory component can assign a template data asset to use instead of its ownContainerSettingsarrayThis is soft referenced by the inventory component. To async load it, you can call LoadItemAssets
Container template - This is a fragment that can be assigned to a container and it will point to a data asset which will be used instead of its own settings.
When to use
The primary use case of this system is for teams, or large number of actors who share similar inventories. For example, the player pawn is a critical class in nearly every project, so many team members might be fighting for write-access. By making the inventory component use a separate data asset as a template, the designer who's working on the inventory does not need to fight for write-access on the player pawn.
This can also be used in combination with loot tables, for example creating a template for AI, and the templates containers use a loot table to determine what items should populate that template. For example, if the AI is a wolf, then populate its inventory with meat. If the AI is an orc, populate its inventory with weaponry.
Serialization
To prevent templates from replacing any containers you've saved, StartComponent will automatically reasign the InventoryTemplate variable to null. The InventoryTemplate variable has the SaveGame metaproperty assigned, so certain serialization solutions will automatically remember to reasign it to null. But if you aren't using a serialization solution that utilizes that metaproperty flag, you will want to manually remove the inventory template when loading a save *before* calling StartComponent
Last updated