fast bullet accelerates instead of being fast immediately

This commit is contained in:
Vinzenz Schroeter 2024-05-07 21:48:58 +02:00
parent 68e61c5204
commit b1df817ece
5 changed files with 11 additions and 5 deletions

View file

@ -27,4 +27,6 @@ internal sealed class GameRules
public int ReloadDelayMs { get; set; } = 3000;
public double SmartBulletInertia { get; set; } = 1;
public double FastBulletAcceleration { get; set; } = 0.25;
}

View file

@ -17,7 +17,6 @@ internal sealed class MapEntityManager(
public void SpawnBullet(Player tankOwner, FloatPosition position, double rotation, MagazineType type)
{
var speed = _rules.BulletSpeed * (type.HasFlag(MagazineType.Fast) ? 2 : 1);
_bullets.Add(new Bullet
{
Owner = tankOwner,
@ -26,8 +25,9 @@ internal sealed class MapEntityManager(
IsExplosive = type.HasFlag(MagazineType.Explosive),
Timeout = DateTime.Now + _bulletTimeout,
OwnerCollisionAfter = DateTime.Now + TimeSpan.FromSeconds(1),
Speed = speed,
IsSmart = type.HasFlag(MagazineType.Smart)
Speed = _rules.BulletSpeed,
IsSmart = type.HasFlag(MagazineType.Smart),
Acceleration = type.HasFlag(MagazineType.Fast) ? _rules.FastBulletAcceleration : 0d
});
}

View file

@ -24,6 +24,8 @@ internal sealed class MoveBullets(
bullet.Rotation += difference * inertiaFactor;
}
bullet.Speed *= 1 + (bullet.Acceleration * delta.TotalSeconds);
var speed = bullet.Speed * delta.TotalSeconds;
var angle = bullet.Rotation * 2 * Math.PI;
bullet.Position = new FloatPosition(

View file

@ -16,7 +16,9 @@ internal sealed class Bullet : IMapEntity
internal required DateTime OwnerCollisionAfter { get; init; }
public required double Speed { get; init; }
public required double Speed { get; set; }
public required double Acceleration { get; init; }
public required bool IsSmart { get; init; }
}

View file

@ -33,7 +33,7 @@
"SmartBulletHomingSpeed": 1.5
},
"Host": {
"EnableServicePointDisplay": false,
"EnableServicePointDisplay": true,
"ServicePointDisplayMinFrameTimeMs": 28,
"ClientScreenMinFrameTime": 5
}