sugary-panda (#1)

Reviewed-on: #1
Co-authored-by: Bryce <bryce@brycecovertoperations.com>
Co-committed-by: Bryce <bryce@brycecovertoperations.com>
This commit was merged in pull request #1.
This commit is contained in:
2026-04-28 22:05:11 -07:00
committed by notid
parent dee6216873
commit 639060fa7f
30 changed files with 2402 additions and 6 deletions

View File

@@ -128,7 +128,12 @@ func _unhandled_input(event):
if ScriptBuilder.current_script and not ScriptBuilder.current_script.can_interrupt:
if ScriptBuilder.current_script.handle_input(event):
return
# Block input when inventory overlay is active
var overlay = get_node_or_null("/root/Node2D/InventoryOverlay")
if overlay and overlay is InventoryOverlay and overlay.is_active():
return
var root = get_node("/root/Node2D")
# If look cursor is active and we got here, no SetPiece handled the input
# so this is a room-wide look
@@ -138,7 +143,46 @@ func _unhandled_input(event):
if ActionState.current_action == ActionState.Action.WALK:
var path = NavigationServer2D.map_get_path(map, ego.position, pathfind.to_local(get_global_mouse_position()), true)
start_main_script(ScriptBuilder.init(ScriptBuilder.walk_path(ego, path)).can_interrupt().build(self, "_on_script_complete"))
if ActionState.current_action == ActionState.Action.ITEM:
_on_item_use_in_world()
func _on_room_looked() -> void:
# Default room look description - override in room scripts
pass
func _on_item_use_in_world() -> void:
if not InventoryManager.selected_item:
return
var item_id = InventoryManager.selected_item
var top_piece = ActionState.get_top_hovered_setpiece()
if top_piece:
_use_item_on_setpiece(item_id, top_piece)
else:
_on_item_used_empty_space(item_id)
func _use_item_on_setpiece(item_id: String, piece: SetPiece) -> void:
if piece.has_method("_on_item_used"):
piece._on_item_used(item_id)
else:
var def = InventoryManager.get_item_definition(item_id)
var item_name = item_id
if def:
item_name = def.name
var piece_name = piece.label if piece.label else piece.name
start_main_script(ScriptBuilder.init(ScriptBuilder.say(ego, "I can't use the %s on the %s." % [item_name, piece_name])).build(self, "_on_script_complete"))
func _on_item_used_empty_space(item_id: String) -> void:
var def = InventoryManager.get_item_definition(item_id)
var item_name = item_id
if def:
item_name = def.name
start_main_script(ScriptBuilder.init(ScriptBuilder.say(ego, "There's nothing to use the %s on here." % [item_name])).build(self, "_on_script_complete"))
func give_item(item_id: String) -> void:
InventoryManager.acquire_item(item_id)
func remove_item(item_id: String, quiet: bool = false) -> void:
InventoryManager.remove_item(item_id, quiet)
func strip_items(event_items: Array[String], exempt_items: Array[String] = []) -> void:
InventoryManager.bulk_strip_items(event_items, exempt_items)