tanks can spawn and get rendered
This commit is contained in:
parent
151cad4cee
commit
a3bd582b2e
1 changed files with 283 additions and 105 deletions
20
TanksServer/Services/TankManager.cs
Normal file
20
TanksServer/Services/TankManager.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TanksServer.Models;
|
||||
|
||||
namespace TanksServer.Services;
|
||||
|
||||
internal sealed class TankManager(ILogger<TankManager> logger) : IEnumerable<Tank>
|
||||
{
|
||||
private readonly ConcurrentBag<Tank> _tanks = new();
|
||||
|
||||
public void Add(Tank tank)
|
||||
{
|
||||
logger.LogInformation("Tank added");
|
||||
_tanks.Add(tank);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public IEnumerator<Tank> GetEnumerator() => _tanks.GetEnumerator();
|
||||
}
|
||||
Reference in a new issue