|
@ -9,6 +9,7 @@ signal item_dropped(item: DBItemResource) |
|
|
signal inventory_opened |
|
|
signal inventory_opened |
|
|
signal inventory_closed |
|
|
signal inventory_closed |
|
|
|
|
|
|
|
|
|
|
|
signal clear_inventory |
|
|
signal add_to_inventory(item_id: String, amount: int) |
|
|
signal add_to_inventory(item_id: String, amount: int) |
|
|
signal remove_from_inventory(item_id: String, amount: int) |
|
|
signal remove_from_inventory(item_id: String, amount: int) |
|
|
signal item_added(item_id: String, amount: int) |
|
|
signal item_added(item_id: String, amount: int) |
|
@ -21,6 +22,7 @@ var max_inventory_items: int = 40 # 4 rows of 10 |
|
|
var inventory: Array[DBItemResource] = [] |
|
|
var inventory: Array[DBItemResource] = [] |
|
|
var _inventory_cache: Dictionary[String, Dictionary] = {} ## Used for caching certain information |
|
|
var _inventory_cache: Dictionary[String, Dictionary] = {} ## Used for caching certain information |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void: |
|
|
func _ready() -> void: |
|
|
self.quick_slot_item_changed.connect(_on_quick_slot_item_changed) |
|
|
self.quick_slot_item_changed.connect(_on_quick_slot_item_changed) |
|
|
self.item_picked_up.connect(_on_item_picked_up) |
|
|
self.item_picked_up.connect(_on_item_picked_up) |
|
@ -28,6 +30,7 @@ func _ready() -> void: |
|
|
|
|
|
|
|
|
self.add_to_inventory.connect(_on_add_to_inventory) |
|
|
self.add_to_inventory.connect(_on_add_to_inventory) |
|
|
self.remove_from_inventory.connect(_on_remove_from_inventory) |
|
|
self.remove_from_inventory.connect(_on_remove_from_inventory) |
|
|
|
|
|
self.clear_inventory.connect(_on_clear_inventory) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func available_space(item_id: String) -> int: |
|
|
func available_space(item_id: String) -> int: |
|
@ -129,6 +132,10 @@ func _on_remove_from_inventory(item_id: String, amount: int = 1) -> void: |
|
|
|
|
|
|
|
|
item_removed.emit(item_id, amount - amount_remaining) |
|
|
item_removed.emit(item_id, amount - amount_remaining) |
|
|
|
|
|
|
|
|
|
|
|
func _on_clear_inventory() -> void: |
|
|
|
|
|
inventory.clear() |
|
|
|
|
|
_inventory_cache.clear() |
|
|
|
|
|
|
|
|
func _on_item_dropped(item_id: String) -> void: |
|
|
func _on_item_dropped(item_id: String) -> void: |
|
|
_on_remove_from_inventory(item_id, 1) |
|
|
_on_remove_from_inventory(item_id, 1) |
|
|
|
|
|
|
|
|