diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index 9cd9976cea9..b49bc55d1be 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Popups; using Robust.Shared.Prototypes; using Robust.Shared.Random; +using Content.Server.Kitchen.EntitySystems; namespace Content.Server.Access.Systems; @@ -18,6 +19,7 @@ public sealed class IdCardSystem : SharedIdCardSystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly MicrowaveSystem _microwave = default!; public override void Initialize() { @@ -27,9 +29,13 @@ public override void Initialize() private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowavedEvent args) { + if (!component.CanMicrowave || !TryComp(args.Microwave, out var micro) || micro.Broken) + return; + if (TryComp(uid, out var access)) { float randomPick = _random.NextFloat(); + // if really unlucky, burn card if (randomPick <= 0.15f) { @@ -46,6 +52,14 @@ private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowa EntityManager.QueueDeleteEntity(uid); return; } + + //Explode if the microwave can't handle it + if (!micro.CanMicrowaveIdsSafely) + { + _microwave.Explode((args.Microwave, micro)); + return; + } + // If they're unlucky, brick their ID if (randomPick <= 0.25f) { @@ -70,6 +84,7 @@ private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowa _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.Microwave)} added {random.ID} access to {ToPrettyString(uid):entity}"); + } } } diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 3be444bea39..8ddc007858a 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -104,6 +104,12 @@ public sealed partial class MicrowaveComponent : Component /// Chance of lightning occurring when we microwave a metallic object [DataField, ViewVariables(VVAccess.ReadWrite)] public float LightningChance = .75f; + + /// + /// If this microwave can give ids accesses without exploding + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public bool CanMicrowaveIdsSafely = true; } public sealed class BeingMicrowavedEvent : HandledEntityEventArgs diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 83560b620c6..6ed0b5f0bc4 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -1,3 +1,4 @@ +using Content.Server.Administration.Logs; using Content.Server.Body.Systems; using Content.Server.Chemistry.Containers.EntitySystems; using Content.Server.Construction; @@ -15,6 +16,7 @@ using Content.Shared.Chemistry.Components.SolutionManager; using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Construction.EntitySystems; +using Content.Shared.Database; using Content.Shared.Destructible; using Content.Shared.FixedPoint; using Content.Shared.Interaction; @@ -35,7 +37,8 @@ using System.Linq; using Robust.Shared.Prototypes; using Robust.Shared.Timing; -using Content.Shared.Access.Components; +using Content.Shared.Stacks; +using Content.Server.Construction.Components; namespace Content.Server.Kitchen.EntitySystems { @@ -59,6 +62,9 @@ public sealed class MicrowaveSystem : EntitySystem [Dependency] private readonly UserInterfaceSystem _userInterface = default!; [Dependency] private readonly HandsSystem _handsSystem = default!; [Dependency] private readonly SharedItemSystem _item = default!; + [Dependency] private readonly SharedStackSystem _stack = default!; + [Dependency] private readonly IPrototypeManager _prototype = default!; + [Dependency] private readonly IAdminLogManager _adminLogger = default!; [ValidatePrototypeId] private const string MalfunctionSpark = "Spark"; @@ -394,6 +400,23 @@ public static bool HasContents(MicrowaveComponent component) return component.Storage.ContainedEntities.Any(); } + /// + /// Explodes the microwave internally, turning it into a broken state, destroying its board, and spitting out its machine parts + /// + /// + public void Explode(Entity ent) + { + ent.Comp.Broken = true; // Make broken so we stop processing stuff + _explosion.TriggerExplosive(ent); + if (TryComp(ent, out var machine)) + { + _container.CleanContainer(machine.BoardContainer); + _container.EmptyContainer(machine.PartContainer); + } + + _adminLogger.Add(LogType.Action, LogImpact.Medium, + $"{ToPrettyString(ent)} exploded from unsafe cooking!"); + } /// /// Handles the attempted cooking of unsafe objects /// @@ -411,7 +434,7 @@ private void RollMalfunction(Entity