remove guid, reduce latency (gets stuck sometimes tho)

This commit is contained in:
Vinzenz Schroeter 2024-04-28 12:53:18 +02:00
parent 6bc6a039bd
commit 7044ffda79
19 changed files with 291 additions and 251 deletions

View file

@ -5,6 +5,4 @@ public class HostConfiguration
public bool EnableServicePointDisplay { get; set; } = true;
public int ServicePointDisplayMinFrameTimeMs { get; set; } = 25;
public int ClientDisplayMinFrameTimeMs { get; set; } = 25;
}

View file

@ -2,15 +2,23 @@ using System.Text.Json.Serialization;
namespace TanksServer.Models;
internal sealed class Player(string name, Guid id)
internal sealed class Player : IEquatable<Player>
{
public string Name => name;
[JsonIgnore] public Guid Id => id;
public required string Name { get; init; }
[JsonIgnore] public PlayerControls Controls { get; } = new();
public Scores Scores { get; } = new();
public DateTime LastInput { get; set; } = DateTime.Now;
public override bool Equals(object? obj) => obj is Player p && Equals(p);
public bool Equals(Player? other) => other?.Name == Name;
public override int GetHashCode() => Name.GetHashCode();
public static bool operator ==(Player? left, Player? right) => Equals(left, right);
public static bool operator !=(Player? left, Player? right) => !Equals(left, right);
}