add explosive bullet power up
This commit is contained in:
parent
3f4a301993
commit
a2d46bda92
1 changed files with 407 additions and 253 deletions
18
TanksServer/GameLogic/SpawnPowerUp.cs
Normal file
18
TanksServer/GameLogic/SpawnPowerUp.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class SpawnPowerUp(
|
||||
IOptions<GameRules> options,
|
||||
MapEntityManager entityManager
|
||||
) : ITickStep
|
||||
{
|
||||
private readonly double _spawnChance = options.Value.PowerUpSpawnChance;
|
||||
|
||||
public Task TickAsync(TimeSpan delta)
|
||||
{
|
||||
if (Random.Shared.NextDouble() > _spawnChance * delta.TotalSeconds)
|
||||
return Task.CompletedTask;
|
||||
|
||||
entityManager.SpawnPowerUp();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in a new issue