Developed in C++
Following the same logic as how EPIC expects us to work on the project. (Or at least our interpretation of it.)
Which is based on using a component to manage all the inputs and outputs of the inventory. This “InventoryManagerComponent” can be assigned to any actor, so that it has an inventory, with all its functionalities.
The InventoryManagerComponent manages the items, in two forms:
A) As an Instance (ItemInstance),
B) As an Abstract Definition (ItemDefinition).
The code provides functions so that you can manipulate both.
When is ItemDefinition used and when is Instance?
We remember that conceptually, an ItemDefinition is an Abstract class, with which it can never be instantiated, it serves as a reference or guide.
Instead, the Instance, yes, is running and replicated.
Let’s assume an example, the reward of a chest:
When we decide which items the chest is going to deliver, we do it from the editor, and since we are in “edition” we cannot “instantiate” items, therefore, we must use the definition.
What this method does is from an “ItemDefinition” it creates an instance of the definition and assigns it to the Inventory that we pass as a parameter. Also, it returns the ItemInstance that was created.
Therefore, we can affirm that the difference between an ItemDefinition and an ItemInstance, lies in whether or not the item is running.
Finally, let’s talk about the composition of the Items
If I want to add, for example to my item, a “Niagara” component, I must use fragments.
The fragments are small parts that give attributes to the item. Therefore, an item is made up of fragments.
Using a “TREE” approach. Being the item the Root and the “leaves” the fragments that compose it.
The advantage of using this scheme is the ease and optimization of the code.
Since each item has only the fragments that we assign to it.
If I create an item that doesn’t need a StaticMesh directly, I don’t add the fragment to it. And I end up saving a lot of resources.
As if this were not enough, since the Items are executed on the server, and are replicated, using this fragment scheme only leads us to have “replicated” the instance of it. Saving a lot of resources. Since the fragments are not altered in execution, and therefore, it is not necessary that they be replicated.
The result is excellent Network performance.