Weapons in the inventory

Weapons have been redesigned to be a permanent upgrade in the inventory rather than an item.

See:

Goals

To avoid re-coding the inventory system, the weapon system uses the existing inventory system. When an item is collected, if it is a weapon, the weapon system will store and handle the weapon along with the items (InventoryModel.gd > current_weapon_unlocked).

How it works

When an item is collected (InventoryController.gd > add_new_item() > InventoryItemManager.gd > add_new_item()) if the type of the item is "Weapon" then the add_new_weapon() function is called instead of .add_new_item().

The add_new_weapon() function checks if the weapon was already unlocked and if the new weapon we got is stronger than the one we already have. Then it returns a status enum { WEAPON_ADDED, WEAPON_REPLACED, WEAPON_NOT_REPLACED, WEAPON_FAILED } to the InventoryController.gd which prints the status to the output window.

If multiple weapons are unlocked, the user can cycle through them (see controls) (cycle_item_next and cycle_item_previous in the input map).

With what script it communicates

  • src\DebugItemManager.gd
  • src\HUD.gd
  • src\Inventory.gd
  • src\InventoryController.gd
  • src\InventoryItemManager.gd
  • src\InventoryModel.gd
  • src\ItemResource.gd
  • src\NumberLimits.gd