126 lines
3.5 KiB
GDScript
126 lines
3.5 KiB
GDScript
extends Node
|
|
|
|
# PlayerRaceManager - Refactored to remove lap-based racing
|
|
# Now only handles goals and playerboard state for the cycle-based system
|
|
|
|
var player: Node3D
|
|
var enhanced_gridmap: Node
|
|
|
|
# Goals and Playerboard (core functionality retained)
|
|
var goals: Array[int] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
var playerboard: Array[int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
# DEPRECATED: Lap system removed - keeping stubs for compatibility
|
|
var can_finish: bool = false # No longer used
|
|
var current_lap: int = 0 # No longer used
|
|
var race_position: int = 0 # No longer used
|
|
var has_finished_race: bool = false # No longer used
|
|
static var lap1_finishers: int = 0 # No longer used
|
|
static var lap2_finishers: int = 0 # No longer used
|
|
|
|
func initialize(p_player: Node3D, p_gridmap: Node):
|
|
player = p_player
|
|
enhanced_gridmap = p_gridmap
|
|
|
|
func get_ordinal_string(number: int) -> String:
|
|
match number:
|
|
1: return "1st"
|
|
2: return "2nd"
|
|
3: return "3rd"
|
|
4: return "4th"
|
|
_: return str(number) + "th"
|
|
|
|
# =============================================================================
|
|
# Goal Pattern Matching (Core Functionality)
|
|
# =============================================================================
|
|
|
|
func check_3x3_section(board: Array, goals_pattern: Array, start_row: int, start_col: int) -> bool:
|
|
for i in range(3):
|
|
for j in range(3):
|
|
if goals_pattern[i][j] != -1:
|
|
var board_value = board[start_row + i][start_col + j]
|
|
if board_value == -1:
|
|
return false
|
|
|
|
for i in range(3):
|
|
for j in range(3):
|
|
if goals_pattern[i][j] != -1:
|
|
if board[start_row + i][start_col + j] != goals_pattern[i][j]:
|
|
return false
|
|
return true
|
|
|
|
func check_pattern_match() -> bool:
|
|
"""Check if playerboard matches goals pattern. Core function for goal completion."""
|
|
if playerboard.size() != 25 or goals.size() != 9:
|
|
return false
|
|
|
|
var board_2d = []
|
|
var goals_2d = []
|
|
|
|
for i in range(5):
|
|
var row = []
|
|
for j in range(5):
|
|
row.append(playerboard[i * 5 + j])
|
|
board_2d.append(row)
|
|
|
|
for i in range(3):
|
|
var row = []
|
|
for j in range(3):
|
|
row.append(goals[i * 3 + j])
|
|
goals_2d.append(row)
|
|
|
|
for start_row in range(3):
|
|
for start_col in range(3):
|
|
if check_3x3_section(board_2d, goals_2d, start_row, start_col):
|
|
return true
|
|
return false
|
|
|
|
# =============================================================================
|
|
# DEPRECATED STUBS - Left for backward compatibility, do nothing
|
|
# =============================================================================
|
|
|
|
var finish_locations = [] # No longer used
|
|
var spawn_locations = [] # No longer used
|
|
var first_lap_goals: Array[int] = []
|
|
var second_lap_goals: Array[int] = []
|
|
|
|
func get_current_finish_locations() -> Array:
|
|
# DEPRECATED: No finish line in cycle-based system
|
|
return []
|
|
|
|
func update_finish_availability():
|
|
# DEPRECATED: No finish line checking needed
|
|
pass
|
|
|
|
func highlight_finish_line():
|
|
# DEPRECATED: No finish line to highlight
|
|
pass
|
|
|
|
func unhighlight_finish_line():
|
|
# DEPRECATED: No finish line to unhighlight
|
|
pass
|
|
|
|
func is_at_finish_line() -> bool:
|
|
# DEPRECATED: Always false, no finish line
|
|
return false
|
|
|
|
func finish_race():
|
|
# DEPRECATED: No race finish in cycle-based system
|
|
pass
|
|
|
|
func on_race_completed(_final_position: int):
|
|
# DEPRECATED: No race completion
|
|
pass
|
|
|
|
func start_new_lap():
|
|
# DEPRECATED: No laps in cycle-based system
|
|
pass
|
|
|
|
func find_valid_position_in_finish_line() -> Vector2i:
|
|
# DEPRECATED: No finish line
|
|
return Vector2i(-1, -1)
|
|
|
|
func generate_second_lap_goals():
|
|
# DEPRECATED: No second lap goals needed
|
|
pass
|