NeoFPS has its own inventory system that it uses for all of its weapons and items. The inventory is implemented as separate components to the itemas themselves so it should be easy to replace with an alternative system if desired.
The NeoFPS inventory system is implemented in 2 parts: inventory and quickslots.
The inventory is a container of items. It manages item ownership and quantities and invokes events to react to changes.
The demo implementations of the inventory are not fixed. The inventory is referenced externally via the
IInventory interface, meaning that it can be swapped out with another implementation and the system as a whole will adapt.
The quick-slots system binds items to slots that can be mapped to inputs. In a simple, traditional FPS system that would mean each slot being mapped to a number key on the keyboard. It could also mean a slot for each direction on a game controller d-pad.
As with the inventory, the implementation is not fixed. It is referenced externally via the
IQuickSlots interface and, like the inventory, the implementation can be swapped and the system will adapt.
NeoFPS comes with a number of example inventories that implement quick slots in different ways to model popular first person shooters. For more information see Inventory Examples.
Items And Quick-Slot Items
Items are objects that implement the
IInventoryItem interface. The interface has properties for quantity and ownership, along with methods that are called when added or removed from an inventory.
Quick-Slot items implement the
IQuickSlotItem interface. This has properties and methods for selection and for dropping.
Inventory items pickups can be interactive, meaning you need to look at them and hit use, or contact based, meaning you need to walk over them.
The simplest way to create an inventory pickup is using the Pickup Wizard in the NeoFPS Hub. There are also specialised pickups for modular firearms that track ammo count, and for other wieldable items such as melee and thrown weapons. These can all be created from the wizard.
The Inventory Database
The inventory database is a system for managing the inventory keys used to identify each unique item. The database is made up of tables, which are used to gather inventory IDs together. The inventory system used to use GeneratedConstant based keys. The new database system has one fixed table that references the old FpsInventoryKey constants and uses them as keys. This allows you to use the constants to reference inventory item IDs directly in code - useful for items like the keyring, which is a unique, but constant item.
You can create an inventory database table for your project by right-clicking in the project browser and selecting Create/NeoFPS/Inventory/Database Table. This allows you to add your own keys without the risk of clashing with any changes to the NeoFPS demo inventory keys in future updates. Once you have created a table, add it to the database via the NeoFPS Hub: Managers/Inventory Database.
To assign an ID to an object, clicking the ID button will show the inventory database browser.
From here you can browse the different tables to select an ID. You can filter by name using the filter field at the top. You can also add new keys from the browser itself. In the NewEntry section, select the table you want to add to, input a name, and hit Add New Entry button. This will add the a new entry to the selected table, and apply its ID to the object you are editing.
Inventory loadouts are a simple list of inventory objects that should be added to a character's inventory.
You can assign this to a game mode component, and it will apply the loadout on spawning a player character instead of using the character's starting items.