Add a proper server logic without lobby

This commit is contained in:
2025-01-28 23:54:14 +01:00
parent 9b1ab02b94
commit 3e6eab08fd
9 changed files with 327 additions and 20 deletions

View File

@ -8,6 +8,10 @@ var player_spawner: PlayerSpawnerController
var object_spawner: Node3D
@onready var spawn_locations: SpawnController = $SpawnLocations
func _on_player_connected(id):
if multiplayer.is_server():
GameServerManager.load_map.rpc_id(id, GameServerManager.current_map)
# add the player to the
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -23,18 +27,22 @@ func _ready() -> void:
print("Couldn't load object spawner")
# add objects spawner
if multiplayer.is_server():
_spawn_player()
_spawn_player(1)
else:
_request_spawn.rpc_id(1, multiplayer.get_unique_id())
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
@rpc("call_local", "reliable", "any_peer")
func _request_spawn(id: int):
_spawn_player(id)
func _spawn_player():
func _spawn_player(id: int):
var char : Node3D = null
player_spawner.spawn_players(spawn_locations)
player_spawner.spawn_players(spawn_locations, id)
func _add_player_spawner() -> Error :
if not ResourceLoader.exists(PLAYER_SPAWNER):