Round system

This commit is contained in:
Rendo 2025-11-29 23:46:16 +05:00
commit 3df8247a84
32 changed files with 573 additions and 123 deletions

View file

@ -7,6 +7,14 @@ func _ready() -> void:
if not multiplayer.is_server():
queue_free()
return
Session.round_started.connect(spawn)
func _exit_tree() -> void:
if not multiplayer.is_server():
return
Session.round_started.disconnect(spawn)
func spawn():
match team:
Session.TEAMS.ATTACK:
for attacker in Lobby.attack_team:
@ -23,6 +31,10 @@ func spawn_player(id: int) -> void:
var inst: Player = player.instantiate()
Session.player_nodes[id] = inst
inst.name = str(id)
if team == Session.TEAMS.DEFENCE:
Session.defenders_alive += 1
elif team == Session.TEAMS.ATTACK:
Session.attackers_alive += 1
deferred_setup.bind(inst,team).call_deferred()
@ -34,7 +46,7 @@ func spawn_spectator(id: int) -> void:
deferred_setup.bind(inst,Session.TEAMS.SPECTATE).call_deferred()
func deferred_setup(what: Node3D, new_team: Session.TEAMS):
get_parent().add_child(what)
get_parent().add_child(what,true)
var distance = randf_range(0,spawn_radius)
var angle = randf_range(0,TAU)
var new_position = global_position + Vector3.RIGHT.rotated(Vector3.UP,angle) * distance