using Content.Server.Body.Systems;
+using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Stack;
[Dependency] private readonly BodySystem _body = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly StackSystem _stack = default!;
+ [Dependency] private readonly PopupSystem _popup = default!;
/// <inheritdoc/>
public override void Initialize()
if (!args.CanAccess || !args.CanInteract || args.Hands == null || ent.Comp.Crushing)
return;
- if (!TryComp<EntityStorageComponent>(ent, out var entityStorageComp) || entityStorageComp.Contents.ContainedEntities.Count == 0)
+ if (!TryComp<EntityStorageComponent>(ent, out var entityStorageComp) ||
+ entityStorageComp.Contents.ContainedEntities.Count == 0)
return;
if (!this.IsPowered(ent, EntityManager))
public void StartCrushing(Entity<ArtifactCrusherComponent, EntityStorageComponent> 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;
/// </summary>
[DataField]
public (EntityUid, AudioComponent)? CrushingSoundEntity;
+
+ /// <summary>
+ /// When enabled, stops the artifact crusher from being opened when it is being crushed.
+ /// </summary>
+ [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
+ public bool AutoLock = false;
}
[Serializable, NetSerializable]
+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;
SubscribeLocalEvent<ArtifactCrusherComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ArtifactCrusherComponent, StorageAfterOpenEvent>(OnStorageAfterOpen);
+ SubscribeLocalEvent<ArtifactCrusherComponent, StorageOpenAttemptEvent>(OnStorageOpenAttempt);
+ SubscribeLocalEvent<ArtifactCrusherComponent, ExaminedEvent>(OnExamine);
+ SubscribeLocalEvent<ArtifactCrusherComponent, GotEmaggedEvent>(OnEmagged);
}
private void OnInit(Entity<ArtifactCrusherComponent> ent, ref ComponentInit args)
ContainerSystem.EmptyContainer(ent.Comp.OutputContainer);
}
+ private void OnEmagged(Entity<ArtifactCrusherComponent> ent, ref GotEmaggedEvent args)
+ {
+ ent.Comp.AutoLock = true;
+ args.Handled = true;
+ }
+
+ private void OnStorageOpenAttempt(Entity<ArtifactCrusherComponent> ent, ref StorageOpenAttemptEvent args)
+ {
+ if (ent.Comp.AutoLock && ent.Comp.Crushing)
+ args.Cancelled = true;
+ }
+
+ private void OnExamine(Entity<ArtifactCrusherComponent> 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<ArtifactCrusherComponent> ent, bool early = true)
{
var (_, crusher) = ent;
--- /dev/null
+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!