using Content.Shared.Atmos; using Content.Shared.DoAfter; using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Disposal.Components; /// /// Takes in entities and flushes them out to attached disposals tubes after a timer. /// [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), AutoGenerateComponentPause] public sealed partial class DisposalUnitComponent : Component { /// /// Air contained in the disposal unit. /// [DataField] public GasMixture Air = new(Atmospherics.CellVolume); /// /// Name of the flushing animation state. /// [DataField] public string FlushingState = "disposal-flush"; /// /// The animation used when unit flushes. /// [ViewVariables(VVAccess.ReadWrite)] public object FlushingAnimation = default!; /// /// 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"); /// /// The next time that the insertion sound is allowed to be played. /// Used to reduce audio spam when dumping multiple items into the unit. /// [DataField, AutoNetworkedField, AutoPausedField] public TimeSpan NextAllowedInsertSound = TimeSpan.Zero; /// /// Delay in seconds before the insertion audio can be played again. /// [DataField] public TimeSpan InsertSoundDelay = TimeSpan.FromSeconds(0.1); /// /// State for this disposals unit. /// [DataField, AutoNetworkedField] public DisposalsPressureState State; /// /// Next time the disposal unit will be pressurized. /// [DataField, AutoNetworkedField, AutoPausedField] public TimeSpan NextPressurized = TimeSpan.Zero; /// /// The percentage of pressure gained per second by the unit. /// [DataField] public float PressurePerSecond = 0.05f; /// /// 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, AutoPausedField] public TimeSpan LastExitAttempt; /// /// Delay in seconds before entities are allowed another /// attempt to exit the disposal unit again. /// [DataField] public TimeSpan ExitAttemptDelay = TimeSpan.FromSeconds(0.5); /// /// Sets whether the unit should automatically flush /// after something is inserted into it. /// [DataField] public bool AutomaticEngage = true; /// /// Delay for automatic flushing of the disposal unit. /// [DataField, AutoNetworkedField] public TimeSpan AutomaticEngageTime = TimeSpan.FromSeconds(30); /// /// Delay for entities trying to enter disposals themselves. /// [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. /// [DataField] public Container? Container; /// /// 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, AutoNetworkedField, AutoPausedField] public TimeSpan? NextFlush; /// /// The max number of entities that can be inserted in the unit before it needs to be flushed. /// [DataField] public int MaxCapacity = 30; /// /// Proto ID of the holder spawned to contain entities that /// are inserted into the disposals system. /// [DataField] public EntProtoId HolderPrototypeId = "DisposalHolder"; } /// /// Event raised on entities that are entering or exiting disposals. /// [ByRefEvent] public record DisposalSystemTransitionEvent; /// /// Do after raised when attempting to insert an entity into a disposal unit. /// [Serializable, NetSerializable] public sealed partial class DisposalDoAfterEvent : SimpleDoAfterEvent; /// /// Disposal unit pressure states. /// [Serializable, NetSerializable] public enum DisposalsPressureState : byte { /// /// The disposal unit is fully pressurized and ready to flush. /// Ready, /// /// Has been flushed recently within FlushDelay. /// Flushed, /// /// FlushDelay has elapsed and now we're transitioning back to Ready. /// Pressurizing } /// /// Visual keys for disposal units. /// [Serializable, NetSerializable] public enum DisposalUnitVisuals : byte { IsReady, IsEngaged, IsFlushing, IsCharging, IsFull, } /// /// Sprite layers for disposal units. /// [Serializable, NetSerializable] public enum DisposalUnitVisualLayers : byte { Base, OverlayFlushing, OverlayEngaged, OverlayCharging, OverlayFull, } /// /// UI button types for disposal units. /// [Serializable, NetSerializable] public enum DisposalUnitUiButton : byte { Eject, Engage, Power, } /// /// Message data sent from client to server when a disposal unit ui button is pressed. /// [Serializable, NetSerializable] public sealed class DisposalUnitUiButtonPressedMessage : BoundUserInterfaceMessage { public readonly DisposalUnitUiButton Button; public DisposalUnitUiButtonPressedMessage(DisposalUnitUiButton button) { Button = button; } } /// /// Key for the disposal unit UI. /// [Serializable, NetSerializable] public enum DisposalUnitUiKey : byte { Key }