From 5d2339a29b416960ac75304694e84dc69d717b71 Mon Sep 17 00:00:00 2001 From: ANG-Server <96008766+ANGJustinl@users.noreply.github.com> Date: Wed, 22 Jul 2026 14:20:18 +0800 Subject: [PATCH] fix: separate wall and floor decor placement --- scenes/Maps/PersonalSpace.gd | 42 ++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/scenes/Maps/PersonalSpace.gd b/scenes/Maps/PersonalSpace.gd index f69805d..7d31973 100644 --- a/scenes/Maps/PersonalSpace.gd +++ b/scenes/Maps/PersonalSpace.gd @@ -23,8 +23,8 @@ const DECOR_TEXTURE_FILTER: int = CanvasItem.TEXTURE_FILTER_LINEAR const DECOR_COLLISION_LAYER: int = 1 const DECOR_COLLISION_MASK: int = 1 const ROOM_GRID_SIZE: float = 16.0 -const FLOOR_PLACE_BOUNDS: Rect2 = Rect2(-426.0, -186.0, 852.0, 398.0) -const WALL_PLACE_BOUNDS: Rect2 = Rect2(-378.0, -258.0, 756.0, 72.0) +const FLOOR_PLACE_BOUNDS: Rect2 = Rect2(-426.0, -176.0, 852.0, 388.0) +const WALL_PLACE_BOUNDS: Rect2 = Rect2(-378.0, -258.0, 756.0, 66.0) @onready var player: PlayerController = $YSortWorld/Characters/Players/Player @onready var playerCamera: Camera2D = $YSortWorld/Characters/Players/Player/Camera2D @@ -204,8 +204,14 @@ func _build_placement_grid() -> void: _gridOverlay.visible = false ySortWorld.add_child(_gridOverlay) ySortWorld.move_child(_gridOverlay, 0) - _add_grid_zone(FLOOR_PLACE_BOUNDS, Color(0.050, 0.560, 0.900, 0.20), Color(0.050, 0.560, 0.900, 0.62)) - _add_grid_zone(WALL_PLACE_BOUNDS, Color(0.620, 0.330, 0.860, 0.20), Color(0.620, 0.330, 0.860, 0.62)) + _rebuild_placement_grid() + +func _rebuild_placement_grid() -> void: + if _gridOverlay == null: + return + _clear_children(_gridOverlay) + _add_grid_zone(_placement_bounds_for_surface("floor"), Color(0.050, 0.560, 0.900, 0.20), Color(0.050, 0.560, 0.900, 0.62)) + _add_grid_zone(_placement_bounds_for_surface("wall"), Color(0.620, 0.330, 0.860, 0.20), Color(0.620, 0.330, 0.860, 0.62)) func _add_grid_zone(bounds: Rect2, line_color: Color, edge_color: Color) -> void: if _gridOverlay == null: @@ -617,6 +623,7 @@ func _apply_remote_decor_definitions(definitionsVariant: Variant) -> void: _to_float(position.get("y", 0.0), 0.0) ) _remoteDecorDefinitions[decorId] = definition + _rebuild_placement_grid() func _render_inventory_list() -> void: if _visitorMode: @@ -679,7 +686,8 @@ func _create_inventory_card(decorId: String) -> Button: var status := Label.new() status.custom_minimum_size = Vector2(0, 22) - status.text = "已摆放" if bool(item.get("placed", false)) else "未摆放" + var surface_label := "墙面挂饰" if str(item.get("placement_surface", "floor")) == "wall" else "地面家具" + status.text = "%s · %s" % [surface_label, "已摆放" if bool(item.get("placed", false)) else "未摆放"] status.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT status.add_theme_font_size_override("font_size", 14) status.add_theme_color_override("font_color", ACCENT_COLOR if bool(item.get("placed", false)) else MUTED_COLOR) @@ -1355,7 +1363,29 @@ func _leave_visited_room() -> void: SceneManager.change_scene("square") func _placement_bounds_for_item(item: Dictionary) -> Rect2: - return WALL_PLACE_BOUNDS if str(item.get("placement_surface", "floor")) == "wall" else FLOOR_PLACE_BOUNDS + var surface := str(item.get("placement_surface", "floor")) + return _placement_bounds_from_variant(item.get("placement_bounds", null), WALL_PLACE_BOUNDS if surface == "wall" else FLOOR_PLACE_BOUNDS) + +func _placement_bounds_for_surface(surface: String) -> Rect2: + for definition_variant in _remoteDecorDefinitions.values(): + if not (definition_variant is Dictionary): + continue + var definition: Dictionary = definition_variant as Dictionary + if str(definition.get("placement_surface", "floor")) == surface: + return _placement_bounds_from_variant(definition.get("placement_bounds", null), WALL_PLACE_BOUNDS if surface == "wall" else FLOOR_PLACE_BOUNDS) + return WALL_PLACE_BOUNDS if surface == "wall" else FLOOR_PLACE_BOUNDS + +func _placement_bounds_from_variant(value: Variant, fallback: Rect2) -> Rect2: + if not (value is Dictionary): + return fallback + var bounds: Dictionary = value as Dictionary + var min_x := _to_float(bounds.get("min_x", fallback.position.x), fallback.position.x) + var max_x := _to_float(bounds.get("max_x", fallback.end.x), fallback.end.x) + var min_y := _to_float(bounds.get("min_y", fallback.position.y), fallback.position.y) + var max_y := _to_float(bounds.get("max_y", fallback.end.y), fallback.end.y) + if min_x >= max_x or min_y >= max_y: + return fallback + return Rect2(min_x, min_y, max_x - min_x, max_y - min_y) func _constrain_room_position(position: Vector2, item: Dictionary) -> Vector2: var bounds := _placement_bounds_for_item(item)