diff --git a/addons/enhanced_gridmap/enhanced_gridmap.gd b/addons/enhanced_gridmap/enhanced_gridmap.gd index c750291..d7a1ed5 100644 --- a/addons/enhanced_gridmap/enhanced_gridmap.gd +++ b/addons/enhanced_gridmap/enhanced_gridmap.gd @@ -638,12 +638,13 @@ func _update_cell_option_buttons(): set_cell_item(position, 0) func _set(property, value): - if property == "mesh_library": - mesh_library = value - _on_mesh_library_changed() - return true + if property.begins_with("data/cells") and Engine.is_editor_hint(): + call_deferred("_emit_grid_updated") return false +func _emit_grid_updated(): + emit_signal("grid_updated") + # Toggle diagonal movement func set_diagonal_movement(enable: bool): diagonal_movement = enable diff --git a/addons/enhanced_gridmap/enhanced_gridmap_dock.gd b/addons/enhanced_gridmap/enhanced_gridmap_dock.gd index e00e8e9..f958eca 100644 --- a/addons/enhanced_gridmap/enhanced_gridmap_dock.gd +++ b/addons/enhanced_gridmap/enhanced_gridmap_dock.gd @@ -121,6 +121,7 @@ func add_custom_item_state(name: String, id: int): # #item_states_container.add_child(container) + func add_item_state_ui(item_state: CustomItemState): var container = HBoxContainer.new() @@ -295,10 +296,14 @@ func _update_grid_ui(): # Ensure the selected item in the OptionButton corresponds to the current cell item var cell_item = enhanced_gridmap.get_cell_item(Vector3i(x, current_floor, z)) - if cell_item != -1 and cell_item < option.get_item_count(): - option.select(cell_item) + if cell_item == -1: + option.select(0) # "Empty" else: - option.select(0) # Select the first item if the cell is empty + var item_index = cell_item + 1 # because "Empty" is index 0 + if item_index < option.get_item_count(): + option.select(item_index) + else: + option.select(0) option.item_selected.connect(_on_cell_item_selected.bind(option)) option.size_flags_horizontal = Control.SIZE_EXPAND_FILL @@ -324,7 +329,9 @@ func _update_grid_ui(): cell_container.add_child(rotation_option) row_container.add_child(cell_container) cell_options.append(option) - enhanced_gridmap._update_cell_option_buttons() + + + # enhanced_gridmap._update_cell_option_buttons() func _update_astar_ui(): start_x_spin.max_value = enhanced_gridmap.columns - 1 @@ -456,7 +463,7 @@ func _on_non_walkable_item_changed(value): func _on_grid_updated(): update_ui() - enhanced_gridmap._update_cell_option_buttons() + # enhanced_gridmap._update_cell_option_buttons() func _on_cell_rotation_changed(index: int, option: OptionButton): var position = option.get_meta("grid_position") diff --git a/addons/enhanced_gridmap/meshlibrary/default.tres b/addons/enhanced_gridmap/meshlibrary/default.tres index f1d633e..bc27de5 100644 --- a/addons/enhanced_gridmap/meshlibrary/default.tres +++ b/addons/enhanced_gridmap/meshlibrary/default.tres @@ -51,22 +51,21 @@ item/5/mesh_cast_shadow = 1 item/5/shapes = [] item/5/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/5/navigation_layers = 1 -item/6/name = "tile_coin" -item/6/mesh = ExtResource("4_76xkl") +item/6/name = "empty" item/6/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/6/mesh_cast_shadow = 1 item/6/shapes = [] item/6/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/6/navigation_layers = 1 -item/7/name = "tile_diamond" -item/7/mesh = ExtResource("5_j2mx0") +item/7/name = "tile_heart" +item/7/mesh = ExtResource("6_ptqbt") item/7/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/7/mesh_cast_shadow = 1 item/7/shapes = [] item/7/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/7/navigation_layers = 1 -item/8/name = "tile_heart" -item/8/mesh = ExtResource("6_ptqbt") +item/8/name = "tile_diamond" +item/8/mesh = ExtResource("5_j2mx0") item/8/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/8/mesh_cast_shadow = 1 item/8/shapes = [] @@ -79,3 +78,10 @@ item/9/mesh_cast_shadow = 1 item/9/shapes = [] item/9/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/9/navigation_layers = 1 +item/10/name = "tile_coin" +item/10/mesh = ExtResource("4_76xkl") +item/10/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) +item/10/mesh_cast_shadow = 1 +item/10/shapes = [] +item/10/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) +item/10/navigation_layers = 1 diff --git a/scenes/main.tscn b/scenes/main.tscn index 7c7b7ec..9530d6d 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -39,7 +39,7 @@ turn_based_mode = false mesh_library = ExtResource("1_110wo") cell_size = Vector3(1, 0.2, 1) data = { -"cells": PackedInt32Array(65537, 0, 8, 65537, 1, 8, 65537, 2, 6, 65537, 3, 7, 65537, 4, 7, 65537, 5, 6, 65537, 6, 8, 65537, 7, 6, 65537, 8, 8, 65537, 9, 7, 65537, 10, 8, 65537, 11, 9, 65537, 12, 7, 65537, 13, 6, 65538, 0, 9, 65538, 1, 7, 65538, 2, 8, 65538, 3, 7, 65538, 4, 8, 65538, 5, 8, 65538, 6, 9, 65538, 7, 7, 65538, 8, 9, 65538, 9, 8, 65538, 10, 9, 65538, 11, 9, 65538, 12, 8, 65538, 13, 8, 65539, 0, 9, 65539, 1, 6, 65539, 2, 8, 65539, 3, 9, 65539, 4, 7, 65539, 5, 7, 65539, 6, 6, 65539, 7, 8, 65539, 8, 8, 65539, 9, 7, 65539, 10, 8, 65539, 11, 6, 65539, 12, 7, 65539, 13, 7, 65540, 0, 6, 65540, 1, 8, 65540, 2, 8, 65540, 3, 7, 65540, 4, 9, 65540, 5, 8, 65540, 6, 9, 65540, 7, 8, 65540, 8, 9, 65540, 9, 7, 65540, 10, 8, 65540, 11, 8, 65540, 12, 7, 65540, 13, 8, 65541, 0, 8, 65541, 1, 8, 65541, 2, 8, 65541, 3, 9, 65541, 4, 6, 65541, 5, 7, 65541, 6, 7, 65541, 7, 8, 65541, 8, 8, 65541, 9, 8, 65541, 10, 6, 65541, 11, 9, 65541, 12, 9, 65541, 13, 9, 65542, 0, 8, 65542, 1, 8, 65542, 2, 9, 65542, 3, 9, 65542, 4, 7, 65542, 5, 6, 65542, 6, 8, 65542, 7, 6, 65542, 8, 9, 65542, 9, 6, 65542, 10, 6, 65542, 11, 7, 65542, 12, 6, 65542, 13, 7, 65543, 0, 6, 65543, 1, 7, 65543, 2, 8, 65543, 3, 7, 65543, 4, 8, 65543, 5, 7, 65543, 6, 6, 65543, 7, 9, 65543, 8, 9, 65543, 9, 6, 65543, 10, 9, 65543, 11, 6, 65543, 12, 8, 65543, 13, 6, 65544, 0, 9, 65544, 1, 8, 65544, 2, 6, 65544, 3, 7, 65544, 4, 8, 65544, 5, 9, 65544, 6, 8, 65544, 7, 9, 65544, 8, 6, 65544, 9, 8, 65544, 10, 6, 65544, 11, 9, 65544, 12, 6, 65544, 13, 7, 65545, 0, 6, 65545, 1, 9, 65545, 2, 9, 65545, 3, 8, 65545, 4, 9, 65545, 5, 8, 65545, 6, 7, 65545, 7, 8, 65545, 8, 7, 65545, 9, 6, 65545, 10, 8, 65545, 11, 8, 65545, 12, 6, 65545, 13, 8, 65546, 0, 8, 65546, 1, 6, 65546, 2, 6, 65546, 3, 7, 65546, 4, 8, 65546, 5, 7, 65546, 6, 9, 65546, 7, 7, 65546, 8, 6, 65546, 9, 7, 65546, 10, 9, 65546, 11, 7, 65546, 12, 7, 65546, 13, 8, 65547, 0, 7, 65547, 1, 9, 65547, 2, 6, 65547, 3, 9, 65547, 4, 8, 65547, 5, 7, 65547, 6, 6, 65547, 7, 6, 65547, 8, 8, 65547, 9, 8, 65547, 10, 8, 65547, 11, 6, 65547, 12, 9, 65547, 13, 6, 65548, 0, 6, 65548, 1, 6, 65548, 2, 7, 65548, 3, 6, 65548, 4, 8, 65548, 5, 8, 65548, 6, 8, 65548, 7, 9, 65548, 8, 9, 65548, 9, 7, 65548, 10, 9, 65548, 11, 7, 65548, 12, 7, 65548, 13, 8, 131072, 0, 5, 131072, 1, 5, 131072, 2, 5, 131072, 3, 5, 131072, 4, 5, 131072, 5, 5, 131072, 6, 5, 131072, 7, 5, 131072, 8, 5, 131072, 9, 5, 131072, 10, 5, 131072, 11, 5, 131072, 12, 5, 131072, 13, 5, 131073, 0, 5, 131073, 1, 5, 131073, 2, 5, 131073, 3, 5, 131073, 4, 5, 131073, 5, 5, 131073, 6, 5, 131073, 7, 5, 131073, 8, 5, 131073, 9, 5, 131073, 10, 5, 131073, 11, 5, 131073, 12, 5, 131073, 13, 5, 131074, 0, 5, 131074, 1, 5, 131074, 2, 5, 131074, 3, 5, 131074, 4, 5, 131074, 5, 5, 131074, 6, 5, 131074, 7, 5, 131074, 8, 5, 131074, 9, 5, 131074, 10, 5, 131074, 11, 5, 131074, 12, 5, 131074, 13, 5, 131075, 0, 5, 131075, 1, 5, 131075, 2, 5, 131075, 3, 5, 131075, 4, 5, 131075, 5, 5, 131075, 6, 5, 131075, 7, 5, 131075, 8, 5, 131075, 9, 5, 131075, 10, 5, 131075, 11, 5, 131075, 12, 5, 131075, 13, 5, 131076, 0, 5, 131076, 1, 5, 131076, 2, 5, 131076, 3, 5, 131076, 4, 5, 131076, 5, 5, 131076, 6, 5, 131076, 7, 5, 131076, 8, 5, 131076, 9, 5, 131076, 10, 5, 131076, 11, 5, 131076, 12, 5, 131076, 13, 5, 131077, 0, 5, 131077, 1, 5, 131077, 2, 5, 131077, 3, 5, 131077, 4, 5, 131077, 5, 5, 131077, 6, 5, 131077, 7, 5, 131077, 8, 5, 131077, 9, 5, 131077, 10, 5, 131077, 11, 5, 131077, 12, 5, 131077, 13, 5, 131078, 0, 5, 131078, 1, 5, 131078, 2, 5, 131078, 3, 5, 131078, 4, 5, 131078, 5, 5, 131078, 6, 5, 131078, 7, 5, 131078, 8, 5, 131078, 9, 5, 131078, 10, 5, 131078, 11, 5, 131078, 12, 5, 131078, 13, 5, 131079, 0, 5, 131079, 1, 5, 131079, 2, 5, 131079, 3, 5, 131079, 4, 5, 131079, 5, 5, 131079, 6, 5, 131079, 7, 5, 131079, 8, 5, 131079, 9, 5, 131079, 10, 5, 131079, 11, 5, 131079, 12, 5, 131079, 13, 5, 131080, 0, 5, 131080, 1, 5, 131080, 2, 5, 131080, 3, 5, 131080, 4, 5, 131080, 5, 5, 131080, 6, 5, 131080, 7, 5, 131080, 8, 5, 131080, 9, 5, 131080, 10, 5, 131080, 11, 5, 131080, 12, 5, 131080, 13, 5, 131081, 0, 5, 131081, 1, 5, 131081, 2, 5, 131081, 3, 5, 131081, 4, 5, 131081, 5, 5, 131081, 6, 5, 131081, 7, 5, 131081, 8, 5, 131081, 9, 5, 131081, 10, 5, 131081, 11, 5, 131081, 12, 5, 131081, 13, 5, 131082, 0, 5, 131082, 1, 5, 131082, 2, 5, 131082, 3, 5, 131082, 4, 5, 131082, 5, 5, 131082, 6, 5, 131082, 7, 5, 131082, 8, 5, 131082, 9, 5, 131082, 10, 5, 131082, 11, 5, 131082, 12, 5, 131082, 13, 5, 131083, 0, 5, 131083, 1, 5, 131083, 2, 5, 131083, 3, 5, 131083, 4, 5, 131083, 5, 5, 131083, 6, 5, 131083, 7, 5, 131083, 8, 5, 131083, 9, 5, 131083, 10, 5, 131083, 11, 5, 131083, 12, 5, 131083, 13, 5, 131084, 0, 5, 131084, 1, 5, 131084, 2, 5, 131084, 3, 5, 131084, 4, 5, 131084, 5, 5, 131084, 6, 5, 131084, 7, 5, 131084, 8, 5, 131084, 9, 5, 131084, 10, 5, 131084, 11, 5, 131084, 12, 5, 131084, 13, 5, 131085, 0, 5, 131085, 1, 5, 131085, 2, 5, 131085, 3, 5, 131085, 4, 5, 131085, 5, 5, 131085, 6, 5, 131085, 7, 5, 131085, 8, 5, 131085, 9, 5, 131085, 10, 5, 131085, 11, 5, 131085, 12, 5, 131085, 13, 5, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0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0, 11, 1, 0, 11, 2, 0, 11, 3, 0, 11, 4, 0, 11, 5, 0, 11, 6, 0, 11, 7, 0, 11, 8, 0, 11, 9, 0, 11, 10, 0, 11, 11, 0, 11, 12, 0, 11, 13, 0, 12, 0, 0, 12, 1, 0, 12, 2, 0, 12, 3, 0, 12, 4, 0, 12, 5, 0, 12, 6, 0, 12, 7, 0, 12, 8, 0, 12, 9, 0, 12, 10, 0, 12, 11, 0, 12, 12, 0, 12, 13, 0, 13, 0, 0, 13, 1, 0, 13, 2, 0, 13, 3, 0, 13, 4, 0, 13, 5, 0, 13, 6, 0, 13, 7, 0, 13, 8, 0, 13, 9, 0, 13, 10, 0, 13, 11, 0, 13, 12, 0, 13, 13, 0, 65537, 0, 7, 65537, 1, 7, 65537, 2, 9, 65537, 3, 7, 65537, 4, 9, 65537, 5, 8, 65537, 6, 7, 65537, 7, 8, 65537, 8, 10, 65537, 9, 8, 65537, 10, 7, 65537, 11, 7, 65537, 12, 10, 65537, 13, 10, 65538, 0, 10, 65538, 1, 7, 65538, 2, 9, 65538, 3, 7, 65538, 4, 8, 65538, 5, 10, 65538, 6, 8, 65538, 7, 8, 65538, 8, 8, 65538, 9, 10, 65538, 10, 8, 65538, 11, 10, 65538, 12, 7, 65538, 13, 7, 65539, 0, 7, 65539, 1, 9, 65539, 2, 7, 65539, 3, 9, 65539, 4, 8, 65539, 5, 10, 65539, 6, 10, 65539, 7, 8, 65539, 8, 7, 65539, 9, 10, 65539, 10, 9, 65539, 11, 8, 65539, 12, 8, 65539, 13, 7, 65540, 0, 9, 65540, 1, 8, 65540, 2, 7, 65540, 3, 7, 65540, 4, 9, 65540, 5, 7, 65540, 6, 10, 65540, 7, 10, 65540, 8, 10, 65540, 9, 9, 65540, 10, 8, 65540, 11, 7, 65540, 12, 7, 65540, 13, 9, 65541, 0, 9, 65541, 1, 9, 65541, 2, 10, 65541, 3, 8, 65541, 4, 7, 65541, 5, 9, 65541, 6, 10, 65541, 7, 9, 65541, 8, 8, 65541, 9, 9, 65541, 10, 10, 65541, 11, 9, 65541, 12, 9, 65541, 13, 9, 65542, 0, 10, 65542, 1, 7, 65542, 2, 8, 65542, 3, 8, 65542, 4, 10, 65542, 5, 9, 65542, 6, 8, 65542, 7, 7, 65542, 8, 9, 65542, 9, 8, 65542, 10, 8, 65542, 11, 10, 65542, 12, 10, 65542, 13, 8, 65543, 0, 9, 65543, 1, 9, 65543, 2, 9, 65543, 3, 8, 65543, 4, 10, 65543, 5, 9, 65543, 6, 7, 65543, 7, 7, 65543, 8, 8, 65543, 9, 8, 65543, 10, 7, 65543, 11, 7, 65543, 12, 9, 65543, 13, 10, 65544, 0, 8, 65544, 1, 7, 65544, 2, 8, 65544, 3, 8, 65544, 4, 9, 65544, 5, 9, 65544, 6, 8, 65544, 7, 7, 65544, 8, 8, 65544, 9, 7, 65544, 10, 8, 65544, 11, 10, 65544, 12, 9, 65544, 13, 7, 65545, 0, 8, 65545, 1, 7, 65545, 2, 9, 65545, 3, 9, 65545, 4, 7, 65545, 5, 7, 65545, 6, 10, 65545, 7, 7, 65545, 8, 10, 65545, 9, 10, 65545, 10, 10, 65545, 11, 7, 65545, 12, 10, 65545, 13, 8, 65546, 0, 7, 65546, 1, 7, 65546, 2, 9, 65546, 3, 8, 65546, 4, 7, 65546, 5, 9, 65546, 6, 8, 65546, 7, 7, 65546, 8, 10, 65546, 9, 8, 65546, 10, 9, 65546, 11, 9, 65546, 12, 9, 65546, 13, 8, 65547, 0, 9, 65547, 1, 7, 65547, 2, 10, 65547, 3, 10, 65547, 4, 9, 65547, 5, 10, 65547, 6, 10, 65547, 7, 8, 65547, 8, 10, 65547, 9, 9, 65547, 10, 8, 65547, 11, 8, 65547, 12, 7, 65547, 13, 8, 65548, 0, 7, 65548, 1, 9, 65548, 2, 10, 65548, 3, 9, 65548, 4, 8, 65548, 5, 10, 65548, 6, 10, 65548, 7, 7, 65548, 8, 7, 65548, 9, 9, 65548, 10, 9, 65548, 11, 9, 65548, 12, 10, 65548, 13, 8) } script = ExtResource("2_hbe1v") columns = 14 @@ -70,6 +70,7 @@ offset_bottom = 93.0 theme_override_styles/panel = ExtResource("5_dvx6y") [node name="PlayerboardUI" type="GridContainer" parent="."] +visible = false clip_contents = true anchors_preset = 2 anchor_top = 1.0 diff --git a/scenes/player.gd b/scenes/player.gd index 3fdff88..a350f47 100644 --- a/scenes/player.gd +++ b/scenes/player.gd @@ -32,7 +32,15 @@ var spawn_locations = [ Vector2i(0, 2), # (0,1,2) Vector2i(0, 3), # (0,1,3) Vector2i(0, 4), # (0,1,4) - Vector2i(0, 5) # (0,1,5) + Vector2i(0, 5), # (0,1,5) + Vector2i(0, 6), + Vector2i(0, 7), + Vector2i(0, 8), + Vector2i(0, 9), + Vector2i(0, 10), + Vector2i(0, 11), + Vector2i(0, 12), + Vector2i(0, 13) ] # Add these as class variables at the top of the file @@ -42,7 +50,15 @@ var finish_locations = [ Vector2i(13, 2), # (13,0,2) Vector2i(13, 3), # (13,0,3) Vector2i(13, 4), # (13,0,4) - Vector2i(13, 5) # (13,0,5) + Vector2i(13, 5), # (13,0,5) + Vector2i(13, 6), + Vector2i(13, 7), + Vector2i(13, 8), + Vector2i(13, 9), + Vector2i(13, 10), + Vector2i(13, 11), + Vector2i(13, 12), + Vector2i(13, 13) ] var spawn_point_selected = false @@ -184,8 +200,6 @@ func _ready(): if is_multiplayer_authority(): rpc("sync_position", current_position) - - # Add function to check if position is at finish line func is_at_finish_line() -> bool: return current_position in finish_locations @@ -1035,11 +1049,10 @@ func auto_put_item() -> bool: # Step 1: Find empty adjacent (or current) grid cells var valid_put_positions = [] - # Check current position var current_cell_3d = Vector3i(current_position.x, 1, current_position.y) if enhanced_gridmap.get_cell_item(current_cell_3d) == -1: valid_put_positions.append(current_position) - # Check neighbors + var neighbors = enhanced_gridmap.get_neighbors(current_position, 0) for neighbor in neighbors: if neighbor.is_walkable: @@ -1051,18 +1064,60 @@ func auto_put_item() -> bool: if valid_put_positions.is_empty(): return false - # Step 2: Find a playerboard tile that matches any goal + # Step 2: Find a tile that should NOT be on the board var put_slot = -1 + + # Count how many times each goal item appears in central 3x3 + var goal_counts = {} + for i in range(3): + for j in range(3): + var g = goals[i * 3 + j] + if g != -1: + goal_counts[g] = goal_counts.get(g, 0) + 1 + + # Now scan playerboard for i in range(playerboard.size()): - if playerboard[i] in goals: + var item = playerboard[i] + if item == -1: + continue + + # Case 1: Item is not in goals at all → definitely junk + if not item in goals: put_slot = i break + # Case 2: Item is in goals, but we already have enough in correct spots + var current_count = 0 + for r in range(1, 4): # central rows 1-3 (5x5 board) + for c in range(1, 4): # central cols 1-3 + var idx = r * 5 + c + if playerboard[idx] == item: + current_count += 1 + + # If we already have all needed copies in central area, this is extra + if current_count >= goal_counts.get(item, 0): + put_slot = i + break + + # If no junk found, fall back to any non-goal-matching tile outside center if put_slot == -1: - return false + for i in range(playerboard.size()): + var item = playerboard[i] + if item == -1: + continue + var row = i / 5 + var col = i % 5 + # If it's outside the central 3x3, it shouldn't be there + if row < 1 or row > 3 or col < 1 or col > 3: + if not item in goals or playerboard[i] != goals[(row - 1) * 3 + (col - 1)]: + put_slot = i + break + + if put_slot == -1: + return false # Nothing suitable to put # Step 3: Perform the put - var target_pos = valid_put_positions[0] # pick first valid + var target_pos = valid_put_positions[0] var item = playerboard[put_slot] var cell = Vector3i(target_pos.x, 1, target_pos.y) @@ -1079,57 +1134,6 @@ func auto_put_item() -> bool: return true -# Disabled logic, due the auto put -#func put_item(grid_position: Vector2i = current_position) -> bool: - #if not enhanced_gridmap or action_points <= 0 or selected_playerboard_slot == -1: - #return false -# - #var cell = Vector3i(grid_position.x, 1, grid_position.y) - #if enhanced_gridmap.get_cell_item(cell) != -1: - #return false -# - ## Check if position is adjacent or current position - #if grid_position != current_position: - #var is_adjacent = false - #var neighbors = enhanced_gridmap.get_neighbors(current_position, 0) - #for neighbor in neighbors: - #if neighbor.position == grid_position: - #is_adjacent = true - #break - #if not is_adjacent: - #return false -# - ## Get the item to place first - #var item = playerboard[selected_playerboard_slot] - # - ## For clients, we need to RPC to the server first, then let the server RPC back - #if is_multiplayer_authority() and not multiplayer.is_server(): - ## Client requests server to perform the put operation - #rpc_id(1, "request_server_put", grid_position, selected_playerboard_slot, cell.x, cell.y, cell.z, item) - # - ## We'll return true and let the server handle the actual operation - ## The server will RPC back to update our state if successful - #return true - #elif is_multiplayer_authority() and multiplayer.is_server(): - ## Server directly implements the change - #rpc("sync_grid_item", cell.x, cell.y, cell.z, item) - #playerboard[selected_playerboard_slot] = -1 - #rpc("sync_playerboard", playerboard) - # - #has_performed_action = true - #consume_action_points(1) - #if not is_bot == true: - #clear_highlights() - #clear_playerboard_highlights() - #selected_playerboard_slot = -1 - # - #var main = get_tree().get_root().get_node_or_null("Main") - #if main: - #main.set_action_state(main.ActionState.NONE) - #_after_action_completed() - #return true - # - #return false @rpc("any_peer", "reliable") func request_server_put(grid_position: Vector2i, slot_index: int, x: int, y: int, z: int, item: int):