Concepts
Overview
Summary of the key inventory concepts.
The inventory system is assembled from individual components that let you add powerful inventory management capabilities to your game.
You can use the system as-is to get started quickly, or select individual components for a highly bespoke solution with deep integration and a completely unique look and feel.
Terminology
Entities
Entities are characters and objects in the game world: Character, houses, storage boxes, book shelves, etc. In the context of the inventory system, the relevant entities are the game objects that may have an inventory component.
Diegetic vs extra-diegetic
Diegetic elements exist in the game world and are experienced by the characters. Extra-diegetic elements exist outside of the game world and are only experienced by players.
Approximately speaking, Node2D or Node3D-based scenes
represent diegetic elements, while Control-based user interfaces are extra-diegetic.
Theory of Operation
At a high-level:
- Characters and objects have inventories.
- Players control characters.
- Characters interact with objects.
- Interactions open the inventory user interface.
- Player interacts with inventory through the user interface
Entities have Inventories
The inventory component provides item storage and inventory management capabilities to entities. The inventory component itself doesn't have a user interface. The UI is provided through separate UI components.
Players control Characters
The inventory mechanics make a distinction between the player and the character. That may sound like pedantic semantics, but there's a good reason for it: The character is the "actor," while the player just happens to be controlling the character. This allows for scenarios where a player controls multiple characters, each with their own set of capabilities and permissions.
The distinction is also made because characters could be controlled by the computer/AI as is the case with NPCs (non-player characters).
Characters interact with Entities
The ability for characters to interact with other entities is provided by a separate set of interaction components: The interactor and interactable.
The charactor (also known as the "actor") uses the interactor component to detect and interact with interactable components. Interactions can trigger any kind of action; picking up items, toggling switches, or opening up storage boxes to access inventories.
Accessing inventories
Whether a character can access an entity is handled by the permissions addon. The access management component is configured by the entity's access policy. Access policies are classes that encapsulate your game's permission rules. This is especially important for multiplayer games.
Players interact with UIs
When an inventory is opened by a character, a user interface is presented to the character's player. The player that interacts with the user interface acts on behalf of their character. What a character can do with the inventory depends on that inventory's access policy.
Fundamentally, the separation of these concerns allows for complex behaviors and customization, some of which is explored in this chapter.
A high-level inventory game user Interface provides semantic abstractions for accessing inventories in browse/transfer mode.