using System.Threading;
using Content.Server.Atmos;
using Content.Shared.Atmos;
using Content.Shared.Disposal.Components;
using Robust.Shared.Containers;
namespace Content.Server.Disposal.Unit.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedDisposalUnitComponent))]
public sealed class DisposalUnitComponent : SharedDisposalUnitComponent, IGasMixtureHolder
{
///
/// Last time that an entity tried to exit this disposal unit.
///
[ViewVariables]
public TimeSpan LastExitAttempt;
///
/// The current pressure of this disposal unit.
/// Prevents it from flushing if it is not equal to or bigger than 1.
///
[ViewVariables]
[DataField("pressure")]
public float Pressure = 1f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("autoEngageTime")]
public readonly TimeSpan AutomaticEngageTime = TimeSpan.FromSeconds(30);
[ViewVariables(VVAccess.ReadWrite)]
[DataField("flushDelay")]
public readonly TimeSpan FlushDelay = TimeSpan.FromSeconds(3);
///
/// Delay from trying to enter disposals ourselves.
///
[ViewVariables(VVAccess.ReadWrite)]
[DataField("entryDelay")]
public float EntryDelay = 0.5f;
///
/// Delay from trying to shove someone else into disposals.
///
[ViewVariables(VVAccess.ReadWrite)]
public float DraggedEntryDelay = 0.5f;
///
/// Token used to cancel the automatic engage of a disposal unit
/// after an entity enters it.
///
public CancellationTokenSource? AutomaticEngageToken;
///
/// Container of entities inside this disposal unit.
///
[ViewVariables] public Container Container = default!;
[ViewVariables] public bool Powered = false;
[ViewVariables] public PressureState State = PressureState.Ready;
[ViewVariables(VVAccess.ReadWrite)]
public bool Engaged { get; set; }
[DataField("air")]
public GasMixture Air { get; set; } = new(Atmospherics.CellVolume);
}
}