Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The DEMAG #824

Merged
merged 23 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Server/Doors/Systems/DoorBoltSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
21 changes: 20 additions & 1 deletion Content.Server/Doors/Systems/DoorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
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;
using Content.Shared.Tools.Systems;
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;

Expand All @@ -33,6 +34,7 @@ public override void Initialize()
SubscribeLocalEvent<DoorComponent, WeldableAttemptEvent>(OnWeldAttempt);
SubscribeLocalEvent<DoorComponent, WeldableChangedEvent>(OnWeldChanged);
SubscribeLocalEvent<DoorComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<DoorComponent, GotUnEmaggedEvent>(OnUnEmagged); // Frontier - Added DEMUG
SubscribeLocalEvent<DoorComponent, PriedEvent>(OnAfterPry);
}

Expand Down Expand Up @@ -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<AirlockComponent>(uid, out var airlockComponent))
{
if (HasComp<EmaggedComponent>(uid))
{
if (TryComp<DoorBoltComponent>(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))
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public override void Initialize()
SubscribeLocalEvent<VendingMachineComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<VendingMachineComponent, BreakageEventArgs>(OnBreak);
SubscribeLocalEvent<VendingMachineComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<VendingMachineComponent, GotUnEmaggedEvent>(OnUnEmagged); // Frontier - Added DEMUG
SubscribeLocalEvent<VendingMachineComponent, DamageChangedEvent>(OnDamage);
SubscribeLocalEvent<VendingMachineComponent, PriceCalculationEvent>(OnVendingPrice);
SubscribeLocalEvent<VendingMachineComponent, EmpPulseEvent>(OnEmpPulse);
Expand Down Expand Up @@ -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 ||
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Access/Systems/AccessReaderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<AccessReaderComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<AccessReaderComponent, GotUnEmaggedEvent>(OnUnEmagged); // Frontier - DEMAG
SubscribeLocalEvent<AccessReaderComponent, LinkAttemptEvent>(OnLinkAttempt);

SubscribeLocalEvent<AccessReaderComponent, ComponentGetState>(OnGetState);
Expand Down Expand Up @@ -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);
}

/// <summary>
/// Searches the source for access tags
/// then compares it with the all targets accesses to see if it is allowed.
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Emag/Components/EmagComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ public sealed partial class EmagComponent : Component
[DataField("emagImmuneTag", customTypeSerializer: typeof(PrototypeIdSerializer<TagPrototype>)), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public string EmagImmuneTag = "EmagImmune";

/// <summary>
/// Frontier - Reverse emags
/// </summary>
[DataField("demag")]
public bool Demag = false;
}
28 changes: 27 additions & 1 deletion Content.Shared/Emag/Systems/EmagSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -86,7 +92,27 @@ public bool DoEmagEffect(EntityUid user, EntityUid target)
EnsureComp<EmaggedComponent>(target);
return emaggedEvent.Handled;
}

/// <summary>
/// Frontier - Does the DEMAG effect on a specified entity
/// </summary>
public bool DoUnEmagEffect(EntityUid user, EntityUid target)
{
// prevent unemagging twice
if (!HasComp<EmaggedComponent>(target))
return false;

var unEmaggedEvent = new GotUnEmaggedEvent(user);
RaiseLocalEvent(target, ref unEmaggedEvent);

if (unEmaggedEvent.Handled)
EntityManager.RemoveComponent<EmaggedComponent>(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
20 changes: 18 additions & 2 deletions Content.Shared/Lock/LockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -39,6 +41,7 @@ public override void Initialize()
SubscribeLocalEvent<LockComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<LockComponent, GetVerbsEvent<AlternativeVerb>>(AddToggleLockVerb);
SubscribeLocalEvent<LockComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<LockComponent, GotUnEmaggedEvent>(OnUnEmagged); // Frontier - Added DEMUG
}

private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
Expand Down Expand Up @@ -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<LockComponent>(uid); //Literally destroys the lock as a tell it was emagged
//RemComp<LockComponent>(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<EmaggedComponent>(uid))
{
_audio.PlayPredicted(component.UnlockSound, uid, null, AudioParams.Default.WithVolume(-5));
_appearanceSystem.SetData(uid, StorageVisuals.Locked, true);
//EnsureComp<LockComponent>(uid); //Literally addes the lock as a tell it was emagged
component.Locked = true;
args.Handled = true;
}
}
}

4 changes: 4 additions & 0 deletions Resources/Prototypes/Catalog/Fills/Lockers/heads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -346,6 +347,7 @@
- id: JetpackSecurityFilled # Frontier
- id: HandheldGPSBasic # Frontier
- id: ClothingShoesBootsMagCombatFilled # Frontier
- id: Demag # Frontier

- type: entity
id: LockerHeadOfSecurityFilled
Expand Down Expand Up @@ -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" ] ]
Expand Down
30 changes: 30 additions & 0 deletions Resources/Prototypes/_NF/Entities/Objects/Tools/emag.yml
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Resources/Textures/_NF/Objects/Tools/demag.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Loading