From 819f18b64c1c2c2f0879b22d3613f404e5390783 Mon Sep 17 00:00:00 2001 From: Steven Wroblewski Date: Fri, 17 Apr 2026 21:16:07 +0200 Subject: [PATCH] feat(navigator): add go_to_home / go_to_hospital with home_entered / hospital_entered signals --- scripts/systems/room_navigator.gd | 42 +++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/scripts/systems/room_navigator.gd b/scripts/systems/room_navigator.gd index e5c6d39..5ee3546 100644 --- a/scripts/systems/room_navigator.gd +++ b/scripts/systems/room_navigator.gd @@ -1,14 +1,19 @@ -## RoomNavigator — autoload that moves the Camera2D smoothly between hospital floors and rooms. +## RoomNavigator — autoload that moves the Camera2D smoothly between hospital floors, rooms, and the home/garden area. extends Node signal room_changed(floor_index: int, room_index: int) +signal home_entered() +signal hospital_entered() const FLOOR_HEIGHT: float = 720.0 const ROOM_WIDTH: float = 1280.0 +const HOME_CAMERA_X: float = 640.0 +const HOME_CAMERA_Y: float = 1080.0 const CAMERA_TWEEN_DURATION: float = 0.6 var _current_floor: int = 0 var _current_room: int = 0 +var _is_at_home: bool = false var _camera: Camera2D @@ -23,8 +28,9 @@ func go_to_floor(floor_index: int) -> void: func go_to_room(floor_index: int, room_index: int) -> void: if _camera == null: return - if floor_index == _current_floor and room_index == _current_room: + if not _is_at_home and floor_index == _current_floor and room_index == _current_room: return + _is_at_home = false _current_floor = floor_index _current_room = room_index var target_x: float = room_index * ROOM_WIDTH + ROOM_WIDTH * 0.5 @@ -36,9 +42,41 @@ func go_to_room(floor_index: int, room_index: int) -> void: tween.finished.connect(func() -> void: room_changed.emit(floor_index, room_index)) +func go_to_home() -> void: + if _camera == null: + return + if _is_at_home: + return + _is_at_home = true + var tween: Tween = create_tween() + tween.set_ease(Tween.EASE_IN_OUT) + tween.set_trans(Tween.TRANS_SINE) + tween.tween_property(_camera, "position", Vector2(HOME_CAMERA_X, HOME_CAMERA_Y), CAMERA_TWEEN_DURATION) + tween.finished.connect(func() -> void: home_entered.emit()) + + +func go_to_hospital() -> void: + if _camera == null: + return + if not _is_at_home: + return + _is_at_home = false + var target_x: float = _current_room * ROOM_WIDTH + ROOM_WIDTH * 0.5 + var target_y: float = _current_floor * -FLOOR_HEIGHT + FLOOR_HEIGHT * 0.5 + var tween: Tween = create_tween() + tween.set_ease(Tween.EASE_IN_OUT) + tween.set_trans(Tween.TRANS_SINE) + tween.tween_property(_camera, "position", Vector2(target_x, target_y), CAMERA_TWEEN_DURATION) + tween.finished.connect(func() -> void: hospital_entered.emit()) + + func get_current_floor() -> int: return _current_floor func get_current_room() -> int: return _current_room + + +func is_at_home() -> bool: + return _is_at_home