diff --git a/scripts/event_bus.gd b/scripts/event_bus.gd index d7b486c..43552e9 100644 --- a/scripts/event_bus.gd +++ b/scripts/event_bus.gd @@ -1,5 +1,10 @@ extends Node +# --------------------------------------------------------------------------- +# Save System +# --------------------------------------------------------------------------- +signal save_loaded + # --------------------------------------------------------------------------- # Player / Run lifecycle # --------------------------------------------------------------------------- diff --git a/scripts/game_manager.gd b/scripts/game_manager.gd index 5c9bbf3..464eb33 100644 --- a/scripts/game_manager.gd +++ b/scripts/game_manager.gd @@ -22,6 +22,7 @@ func _ready() -> void: func _load_game() -> void: SaveManager.load_save() + EventBus.save_loaded.emit() func change_state(new_state: GameState) -> void: _previous_state = current_state diff --git a/scripts/player/player_stats.gd b/scripts/player/player_stats.gd index 6c189f7..0606d92 100644 --- a/scripts/player/player_stats.gd +++ b/scripts/player/player_stats.gd @@ -51,6 +51,7 @@ var shield_projector: bool = false func _ready() -> void: EventBus.body_part_equipped.connect(_on_part_equipped) + EventBus.save_loaded.connect(_on_save_loaded) recalculate() if RunManager.player_health_carry > 0.0: current_health = minf(RunManager.player_health_carry, max_health) @@ -58,6 +59,15 @@ func _ready() -> void: else: current_health = max_health # fresh run — start at full HP +func _on_save_loaded() -> void: + var old_max := max_health + recalculate() + # Grant bonus HP from body parts on fresh start + if RunManager.player_health_carry < 0.0 and max_health > old_max: + current_health += (max_health - old_max) + current_health = minf(current_health, max_health) + EventBus.player_health_changed.emit(current_health, max_health) + func recalculate() -> void: speed = BASE_SPEED + UpgradeManager.get_stat_modifier("speed") max_health = BASE_MAX_HEALTH + UpgradeManager.get_stat_modifier("max_health") diff --git a/scripts/rooms/door.gd b/scripts/rooms/door.gd index bb7e2b5..f9c5e99 100644 --- a/scripts/rooms/door.gd +++ b/scripts/rooms/door.gd @@ -9,10 +9,11 @@ const INDICATOR_SIZE := 10.0 const INDICATOR_OFFSET := 20.0 # distance above door # Indicator light colors - only for special rooms, matching floor colors but brighter +# Keys are int values to match what get_room_type_at() returns const INDICATOR_COLORS := { - RoomData.RoomType.ITEM: Color(0.2, 0.45, 0.2), # green - RoomData.RoomType.SHOP: Color(0.9, 0.75, 0.1), # yellow - RoomData.RoomType.BOSS: Color(0.7, 0.15, 0.15), # red + 2: Color(0.2, 0.45, 0.2), # ITEM = green + 3: Color(0.9, 0.75, 0.1), # SHOP = yellow + 4: Color(0.7, 0.15, 0.15), # BOSS = red } # --------------------------------------------------------------------------- @@ -70,7 +71,8 @@ func _build_barrier() -> void: func _build_indicator() -> void: # Only show indicators for special rooms (ITEM, SHOP, BOSS) - if not INDICATOR_COLORS.has(adjacent_room_type): + var type_id := int(adjacent_room_type) + if not INDICATOR_COLORS.has(type_id): return _indicator = Polygon2D.new() @@ -91,7 +93,7 @@ func _build_indicator() -> void: "right": offset = Vector2(door_size.x / 2.0 + INDICATOR_OFFSET, 0) _indicator.position = offset - _indicator.color = INDICATOR_COLORS[adjacent_room_type] + _indicator.color = INDICATOR_COLORS[type_id] add_child(_indicator)