using Content.Shared.Guidebook; using Content.Shared.Trigger.Systems; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using System.Linq; namespace Content.Shared.Trigger.Components; /// /// Starts a timer when activated by a trigger. /// Will cause a different trigger once the time is over. /// Can play a sound while the timer is active. /// The time can be set by other components, for example . /// [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause] public sealed partial class TimerTriggerComponent : Component { /// /// The keys that will activate the timer. /// [DataField, AutoNetworkedField] public List KeysIn = new() { TriggerSystem.DefaultTriggerKey }; /// /// The key that will trigger once the timer is finished. /// [DataField, AutoNetworkedField] public string? KeyOut = "timer"; /// /// The time after which this timer will trigger after it is activated. /// [DataField, AutoNetworkedField] public TimeSpan Delay = TimeSpan.FromSeconds(1); /// /// If not empty, a user can use verbs to configure the delay to one of these options. /// [DataField, AutoNetworkedField] public List DelayOptions = new(); /// /// The time at which this trigger will activate. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoNetworkedField, AutoPausedField] public TimeSpan NextTrigger = TimeSpan.Zero; /// /// Time of the next beeping sound. /// /// /// Not networked because it's only used server side. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoPausedField] public TimeSpan NextBeep = TimeSpan.Zero; /// /// Initial beep delay. /// Defaults to a single BeepInterval if null. /// /// /// Not networked because it's only used server side. /// [DataField] public TimeSpan? InitialBeepDelay; /// /// The time between beeps. /// [DataField, AutoNetworkedField] public TimeSpan BeepInterval = TimeSpan.FromSeconds(1); /// /// The entity that activated this trigger. /// [DataField, AutoNetworkedField] public EntityUid? User; /// /// The beeping sound, if any. /// [DataField, AutoNetworkedField] public SoundSpecifier? BeepSound; /// /// Whether you can examine the item to see its timer or not. /// [DataField, AutoNetworkedField] public bool Examinable = true; /// /// The popup to show the user when starting the timer, if any. /// [DataField, AutoNetworkedField] public LocId? Popup = "timer-trigger-activated"; #region GuidebookData [GuidebookData] public float? ShortestDelayOption => DelayOptions.Count == 0 ? null : (float)DelayOptions.Min().TotalSeconds; [GuidebookData] public float? LongestDelayOption => DelayOptions.Count == 0 ? null : (float)DelayOptions.Max().TotalSeconds; #endregion GuidebookData }