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:
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user