Terminology

The Ultimate Inventory System is a very flexible system allow you to create any type of inventory. Usually the more a framework is flexible the harder it is to use and understand. The Ultimate Inventory System is structured in a way to make it as easy to understand as possible. To do this the system includes a workflow with some rules and streamlines the items should be created. There are many components in the system and they each play a key part:

Attributes

Attributes are used throughout the system. Attributes are allowed to override, inherit or modify the value of another attribute.  Attributes are used to create variants of Item Definitions and speeds up iteration time. 

The three variant types are:

  • Override: Overrides the parent attribute value.
  • Inherit: Inherits the parent attribute value.
  • Modify: Uses an expression to compute a value that is dependent on the “parent” attribute or any other attribute in the same collection.
    Example myAttribute2 = “[myAttriute1] * 20 + <Inherit>”
    Modify is extremely powerful when it comes to speeding up iteration time. It also gives the ability for non-programmers to have simple logic on their items. Item Actions should be used for more complex equations.

Example:

  • Parent -> child
  • HealAmount:  5 -> HealAmount (override 10): 10
  • HealAmount:  5 -> HealAmount (inherit): 5
  • HealAmount:  5 -> HealAmount (modify “<Inherit>*3”): 15

Item Category

Item Categories are used to structure your items in a sensible way. All items of a certain category will have the same attributes, with varying values. This ensures that the same action can be performed on any items that are part of the same category. Categories can be nested and parented with multiple children and parents. Mutable categories will set all of the child items to mutable which mean that the attribute values can change at runtime.

Example:

  • Equippable
  • OneHanded
  • Weapon : Equippable
  • OneHandedWeapon : Weapon, OneHanded
  • Dagger: OneHandedWeapon
  • Sword: OneHandedWeapon

Item Definition

Item Definitions can be thought of as templates or molds for items. Item Definitions can have attributes that are consistent across all items created from it. It also contains a reference to a “Default Item” which is used as a base to create the other item instances.

Example:

  • No Parent -> HealPotion (HealAmount: 10, CoolDown: 2)
  • HealPotion  -> SmallHealPotion (HealAmount (Override 6): 6, CoolDown (Inherit): 2)
  • HealPotion  -> BigHealPotion (HealAmount (Modify “<Inherit>*2.5”): 25,
    CoolDown (Override 3): 3)

Item

Items are created at runtime and contain attribute values that can be unique to that Item. Even though two Items have the same mold (Item Definition) they can be set to be slightly different. If the Item is part of a mutable Item Category it is even possible to change the values of the Item attributes at runtime.

Items do not have any “item specific logic” attached to it. It is meant to be a simple set of data. Using that data, which consists of the Item Category, Item Definition and Item attributes, the system knows what kind of actions can be performed on them.

Items can be mutable or immutable. Mutable items can be changed at runtime, whereas immutable items cannot be.

Item Action

Item Actions contain logic that can be performed on some Items of a certain category. A simple example is a “Consume” action which can be performed on any item of a “Consumable” category. Or an “Equip” action that could be performed on any “Equippable” items. These actions are game specific, with examples of use cases in the demo. The Item Actions are meant to be expanded upon in order to take full advantage of.

Item Action Set

Item Action Sets are Scriptable Objects that contain multiple Item Actions grouped by Item Category. They are extremely useful as they can be added in most UI that contains Items.

Category Item Action Set

Category Item Action Sets are Scriptable Objects that contain a list of Item Action Sets. They can be used to retrieve a subset of They are extremely useful as they can be added in most UI that contains Items.

Item Object

Item Object is a MonoBehaviour which binds an Item to a GameObject. This is useful for Items that can be equipped, picked up/ dropped or simply that need a presence in the scene.

Item Object Behaviour

Item Object Behaviours are components which allow attaching logic to an Item Object. For example using a “Sword” to attack or a “Gun” to fire, reload, etc. Having a presence in the scene lets you check for trigger/collision events or spawn projectiles from the point of the gun’s barrel.

Currency

Currency is an abstract object which can be used to exchange with other objects.

Crafting Recipe

A Crafting Recipe contains the input and outputs for combining one or more objects into a new item. The Crafting Recipe works with the Crafting Processor in order to perform the logic to covert one set of objects into another.

Inventory

An Inventory is a group of Item Collections. An Item Collection can have any restrictions on the items that go in or out. Splitting the inventory in different chunks is a good way to organize it. For example, having two Item Collections, one for the equipped Items and another for the non-equipped Items is a common organizational structure.

Item Collection

Item Collections contain a set of Items. Items are stored in a collection as a list of Item Stacks. The Item Collection sends events to the Inventory when Items are added, removed, etc…

Item Stack

An Item Stack is an object that stores an amount of an item amount. An example of an Item Stack is “5 apples”. Item Stacks should only exist within an Item Collection. It should not be confused with an Item Amount which can exist outside of the collection.

Item Amount

An Item Amount is a simple structure with an Item and an amount. It should not be confused with an Item Stack which requires an Item Collection.

Item Info

Item Info gives more specification about the items and where they came from. It has not only the Item Amount but also reference to an Item Stack and/or Item Collection.

For example imagine an Inventory with 2 Item Stacks:

  • Stack 1:”5 apples”
  • Stack 2:”10 apples”

Where apple is an immutable Item.  If you wish to remove 3 apples from Stack 2 you can specify an Item Info as such. When adding Items to an Item Collection you may also specify where the Item came from and in which Item Stack it should be added to.

Item Slot Set

An Item Slot Set is a Scriptable object used to define the slots for an Item Slot Collection. Each slot is simply a name and an Item Category.  The Item Slot Set and Item Slot Collection is often used for equipping items with an Equipper.

Item View

An Item View is used to display an item is the UI, it uses Item View Modules to customize exactly how the item shows up.

Item View Slot

An Item View Slot is used in the UI to detect interactions such as select, click, drag, drop and more. It usually contains an Item View.

Inventory System Database

This is an asset that is created in the editor and it is used to store all your Item Categories, Item Definitions, Currencies, Crafting Categories and Crafting Recipes for your project. These objects are referred to as Inventory System Objects. The database is simply a container of data and is loaded in the Inventory System Manager at the start of a game.

Inventory System Manager

The Inventory system Manager is very important as it manages every Item, Item Definition, Item Category, Currency, Crafting Category and Crafting Recipe in your project. When the project starts it will load the Inventory System Database and it will get references from any of the registered inventory system objects. 

The Inventory System Manager ensures only valid objects are registered and also provides a convenient method to look up objects based on an ID or name. The Inventory System Manager is also used to create Items at runtime.