using System.Threading; using Content.Shared.Construction.Prototypes; using Content.Shared.DeviceLinking; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; namespace Content.Shared.Singularity.Components; [RegisterComponent, NetworkedComponent] public sealed partial class EmitterComponent : Component { public CancellationTokenSource? TimerCancel; /// /// Whether the power switch is on /// [ViewVariables] public bool IsOn; /// /// Whether the power switch is on AND the machine has enough power (so is actively firing) /// [ViewVariables] public bool IsPowered; /// /// counts the number of consecutive shots fired. /// [ViewVariables] public int FireShotCounter; /// /// The entity that is spawned when the emitter fires. /// [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string BoltType = "EmitterBolt"; [DataField(customTypeSerializer: typeof(PrototypeIdListSerializer))] public List SelectableTypes = new(); /// /// The current amount of power being used. /// [DataField] public int PowerUseActive = 600; /// /// The amount of shots that are fired in a single "burst" /// [DataField] public int FireBurstSize = 3; /// /// The time between each shot during a burst. /// [DataField] public TimeSpan FireInterval = TimeSpan.FromSeconds(2); /// /// The base amount of time between each shot during a burst. /// [DataField] public TimeSpan BaseFireInterval = TimeSpan.FromSeconds(2); /// /// The current minimum delay between bursts. /// [DataField] public TimeSpan FireBurstDelayMin = TimeSpan.FromSeconds(4); /// /// The current maximum delay between bursts. /// [DataField] public TimeSpan FireBurstDelayMax = TimeSpan.FromSeconds(10); /// /// The base minimum delay between shot bursts. /// Used for machine part rating calculations. /// [DataField] public TimeSpan BaseFireBurstDelayMin = TimeSpan.FromSeconds(4); /// /// The base maximum delay between shot bursts. /// Used for machine part rating calculations. /// [DataField] public TimeSpan BaseFireBurstDelayMax = TimeSpan.FromSeconds(10); /// /// The multiplier for the base delay between shot bursts as well as /// the fire interval /// [DataField] public float FireRateMultiplier = 0.8f; /// /// The machine part that affects burst delay. /// [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string MachinePartFireRate = "Capacitor"; /// /// The visual state that is set when the emitter is turned on /// [DataField] public string? OnState = "beam"; /// /// The visual state that is set when the emitter doesn't have enough power. /// [DataField] public string? UnderpoweredState = "underpowered"; /// /// Signal port that turns on the emitter. /// [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string OnPort = "On"; /// /// Signal port that turns off the emitter. /// [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string OffPort = "Off"; /// /// Signal port that toggles the emitter on or off. /// [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string TogglePort = "Toggle"; /// /// Map of signal ports to entity prototype IDs of the entity that will be fired. /// [DataField(customTypeSerializer: typeof(PrototypeIdDictionarySerializer))] public Dictionary SetTypePorts = new(); } [NetSerializable, Serializable] public enum EmitterVisuals : byte { VisualState } [Serializable, NetSerializable] public enum EmitterVisualLayers : byte { Lights } [NetSerializable, Serializable] public enum EmitterVisualState { On, Underpowered, Off }