Fix AI radial on objects without access (#38444)

* init

* review

* Update SharedStationAiSystem.cs

* bolt
This commit is contained in:
ScarKy0
2025-10-13 22:42:21 +02:00
committed by GitHub
parent ee9d1032bb
commit 9a05b1111f
4 changed files with 30 additions and 8 deletions

View File

@@ -4,10 +4,9 @@ using Content.Shared.Electrocution;
namespace Content.Shared.Silicons.StationAi; namespace Content.Shared.Silicons.StationAi;
// Handles airlock radial
public abstract partial class SharedStationAiSystem public abstract partial class SharedStationAiSystem
{ {
// Handles airlock radial
private void InitializeAirlock() private void InitializeAirlock()
{ {
SubscribeLocalEvent<DoorBoltComponent, StationAiBoltEvent>(OnAirlockBolt); SubscribeLocalEvent<DoorBoltComponent, StationAiBoltEvent>(OnAirlockBolt);
@@ -20,12 +19,18 @@ public abstract partial class SharedStationAiSystem
/// </summary> /// </summary>
private void OnAirlockBolt(EntityUid ent, DoorBoltComponent component, StationAiBoltEvent args) private void OnAirlockBolt(EntityUid ent, DoorBoltComponent component, StationAiBoltEvent args)
{ {
if (component.BoltWireCut) if (component.BoltWireCut || !PowerReceiver.IsPowered(ent))
{ {
ShowDeviceNotRespondingPopup(args.User); ShowDeviceNotRespondingPopup(args.User);
return; return;
} }
if (!_access.IsAllowed(args.User, ent))
{
ShowDeviceNoAccessPopup(args.User);
return;
}
var setResult = _doors.TrySetBoltDown((ent, component), args.Bolted, args.User, predicted: true); var setResult = _doors.TrySetBoltDown((ent, component), args.Bolted, args.User, predicted: true);
if (!setResult) if (!setResult)
{ {
@@ -44,6 +49,12 @@ public abstract partial class SharedStationAiSystem
return; return;
} }
if (!_access.IsAllowed(args.User, ent))
{
ShowDeviceNoAccessPopup(args.User);
return;
}
_airlocks.SetEmergencyAccess((ent, component), args.EmergencyAccess, args.User, predicted: true); _airlocks.SetEmergencyAccess((ent, component), args.EmergencyAccess, args.User, predicted: true);
} }
@@ -52,15 +63,18 @@ public abstract partial class SharedStationAiSystem
/// </summary> /// </summary>
private void OnElectrified(EntityUid ent, ElectrifiedComponent component, StationAiElectrifiedEvent args) private void OnElectrified(EntityUid ent, ElectrifiedComponent component, StationAiElectrifiedEvent args)
{ {
if ( if (component.IsWireCut || !PowerReceiver.IsPowered(ent))
component.IsWireCut
|| !PowerReceiver.IsPowered(ent)
)
{ {
ShowDeviceNotRespondingPopup(args.User); ShowDeviceNotRespondingPopup(args.User);
return; return;
} }
if (!_access.IsAllowed(args.User, ent))
{
ShowDeviceNoAccessPopup(args.User);
return;
}
_electrify.SetElectrified((ent, component), args.Electrified); _electrify.SetElectrified((ent, component), args.Electrified);
var soundToPlay = component.Enabled var soundToPlay = component.Enabled
? component.AirlockElectrifyDisabled ? component.AirlockElectrifyDisabled

View File

@@ -206,6 +206,11 @@ public abstract partial class SharedStationAiSystem
{ {
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), toEntity, PopupType.MediumCaution); _popup.PopupClient(Loc.GetString("ai-device-not-responding"), toEntity, PopupType.MediumCaution);
} }
private void ShowDeviceNoAccessPopup(EntityUid toEntity)
{
_popup.PopupClient(Loc.GetString("ai-device-no-access"), toEntity, PopupType.MediumCaution);
}
} }
/// <summary> /// <summary>

View File

@@ -1,3 +1,4 @@
using Content.Shared.Access.Systems;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Administration.Managers; using Content.Shared.Administration.Managers;
@@ -42,6 +43,7 @@ public abstract partial class SharedStationAiSystem : EntitySystem
[Dependency] private readonly INetManager _net = default!; [Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly ItemSlotsSystem _slots = default!; [Dependency] private readonly ItemSlotsSystem _slots = default!;
[Dependency] private readonly ItemToggleSystem _toggles = default!; [Dependency] private readonly ItemToggleSystem _toggles = default!;
[Dependency] private readonly AccessReaderSystem _access = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly MetaDataSystem _metadata = default!; [Dependency] private readonly MetaDataSystem _metadata = default!;
[Dependency] private readonly SharedAirlockSystem _airlocks = default!; [Dependency] private readonly SharedAirlockSystem _airlocks = default!;

View File

@@ -25,6 +25,7 @@ electrify-door-off = Disable overcharge
toggle-light = Toggle light toggle-light = Toggle light
ai-device-not-responding = Device is not responding ai-device-not-responding = Device is not responding
ai-device-no-access = You have no access to this device
ai-consciousness-download-warning = Your consciousness is being downloaded. ai-consciousness-download-warning = Your consciousness is being downloaded.
@@ -48,4 +49,4 @@ station-ai-hologram-female = Female appearance
station-ai-hologram-male = Male appearance station-ai-hologram-male = Male appearance
station-ai-hologram-face = Disembodied head station-ai-hologram-face = Disembodied head
station-ai-hologram-cat = Cat form station-ai-hologram-cat = Cat form
station-ai-hologram-dog = Corgi form station-ai-hologram-dog = Corgi form