Changed Escape, portal spawns at spawn to exit.

This commit is contained in:
dingo
2025-12-16 22:39:50 -05:00
parent 9cd00b3b06
commit 2c9d3200f8
7 changed files with 155 additions and 9 deletions
+11 -5
View File
@@ -14,6 +14,7 @@ const WORLD_TILE_SIZE := TILE_SIZE * TILE_SCALE # 32 pixels per tile in world
@onready var mobs_container = $Entities/Mobs
@onready var chests_container = $Entities/Chests
@onready var items_container = $Entities/DroppedItems
@onready var portals_container = $Entities/Portals
@onready var tilemap: TileMapLayer = $TileMapLayer
@onready var hud = $Hud
@onready var inventory_panel = $Inventory
@@ -24,6 +25,7 @@ var player_scene: PackedScene = null
var mob_scene: PackedScene = null
var chest_scene: PackedScene = null
var item_scene: PackedScene = null
var portal_scene: PackedScene = null
var aim_angle: float = 0.0
@@ -37,6 +39,8 @@ func _ready():
chest_scene = load("res://scenes/dungeon/chest.tscn")
if ResourceLoader.exists("res://scenes/dungeon/dropped_item.tscn"):
item_scene = load("res://scenes/dungeon/dropped_item.tscn")
if ResourceLoader.exists("res://scenes/dungeon/portal.tscn"):
portal_scene = load("res://scenes/dungeon/portal.tscn")
# Defer GameState connections
call_deferred("_connect_gamestate")
@@ -169,19 +173,19 @@ func _handle_input():
# Inventory toggle (I key)
if Input.is_action_just_pressed("inventory"):
_toggle_inventory()
if chat_panel.visible != true:
_toggle_inventory()
# Escape handling
# Escape handling - close UI panels, or show hint about portals
if Input.is_action_just_pressed("escape_menu"):
# Close UI first
if inventory_panel and inventory_panel.visible:
inventory_panel.visible = false
elif chat_panel and chat_panel.visible:
chat_panel.visible = false
elif GameState.is_escaping:
GameState.cancel_escape()
else:
GameState.start_escape()
# Player pressed escape but no UI open - hint about portals
print("[Dungeon] To exit, walk into the purple exit portal near spawn")
# Chat (Enter key)
if Input.is_action_just_pressed("chat"):
@@ -240,6 +244,8 @@ func _on_state_updated():
_update_entities(chests_container, GameState.chests, chest_scene)
if item_scene and items_container:
_update_entities(items_container, GameState.dropped_items, item_scene)
if portal_scene and portals_container:
_update_entities(portals_container, GameState.portals, portal_scene)
func _update_entities(container: Node2D, data: Dictionary, scene: PackedScene):
if scene == null or container == null: