using AceField.Scripts.Logic; using Godot; namespace AceField.Scripts.UI; public partial class BootScreen : Control { [Export] public World World; [Export] public Button StartGameButton; [Export] public LineEdit PlayerNameInput; [Export] public Label PlayerCountLabel; [Signal] public delegate void StartGameEventHandler(); public override void _Ready() { StartGameButton.Pressed += () => { Rpc(nameof(Start)); }; } public override void _Process(double delta) { var count = Multiplayer.GetPeers().Length; PlayerCountLabel.Text = $"{(count + 1):00}/{16}"; StartGameButton.Disabled = !Multiplayer.IsServer() || Multiplayer.GetPeers().Length == 0; } [Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true)] private void Start() { EmitSignal(SignalName.StartGame); var name = string.IsNullOrEmpty(PlayerNameInput.Text) ? null : PlayerNameInput.Text; World.Scoreboard.SetName(Multiplayer.GetUniqueId(), name ?? $"Player#{Multiplayer.GetUniqueId()}"); World.StartGame(currentPlayerName: name); Hide(); } }