Stabilise singularity a lot more (#5725)

This commit is contained in:
metalgearsloth
2021-12-15 13:47:12 +11:00
committed by GitHub
parent 5d15787b04
commit a2476ed974
4 changed files with 130 additions and 58 deletions

View File

@@ -1,3 +1,4 @@
using System;
using Content.Server.Singularity.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
@@ -12,7 +13,8 @@ namespace Content.Server.Physics.Controllers
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
private const float MaxMoveCooldown = 10f;
// SS13 has 10s but that's quite a while
private const float MaxMoveCooldown = 5f;
private const float MinMoveCooldown = 2f;
public override void UpdateBeforeSolve(bool prediction, float frameTime)
@@ -28,7 +30,7 @@ namespace Content.Server.Physics.Controllers
if (singularity.MoveAccumulator > 0f) continue;
singularity.MoveAccumulator = MinMoveCooldown + (MaxMoveCooldown - MinMoveCooldown) * _robustRandom.NextFloat();
singularity.MoveAccumulator = _robustRandom.NextFloat(MinMoveCooldown, MaxMoveCooldown);
MoveSingulo(singularity, physics);
}
@@ -44,13 +46,12 @@ namespace Content.Server.Physics.Controllers
}
// TODO: Could try gradual changes instead
var pushVector = new Vector2(_robustRandom.Next(-10, 10), _robustRandom.Next(-10, 10));
if (pushVector == Vector2.Zero) return;
var pushAngle = _robustRandom.NextAngle();
var pushStrength = _robustRandom.NextFloat(0.75f, 1.0f);
physics.LinearVelocity = Vector2.Zero;
physics.BodyStatus = BodyStatus.InAir;
physics.ApplyLinearImpulse(pushVector.Normalized + 1f / singularity.Level * physics.Mass);
physics.ApplyLinearImpulse(pushAngle.ToVec() * (pushStrength + 10f / Math.Min(singularity.Level, 4) * physics.Mass));
// TODO: Speedcap it probably?
}
}