diff --git a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactCrusherSystem.cs b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactCrusherSystem.cs index 7d6f2785c6..09fdc260d7 100644 --- a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactCrusherSystem.cs +++ b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactCrusherSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Body.Systems; +using Content.Server.Popups; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; using Content.Server.Stack; @@ -23,6 +24,7 @@ public sealed class ArtifactCrusherSystem : SharedArtifactCrusherSystem [Dependency] private readonly BodySystem _body = default!; [Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly StackSystem _stack = default!; + [Dependency] private readonly PopupSystem _popup = default!; /// public override void Initialize() @@ -38,7 +40,8 @@ public sealed class ArtifactCrusherSystem : SharedArtifactCrusherSystem if (!args.CanAccess || !args.CanInteract || args.Hands == null || ent.Comp.Crushing) return; - if (!TryComp(ent, out var entityStorageComp) || entityStorageComp.Contents.ContainedEntities.Count == 0) + if (!TryComp(ent, out var entityStorageComp) || + entityStorageComp.Contents.ContainedEntities.Count == 0) return; if (!this.IsPowered(ent, EntityManager)) @@ -61,11 +64,14 @@ public sealed class ArtifactCrusherSystem : SharedArtifactCrusherSystem public void StartCrushing(Entity ent) { - var (_, crusher, _) = ent; + var (uid, crusher, _) = ent; if (crusher.Crushing) return; + if (crusher.AutoLock) + _popup.PopupEntity(Loc.GetString("artifact-crusher-autolocks-enable"), uid); + crusher.Crushing = true; crusher.NextSecond = _timing.CurTime + TimeSpan.FromSeconds(1); crusher.CrushEndTime = _timing.CurTime + crusher.CrushDuration; diff --git a/Content.Shared/Xenoarchaeology/Equipment/ArtifactCrusherComponent.cs b/Content.Shared/Xenoarchaeology/Equipment/ArtifactCrusherComponent.cs index 687b29f208..e21cedb6f9 100644 --- a/Content.Shared/Xenoarchaeology/Equipment/ArtifactCrusherComponent.cs +++ b/Content.Shared/Xenoarchaeology/Equipment/ArtifactCrusherComponent.cs @@ -101,6 +101,12 @@ public sealed partial class ArtifactCrusherComponent : Component /// [DataField] public (EntityUid, AudioComponent)? CrushingSoundEntity; + + /// + /// When enabled, stops the artifact crusher from being opened when it is being crushed. + /// + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] + public bool AutoLock = false; } [Serializable, NetSerializable] diff --git a/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactCrusherSystem.cs b/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactCrusherSystem.cs index 44e1b91a90..da253ba80a 100644 --- a/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactCrusherSystem.cs +++ b/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactCrusherSystem.cs @@ -1,6 +1,8 @@ +using Content.Shared.Examine; using Content.Shared.Storage.Components; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; +using Content.Shared.Emag.Systems; namespace Content.Shared.Xenoarchaeology.Equipment; @@ -20,6 +22,9 @@ public abstract class SharedArtifactCrusherSystem : EntitySystem SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnStorageAfterOpen); + SubscribeLocalEvent(OnStorageOpenAttempt); + SubscribeLocalEvent(OnExamine); + SubscribeLocalEvent(OnEmagged); } private void OnInit(Entity ent, ref ComponentInit args) @@ -33,6 +38,23 @@ public abstract class SharedArtifactCrusherSystem : EntitySystem ContainerSystem.EmptyContainer(ent.Comp.OutputContainer); } + private void OnEmagged(Entity ent, ref GotEmaggedEvent args) + { + ent.Comp.AutoLock = true; + args.Handled = true; + } + + private void OnStorageOpenAttempt(Entity ent, ref StorageOpenAttemptEvent args) + { + if (ent.Comp.AutoLock && ent.Comp.Crushing) + args.Cancelled = true; + } + + private void OnExamine(Entity ent, ref ExaminedEvent args) + { + args.PushMarkup(ent.Comp.AutoLock ? Loc.GetString("artifact-crusher-examine-autolocks") : Loc.GetString("artifact-crusher-examine-no-autolocks")); + } + public void StopCrushing(Entity ent, bool early = true) { var (_, crusher) = ent; diff --git a/Resources/Locale/en-US/artifacts/artifact-crusher.ftl b/Resources/Locale/en-US/artifacts/artifact-crusher.ftl new file mode 100644 index 0000000000..d9f10f4334 --- /dev/null +++ b/Resources/Locale/en-US/artifacts/artifact-crusher.ftl @@ -0,0 +1,3 @@ +artifact-crusher-examine-no-autolocks = The machine's autolocks are [color=green]disabled[/color]. +artifact-crusher-examine-autolocks = The machine's autolocks are [color=red]enabled[/color]. +artifact-crusher-autolocks-enable = The machine's locks snap shut!