Maybe fix door deconstruct (#6420)
This commit is contained in:
@@ -34,7 +34,7 @@ public sealed class DoorSystem : SharedDoorSystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<DoorComponent, MapInitEvent>(OnMapInit);
|
SubscribeLocalEvent<DoorComponent, MapInitEvent>(OnMapInit);
|
||||||
SubscribeLocalEvent<DoorComponent, InteractUsingEvent>(OnInteractUsing);
|
SubscribeLocalEvent<DoorComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ConstructionSystem) });
|
||||||
|
|
||||||
SubscribeLocalEvent<DoorComponent, PryFinishedEvent>(OnPryFinished);
|
SubscribeLocalEvent<DoorComponent, PryFinishedEvent>(OnPryFinished);
|
||||||
SubscribeLocalEvent<DoorComponent, PryCancelledEvent>(OnPryCancelled);
|
SubscribeLocalEvent<DoorComponent, PryCancelledEvent>(OnPryCancelled);
|
||||||
@@ -109,15 +109,13 @@ public sealed class DoorSystem : SharedDoorSystem
|
|||||||
|
|
||||||
if (tool.Qualities.Contains(door.PryingQuality))
|
if (tool.Qualities.Contains(door.PryingQuality))
|
||||||
{
|
{
|
||||||
TryPryDoor(uid, args.Used, args.User, door);
|
args.Handled = TryPryDoor(uid, args.Used, args.User, door);
|
||||||
args.Handled = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (door.Weldable && tool.Qualities.Contains(door.WeldingQuality))
|
if (door.Weldable && tool.Qualities.Contains(door.WeldingQuality))
|
||||||
{
|
{
|
||||||
TryWeldDoor(uid, args.Used, args.User, door);
|
args.Handled = TryWeldDoor(uid, args.Used, args.User, door);
|
||||||
args.Handled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,40 +123,44 @@ public sealed class DoorSystem : SharedDoorSystem
|
|||||||
/// Attempt to weld a door shut, or unweld it if it is already welded. This does not actually check if the user
|
/// Attempt to weld a door shut, or unweld it if it is already welded. This does not actually check if the user
|
||||||
/// is holding the correct tool.
|
/// is holding the correct tool.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void TryWeldDoor(EntityUid target, EntityUid used, EntityUid user, DoorComponent door)
|
private bool TryWeldDoor(EntityUid target, EntityUid used, EntityUid user, DoorComponent door)
|
||||||
{
|
{
|
||||||
if (!door.Weldable || door.BeingWelded || door.CurrentlyCrushing.Count > 0)
|
if (!door.Weldable || door.BeingWelded || door.CurrentlyCrushing.Count > 0)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// is the door in a weld-able state?
|
// is the door in a weld-able state?
|
||||||
if (door.State != DoorState.Closed && door.State != DoorState.Welded)
|
if (door.State != DoorState.Closed && door.State != DoorState.Welded)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// perform a do-after delay
|
// perform a do-after delay
|
||||||
door.BeingWelded = true;
|
door.BeingWelded = true;
|
||||||
_toolSystem.UseTool(used, user, target, 3f, 3f, door.WeldingQuality,
|
_toolSystem.UseTool(used, user, target, 3f, 3f, door.WeldingQuality,
|
||||||
new WeldFinishedEvent(), new WeldCancelledEvent(), target);
|
new WeldFinishedEvent(), new WeldCancelledEvent(), target);
|
||||||
|
|
||||||
|
return true; // we might not actually succeeded, but a do-after has started
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pry open a door. This does not check if the user is holding the required tool.
|
/// Pry open a door. This does not check if the user is holding the required tool.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void TryPryDoor(EntityUid target, EntityUid tool, EntityUid user, DoorComponent door)
|
private bool TryPryDoor(EntityUid target, EntityUid tool, EntityUid user, DoorComponent door)
|
||||||
{
|
{
|
||||||
if (door.State == DoorState.Welded)
|
if (door.State == DoorState.Welded)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
var canEv = new BeforeDoorPryEvent(user);
|
var canEv = new BeforeDoorPryEvent(user);
|
||||||
RaiseLocalEvent(target, canEv, false);
|
RaiseLocalEvent(target, canEv, false);
|
||||||
|
|
||||||
if (canEv.Cancelled)
|
if (canEv.Cancelled)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
var modEv = new DoorGetPryTimeModifierEvent();
|
var modEv = new DoorGetPryTimeModifierEvent();
|
||||||
RaiseLocalEvent(target, modEv, false);
|
RaiseLocalEvent(target, modEv, false);
|
||||||
|
|
||||||
_toolSystem.UseTool(tool, user, target, 0f, modEv.PryTimeModifier * door.PryTime, door.PryingQuality,
|
_toolSystem.UseTool(tool, user, target, 0f, modEv.PryTimeModifier * door.PryTime, door.PryingQuality,
|
||||||
new PryFinishedEvent(), new PryCancelledEvent(), target);
|
new PryFinishedEvent(), new PryCancelledEvent(), target);
|
||||||
|
|
||||||
|
return true; // we might not actually succeeded, but a do-after has started
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWeldCancelled(EntityUid uid, DoorComponent door, WeldCancelledEvent args)
|
private void OnWeldCancelled(EntityUid uid, DoorComponent door, WeldCancelledEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user