feat: Introduce player input and movement managers to handle continuous, turn-based, and targeted grid interactions.
This commit is contained in:
@@ -11,7 +11,7 @@ func initialize(p_player: Node3D, p_movement_manager: Node, p_race_manager: Node
|
||||
|
||||
func _process(delta):
|
||||
# Early return conditions
|
||||
if not is_instance_valid(player) or not player.is_multiplayer_authority() or player.is_bot or player.is_in_group("Bots"):
|
||||
if not is_instance_valid(player) or not player.is_multiplayer_authority() or player.is_bot or player.is_in_group("Bots") or player.is_frozen or player.is_stop_frozen:
|
||||
return
|
||||
|
||||
if TurnManager.turn_based_mode:
|
||||
@@ -83,7 +83,7 @@ func handle_unhandled_input(event):
|
||||
return
|
||||
|
||||
# Turn-based mouse input (handled in unhandled_input)
|
||||
if not player.is_multiplayer_authority() or (TurnManager.turn_based_mode and (not player.is_my_turn or movement_manager.is_moving)):
|
||||
if not player.is_multiplayer_authority() or player.is_frozen or player.is_stop_frozen or (TurnManager.turn_based_mode and (not player.is_my_turn or movement_manager.is_moving)):
|
||||
return
|
||||
|
||||
# --- Keyboard Shortcuts (Event-based) ---
|
||||
@@ -162,7 +162,7 @@ func handle_unhandled_input(event):
|
||||
handle_grid_click(click_position)
|
||||
|
||||
func handle_grid_click(grid_position: Vector2i):
|
||||
if player.is_bot == true or player.is_in_group("Bots"):
|
||||
if player.is_frozen or player.is_stop_frozen or player.is_bot == true or player.is_in_group("Bots"):
|
||||
return
|
||||
var main = player.get_node("/root/Main")
|
||||
if not main:
|
||||
|
||||
@@ -58,7 +58,7 @@ func simple_move_to(grid_position: Vector2i) -> bool:
|
||||
# print("[Move] Failed: Not authority for ", player.name)
|
||||
return false
|
||||
|
||||
if player.get("is_frozen"):
|
||||
if player.get("is_frozen") or player.get("is_stop_frozen"):
|
||||
print("[Move] Failed: Player is frozen")
|
||||
return false
|
||||
|
||||
@@ -242,7 +242,7 @@ func move_to_clicked_position(grid_position: Vector2i) -> bool:
|
||||
return false
|
||||
|
||||
# Check if player is frozen
|
||||
if player.get("is_frozen"):
|
||||
if player.get("is_frozen") or player.get("is_stop_frozen"):
|
||||
return false
|
||||
|
||||
# Validate grid position is within bounds
|
||||
|
||||
@@ -147,6 +147,14 @@ func _start_phase(phase: Phase):
|
||||
var phase_name = "GO" if phase == Phase.GO else "STOP"
|
||||
if can_rpc():
|
||||
rpc("sync_phase", phase_name, phase_timer)
|
||||
|
||||
# If GO phase starts, clear all STOP phase freezes
|
||||
if phase == Phase.GO:
|
||||
var all_players = get_tree().get_nodes_in_group("Players")
|
||||
for p in all_players:
|
||||
if p.has_method("sync_stop_freeze"):
|
||||
p.rpc("sync_stop_freeze", false)
|
||||
|
||||
emit_signal("phase_changed", phase_name, phase_timer)
|
||||
|
||||
func can_rpc() -> bool:
|
||||
@@ -196,8 +204,8 @@ func _apply_arena_setup():
|
||||
# Clear existing items on all layers
|
||||
gridmap.clear()
|
||||
|
||||
# Safe Zones Columns: 6, 7, 8 and 14, 15, 16
|
||||
var safe_columns = [6, 7, 8, 14, 15, 16]
|
||||
# Safe Zones Columns: 6, 7, 8 (Only one band now)
|
||||
var safe_columns = [6, 7, 8]
|
||||
|
||||
# Create bands based on X (Horizontal Progress)
|
||||
for x in range(gridmap.columns):
|
||||
@@ -263,24 +271,32 @@ func _spawn_mission_tiles():
|
||||
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
|
||||
if not gridmap: return
|
||||
|
||||
# Tile IDs for missions: Heart(7), Diamond(8), Star(9), Coin(10)
|
||||
var mission_tiles = [7, 8, 9, 10]
|
||||
# Forbidden Zones (Start, Safe, Finish) - No items here
|
||||
var forbidden_x = [0, 6, 7, 8, 21]
|
||||
|
||||
for tile_type in mission_tiles:
|
||||
var count = 0
|
||||
while count < 15: # 15 of each type (plenty for finding 3)
|
||||
var x = randi() % gridmap.columns
|
||||
var z = randi() % gridmap.rows
|
||||
# Goal items: Heart(7), Diamond(8), Star(9), Coin(10)
|
||||
var goal_items = [7, 8, 9, 10]
|
||||
|
||||
for x in range(gridmap.columns):
|
||||
if x in forbidden_x:
|
||||
continue # Clear zone
|
||||
|
||||
# Only spawn in walkable areas (Floor 0 must be 0 or 2, and Floor 1 empty)
|
||||
var floor_item = gridmap.get_cell_item(Vector3i(x, 0, z))
|
||||
if (floor_item == TILE_WALKABLE or floor_item == TILE_SAFE):
|
||||
if gridmap.get_cell_item(Vector3i(x, 1, z)) == -1:
|
||||
gridmap.set_cell_item(Vector3i(x, 1, z), tile_type)
|
||||
var main = get_node("/root/Main")
|
||||
if main and can_rpc():
|
||||
main.rpc("sync_grid_item", x, 1, z, tile_type)
|
||||
count += 1
|
||||
for z in range(gridmap.rows):
|
||||
# Ensure we don't spawn on obstacles
|
||||
var base_tile = gridmap.get_cell_item(Vector3i(x, 0, z))
|
||||
if base_tile == TILE_OBSTACLE:
|
||||
continue
|
||||
|
||||
# Randomly populate other floors with goal tiles
|
||||
# 30% chance to have a tile to avoid overcrowding
|
||||
if randf() < 0.3:
|
||||
var tile_type = goal_items[randi() % goal_items.size()]
|
||||
gridmap.set_cell_item(Vector3i(x, 1, z), tile_type)
|
||||
|
||||
# Sync to clients
|
||||
var main = get_node("/root/Main")
|
||||
if main:
|
||||
main.rpc("sync_grid_item", x, 1, z, tile_type)
|
||||
|
||||
func _assign_missions():
|
||||
# NO-OP: Missions are now achievement-based (Complete 3 Goals)
|
||||
|
||||
Reference in New Issue
Block a user