Merge branch 'master' into replace-sounds-with-sound-specifier

This commit is contained in:
ShadowCommander
2021-08-10 15:05:49 -07:00
183 changed files with 5472 additions and 2022 deletions

View File

@@ -25,30 +25,47 @@ namespace Content.Server.Doors.Components
/// Companion component to ServerDoorComponent that handles airlock-specific behavior -- wires, requiring power to operate, bolts, and allowing automatic closing.
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(IDoorCheck))]
public class AirlockComponent : Component, IWires, IDoorCheck
public class AirlockComponent : Component, IWires
{
public override string Name => "Airlock";
[ComponentDependency]
private readonly ServerDoorComponent? _doorComponent = null;
public readonly ServerDoorComponent? DoorComponent = null;
[ComponentDependency]
private readonly SharedAppearanceComponent? _appearanceComponent = null;
public readonly SharedAppearanceComponent? AppearanceComponent = null;
[ComponentDependency]
private readonly ApcPowerReceiverComponent? _receiverComponent = null;
public readonly ApcPowerReceiverComponent? ReceiverComponent = null;
[ComponentDependency]
private readonly WiresComponent? _wiresComponent = null;
public readonly WiresComponent? WiresComponent = null;
/// <summary>
/// Sound to play when the bolts on the airlock go up.
/// </summary>
[DataField("boltUpSound")]
public SoundSpecifier BoltUpSound = new SoundPathSpecifier("/Audio/Machines/boltsup.ogg");
/// <summary>
/// Sound to play when the bolts on the airlock go down.
/// </summary>
[DataField("boltDownSound")]
public SoundSpecifier BoltDownSound = new SoundPathSpecifier("/Audio/Machines/boltsdown.ogg");
/// <summary>
/// Duration for which power will be disabled after pulsing either power wire.
/// </summary>
private static readonly TimeSpan PowerWiresTimeout = TimeSpan.FromSeconds(5.0);
[DataField("powerWiresTimeout")]
public float PowerWiresTimeout = 5.0f;
/// <summary>
/// Whether the maintenance panel should be visible even if the airlock is opened.
/// </summary>
[DataField("openPanelVisible")]
public bool OpenPanelVisible = false;
private CancellationTokenSource _powerWiresPulsedTimerCancel = new();
private bool _powerWiresPulsed;
/// <summary>
@@ -85,7 +102,7 @@ namespace Content.Server.Doors.Components
private bool BoltLightsVisible
{
get => _boltLightsWirePulsed && BoltsDown && IsPowered()
&& _doorComponent != null && _doorComponent.State == SharedDoorComponent.DoorState.Closed;
&& DoorComponent != null && DoorComponent.State == SharedDoorComponent.DoorState.Closed;
set
{
_boltLightsWirePulsed = value;
@@ -93,124 +110,53 @@ namespace Content.Server.Doors.Components
}
}
[DataField("setBoltsDownSound")] private SoundSpecifier _setBoltsDownSound = new SoundPathSpecifier("/Audio/Machines/boltsdown.ogg");
[DataField("setBoltsUpSound")] private SoundSpecifier _setBoltsUpSound = new SoundPathSpecifier("/Audio/Machines/boltsup.ogg");
private static readonly TimeSpan AutoCloseDelayFast = TimeSpan.FromSeconds(1);
[ViewVariables(VVAccess.ReadWrite)]
[DataField("autoClose")]
public bool AutoClose = true;
[ViewVariables(VVAccess.ReadWrite)]
private bool _autoClose = true;
[DataField("autoCloseDelayModifier")]
public float AutoCloseDelayModifier = 1.0f;
[ViewVariables(VVAccess.ReadWrite)]
private bool _normalCloseSpeed = true;
[ViewVariables(VVAccess.ReadWrite)]
private bool _safety = true;
public bool Safety = true;
protected override void Initialize()
{
base.Initialize();
if (_receiverComponent != null && _appearanceComponent != null)
if (ReceiverComponent != null && AppearanceComponent != null)
{
_appearanceComponent.SetData(DoorVisuals.Powered, _receiverComponent.Powered);
AppearanceComponent.SetData(DoorVisuals.Powered, ReceiverComponent.Powered);
}
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case PowerChangedMessage powerChanged:
PowerDeviceOnOnPowerStateChanged(powerChanged);
break;
}
}
void IDoorCheck.OnStateChange(SharedDoorComponent.DoorState doorState)
{
// Only show the maintenance panel if the airlock is closed
if (_wiresComponent != null)
{
_wiresComponent.IsPanelVisible = doorState != SharedDoorComponent.DoorState.Open;
}
// If the door is closed, we should look if the bolt was locked while closing
UpdateBoltLightStatus();
}
bool IDoorCheck.OpenCheck() => CanChangeState();
bool IDoorCheck.CloseCheck() => CanChangeState();
bool IDoorCheck.DenyCheck() => CanChangeState();
bool IDoorCheck.SafetyCheck() => _safety;
bool IDoorCheck.AutoCloseCheck() => _autoClose;
TimeSpan? IDoorCheck.GetCloseSpeed()
{
if (_normalCloseSpeed)
{
return null;
}
return AutoCloseDelayFast;
}
bool IDoorCheck.BlockActivate(ActivateEventArgs eventArgs)
{
if (_wiresComponent != null && _wiresComponent.IsPanelOpen &&
eventArgs.User.TryGetComponent(out ActorComponent? actor))
{
_wiresComponent.OpenInterface(actor.PlayerSession);
return true;
}
return false;
}
bool IDoorCheck.CanPryCheck(InteractUsingEventArgs eventArgs)
{
if (IsBolted())
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("airlock-component-cannot-pry-is-bolted-message "));
return false;
}
if (IsPowered())
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("airlock-component-cannot-pry-is-powered-message"));
return false;
}
return true;
}
private bool CanChangeState()
public bool CanChangeState()
{
return IsPowered() && !IsBolted();
}
private bool IsBolted()
public bool IsBolted()
{
return _boltsDown;
}
private bool IsPowered()
public bool IsPowered()
{
return _receiverComponent == null || _receiverComponent.Powered;
return ReceiverComponent == null || ReceiverComponent.Powered;
}
private void UpdateBoltLightStatus()
public void UpdateBoltLightStatus()
{
if (_appearanceComponent != null)
if (AppearanceComponent != null)
{
_appearanceComponent.SetData(DoorVisuals.BoltLights, BoltLightsVisible);
AppearanceComponent.SetData(DoorVisuals.BoltLights, BoltLightsVisible);
}
}
private void UpdateWiresStatus()
public void UpdateWiresStatus()
{
if (_doorComponent == null)
if (DoorComponent == null)
{
return;
}
@@ -220,9 +166,9 @@ namespace Content.Server.Doors.Components
{
powerLight = new StatusLightData(Color.Yellow, StatusLightState.BlinkingFast, "POWR");
}
else if (_wiresComponent != null &&
_wiresComponent.IsWireCut(Wires.MainPower) &&
_wiresComponent.IsWireCut(Wires.BackupPower))
else if (WiresComponent != null &&
WiresComponent.IsWireCut(Wires.MainPower) &&
WiresComponent.IsWireCut(Wires.BackupPower))
{
powerLight = new StatusLightData(Color.Red, StatusLightState.On, "POWR");
}
@@ -232,63 +178,59 @@ namespace Content.Server.Doors.Components
var boltLightsStatus = new StatusLightData(Color.Lime,
_boltLightsWirePulsed ? StatusLightState.On : StatusLightState.Off, "BLTL");
var ev = new DoorGetCloseTimeModifierEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
var timingStatus =
new StatusLightData(Color.Orange, !_autoClose ? StatusLightState.Off :
!_normalCloseSpeed ? StatusLightState.BlinkingSlow :
new StatusLightData(Color.Orange, !AutoClose ? StatusLightState.Off :
!MathHelper.CloseTo(ev.CloseTimeModifier, 1.0f) ? StatusLightState.BlinkingSlow :
StatusLightState.On,
"TIME");
var safetyStatus =
new StatusLightData(Color.Red, _safety ? StatusLightState.On : StatusLightState.Off, "SAFE");
new StatusLightData(Color.Red, Safety ? StatusLightState.On : StatusLightState.Off, "SAFE");
if (_wiresComponent == null)
if (WiresComponent == null)
{
return;
}
_wiresComponent.SetStatus(AirlockWireStatus.PowerIndicator, powerLight);
_wiresComponent.SetStatus(AirlockWireStatus.BoltIndicator, boltStatus);
_wiresComponent.SetStatus(AirlockWireStatus.BoltLightIndicator, boltLightsStatus);
_wiresComponent.SetStatus(AirlockWireStatus.AIControlIndicator, new StatusLightData(Color.Purple, StatusLightState.BlinkingSlow, "AICT"));
_wiresComponent.SetStatus(AirlockWireStatus.TimingIndicator, timingStatus);
_wiresComponent.SetStatus(AirlockWireStatus.SafetyIndicator, safetyStatus);
/*
_wires.SetStatus(6, powerLight);
_wires.SetStatus(7, powerLight);
_wires.SetStatus(8, powerLight);
_wires.SetStatus(9, powerLight);
_wires.SetStatus(10, powerLight);
_wires.SetStatus(11, powerLight);*/
WiresComponent.SetStatus(AirlockWireStatus.PowerIndicator, powerLight);
WiresComponent.SetStatus(AirlockWireStatus.BoltIndicator, boltStatus);
WiresComponent.SetStatus(AirlockWireStatus.BoltLightIndicator, boltLightsStatus);
WiresComponent.SetStatus(AirlockWireStatus.AIControlIndicator, new StatusLightData(Color.Purple, StatusLightState.BlinkingSlow, "AICT"));
WiresComponent.SetStatus(AirlockWireStatus.TimingIndicator, timingStatus);
WiresComponent.SetStatus(AirlockWireStatus.SafetyIndicator, safetyStatus);
}
private void UpdatePowerCutStatus()
{
if (_receiverComponent == null)
if (ReceiverComponent == null)
{
return;
}
if (PowerWiresPulsed)
{
_receiverComponent.PowerDisabled = true;
ReceiverComponent.PowerDisabled = true;
return;
}
if (_wiresComponent == null)
if (WiresComponent == null)
{
return;
}
_receiverComponent.PowerDisabled =
_wiresComponent.IsWireCut(Wires.MainPower) ||
_wiresComponent.IsWireCut(Wires.BackupPower);
ReceiverComponent.PowerDisabled =
WiresComponent.IsWireCut(Wires.MainPower) ||
WiresComponent.IsWireCut(Wires.BackupPower);
}
private void PowerDeviceOnOnPowerStateChanged(PowerChangedMessage e)
{
if (_appearanceComponent != null)
if (AppearanceComponent != null)
{
_appearanceComponent.SetData(DoorVisuals.Powered, e.Powered);
AppearanceComponent.SetData(DoorVisuals.Powered, e.Powered);
}
// BoltLights also got out
@@ -347,19 +289,13 @@ namespace Content.Server.Doors.Components
builder.CreateWire(Wires.BoltLight);
builder.CreateWire(Wires.Timing);
builder.CreateWire(Wires.Safety);
/*
builder.CreateWire(6);
builder.CreateWire(7);
builder.CreateWire(8);
builder.CreateWire(9);
builder.CreateWire(10);
builder.CreateWire(11);*/
UpdateWiresStatus();
}
public void WiresUpdate(WiresUpdateEventArgs args)
{
if (_doorComponent == null)
if (DoorComponent == null)
{
return;
}
@@ -373,7 +309,7 @@ namespace Content.Server.Doors.Components
PowerWiresPulsed = true;
_powerWiresPulsedTimerCancel.Cancel();
_powerWiresPulsedTimerCancel = new CancellationTokenSource();
Owner.SpawnTimer(PowerWiresTimeout,
Owner.SpawnTimer(TimeSpan.FromSeconds(PowerWiresTimeout),
() => PowerWiresPulsed = false,
_powerWiresPulsedTimerCancel.Token);
break;
@@ -396,11 +332,11 @@ namespace Content.Server.Doors.Components
BoltLightsVisible = !_boltLightsWirePulsed;
break;
case Wires.Timing:
_normalCloseSpeed = !_normalCloseSpeed;
_doorComponent.RefreshAutoClose();
AutoCloseDelayModifier = 0.5f;
DoorComponent.RefreshAutoClose();
break;
case Wires.Safety:
_safety = !_safety;
Safety = !Safety;
break;
}
}
@@ -419,11 +355,11 @@ namespace Content.Server.Doors.Components
BoltLightsVisible = true;
break;
case Wires.Timing:
_autoClose = true;
_doorComponent.RefreshAutoClose();
AutoClose = true;
DoorComponent.RefreshAutoClose();
break;
case Wires.Safety:
_safety = true;
Safety = true;
break;
}
}
@@ -439,11 +375,11 @@ namespace Content.Server.Doors.Components
BoltLightsVisible = false;
break;
case Wires.Timing:
_autoClose = false;
_doorComponent.RefreshAutoClose();
AutoClose = false;
DoorComponent.RefreshAutoClose();
break;
case Wires.Safety:
_safety = false;
Safety = false;
break;
}
}
@@ -461,14 +397,7 @@ namespace Content.Server.Doors.Components
BoltsDown = newBolts;
if (newBolts)
{
SoundSystem.Play(Filter.Broadcast(), _setBoltsDownSound.GetSound(), Owner);
}
else
{
SoundSystem.Play(Filter.Broadcast(), _setBoltsUpSound.GetSound(), Owner);
}
SoundSystem.Play(Filter.Broadcast(), newBolts ? BoltDownSound.GetSound() : BoltUpSound.GetSound(), Owner);
}
}
}

View File

@@ -0,0 +1,88 @@
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Doors;
using Content.Server.Doors.Components;
using Content.Shared.Doors;
using Content.Shared.Interaction;
using Content.Shared.Notification.Managers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Doors.Components
{
/// <summary>
/// Companion component to ServerDoorComponent that handles firelock-specific behavior -- primarily prying,
/// and not being openable on open-hand click.
/// </summary>
[RegisterComponent]
public class FirelockComponent : Component
{
public override string Name => "Firelock";
[ComponentDependency]
public readonly ServerDoorComponent? DoorComponent = null;
/// <summary>
/// Pry time modifier to be used when the firelock is currently closed due to fire or pressure.
/// </summary>
/// <returns></returns>
[DataField("lockedPryTimeModifier")]
public float LockedPryTimeModifier = 1.5f;
public bool EmergencyPressureStop()
{
if (DoorComponent != null && DoorComponent.State == SharedDoorComponent.DoorState.Open && DoorComponent.CanCloseGeneric())
{
DoorComponent.Close();
if (Owner.TryGetComponent(out AirtightComponent? airtight))
{
EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, true);
}
return true;
}
return false;
}
public bool IsHoldingPressure(float threshold = 20)
{
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
var minMoles = float.MaxValue;
var maxMoles = 0f;
foreach (var adjacent in atmosphereSystem.GetAdjacentTileMixtures(Owner.Transform.Coordinates))
{
var moles = adjacent.TotalMoles;
if (moles < minMoles)
minMoles = moles;
if (moles > maxMoles)
maxMoles = moles;
}
return (maxMoles - minMoles) > threshold;
}
public bool IsHoldingFire()
{
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
if (!atmosphereSystem.TryGetGridAndTile(Owner.Transform.Coordinates, out var tuple))
return false;
if (atmosphereSystem.GetTileMixture(tuple.Value.Grid, tuple.Value.Tile) == null)
return false;
if (atmosphereSystem.IsHotspotActive(tuple.Value.Grid, tuple.Value.Tile))
return true;
foreach (var adjacent in atmosphereSystem.GetAdjacentTiles(Owner.Transform.Coordinates))
{
if (atmosphereSystem.IsHotspotActive(tuple.Value.Grid, adjacent))
return true;
}
return false;
}
}
}

View File

@@ -38,9 +38,6 @@ namespace Content.Server.Doors.Components
[ComponentReference(typeof(SharedDoorComponent))]
public class ServerDoorComponent : SharedDoorComponent, IActivate, IInteractUsing, IMapInit
{
[ComponentDependency]
private readonly IDoorCheck? _doorCheck = null;
[ViewVariables]
[DataField("board")]
private string? _boardPrototype;
@@ -67,11 +64,8 @@ namespace Content.Server.Doors.Components
_ => throw new ArgumentOutOfRangeException(),
};
if (_doorCheck != null)
{
_doorCheck.OnStateChange(State);
RefreshAutoClose();
}
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
_autoCloseCancelTokenSource?.Cancel();
Dirty();
}
@@ -109,7 +103,7 @@ namespace Content.Server.Doors.Components
/// Handled in Startup().
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField("startOpen")]
private bool _startOpen;
private bool _startOpen = false;
/// <summary>
/// Whether the airlock is welded shut. Can be set by the prototype, although this will fail if the door isn't weldable.
@@ -143,6 +137,41 @@ namespace Content.Server.Doors.Components
[DataField("weldable")]
private bool _weldable = true;
/// <summary>
/// Sound to play when the door opens.
/// </summary>
[DataField("openSound")]
public SoundSpecifier? OpenSound;
/// <summary>
/// Sound to play when the door closes.
/// </summary>
[DataField("closeSound")]
public SoundSpecifier? CloseSound;
/// <summary>
/// Sound to play if the door is denied.
/// </summary>
[DataField("denySound")]
public SoundSpecifier? DenySound;
/// <summary>
/// Default time that the door should take to pry open.
/// </summary>
[DataField("pryTime")]
public float PryTime = 0.5f;
/// <summary>
/// Minimum interval allowed between deny sounds in milliseconds.
/// </summary>
[DataField("denySoundMinimumInterval")]
public float DenySoundMinimumInterval = 250.0f;
/// <summary>
/// Used to stop people from spamming the deny sound.
/// </summary>
private TimeSpan LastDenySoundTime = TimeSpan.Zero;
/// <summary>
/// Whether the door can currently be welded.
/// </summary>
@@ -153,6 +182,7 @@ namespace Content.Server.Doors.Components
/// </summary>
private bool _beingWelded;
//[ViewVariables(VVAccess.ReadWrite)]
//[DataField("canCrush")]
//private bool _canCrush = true; // TODO implement door crushing
@@ -191,7 +221,7 @@ namespace Content.Server.Doors.Components
Logger.Warning("{0} prototype loaded with incompatible flags: 'welded' and 'startOpen' are both true.", Owner.Name);
return;
}
QuickOpen();
QuickOpen(false);
}
CreateDoorElectronicsBoard();
@@ -199,10 +229,10 @@ namespace Content.Server.Doors.Components
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (_doorCheck != null && _doorCheck.BlockActivate(eventArgs))
{
DoorClickShouldActivateEvent ev = new DoorClickShouldActivateEvent(eventArgs);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (ev.Handled)
return;
}
if (State == DoorState.Open)
{
@@ -282,12 +312,10 @@ namespace Content.Server.Doors.Components
{
return false;
}
if(_doorCheck != null)
{
return _doorCheck.OpenCheck();
}
return true;
var ev = new BeforeDoorOpenedEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
return !ev.Cancelled;
}
/// <summary>
@@ -304,12 +332,19 @@ namespace Content.Server.Doors.Components
_stateChangeCancelTokenSource?.Cancel();
_stateChangeCancelTokenSource = new();
if (OpenSound != null)
{
SoundSystem.Play(Filter.Pvs(Owner), OpenSound.GetSound(),
AudioParams.Default.WithVolume(-5));
}
Owner.SpawnTimer(OpenTimeOne, async () =>
{
OnPartialOpen();
await Timer.Delay(OpenTimeTwo, _stateChangeCancelTokenSource.Token);
State = DoorState.Open;
RefreshAutoClose();
}, _stateChangeCancelTokenSource.Token);
}
@@ -323,7 +358,7 @@ namespace Content.Server.Doors.Components
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, false));
}
private void QuickOpen()
private void QuickOpen(bool refresh)
{
if (Occludes && Owner.TryGetComponent(out OccluderComponent? occluder))
{
@@ -331,6 +366,8 @@ namespace Content.Server.Doors.Components
}
OnPartialOpen();
State = DoorState.Open;
if(refresh)
RefreshAutoClose();
}
#endregion
@@ -369,17 +406,19 @@ namespace Content.Server.Doors.Components
/// <returns>Boolean describing whether this door can close.</returns>
public bool CanCloseGeneric()
{
if (_doorCheck != null && !_doorCheck.CloseCheck())
{
var ev = new BeforeDoorClosedEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (ev.Cancelled)
return false;
}
return !IsSafetyColliding();
}
private bool SafetyCheck()
{
return (_doorCheck != null && _doorCheck.SafetyCheck()) || _inhibitCrush;
var ev = new DoorSafetyEnabledEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
return ev.Safety || _inhibitCrush;
}
/// <summary>
@@ -415,6 +454,13 @@ namespace Content.Server.Doors.Components
_stateChangeCancelTokenSource?.Cancel();
_stateChangeCancelTokenSource = new();
if (CloseSound != null)
{
SoundSystem.Play(Filter.Pvs(Owner), CloseSound.GetSound(),
AudioParams.Default.WithVolume(-10));
}
Owner.SpawnTimer(CloseTimeOne, async () =>
{
// if somebody walked into the door as it was closing, and we don't crush things
@@ -507,10 +553,10 @@ namespace Content.Server.Doors.Components
public void Deny()
{
if (_doorCheck != null && !_doorCheck.DenyCheck())
{
var ev = new BeforeDoorDeniedEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (ev.Cancelled)
return;
}
if (State == DoorState.Open || IsWeldedShut)
return;
@@ -518,6 +564,25 @@ namespace Content.Server.Doors.Components
_stateChangeCancelTokenSource?.Cancel();
_stateChangeCancelTokenSource = new();
SetAppearance(DoorVisualState.Deny);
if (DenySound != null)
{
if (LastDenySoundTime == TimeSpan.Zero)
{
LastDenySoundTime = _gameTiming.CurTime;
}
else
{
var difference = _gameTiming.CurTime - LastDenySoundTime;
if (difference < TimeSpan.FromMilliseconds(DenySoundMinimumInterval))
return;
}
LastDenySoundTime = _gameTiming.CurTime;
SoundSystem.Play(Filter.Pvs(Owner), DenySound.GetSound(),
AudioParams.Default.WithVolume(-3));
}
Owner.SpawnTimer(DenyTime, () =>
{
SetAppearance(DoorVisualState.Closed);
@@ -525,19 +590,24 @@ namespace Content.Server.Doors.Components
}
/// <summary>
/// Stops the current auto-close timer if there is one. Starts a new one if this is appropriate (i.e. entity has an IDoorCheck component that allows auto-closing).
/// Starts a new auto close timer if this is appropriate
/// (i.e. event raised is not cancelled).
/// </summary>
public void RefreshAutoClose()
{
_autoCloseCancelTokenSource?.Cancel();
if (State != DoorState.Open || _doorCheck == null || !_doorCheck.AutoCloseCheck())
{
if (State != DoorState.Open)
return;
}
var autoev = new BeforeDoorAutoCloseEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, autoev, false);
if (autoev.Cancelled)
return;
_autoCloseCancelTokenSource = new();
var realCloseTime = _doorCheck.GetCloseSpeed() ?? AutoCloseDelay;
var ev = new DoorGetCloseTimeModifierEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
var realCloseTime = AutoCloseDelay * ev.CloseTimeModifier;
Owner.SpawnRepeatingTimer(realCloseTime, async () =>
{
@@ -559,21 +629,18 @@ namespace Content.Server.Doors.Components
// for prying doors
if (tool.HasQuality(ToolQuality.Prying) && !IsWeldedShut)
{
var successfulPry = false;
var ev = new DoorGetPryTimeModifierEvent();
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ev, false);
if (_doorCheck != null)
{
_doorCheck.OnStartPry(eventArgs);
successfulPry = await tool.UseTool(eventArgs.User, Owner,
_doorCheck.GetPryTime() ?? 0.5f, ToolQuality.Prying, () => _doorCheck.CanPryCheck(eventArgs));
}
else
{
successfulPry = await tool.UseTool(eventArgs.User, Owner, 0.5f, ToolQuality.Prying);
}
var canEv = new BeforeDoorPryEvent(eventArgs);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, canEv, false);
var successfulPry = await tool.UseTool(eventArgs.User, Owner,
ev.PryTimeModifier * PryTime, ToolQuality.Prying, () => !canEv.Cancelled);
if (successfulPry && !IsWeldedShut)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new OnDoorPryEvent(eventArgs), false);
if (State == DoorState.Closed)
{
Open();