]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix thrusters not dealing damage (#35088)
authorWinkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Thu, 13 Feb 2025 19:27:33 +0000 (22:27 +0300)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 19:27:33 +0000 (20:27 +0100)
* Fix thrusters not dealing damage

* Fixes

* Update

* Update

* Update

Content.Server/Shuttles/Components/ThrusterComponent.cs
Content.Server/Shuttles/Systems/ThrusterSystem.cs

index 3bba9b5a7f0635f7b61d048a0b6b95fa0fe81fdb..20f020743d14e81f0ef8e0a2ffe27777e2f5225e 100644 (file)
@@ -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;
 
+        /// <summary>
+        /// How often thruster deals damage.
+        /// </summary>
+        [DataField]
+        public TimeSpan FireCooldown = TimeSpan.FromSeconds(2);
+
         /// <summary>
         /// Next time we tick damage for anyone colliding.
         /// </summary>
-        [ViewVariables(VVAccess.ReadWrite), DataField("nextFire", customTypeSerializer:typeof(TimeOffsetSerializer))]
-        public TimeSpan NextFire;
+        [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
+        public TimeSpan NextFire = TimeSpan.Zero;
     }
 
     public enum ThrusterType
index f5e8f7823e72c5aefc097b052e464448d203a631..a75ddc911a47ddecf19161dc8b52deaa07e8948b 100644 (file)
@@ -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())
             {