private void OnBeforePry(EntityUid uid, AirlockComponent component, ref BeforePryEvent args)
{
- if (this.IsPowered(uid, EntityManager) && !args.PryPowered)
- {
- Popup.PopupEntity(Loc.GetString("airlock-component-cannot-pry-is-powered-message"), uid, args.User);
- args.Cancelled = true;
- }
+ if (args.Cancelled)
+ return;
+
+ if (!this.IsPowered(uid, EntityManager) || args.PryPowered)
+ return;
+
+ args.Message = "airlock-component-cannot-pry-is-powered-message";
+
+ args.Cancelled = true;
+
}
public bool CanChangeState(EntityUid uid, AirlockComponent component)
private void OnDoorPry(EntityUid uid, DoorBoltComponent component, ref BeforePryEvent args)
{
- if (component.BoltsDown && !args.Force)
- {
- Popup.PopupEntity(Loc.GetString("airlock-component-cannot-pry-is-bolted-message"), uid, args.User);
- args.Cancelled = true;
- }
+ if (args.Cancelled)
+ return;
+
+ if (!component.BoltsDown || args.Force)
+ return;
+
+ args.Message = "airlock-component-cannot-pry-is-bolted-message";
+
+ args.Cancelled = true;
}
private void OnBeforeDoorOpened(EntityUid uid, DoorBoltComponent component, BeforeDoorOpenedEvent args)
using Content.Shared.Doors.Components;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Interaction;
+using Content.Shared.Popups;
using PryUnpoweredComponent = Content.Shared.Prying.Components.PryUnpoweredComponent;
namespace Content.Shared.Prying.Systems;
[Dependency] private readonly ISharedAdminLogManager _adminLog = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
+ [Dependency] private readonly SharedPopupSystem Popup = default!;
public override void Initialize()
{
if (!comp.Enabled)
return false;
- if (!CanPry(target, user, comp))
+ if (!CanPry(target, user, out var message, comp))
{
+ if (message != null)
+ Popup.PopupEntity(Loc.GetString(message), target, user);
// If we have reached this point we want the event that caused this
- // to be marked as handled as a popup would be generated on failure.
+ // to be marked as handled.
return true;
}
{
id = null;
- if (!CanPry(target, user))
+ // We don't care about displaying a message if no tool was used.
+ if (!CanPry(target, user, out _))
// If we have reached this point we want the event that caused this
- // to be marked as handled as a popup would be generated on failure.
+ // to be marked as handled.
return true;
return StartPry(target, user, null, 0.1f, out id); // hand-prying is much slower
}
- private bool CanPry(EntityUid target, EntityUid user, PryingComponent? comp = null)
+ private bool CanPry(EntityUid target, EntityUid user, out string? message, PryingComponent? comp = null)
{
BeforePryEvent canev;
else
{
if (!TryComp<PryUnpoweredComponent>(target, out _))
+ {
+ message = null;
return false;
+ }
+
canev = new BeforePryEvent(user, false, false);
}
RaiseLocalEvent(target, ref canev);
- if (canev.Cancelled)
- return false;
- return true;
+ message = canev.Message;
+
+ return !canev.Cancelled;
}
private bool StartPry(EntityUid target, EntityUid user, EntityUid? tool, float toolModifier, [NotNullWhen(true)] out DoAfterId? id)