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 implementation of the inventory is not fixed. It 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 sample implementation is a simple system that allocates a fixed array, using the item identifier as an index. The identifier is GeneratedConstant meaning that the constant needs to be modified in the inspector and re-generated in order to add new item types. This could easily be replaced with a system that stores the contents using a different container type with random access instead of index based. The identifiers could then be swapped for something else like hashes or unique IDs to allow for dynamic item types or even multiple objects of the same type. This would be closer to the type of inventory that you would expect from an RPG instead of a traditional FPS.
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.