Feature 04: Inventory System

One of the main features of most survival games these days is the ability to gather, craft and upgrade loot. In order to do any of this, the player needs a robust framework to manage their belongings and collect useful gear.

I put together an inventory system with two main things in mind:

  1. to make sure that the UI elements were reusable across the UI not just in the inventory menu;
  2. to ensure the UI behaviour stayed decoupled from data transformations, such that data could be transformed from any part of the business logic, without requiring any handle to the main UI that is concerned with the data.

Firstly, the UI elements needed to be reusable as it was clear that items and abilities form a core part of all the interfaces. As a result the way of displaying those items in the system (what I call the Slot widget), would be used in multiple different menus from loot bags, chests, inventory systems, hotkey bars etc.

Secondly, having multiple containers and relationships between slots, items, containers, container menu’s etc requires quite a complex UI system. Tangling the behaviour to transform the data inside this UI system, means I would have a hell of a time either duplicating similar transformations if required outside of the UI system, or unpicking it at a later date. Therefore I designed the system such that all data is transformed through business logic into its records, and the UI effectively registers to listen to the transformations of the data through the records and cache itself.

These were the main considerations with the system, other considerations included: how to decorate the slots with quantities and hotkey information; how to drag and drop items between slots; how to restrict item types for certain slots (e.g. only weapons in the character weapon slot); how inventory systems will work across multiplayer.

All in all it seems to have worked well and been flexible enough to extend to loot systems, abilities and integrate well with my crafting system.


Posted

in

,

by

Tags:

Comments

Leave a Reply