Crouch, walking and scoping support, deleted unnecessary Session rpcs

This commit is contained in:
Rendo 2025-12-03 13:08:32 +05:00
commit d79db8a8d8
6 changed files with 4513 additions and 4456 deletions

View file

@ -15,6 +15,8 @@ func _exit_tree() -> void:
Session.round_started.disconnect(spawn)
func spawn():
if not multiplayer.is_server():
return
match team:
Session.TEAMS.ATTACK:
for attacker in Lobby.attack_team:
@ -36,18 +38,21 @@ func spawn_player(id: int) -> void:
elif team == Session.TEAMS.ATTACK:
Session.attackers_alive += 1
deferred_setup.bind(inst,team).call_deferred()
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
get_parent().add_child(inst)
inst.global_position = new_position
inst.team = team
func spawn_spectator(id: int) -> void:
var spectator: PackedScene = load("res://scenes/spectator.tscn")
var inst = spectator.instantiate()
inst.name = str(id)
deferred_setup.bind(inst,Session.TEAMS.SPECTATE).call_deferred()
func deferred_setup(what: Node3D, new_team: Session.TEAMS):
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
what.set_after_spawn.rpc_id(int(what.name),new_position,new_team)
get_parent().add_child(inst)
inst.global_position = new_position
inst.team = team