]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Signal timer duration limit (#33781)
authorErrant <35878406+Errant-4@users.noreply.github.com>
Mon, 9 Dec 2024 03:41:11 +0000 (04:41 +0100)
committerGitHub <noreply@github.com>
Mon, 9 Dec 2024 03:41:11 +0000 (21:41 -0600)
* max duration

* comment

Content.Server/DeviceLinking/Components/SignalTimerComponent.cs
Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs

index b3535cde1fd11eb0e7d296c1f54015608943b165..3feb69c879fd57c5ef37686a38b701417a8d2f7e 100644 (file)
@@ -1,53 +1,58 @@
 using Content.Shared.DeviceLinking;
 using Robust.Shared.Audio;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
 
 namespace Content.Server.DeviceLinking.Components;
 
 [RegisterComponent]
 public sealed partial class SignalTimerComponent : Component
 {
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public double Delay = 5;
 
     /// <summary>
     ///     This shows the Label: text box in the UI.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public bool CanEditLabel = true;
 
     /// <summary>
     ///     The label, used for TextScreen visuals currently.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public string Label = string.Empty;
 
     /// <summary>
     ///     Default max width of a label (how many letters can this render?)
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public int MaxLength = 5;
 
     /// <summary>
     ///     The port that gets signaled when the timer triggers.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public ProtoId<SourcePortPrototype> TriggerPort = "Timer";
 
     /// <summary>
     ///     The port that gets signaled when the timer starts.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public ProtoId<SourcePortPrototype> StartPort = "Start";
 
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public ProtoId<SinkPortPrototype> Trigger = "Trigger";
 
     /// <summary>
     ///     If not null, this timer will play this sound when done.
     /// </summary>
-    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public SoundSpecifier? DoneSound;
-}
 
+    /// <summary>
+    ///     The maximum duration in seconds
+    ///     When a larger number is in the input box, the display will start counting down from this one instead
+    /// </summary>
+    [DataField]
+    public Double MaxDuration = 3599; // 59m 59s
+}
index 14e0c75d9629c454de4b4736c509ae0dd2ae02d1..b4ae1eb57a311bab7d980d79dc4e6870f77ee7b4 100644 (file)
@@ -152,7 +152,7 @@ public sealed class SignalTimerSystem : EntitySystem
         if (!IsMessageValid(uid, args))
             return;
 
-        component.Delay = args.Delay.TotalSeconds;
+        component.Delay = Math.Min(args.Delay.TotalSeconds, component.MaxDuration);
         _appearanceSystem.SetData(uid, TextScreenVisuals.TargetTime, component.Delay);
     }