move a bunch of stuff into subfolders
This commit is contained in:
parent
8f281d65b2
commit
151cad4cee
1 changed files with 44 additions and 27 deletions
|
|
@ -1,44 +0,0 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace TanksServer;
|
||||
|
||||
internal sealed class PlayerService(ILogger<PlayerService> logger)
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, Player> _players = new();
|
||||
|
||||
public Player GetOrAdd(string name) => _players.GetOrAdd(name, _ => new Player(name));
|
||||
|
||||
public bool TryGet(Guid? playerId, [MaybeNullWhen(false)] out Player foundPlayer)
|
||||
{
|
||||
foreach (var player in _players.Values)
|
||||
{
|
||||
if (player.Id != playerId)
|
||||
continue;
|
||||
foundPlayer = player;
|
||||
return true;
|
||||
}
|
||||
|
||||
foundPlayer = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class Player(string name)
|
||||
{
|
||||
public string Name => name;
|
||||
|
||||
public Guid Id { get; } = Guid.NewGuid();
|
||||
|
||||
public PlayerControls Controls { get; } = new();
|
||||
}
|
||||
|
||||
internal sealed class PlayerControls
|
||||
{
|
||||
public bool Forward { get; set; }
|
||||
public bool Backward { get; set; }
|
||||
public bool TurnLeft { get; set; }
|
||||
public bool TurnRight { get; set; }
|
||||
public bool Shoot { get; set; }
|
||||
}
|
||||
Reference in a new issue