dd
This commit is contained in:
@@ -225,6 +225,9 @@ func handle_grid_click(grid_position: Vector2i):
|
||||
main.ActionState.RANDOMIZING:
|
||||
if grid_position in highlighted_cells:
|
||||
main.randomize_item_at_position(grid_position)
|
||||
main.ActionState.PLACING_OBSTACLE:
|
||||
if grid_position in highlighted_cells:
|
||||
main.place_obstacle(grid_position)
|
||||
|
||||
func is_position_occupied(pos: Vector2i) -> bool:
|
||||
for player in get_tree().get_nodes_in_group("Players"):
|
||||
@@ -1215,3 +1218,35 @@ func sync_position(pos: Vector2i):
|
||||
cell_size.y,
|
||||
current_position.y * cell_size.z + cell_size.z * 0.5
|
||||
) + cell_offset
|
||||
|
||||
func highlight_valid_obstacle_cells():
|
||||
if not is_multiplayer_authority() or is_bot or is_in_group("Bots"):
|
||||
return
|
||||
|
||||
clear_highlights()
|
||||
|
||||
var cells_to_highlight = []
|
||||
|
||||
# Highlight all empty cells on the grid except those occupied by players or obstacles
|
||||
for x in range(enhanced_gridmap.columns):
|
||||
for z in range(enhanced_gridmap.rows):
|
||||
var pos = Vector2i(x, z)
|
||||
var cell = Vector3i(x, 3, z) # Check floor 3 for occupancy
|
||||
var occupied_by_player = false
|
||||
var occupied_by_obstacle = false
|
||||
|
||||
# Check if cell is occupied by any player
|
||||
for player in get_tree().get_nodes_in_group("Players"):
|
||||
if player.current_position == pos:
|
||||
occupied_by_player = true
|
||||
break
|
||||
|
||||
# Check if cell is occupied by an obstacle
|
||||
if enhanced_gridmap.get_cell_item(cell) in enhanced_gridmap.obstacle_items:
|
||||
occupied_by_obstacle = true
|
||||
|
||||
# Only add to highlights if not occupied by player or obstacle
|
||||
if not occupied_by_player and not occupied_by_obstacle:
|
||||
cells_to_highlight.append(pos)
|
||||
|
||||
highlight_cells_if_authorized(cells_to_highlight)
|
||||
|
||||
Reference in New Issue
Block a user