3.0

Engine support: 5.5

IFP is implementing instanced structs! A new feature in 5.5 that many in the community have started calling "Fragments". This means that a large portion of the code base is changing to utilize fragments and has thus constituted this update to become version 3

Fragments

Why?

Short answer: Memory optimizations, feature improvements and future proofing.

Long answer: Both the container and item structs have a lot of redundant data for most projects or in certain contexts. For example:

  • Override settings: Use 1/3 of item struct memory but are rarely needed.

  • Random min/max counts: Only relevant during initialization for stackable items.

  • Compatibility settings: Occupy 25%+ of container memory but aren't used by all containers.

Every time a feature is added to item or container structs, the memory size increases for every project and struct—even those not using that feature.

Blueprints didn't support hierarchical structs and the editor provided no UI for them, which forced me to make this sacrifice. However, in Unreal Engine 5.5, "Instanced Structs" have become part of the core engine, enabling Blueprint support for hierarchical structs.

Key Benefits

  • Reduced memory usage:

    • Item struct size: 276 bytes → 112 bytes (2.5x improvement)

    • Container struct size: 400 bytes → 208 bytes

    • This also means IFP's networking is much more efficient now.

  • Customization: Add any data to container and items structs without worrying about future updates overriding your changes. For instance, you can now create a child of the new CompatibilitySettings fragment and implement your own settings. Or create a fragment with custom data to make more unique item customization.

  • Networking efficiency: While networking in IFP is complex, it's extremely efficient. Due to the small size of the average fragment, it's now possible to create a generic function that takes any fragment and syncs it with all relevant clients. This simplifies the creation of replicable item data in IFP.

Transition Process

  • Properties moved to fragments will be marked as _DEPRECATED. Transition code will automatically transfer settings when objects load. This code can be found in the PostLoad function. So remember, this will only be executed when the object is loaded. So for assets, make sure to open them to fully make sure they got loaded, and for all actors in your level, look at their inventory component to make sure everything executed correctly.

    • Item assets for some reason would have their data wiped if renamed with _DEPRECATED. So Tags and TagValues inside the data asset aren't labelled as deperecated, but should be treated as such.

  • Backup projects during migration. Deprecated properties and transition code will be removed in 6 months, so update before then to avoid losing settings. I will ping everyone on Discord before this code is removed to remind everyone.

Future Proofing

Fragments offer modular customization, enabling unique item and container configurations without altering the base plugin. Examples:

  • Extend the compatibility settings system into an item fragment, allowing all its containers to use those settings instead of—or in combination with—their own

  • Creating a “Container template” fragment that links to a data asset with pre-defined settings, allowing you to make global changes to many containers across different actors and items throughout the game in one place.

  • Adding "Socket Fragments" to store item references near sockets.

Fragments make IFP more flexible, scalable, and prepared for evolving project needs.


Items

  • The item struct now stores a soft reference to the item asset and the regular hard reference has been hidden. The soft reference will automatically populate and reset the hard reference during the PostLoad event. Added a LoadItemAssets function to async load the assets, but if they aren't loaded when StartComponent is called, then they will be loaded instantly.

Important API change: This means that the ItemAsset variable is null before StartComponent or LoadItemAssets is called and whenever you are creating a item struct through the Make S_InventoryItem node, you should fill in the soft reference.

  • The item struct header has been customized to show an icon of the item asset inside of it.


Fragments

  • New default items fragment allows you to safely add default items to an items container. This is recursive.

    • I highly suggest using the DefaultItems fragment rather than ItemsContainers fragment and to stop using the BelongsToItem variable. Code comment explains why this fragment is safe.

  • Tile tags can now be optimized for the game thread. It does this by filling in the empty spaces so the array is 1:1 with the tile map, which makes getting a tag for a tile be searchable in constant time rather than linear time

Bug fixes

  • GAS effects would only be activated if the tag event also had an attribute associated with it.

Last updated