EasyPry airlocks for arrivals. Now also prying refactor I guess (#19394)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -249,7 +249,7 @@ public sealed partial class DoorComponent : Component
|
||||
}
|
||||
|
||||
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
return (float) (NextStateChange.Value - curTime).TotalSeconds;
|
||||
return (float)(NextStateChange.Value - curTime).TotalSeconds;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -299,10 +299,10 @@ public sealed partial class DoorComponent : Component
|
||||
public bool ClickOpen = true;
|
||||
|
||||
[DataField("openDrawDepth", customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
|
||||
public int OpenDrawDepth = (int) DrawDepth.DrawDepth.Doors;
|
||||
public int OpenDrawDepth = (int)DrawDepth.DrawDepth.Doors;
|
||||
|
||||
[DataField("closedDrawDepth", customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
|
||||
public int ClosedDrawDepth = (int) DrawDepth.DrawDepth.Doors;
|
||||
public int ClosedDrawDepth = (int)DrawDepth.DrawDepth.Doors;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -62,35 +62,4 @@ namespace Content.Shared.Doors
|
||||
public sealed class BeforeDoorAutoCloseEvent : CancellableEntityEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised to determine how long the door's pry time should be modified by.
|
||||
/// Multiply PryTimeModifier by the desired amount.
|
||||
/// </summary>
|
||||
public sealed class DoorGetPryTimeModifierEvent : EntityEventArgs
|
||||
{
|
||||
public readonly EntityUid User;
|
||||
public float PryTimeModifier = 1.0f;
|
||||
|
||||
public DoorGetPryTimeModifierEvent(EntityUid user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when an attempt to pry open the door is made.
|
||||
/// Cancel to stop the door from being pried open.
|
||||
/// </summary>
|
||||
public sealed class BeforeDoorPryEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public readonly EntityUid User;
|
||||
public readonly EntityUid Tool;
|
||||
|
||||
public BeforeDoorPryEvent(EntityUid user, EntityUid tool)
|
||||
{
|
||||
User = user;
|
||||
Tool = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Prying.Components;
|
||||
|
||||
namespace Content.Shared.Doors.Systems;
|
||||
|
||||
@@ -16,16 +17,16 @@ public abstract class SharedDoorBoltSystem : EntitySystem
|
||||
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
|
||||
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorClosedEvent>(OnBeforeDoorClosed);
|
||||
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorDeniedEvent>(OnBeforeDoorDenied);
|
||||
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorPryEvent>(OnDoorPry);
|
||||
SubscribeLocalEvent<DoorBoltComponent, BeforePryEvent>(OnDoorPry);
|
||||
|
||||
}
|
||||
|
||||
private void OnDoorPry(EntityUid uid, DoorBoltComponent component, BeforeDoorPryEvent args)
|
||||
private void OnDoorPry(EntityUid uid, DoorBoltComponent component, ref BeforePryEvent args)
|
||||
{
|
||||
if (component.BoltsDown)
|
||||
if (component.BoltsDown && !args.Force)
|
||||
{
|
||||
Popup.PopupEntity(Loc.GetString("airlock-component-cannot-pry-is-bolted-message"), uid, args.User);
|
||||
args.Cancel();
|
||||
Popup.PopupClient(Loc.GetString("airlock-component-cannot-pry-is-bolted-message"), uid, args.User);
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.Prying.Components;
|
||||
|
||||
namespace Content.Shared.Doors.Systems;
|
||||
|
||||
@@ -23,14 +24,14 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly IGameTiming GameTiming = default!;
|
||||
[Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] protected readonly TagSystem Tags = default!;
|
||||
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
|
||||
[Dependency] private readonly OccluderSystem _occluder = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
[Dependency] private readonly OccluderSystem _occluder = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// A body must have an intersection percentage larger than this in order to be considered as colliding with a
|
||||
@@ -61,6 +62,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<DoorComponent, StartCollideEvent>(HandleCollide);
|
||||
SubscribeLocalEvent<DoorComponent, PreventCollideEvent>(PreventCollision);
|
||||
SubscribeLocalEvent<DoorComponent, GetPryTimeModifierEvent>(OnPryTimeModifier);
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnComponentInit(EntityUid uid, DoorComponent door, ComponentInit args)
|
||||
@@ -182,6 +185,11 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPryTimeModifier(EntityUid uid, DoorComponent door, ref GetPryTimeModifierEvent args)
|
||||
{
|
||||
args.BaseTime = door.PryTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the door state/visuals and play an access denied sound when a user without access interacts with the
|
||||
/// door.
|
||||
@@ -206,6 +214,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
PlaySound(uid, door.DenySound, AudioParams.Default.WithVolume(-3), user, predicted);
|
||||
}
|
||||
|
||||
|
||||
public bool TryToggleDoor(EntityUid uid, DoorComponent? door = null, EntityUid? user = null, bool predicted = false)
|
||||
{
|
||||
if (!Resolve(uid, ref door))
|
||||
@@ -246,7 +255,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
if (door.State == DoorState.Welded)
|
||||
return false;
|
||||
|
||||
var ev = new BeforeDoorOpenedEvent(){User=user};
|
||||
var ev = new BeforeDoorOpenedEvent() { User = user };
|
||||
RaiseLocalEvent(uid, ev, false);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
@@ -261,6 +270,14 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Immediately start opening a door
|
||||
/// </summary>
|
||||
/// <param name="uid"> The uid of the door</param>
|
||||
/// <param name="door"> The doorcomponent of the door</param>
|
||||
/// <param name="user"> The user (if any) opening the door</param>
|
||||
/// <param name="predicted">Whether the interaction would have been
|
||||
/// predicted. See comments in the PlaySound method on the Server system for details</param>
|
||||
public virtual void StartOpening(EntityUid uid, DoorComponent? door = null, EntityUid? user = null, bool predicted = false)
|
||||
{
|
||||
if (!Resolve(uid, ref door))
|
||||
@@ -309,6 +326,14 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Immediately start closing a door
|
||||
/// </summary>
|
||||
/// <param name="uid"> The uid of the door</param>
|
||||
/// <param name="door"> The doorcomponent of the door</param>
|
||||
/// <param name="user"> The user (if any) opening the door</param>
|
||||
/// <param name="predicted">Whether the interaction would have been
|
||||
/// predicted. See comments in the PlaySound method on the Server system for details</param>
|
||||
public bool CanClose(EntityUid uid, DoorComponent? door = null, EntityUid? user = null, bool quiet = true)
|
||||
{
|
||||
if (!Resolve(uid, ref door))
|
||||
@@ -444,11 +469,11 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
|
||||
//TODO: Make only shutters ignore these objects upon colliding instead of all airlocks
|
||||
// Excludes Glasslayer for windows, GlassAirlockLayer for windoors, TableLayer for tables
|
||||
if (!otherPhysics.CanCollide || otherPhysics.CollisionLayer == (int) CollisionGroup.GlassLayer || otherPhysics.CollisionLayer == (int) CollisionGroup.GlassAirlockLayer || otherPhysics.CollisionLayer == (int) CollisionGroup.TableLayer)
|
||||
if (!otherPhysics.CanCollide || otherPhysics.CollisionLayer == (int)CollisionGroup.GlassLayer || otherPhysics.CollisionLayer == (int)CollisionGroup.GlassAirlockLayer || otherPhysics.CollisionLayer == (int)CollisionGroup.TableLayer)
|
||||
continue;
|
||||
|
||||
//If the colliding entity is a slippable item ignore it by the airlock
|
||||
if (otherPhysics.CollisionLayer == (int) CollisionGroup.SlipLayer && otherPhysics.CollisionMask == (int) CollisionGroup.ItemMask)
|
||||
if (otherPhysics.CollisionLayer == (int)CollisionGroup.SlipLayer && otherPhysics.CollisionMask == (int)CollisionGroup.ItemMask)
|
||||
continue;
|
||||
|
||||
if ((physics.CollisionMask & otherPhysics.CollisionLayer) == 0 && (otherPhysics.CollisionMask & physics.CollisionLayer) == 0)
|
||||
@@ -598,7 +623,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CheckDoorBump(DoorComponent component, PhysicsComponent body) {}
|
||||
protected virtual void CheckDoorBump(DoorComponent component, PhysicsComponent body) { }
|
||||
|
||||
/// <summary>
|
||||
/// Makes a door proceed to the next state (if applicable).
|
||||
@@ -659,9 +684,4 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
#endregion
|
||||
|
||||
protected abstract void PlaySound(EntityUid uid, SoundSpecifier soundSpecifier, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted);
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed partial class DoorPryDoAfterEvent : SimpleDoAfterEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user