Predict EMPs (#39802)

* predicted emps

* fixes

* fix

* review
This commit is contained in:
slarticodefast
2025-10-04 13:24:42 +02:00
committed by GitHub
parent 690bb5a8f2
commit 5227489360
70 changed files with 669 additions and 516 deletions

View File

@@ -7,6 +7,18 @@ public sealed class EmpSystem : SharedEmpSystem
{
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EmpDisabledComponent, ComponentStartup>(OnStartup);
}
private void OnStartup(Entity<EmpDisabledComponent> ent, ref ComponentStartup args)
{
// EmpPulseEvent.Affected will spawn the first visual effect directly when the emp is used
ent.Comp.TargetTime = Timing.CurTime + _random.NextFloat(0.8f, 1.2f) * ent.Comp.EffectCooldown;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
@@ -16,7 +28,7 @@ public sealed class EmpSystem : SharedEmpSystem
{
if (Timing.CurTime > comp.TargetTime)
{
comp.TargetTime = Timing.CurTime + _random.NextFloat(0.8f, 1.2f) * TimeSpan.FromSeconds(comp.EffectCooldown);
comp.TargetTime = Timing.CurTime + _random.NextFloat(0.8f, 1.2f) * comp.EffectCooldown;
Spawn(EmpDisabledEffectPrototype, transform.Coordinates);
}
}