I tested this on Multiplayer and realized pretty much everything is broken and I haven't been thinking about networking enough. Will start fixing tomorrow.
50 lines
1.1 KiB
Plaintext
50 lines
1.1 KiB
Plaintext
@namespace LuckerParty.UI
|
|
@inherits PanelComponent
|
|
@using System
|
|
@using System.Collections.Immutable
|
|
@implements NetworkManager.IClientEvent
|
|
|
|
<root>
|
|
<div class="title">This is the Lobby</div>
|
|
@foreach ( var client in _clients )
|
|
{
|
|
<div>@client.Name</div>
|
|
}
|
|
</root>
|
|
|
|
@code
|
|
{
|
|
private ImmutableList<Client> _clients;
|
|
private NetworkManager _networkManager;
|
|
|
|
protected override void OnStart()
|
|
{
|
|
base.OnStart();
|
|
_networkManager = Scene.GetComponentInChildren<NetworkManager>();
|
|
UpdateClients();
|
|
}
|
|
|
|
void NetworkManager.IClientEvent.OnConnected( Client client )
|
|
{
|
|
UpdateClients();
|
|
}
|
|
|
|
void NetworkManager.IClientEvent.OnDisconnected( Client client )
|
|
{
|
|
UpdateClients();
|
|
}
|
|
|
|
private void UpdateClients()
|
|
{
|
|
_clients = _networkManager.Clients.Sort( ( clientA, clientB ) => DateTimeOffset.Compare( clientA.ConnectionTime, clientB.ConnectionTime ) );
|
|
}
|
|
|
|
/// <summary>
|
|
/// the hash determines if the system should be rebuilt. If it changes, it will be rebuilt
|
|
/// </summary>
|
|
protected override int BuildHash()
|
|
{
|
|
return HashCode.Combine( _clients );
|
|
}
|
|
}
|