* Boom! Emergency access! * Emergency access sound * locale * Updated sounds * bleh * Door electrify base * feat: popups on attempt to activate AI action when wires cut * refactor: use SharedApcPowerReceiverComponent to check if AI can interact with door * refactor: added icon and sound for door overcharge * meta.json should use tabs not spaces * refactor: extracted sounds for airlock overcharge to static field in system * refactor: cleanup, ScarKy0 mentions for resources * refactor: removed unused textures * feat: now notification is displayed when AI attempting to interact with door which have wire cut * StationAiWhitelistComponent is properly gating BUI OnMessageAttempt, SharedPowerReceiverSystem.IsPowered is now used to check if device powered * refactor: use PlayLocal to play electrify sound only for AI player * refactor: SetBoltsDown now uses TrySetBoltDown, checks for power. * bolts now check for power using SharedPowerReceiverSystem * electrify localization and louder electrify sounds * extracted ShowDeviceNotRespondingPopup, reverted airlocks not opening/closing when ai wire was cut * refactor: cleanup * New sprites and fixes * Copyright * even more sprite changes * refactore: cleanup, rename overcharge => electrify --------- Co-authored-by: ScarKy0 <scarky0@onet.eu> Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
89 lines
4.3 KiB
C#
89 lines
4.3 KiB
C#
using Content.Server.Administration.Logs;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Doors.Components;
|
|
using Content.Shared.Access.Components;
|
|
using Content.Server.Doors.Systems;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Remotes.EntitySystems;
|
|
using Content.Shared.Remotes.Components;
|
|
|
|
namespace Content.Shared.Remotes
|
|
{
|
|
public sealed class DoorRemoteSystem : SharedDoorRemoteSystem
|
|
{
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly AirlockSystem _airlock = default!;
|
|
[Dependency] private readonly DoorSystem _doorSystem = default!;
|
|
[Dependency] private readonly ExamineSystemShared _examine = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DoorRemoteComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
|
|
}
|
|
|
|
private void OnBeforeInteract(Entity<DoorRemoteComponent> entity, ref BeforeRangedInteractEvent args)
|
|
{
|
|
bool isAirlock = TryComp<AirlockComponent>(args.Target, out var airlockComp);
|
|
|
|
if (args.Handled
|
|
|| args.Target == null
|
|
|| !TryComp<DoorComponent>(args.Target, out var doorComp) // If it isn't a door we don't use it
|
|
// Only able to control doors if they are within your vision and within your max range.
|
|
// Not affected by mobs or machines anymore.
|
|
|| !_examine.InRangeUnOccluded(args.User, args.Target.Value, SharedInteractionSystem.MaxRaycastRange, null))
|
|
|
|
{
|
|
return;
|
|
}
|
|
|
|
args.Handled = true;
|
|
|
|
if (!this.IsPowered(args.Target.Value, EntityManager))
|
|
{
|
|
Popup.PopupEntity(Loc.GetString("door-remote-no-power"), args.User, args.User);
|
|
return;
|
|
}
|
|
|
|
if (TryComp<AccessReaderComponent>(args.Target, out var accessComponent)
|
|
&& !_doorSystem.HasAccess(args.Target.Value, args.Used, doorComp, accessComponent))
|
|
{
|
|
_doorSystem.Deny(args.Target.Value, doorComp, args.User);
|
|
Popup.PopupEntity(Loc.GetString("door-remote-denied"), args.User, args.User);
|
|
return;
|
|
}
|
|
|
|
switch (entity.Comp.Mode)
|
|
{
|
|
case OperatingMode.OpenClose:
|
|
if (_doorSystem.TryToggleDoor(args.Target.Value, doorComp, args.Used))
|
|
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.User):player} used {ToPrettyString(args.Used)} on {ToPrettyString(args.Target.Value)}: {doorComp.State}");
|
|
break;
|
|
case OperatingMode.ToggleBolts:
|
|
if (TryComp<DoorBoltComponent>(args.Target, out var boltsComp))
|
|
{
|
|
if (!boltsComp.BoltWireCut)
|
|
{
|
|
_doorSystem.SetBoltsDown((args.Target.Value, boltsComp), !boltsComp.BoltsDown, args.Used);
|
|
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.User):player} used {ToPrettyString(args.Used)} on {ToPrettyString(args.Target.Value)} to {(boltsComp.BoltsDown ? "" : "un")}bolt it");
|
|
}
|
|
}
|
|
break;
|
|
case OperatingMode.ToggleEmergencyAccess:
|
|
if (airlockComp != null)
|
|
{
|
|
_airlock.SetEmergencyAccess((args.Target.Value, airlockComp), !airlockComp.EmergencyAccess);
|
|
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
|
$"{ToPrettyString(args.User):player} used {ToPrettyString(args.Used)} on {ToPrettyString(args.Target.Value)} to set emergency access {(airlockComp.EmergencyAccess ? "on" : "off")}");
|
|
}
|
|
break;
|
|
default:
|
|
throw new InvalidOperationException(
|
|
$"{nameof(DoorRemoteComponent)} had invalid mode {entity.Comp.Mode}");
|
|
}
|
|
}
|
|
}
|
|
}
|