diff --git a/Content.Server/Shuttles/Components/ThrusterComponent.cs b/Content.Server/Shuttles/Components/ThrusterComponent.cs index 3bba9b5a7f..20f020743d 100644 --- a/Content.Server/Shuttles/Components/ThrusterComponent.cs +++ b/Content.Server/Shuttles/Components/ThrusterComponent.cs @@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Server.Shuttles.Components { - [RegisterComponent, NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentPause] [Access(typeof(ThrusterSystem))] public sealed partial class ThrusterComponent : Component { @@ -50,11 +50,17 @@ namespace Content.Server.Shuttles.Components public bool Firing = false; + /// + /// How often thruster deals damage. + /// + [DataField] + public TimeSpan FireCooldown = TimeSpan.FromSeconds(2); + /// /// Next time we tick damage for anyone colliding. /// - [ViewVariables(VVAccess.ReadWrite), DataField("nextFire", customTypeSerializer:typeof(TimeOffsetSerializer))] - public TimeSpan NextFire; + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] + public TimeSpan NextFire = TimeSpan.Zero; } public enum ThrusterType diff --git a/Content.Server/Shuttles/Systems/ThrusterSystem.cs b/Content.Server/Shuttles/Systems/ThrusterSystem.cs index f5e8f7823e..a75ddc911a 100644 --- a/Content.Server/Shuttles/Systems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/Systems/ThrusterSystem.cs @@ -232,6 +232,8 @@ public sealed class ThrusterSystem : EntitySystem private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args) { + component.NextFire = _timing.CurTime + component.FireCooldown; + _ambient.SetAmbience(uid, false); if (!component.Enabled) @@ -461,10 +463,13 @@ public sealed class ThrusterSystem : EntitySystem while (query.MoveNext(out var comp)) { - if (!comp.Firing || comp.Colliding.Count == 0 || comp.Damage == null || comp.NextFire < curTime) + if (comp.NextFire > curTime) continue; - comp.NextFire += TimeSpan.FromSeconds(1); + comp.NextFire += comp.FireCooldown; + + if (!comp.Firing || comp.Colliding.Count == 0 || comp.Damage == null) + continue; foreach (var uid in comp.Colliding.ToArray()) {