Send appearance on connect

main
copygirl 5 years ago
parent 550765796a
commit aa5b6269c2
  1. 3
      src/EscapeMenuAppearance.cs
  2. 8
      src/Scenes/Client.cs

@ -19,6 +19,9 @@ public class EscapeMenuAppearance : CenterContainer
ColorSlider.Value = GD.Randf();
ColorPreview.Modulate = Color.FromHsv((float)ColorSlider.Value, 1.0F, 1.0F);
this.GetClient().OnConnected += () =>
this.GetClient().RPC(Player.ChangeAppearance, DisplayName.Text, ColorPreview.Modulate);
}

@ -7,6 +7,9 @@ public class Client : Game
[Export] public NodePath CursorPath { get; set; }
public Cursor Cursor { get; private set; }
public event Action OnConnected;
public event Action OnDisconnected;
public Client()
{
CustomMultiplayer = new MultiplayerAPI { RootNode = this };
@ -44,13 +47,12 @@ public class Client : Game
if (CustomMultiplayer.NetworkPeer == null) return;
((NetworkedMultiplayerENet)CustomMultiplayer.NetworkPeer).CloseConnection();
CustomMultiplayer.NetworkPeer = null;
OnDisconnected?.Invoke();
}
private void OnConnectedToServer()
{
// TODO: Send initial appearance.
}
=> OnConnected?.Invoke();
private void OnPacketReceived(int id, byte[] bytes)
{

Loading…
Cancel
Save