feat(game): add free ball mode and improve ball state handling

* add Free Ball game mode and lobby selection
* refactor base mode ball state tracking for reaped/sunk balls
* add player ownership tracking and colored-ball support
* add initial 9-ball mode implementation
* update 8-ball and snooker modes to use base ball handling
* replicate ball linear velocity for multiplayer synchronization
* improve ball collision sound propagation and physics settings
* reenable game music and initialize game signals
* improve lobby input focus and mode selection behavior
* adjust cue impulse origin and default game mode
This commit is contained in:
2026-08-10 21:22:52 -05:00
parent 26dcfe0d1b
commit e3bdb21cd2
19 changed files with 234 additions and 62 deletions

View File

@@ -5,8 +5,20 @@ func _ready() -> void:
for ball in bodies.get_children():
_set_ball_physics(ball)
setup_signals()
setup_multiplayer()
func setup_signals() -> void:
# TODO: Need to refactor to not need server signal collision to
# then play sounds. Maybe 2nd collider on ball that triggers?
# Will that work since with clients we:
# set_deferred("freeze", true)
# set_physics_process(false)
#
# Gods forgive me for my sins....
MessageBus.subscribe("balls_collide_signal", _on_balls_collide_signal)
func _physics_process(_delta: float) -> void:
if not Globals.multiplayer_data.can_do_request_server_only():
return
@@ -28,8 +40,19 @@ func _on__ball_body_entered(ball: Node) -> void:
if not Globals.multiplayer_data.can_do_request_server_only():
return
if ball.name == "pool_table": return
if ball.name == "pool_table":
# TODO: Get/generate some type of sound/noise like corse texture of table
return
_play_collide_sound(ball)
MessageBus.emit_propagation_clients_only.rpc(
"balls_collide_signal", str( ball.get_path() )
)
func _on_balls_collide_signal(ball: String) -> void:
_play_collide_sound( get_node(ball) )
func _play_collide_sound(ball: Node) -> void:
var speed = ball.linear_velocity.length()
var speed_norm = clamp(speed / max_speed, 0.0, 1.0)
var volume = remap(