diff --git a/Content.Server/Doors/Systems/DoorBoltSystem.cs b/Content.Server/Doors/Systems/DoorBoltSystem.cs index 133af0013d3..52ca58ff329 100644 --- a/Content.Server/Doors/Systems/DoorBoltSystem.cs +++ b/Content.Server/Doors/Systems/DoorBoltSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Power.Components; +using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; using Content.Shared.Doors; using Content.Shared.Doors.Components; diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index 560149f2289..bcfded45f16 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -6,7 +6,7 @@ using Content.Shared.Database; using Content.Shared.Doors.Components; using Content.Shared.Doors.Systems; -using Content.Shared.Emag.Systems; +using Content.Shared.Emag.Components; using Content.Shared.Interaction; using Content.Shared.Prying.Components; using Content.Shared.Prying.Systems; @@ -14,6 +14,7 @@ using Robust.Shared.Audio; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Events; +using Content.Shared.Emag.Systems; // Frontier - Added DEMUG namespace Content.Server.Doors.Systems; @@ -33,6 +34,7 @@ public override void Initialize() SubscribeLocalEvent(OnWeldAttempt); SubscribeLocalEvent(OnWeldChanged); SubscribeLocalEvent(OnEmagged); + SubscribeLocalEvent(OnUnEmagged); // Frontier - Added DEMUG SubscribeLocalEvent(OnAfterPry); } @@ -168,6 +170,23 @@ private void OnEmagged(EntityUid uid, DoorComponent door, ref GotEmaggedEvent ar } } + private void OnUnEmagged(EntityUid uid, DoorComponent door, ref GotUnEmaggedEvent args) // Frontier - Added DEMUG + { + if (TryComp(uid, out var airlockComponent)) + { + if (HasComp(uid)) + { + if (TryComp(uid, out var doorBoltComponent)) + { + _bolts.SetBoltsDown(uid, doorBoltComponent, !doorBoltComponent.BoltsDown); + SetState(uid, DoorState.Closing, door); + } + PlaySound(uid, door.SparkSound, AudioParams.Default.WithVolume(8), args.UserUid, false); + args.Handled = true; + } + } + } + public override void StartOpening(EntityUid uid, DoorComponent? door = null, EntityUid? user = null, bool predicted = false) { if (!Resolve(uid, ref door)) diff --git a/Content.Server/VendingMachines/VendingMachineSystem.cs b/Content.Server/VendingMachines/VendingMachineSystem.cs index aae71468ccc..c83d0a4cf29 100644 --- a/Content.Server/VendingMachines/VendingMachineSystem.cs +++ b/Content.Server/VendingMachines/VendingMachineSystem.cs @@ -67,6 +67,7 @@ public override void Initialize() SubscribeLocalEvent(OnPowerChanged); SubscribeLocalEvent(OnBreak); SubscribeLocalEvent(OnEmagged); + SubscribeLocalEvent(OnUnEmagged); // Frontier - Added DEMUG SubscribeLocalEvent(OnDamage); SubscribeLocalEvent(OnVendingPrice); SubscribeLocalEvent(OnEmpPulse); @@ -205,6 +206,12 @@ private void OnEmagged(EntityUid uid, VendingMachineComponent component, ref Got args.Handled = component.EmaggedInventory.Count > 0; } + private void OnUnEmagged(EntityUid uid, VendingMachineComponent component, ref GotUnEmaggedEvent args) // Frontier - Added DEMUG + { + // only unemag if there are emag-only items + args.Handled = component.EmaggedInventory.Count > 0; + } + private void OnDamage(EntityUid uid, VendingMachineComponent component, DamageChangedEvent args) { if (component.Broken || component.DispenseOnHitCoolingDown || diff --git a/Content.Shared/Access/Systems/AccessReaderSystem.cs b/Content.Shared/Access/Systems/AccessReaderSystem.cs index cfe70695c9a..0860a7cb13d 100644 --- a/Content.Shared/Access/Systems/AccessReaderSystem.cs +++ b/Content.Shared/Access/Systems/AccessReaderSystem.cs @@ -34,6 +34,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnEmagged); + SubscribeLocalEvent(OnUnEmagged); // Frontier - DEMAG SubscribeLocalEvent(OnLinkAttempt); SubscribeLocalEvent(OnGetState); @@ -86,6 +87,13 @@ private void OnEmagged(EntityUid uid, AccessReaderComponent reader, ref GotEmagg Dirty(uid, reader); } + private void OnUnEmagged(EntityUid uid, AccessReaderComponent reader, ref GotUnEmaggedEvent args) // Frontier - DEMAG + { + args.Handled = true; + reader.Enabled = true; + Dirty(uid, reader); + } + /// /// Searches the source for access tags /// then compares it with the all targets accesses to see if it is allowed. diff --git a/Content.Shared/Emag/Components/EmagComponent.cs b/Content.Shared/Emag/Components/EmagComponent.cs index 235cf0c7444..36b6b5fe487 100644 --- a/Content.Shared/Emag/Components/EmagComponent.cs +++ b/Content.Shared/Emag/Components/EmagComponent.cs @@ -17,4 +17,10 @@ public sealed partial class EmagComponent : Component [DataField("emagImmuneTag", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public string EmagImmuneTag = "EmagImmune"; + + /// + /// Frontier - Reverse emags + /// + [DataField("demag")] + public bool Demag = false; } diff --git a/Content.Shared/Emag/Systems/EmagSystem.cs b/Content.Shared/Emag/Systems/EmagSystem.cs index ebbd4c02ac6..2a520c888e8 100644 --- a/Content.Shared/Emag/Systems/EmagSystem.cs +++ b/Content.Shared/Emag/Systems/EmagSystem.cs @@ -56,7 +56,13 @@ public bool TryUseEmag(EntityUid uid, EntityUid user, EntityUid target, EmagComp return false; } - var handled = DoEmagEffect(user, target); + bool handled; + + if (comp.Demag) + handled = DoUnEmagEffect(user, target); + else + handled = DoEmagEffect(user, target); + if (!handled) return false; @@ -86,7 +92,27 @@ public bool DoEmagEffect(EntityUid user, EntityUid target) EnsureComp(target); return emaggedEvent.Handled; } + + /// + /// Frontier - Does the DEMAG effect on a specified entity + /// + public bool DoUnEmagEffect(EntityUid user, EntityUid target) + { + // prevent unemagging twice + if (!HasComp(target)) + return false; + + var unEmaggedEvent = new GotUnEmaggedEvent(user); + RaiseLocalEvent(target, ref unEmaggedEvent); + + if (unEmaggedEvent.Handled) + EntityManager.RemoveComponent(target); + return unEmaggedEvent.Handled; + } } [ByRefEvent] public record struct GotEmaggedEvent(EntityUid UserUid, bool Handled = false, bool Repeatable = false); + +[ByRefEvent] +public record struct GotUnEmaggedEvent(EntityUid UserUid, bool Handled = false, bool Repeatable = false); // Frontier diff --git a/Content.Shared/Lock/LockSystem.cs b/Content.Shared/Lock/LockSystem.cs index bf18537c80e..9b7ea488f1a 100644 --- a/Content.Shared/Lock/LockSystem.cs +++ b/Content.Shared/Lock/LockSystem.cs @@ -14,6 +14,8 @@ using Robust.Shared.Audio.Systems; using Robust.Shared.Utility; using Content.Shared._NF.Trade.Components; +using Content.Shared.Emag.Components; +using System.Text; // Frontier - DEMAG namespace Content.Shared.Lock; @@ -39,6 +41,7 @@ public override void Initialize() SubscribeLocalEvent(OnExamined); SubscribeLocalEvent>(AddToggleLockVerb); SubscribeLocalEvent(OnEmagged); + SubscribeLocalEvent(OnUnEmagged); // Frontier - Added DEMUG } private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args) @@ -213,15 +216,28 @@ private void AddToggleLockVerb(EntityUid uid, LockComponent component, GetVerbsE private void OnEmagged(EntityUid uid, LockComponent component, ref GotEmaggedEvent args) { - if (component.ImmuneToEmag) + if (component.ImmuneToEmag) // Frontier return; if (!component.Locked || !component.BreakOnEmag) return; _audio.PlayPredicted(component.UnlockSound, uid, null); _appearanceSystem.SetData(uid, StorageVisuals.Locked, false); - RemComp(uid); //Literally destroys the lock as a tell it was emagged + //RemComp(uid); //Literally destroys the lock as a tell it was emagged // Frontier - Has to remove this to allow fixing locks + component.Locked = false; // Disable lock args.Handled = true; } + + private void OnUnEmagged(EntityUid uid, LockComponent component, ref GotUnEmaggedEvent args) // Frontier - DEMAG + { + if (HasComp(uid)) + { + _audio.PlayPredicted(component.UnlockSound, uid, null, AudioParams.Default.WithVolume(-5)); + _appearanceSystem.SetData(uid, StorageVisuals.Locked, true); + //EnsureComp(uid); //Literally addes the lock as a tell it was emagged + component.Locked = true; + args.Handled = true; + } + } } diff --git a/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml b/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml index 3687e9e38e0..582c27a658e 100644 --- a/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml +++ b/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml @@ -142,6 +142,7 @@ # - id: ClothingHandsGlovesCaptain #TODO replace with new item! # - id: ClothingOuterHardsuitCap #TODO replace with new item! # - id: ClothingMaskGasCaptain #TODO replace with new item! + - id: Demag # Frontier - type: entity id: LockerChiefEngineerFilledHardsuit @@ -346,6 +347,7 @@ - id: JetpackSecurityFilled # Frontier - id: HandheldGPSBasic # Frontier - id: ClothingShoesBootsMagCombatFilled # Frontier + - id: Demag # Frontier - type: entity id: LockerHeadOfSecurityFilled @@ -378,12 +380,14 @@ # - id: BookSecretDocuments # Frontier - id: ClothingNeckMantleHOS # Frontier - id: ClothingOuterWinterHoS # Frontier + - id: Demag # Frontier - id: ClothingShoesBootsWinterHoS # Frontier - type: entity id: LockerFreezerVaultFilled suffix: Vault, Locked parent: LockerFreezerBase + noSpawn: true components: - type: AccessReader access: [ [ "Command" ] ] diff --git a/Resources/Prototypes/_NF/Entities/Objects/Tools/emag.yml b/Resources/Prototypes/_NF/Entities/Objects/Tools/emag.yml new file mode 100644 index 00000000000..3ab2e8efc67 --- /dev/null +++ b/Resources/Prototypes/_NF/Entities/Objects/Tools/emag.yml @@ -0,0 +1,30 @@ +- type: entity + parent: BaseItem + id: Demag + name: cryptographic resequencer + description: The all-in-one unhacking solution. The thinking man's lock. The iconic DEMAG fixer. + components: + - type: Emag + demag: true + - type: LimitedCharges + - type: AutoRecharge + - type: Sprite + sprite: _NF/Objects/Tools/demag.rsi + state: icon + - type: Item + sprite: _NF/Objects/Tools/demag.rsi + +- type: entity + parent: BaseItem + id: DemagUnlimited + suffix: Unlimited + name: cryptographic resequencer + description: The all-in-one unhacking solution. The thinking man's lock. The iconic DEMAG fixer. + components: + - type: Emag + demag: true + - type: Sprite + sprite: _NF/Objects/Tools/demag.rsi + state: icon + - type: Item + sprite: _NF/Objects/Tools/demag.rsi diff --git a/Resources/Textures/_NF/Objects/Tools/demag.rsi/icon.png b/Resources/Textures/_NF/Objects/Tools/demag.rsi/icon.png new file mode 100644 index 00000000000..6b28723f3c6 Binary files /dev/null and b/Resources/Textures/_NF/Objects/Tools/demag.rsi/icon.png differ diff --git a/Resources/Textures/_NF/Objects/Tools/demag.rsi/inhand-left.png b/Resources/Textures/_NF/Objects/Tools/demag.rsi/inhand-left.png new file mode 100644 index 00000000000..182dd00a01c Binary files /dev/null and b/Resources/Textures/_NF/Objects/Tools/demag.rsi/inhand-left.png differ diff --git a/Resources/Textures/_NF/Objects/Tools/demag.rsi/inhand-right.png b/Resources/Textures/_NF/Objects/Tools/demag.rsi/inhand-right.png new file mode 100644 index 00000000000..90afbc61284 Binary files /dev/null and b/Resources/Textures/_NF/Objects/Tools/demag.rsi/inhand-right.png differ diff --git a/Resources/Textures/_NF/Objects/Tools/demag.rsi/meta.json b/Resources/Textures/_NF/Objects/Tools/demag.rsi/meta.json new file mode 100644 index 00000000000..add0c3d0f1e --- /dev/null +++ b/Resources/Textures/_NF/Objects/Tools/demag.rsi/meta.json @@ -0,0 +1,22 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from tgstation wiki at https://tgstation13.org/wiki/File:Emag.png, edited by gentlebutter", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + }, + { + "name": "icon" + } + ] +}