Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes vent pump pressure lockout #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,6 @@ public sealed partial class GasVentPumpComponent : Component
[DataField]
public VentPressureBound PressureChecks { get; set; } = VentPressureBound.ExternalBound;

[DataField]
public bool UnderPressureLockout { get; set; } = false;

/// <summary>
/// In releasing mode, do not pump when environment pressure is below this limit.
/// </summary>
[DataField]
public float UnderPressureLockoutThreshold = 80; // this must be tuned in conjunction with atmos.mmos_spacing_speed

/// <summary>
/// Pressure locked vents still leak a little (leading to eventual pressurization of sealed sections)
/// </summary>
/// <remarks>
/// Ratio of pressure difference between pipes and atmosphere that will leak each second, in moles.
/// If the pipes are 200 kPa and the room is spaced, at 0.01 UnderPressureLockoutLeaking, the room will fill
/// at a rate of 2 moles / sec. It will then reach 2 kPa (UnderPressureLockoutThreshold) and begin normal
/// filling after about 20 seconds (depending on room size).
///
/// Since we want to prevent automating the work of atmos, the leaking rate of 0.0001f is set to make auto
/// repressurizing of the development map take about 30 minutes using an oxygen tank (high pressure)
/// </remarks>

[DataField]
public float UnderPressureLockoutLeaking = 0.0001f;
/// <summary>
/// Is the vent pressure lockout currently manually disabled?
/// </summary>
[DataField]
public bool IsPressureLockoutManuallyDisabled = false;
/// <summary>
/// The time when the manual pressure lockout will be reenabled.
/// </summary>
[DataField]
[AutoPausedField]
public TimeSpan ManualLockoutReenabledAt;
/// <summary>
/// How long the lockout should remain manually disabled after being interacted with.
/// </summary>
[DataField]
public TimeSpan ManualLockoutDisabledDuration = TimeSpan.FromSeconds(30); // Enough time to fill a 5x5 room
/// <summary>
/// How long the doAfter should take when attempting to manually disable the pressure lockout.
/// </summary>
public float ManualLockoutDisableDoAfter = 2.0f;

[DataField]
public float ExternalPressureBound
Expand Down Expand Up @@ -143,9 +99,6 @@ public float InternalPressureBound
[DataField]
public float DepressurizePressure = 0;

// When true, ignore under-pressure lockout. Used to re-fill rooms in air alarm "Fill" mode.
[DataField]
public bool PressureLockoutOverride = false;
#endregion

public GasVentPumpData ToAirAlarmData()
Expand All @@ -158,7 +111,6 @@ public GasVentPumpData ToAirAlarmData()
PressureChecks = PressureChecks,
ExternalPressureBound = ExternalPressureBound,
InternalPressureBound = InternalPressureBound,
PressureLockoutOverride = PressureLockoutOverride
};
}

Expand All @@ -170,7 +122,6 @@ public void FromAirAlarmData(GasVentPumpData data)
PressureChecks = data.PressureChecks;
ExternalPressureBound = data.ExternalPressureBound;
InternalPressureBound = data.InternalPressureBound;
PressureLockoutOverride = data.PressureLockoutOverride;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ public override void Initialize()
SubscribeLocalEvent<GasVentPumpComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<GasVentPumpComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
SubscribeLocalEvent<GasVentPumpComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<GasVentPumpComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<GasVentPumpComponent, SignalReceivedEvent>(OnSignalReceived);
SubscribeLocalEvent<GasVentPumpComponent, GasAnalyzerScanEvent>(OnAnalyzed);
SubscribeLocalEvent<GasVentPumpComponent, WeldableChangedEvent>(OnWeldChanged);
SubscribeLocalEvent<GasVentPumpComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<GasVentPumpComponent, VentScrewedDoAfterEvent>(OnVentScrewed);
}

private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, ref AtmosDeviceUpdateEvent args)
Expand Down Expand Up @@ -86,22 +83,10 @@ private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, ref
{
return;
}
// If the lockout has expired, disable it.
if (vent.IsPressureLockoutManuallyDisabled && _timing.CurTime >= vent.ManualLockoutReenabledAt)
{
vent.IsPressureLockoutManuallyDisabled = false;
}

var timeDelta = args.dt;
var pressureDelta = timeDelta * vent.TargetPressureChange;

var lockout = (environment.Pressure < vent.UnderPressureLockoutThreshold) && !vent.IsPressureLockoutManuallyDisabled;
if (vent.UnderPressureLockout != lockout) // update visuals only if this changes
{
vent.UnderPressureLockout = lockout;
UpdateState(uid, vent);
}

if (vent.PumpDirection == VentPumpDirection.Releasing && pipe.Air.Pressure > 0)
{
if (environment.Pressure > vent.MaxPressure)
Expand All @@ -125,16 +110,6 @@ private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, ref
// (ignoring temperature differences because I am lazy)
var transferMoles = pressureDelta * environment.Volume / (pipe.Air.Temperature * Atmospherics.R);

// Only run if the device is under lockout and not being overriden
if (vent.UnderPressureLockout & !vent.PressureLockoutOverride & !vent.IsPressureLockoutManuallyDisabled)
{
// Leak only a small amount of gas as a proportion of supply pipe pressure.
var pipeDelta = pipe.Air.Pressure - environment.Pressure;
transferMoles = (float)timeDelta * pipeDelta * vent.UnderPressureLockoutLeaking;
if (transferMoles < 0.0)
return;
}

// limit transferMoles so the source doesn't go below its bound.
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
{
Expand Down Expand Up @@ -284,30 +259,14 @@ private void UpdateState(EntityUid uid, GasVentPumpComponent vent, AppearanceCom
}
else if (vent.PumpDirection == VentPumpDirection.Releasing)
{
if (vent.UnderPressureLockout & !vent.PressureLockoutOverride & !vent.IsPressureLockoutManuallyDisabled)
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Lockout, appearance);
else
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Out, appearance);
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Out, appearance);
}
else if (vent.PumpDirection == VentPumpDirection.Siphoning)
{
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.In, appearance);
}
}

private void OnExamine(EntityUid uid, GasVentPumpComponent component, ExaminedEvent args)
{
if (!TryComp<GasVentPumpComponent>(uid, out var pumpComponent))
return;
if (args.IsInDetailsRange)
{
if (pumpComponent.PumpDirection == VentPumpDirection.Releasing & pumpComponent.UnderPressureLockout & !pumpComponent.PressureLockoutOverride & !pumpComponent.IsPressureLockoutManuallyDisabled)
{
args.PushMarkup(Loc.GetString("gas-vent-pump-uvlo"));
}
}
}

/// <summary>
/// Returns the gas mixture for the gas analyzer
/// </summary>
Expand Down Expand Up @@ -336,25 +295,6 @@ private void OnWeldChanged(EntityUid uid, GasVentPumpComponent component, ref We
{
UpdateState(uid, component);
}
private void OnInteractUsing(EntityUid uid, GasVentPumpComponent component, InteractUsingEvent args)
{
if (args.Handled
|| component.UnderPressureLockout == false
|| !_toolSystem.HasQuality(args.Used, "Screwing")
|| !Transform(uid).Anchored
)
{
return;
}

args.Handled = true;

_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ManualLockoutDisableDoAfter, new VentScrewedDoAfterEvent(), uid, uid, args.Used));
}
private void OnVentScrewed(EntityUid uid, GasVentPumpComponent component, VentScrewedDoAfterEvent args)
{
component.ManualLockoutReenabledAt = _timing.CurTime + component.ManualLockoutDisabledDuration;
component.IsPressureLockoutManuallyDisabled = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public sealed class GasVentPumpData : IAtmosDeviceData
public VentPressureBound PressureChecks { get; set; } = VentPressureBound.ExternalBound;
public float ExternalPressureBound { get; set; } = Atmospherics.OneAtmosphere;
public float InternalPressureBound { get; set; } = 0f;
public bool PressureLockoutOverride { get; set; } = false;

// Presets for 'dumb' air alarm modes

Expand All @@ -24,7 +23,6 @@ public sealed class GasVentPumpData : IAtmosDeviceData
PressureChecks = VentPressureBound.ExternalBound,
ExternalPressureBound = Atmospherics.OneAtmosphere,
InternalPressureBound = 0f,
PressureLockoutOverride = false
};

public static GasVentPumpData FillModePreset = new GasVentPumpData
Expand All @@ -35,7 +33,6 @@ public sealed class GasVentPumpData : IAtmosDeviceData
PressureChecks = VentPressureBound.ExternalBound,
ExternalPressureBound = Atmospherics.OneAtmosphere * 50,
InternalPressureBound = 0f,
PressureLockoutOverride = true
};

public static GasVentPumpData PanicModePreset = new GasVentPumpData
Expand All @@ -46,7 +43,6 @@ public sealed class GasVentPumpData : IAtmosDeviceData
PressureChecks = VentPressureBound.ExternalBound,
ExternalPressureBound = Atmospherics.OneAtmosphere,
InternalPressureBound = 0f,
PressureLockoutOverride = false
};

public static GasVentPumpData ReplaceModePreset = new GasVentPumpData
Expand All @@ -58,7 +54,6 @@ public sealed class GasVentPumpData : IAtmosDeviceData
PressureChecks = VentPressureBound.ExternalBound,
ExternalPressureBound = Atmospherics.OneAtmosphere,
InternalPressureBound = 0f,
PressureLockoutOverride = false
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public enum VentPumpState : byte
In,
Out,
Welded,
Lockout,
}
}
1 change: 0 additions & 1 deletion Resources/Locale/en-US/atmos/gas-vent-pump.ftl

This file was deleted.