Renamed a bunch of player stuff to pawn stuff and implemented extensive work on getting single-address 'netplay' code working. Not sure if I've created issues with single player but in theory it should all transfer across as if the player is simply always the host.
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
extends Node3D
|
||||
extends Level
|
||||
|
||||
const pawn_controller_template = preload("res://templates/pawn_controller.tscn")
|
||||
|
||||
const multiplayer_pc_template = preload("res://templates/multiplayer_pc.tscn")
|
||||
const camera_template = preload("res://templates/camera.tscn")
|
||||
@onready var player_spawner = %Spawner
|
||||
func _ready() -> void:
|
||||
print("LEVEL LOADING, ID: " + str(Multiplayer.id) + " with " + str(Multiplayer.players.size()) + " keys recognized")
|
||||
if Multiplayer.is_server():
|
||||
for key in Multiplayer.players.values():
|
||||
var pc = multiplayer_pc_template.instantiate()
|
||||
player_spawner.add_player(pc, key)
|
||||
pc.setup(key)
|
||||
var camera = camera_template.instantiate()
|
||||
add_child(camera)
|
||||
Game.level = self
|
||||
|
||||
func setup() -> void:
|
||||
if Multiplayer.is_host():
|
||||
spawn_players()
|
||||
|
||||
func spawn_players() -> void:
|
||||
for key in Game.pawns_selected:
|
||||
var pc : PawnController = pawn_controller_template.instantiate()
|
||||
var pd = Game.pawns_selected[key]
|
||||
player_spawner.add_pawn(pc, key)
|
||||
pc.setup(key,pd.starting_traps)
|
||||
|
||||
Reference in New Issue
Block a user