using Content.Shared.Atmos; using Robust.Shared.Audio; using Content.Shared.Whitelist; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Disposal.Components; /// /// Takes in entities and flushes them out to attached disposals tubes after a timer. /// [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class DisposalUnitComponent : Component { public const string ContainerId = "disposals"; /// /// Air contained in the disposal unit. /// [DataField] public GasMixture Air = new(Atmospherics.CellVolume); /// /// Sounds played upon the unit flushing. /// [DataField("soundFlush"), AutoNetworkedField] public SoundSpecifier? FlushSound = new SoundPathSpecifier("/Audio/Machines/disposalflush.ogg"); /// /// Blacklists (prevents) entities listed from being placed inside. /// [DataField] public EntityWhitelist? Blacklist; /// /// Whitelists (allows) entities listed from being placed inside. /// [DataField] public EntityWhitelist? Whitelist; /// /// Sound played when an object is inserted into the disposal unit. /// [ViewVariables(VVAccess.ReadWrite), DataField("soundInsert")] public SoundSpecifier? InsertSound = new SoundPathSpecifier("/Audio/Effects/trashbag1.ogg"); /// /// State for this disposals unit. /// [DataField, AutoNetworkedField] public DisposalsPressureState State; /// /// Next time the disposal unit will be pressurized. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] public TimeSpan NextPressurized = TimeSpan.Zero; /// /// How long it takes to flush a disposals unit manually. /// [DataField("flushTime")] public TimeSpan ManualFlushTime = TimeSpan.FromSeconds(2); /// /// How long it takes from the start of a flush animation to return the sprite to normal. /// [DataField] public TimeSpan FlushDelay = TimeSpan.FromSeconds(3); /// /// Removes the pressure requirement for flushing. /// [DataField] public bool DisablePressure; /// /// Last time that an entity tried to exit this disposal unit. /// [DataField, AutoNetworkedField] public TimeSpan LastExitAttempt; [DataField] public bool AutomaticEngage = true; [DataField, AutoNetworkedField] public TimeSpan AutomaticEngageTime = TimeSpan.FromSeconds(30); /// /// Delay from trying to enter disposals ourselves. /// [DataField] public float EntryDelay = 0.5f; /// /// Delay from trying to shove someone else into disposals. /// [ViewVariables(VVAccess.ReadWrite)] public float DraggedEntryDelay = 2.0f; /// /// Container of entities inside this disposal unit. /// [ViewVariables] public Container Container = default!; /// /// Was the disposals unit engaged for a manual flush. /// [DataField, AutoNetworkedField] public bool Engaged; /// /// Next time this unit will flush. Is the lesser of and /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] public TimeSpan? NextFlush; [Serializable, NetSerializable] public enum Visuals : byte { VisualState, Handle, Light } [Serializable, NetSerializable] public enum VisualState : byte { UnAnchored, Anchored, OverlayFlushing, OverlayCharging } [Serializable, NetSerializable] public enum HandleState : byte { Normal, Engaged } [Serializable, NetSerializable] [Flags] public enum LightStates : byte { Off = 0, Charging = 1 << 0, Full = 1 << 1, Ready = 1 << 2 } [Serializable, NetSerializable] public enum UiButton : byte { Eject, Engage, Power } /// /// Message data sent from client to server when a disposal unit ui button is pressed. /// [Serializable, NetSerializable] public sealed class UiButtonPressedMessage : BoundUserInterfaceMessage { public readonly UiButton Button; public UiButtonPressedMessage(UiButton button) { Button = button; } } [Serializable, NetSerializable] public enum DisposalUnitUiKey : byte { Key } } [Serializable, NetSerializable] public enum DisposalsPressureState : byte { Ready, /// /// Has been flushed recently within FlushDelay. /// Flushed, /// /// FlushDelay has elapsed and now we're transitioning back to Ready. /// Pressurizing }