update the files, prep for fixing obstacles

This commit is contained in:
2025-04-10 16:17:36 +08:00
parent ca171c65c8
commit ad0085a068
2 changed files with 20 additions and 3 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+20 -3
View File
@@ -23,6 +23,10 @@ var action_points: int = 2
var target_rotation: float = 0.0 var target_rotation: float = 0.0
var rotation_speed: float = 10.0 var rotation_speed: float = 10.0
# Action
var _is_processing_action = false
var _is_highlighting = false
@export var movement_range: int = 1 @export var movement_range: int = 1
@export var use_diagonal_movement: bool = false: @export var use_diagonal_movement: bool = false:
set(value): set(value):
@@ -809,7 +813,12 @@ func highlight_cells_if_authorized(cells_to_highlight: Array):
func highlight_movement_range(): func highlight_movement_range():
if not is_multiplayer_authority() or is_bot or is_in_group("Bots"): if not is_multiplayer_authority() or is_bot or is_in_group("Bots"):
return return
# Prevent recursive highlighting
if _is_highlighting:
return
_is_highlighting = true
clear_highlights() clear_highlights()
var cells_to_highlight = [] var cells_to_highlight = []
@@ -852,7 +861,9 @@ func highlight_movement_range():
if can_reach_cell(test_pos, blocked_cells): if can_reach_cell(test_pos, blocked_cells):
cells_to_highlight.append(test_pos) cells_to_highlight.append(test_pos)
# At the end of the function:
highlight_cells_if_authorized(cells_to_highlight) highlight_cells_if_authorized(cells_to_highlight)
_is_highlighting = false
# Helper function to check if a cell can be reached given the blocked cells # Helper function to check if a cell can be reached given the blocked cells
func can_reach_cell(target_pos: Vector2i, blocked_cells: Array) -> bool: func can_reach_cell(target_pos: Vector2i, blocked_cells: Array) -> bool:
@@ -1187,8 +1198,12 @@ func sync_playerboard(new_playerboard: Array):
_after_action_completed() _after_action_completed()
func _after_action_completed(): func _after_action_completed():
# Guard against recursive calls
if _is_processing_action:
return
_is_processing_action = true
# Clear the highlights after placing the tiles. ( Quickfix for Clientside ) # Clear the highlights after placing the tiles. (Quickfix for Clientside)
clear_highlights() clear_highlights()
if multiplayer.get_unique_id() == get_multiplayer_authority(): if multiplayer.get_unique_id() == get_multiplayer_authority():
@@ -1209,6 +1224,8 @@ func _after_action_completed():
# Add sync for playerboard # Add sync for playerboard
if is_multiplayer_authority(): if is_multiplayer_authority():
main.rpc("sync_playerboard", get_multiplayer_authority(), playerboard) main.rpc("sync_playerboard", get_multiplayer_authority(), playerboard)
_is_processing_action = false
func consume_action_points(points: int): func consume_action_points(points: int):
if not is_instance_valid(self) or not is_multiplayer_authority(): if not is_instance_valid(self) or not is_multiplayer_authority():
@@ -1227,7 +1244,7 @@ func consume_action_points(points: int):
if action_points <= 0: if action_points <= 0:
if main.turn_based_mode: if main.turn_based_mode:
main.request_end_turn() main.request_next_turn()
else: else:
action_points = 2 action_points = 2
has_performed_action = false has_performed_action = false