Can emag artifact crusher (#23957)

* initial commit

* made it emaggable

* removed OnAttemptEmagEvent

* moved emagging to shared

* added local file to git
This commit is contained in:
SpeltIncorrectyl
2024-01-19 15:35:02 +00:00
committed by GitHub
parent 884c866e4d
commit fd673cf6e3
4 changed files with 39 additions and 2 deletions

View File

@@ -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!;
/// <inheritdoc/>
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<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))
@@ -61,11 +64,14 @@ public sealed class ArtifactCrusherSystem : SharedArtifactCrusherSystem
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;

View File

@@ -101,6 +101,12 @@ public sealed partial class ArtifactCrusherComponent : Component
/// </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]

View File

@@ -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<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)
@@ -33,6 +38,23 @@ public abstract class SharedArtifactCrusherSystem : EntitySystem
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;

View File

@@ -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!