bullet hits tank, tank dies
This commit is contained in:
parent
190c0c3143
commit
dd33ec59ad
6 changed files with 45 additions and 9 deletions
|
@ -6,14 +6,20 @@ namespace TanksServer.Services;
|
|||
|
||||
internal sealed class TankManager(ILogger<TankManager> logger) : IEnumerable<Tank>
|
||||
{
|
||||
private readonly ConcurrentBag<Tank> _tanks = new();
|
||||
private readonly ConcurrentDictionary<Tank, byte> _tanks = new();
|
||||
|
||||
public void Add(Tank tank)
|
||||
{
|
||||
logger.LogInformation("Tank added for player {}", tank.Owner.Id);
|
||||
_tanks.Add(tank);
|
||||
_tanks.TryAdd(tank, 0);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public IEnumerator<Tank> GetEnumerator() => _tanks.GetEnumerator();
|
||||
public IEnumerator<Tank> GetEnumerator() => _tanks.Keys.GetEnumerator();
|
||||
|
||||
public void Remove(Tank tank)
|
||||
{
|
||||
logger.LogInformation("Tank removed for player {}", tank.Owner.Id);
|
||||
_tanks.Remove(tank, out _);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue