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

UPD DNA/ID locker #534

Merged
merged 3 commits into from
Oct 28, 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
30 changes: 30 additions & 0 deletions Content.Server/_Cats/DNALocker/Components/DNALockerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Robust.Shared.Audio;

namespace Content.Server.DNALocker;

[RegisterComponent]
public sealed partial class DNALockerComponent : Component
{
[DataField]
public string DNA = string.Empty;

public bool IsLocked => DNA != string.Empty;

[DataField]
public bool IsEquipped = false;

[DataField]
public bool CanBeEmagged = true;

[DataField("lockSound")]
public SoundSpecifier LockSound = new SoundPathSpecifier("/Audio/_Cats/dna-lock.ogg");

[DataField("emagSound")]
public SoundSpecifier EmagSound = new SoundCollectionSpecifier("sparks");

[DataField("lockerExplodeSound")]
public SoundSpecifier LockerExplodeSound = new SoundPathSpecifier("/Audio/Effects/Grenades/SelfDestruct/SDS_Charge.ogg");

[DataField("deniedSound")]
public SoundSpecifier DeniedSound = new SoundPathSpecifier("/Audio/Effects/Cargo/buzz_sigh.ogg");
}
16 changes: 0 additions & 16 deletions Content.Server/_Cats/DNALocker/DNALockComponent.cs

This file was deleted.

62 changes: 0 additions & 62 deletions Content.Server/_Cats/DNALocker/DNALockerSystem.cs

This file was deleted.

130 changes: 130 additions & 0 deletions Content.Server/_Cats/DNALocker/Systems/DNALockerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using Content.Server.Forensics;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Server.Explosion.EntitySystems;
using Robust.Shared.Audio.Systems;
using Content.Shared.Popups;
using Content.Shared.Emag.Systems;
using Robust.Shared.Timing;
using Content.Shared.Interaction.Components;
using Content.Shared.Verbs;
using Robust.Shared.Utility;

namespace Content.Server.DNALocker;

public sealed partial class DNALockerSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly ExplosionSystem _explosion = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DNALockerComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerb);
SubscribeLocalEvent<DNALockerComponent, GotEquippedEvent>(OnEquip);
SubscribeLocalEvent<DNALockerComponent, GotEmaggedEvent>(OnGotEmagged);
}

public void LockEntity(EntityUid uid, DNALockerComponent component, EntityUid equipee)
{
if (!TryComp<DnaComponent>(equipee, out var dna))
{
ExplodeEntity(uid, component, equipee);
return;
}

component.DNA = dna.DNA;
_audioSystem.PlayPvs(component.LockSound, uid);
var selfMessage = Loc.GetString("dna-locker-success");
_popup.PopupEntity(selfMessage, equipee, equipee);
}

public void ExplodeEntity(EntityUid uid, DNALockerComponent component, EntityUid equipee)
{
if (!component.IsLocked)
return;

EnsureComp<UnremoveableComponent>(uid);
var selfMessage = Loc.GetString("dna-locker-failure");
var unremoveableMessage = Loc.GetString("dna-locker-unremoveable");

_popup.PopupEntity(unremoveableMessage, equipee, equipee, PopupType.LargeCaution);
_audioSystem.PlayPvs(component.LockerExplodeSound, uid);
Timer.Spawn(3000, () =>
{
_popup.PopupEntity(selfMessage, equipee, equipee, PopupType.LargeCaution);
_explosion.QueueExplosion(equipee, "Default", 200f, 10f, 100f, 1f);
QueueDel(uid);
});
}

private void OnEquip(EntityUid uid, DNALockerComponent component, GotEquippedEvent args)
{
Log.Debug($"{args.Slot}");
if (!component.IsLocked)
{
LockEntity(uid, component, args.Equipee);
return;
}

if (TryComp<DnaComponent>(args.Equipee, out var dna))
{
if (component.DNA != null && component.DNA != dna.DNA)
{
ExplodeEntity(uid, component, args.Equipee);
}
}
}

private void OnGotEmagged(EntityUid uid, DNALockerComponent component, ref GotEmaggedEvent args)
{
if (!component.CanBeEmagged)
return;

component.DNA = string.Empty;
_audioSystem.PlayPvs(component.EmagSound, uid);
var userUid = args.UserUid;
Timer.Spawn(1500, () =>
{
_audioSystem.PlayPvs(component.LockSound, uid);
var selfMessage = Loc.GetString("dna-locker-unlock");
_popup.PopupEntity(selfMessage, uid, userUid);
});
args.Repeatable = true;
args.Handled = true;
}

private void OnAltVerb(EntityUid uid, DNALockerComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!component.IsLocked)
return;

AlternativeVerb verbDNALock = new()
{
Act = () => MakeUnlocked(uid, component, args.User),
Text = Loc.GetString("dna-locker-verb-name"),
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/fold.svg.192dpi.png")),
};
args.Verbs.Add(verbDNALock);
}

private void MakeUnlocked(EntityUid uid, DNALockerComponent component, EntityUid userUid)
{
if (TryComp<DnaComponent>(userUid, out var userDNAComponent) && component.DNA == userDNAComponent.DNA)
{
var unlocked = Loc.GetString("dna-locker-unlock");
_audioSystem.PlayPvs(component.LockSound, userUid);
_popup.PopupEntity(unlocked, uid, userUid);
component.DNA = string.Empty;
}
else
{
var denied = Loc.GetString("dna-locker-failure");
_audioSystem.PlayPvs(component.DeniedSound, userUid);
_popup.PopupEntity(denied, uid, userUid);
}
}
}
6 changes: 6 additions & 0 deletions Resources/Locale/ru-RU/_Cats/actions/syndicate.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dna-locker-success = Ваш ДНК установлен в качестве основного для данного скафандра.
dna-locker-failure = Ваш ДНК не совпал с требуемым!
dna-locker-unlock = Требуемые ДНК были сброшены.
dna-locker-unremoveable = Замок заблокирован. Скафандр впивается в вашу кожу и сжимает вас.
dna-locker-equipped = Замок издает странный звук и искры, но ничего не происходит. Кажется нужно снять скафандр.
dna-locker-verb-name = Разблокировать замок
4 changes: 0 additions & 4 deletions Resources/Locale/ru-RU/_Cats/syndicate.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
dna-locker-success = Ваш ДНК установлен в качестве основного для данного скафандра.
dna-locker-explode = Ваш ДНК не совпал с требуемым!
dna-locker-unlock = Требуемые ДНК были сброшены.

swarmer-round-end-agent-name = S.W.A.R.M.E.R
19 changes: 14 additions & 5 deletions Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
- MonkeyWearable
- Hardsuit
- WhitelistChameleon
- type: DNALocker
- type: DNALocker # Cats edit

# Syndicate Medic Hardsuit
- type: entity
Expand All @@ -547,7 +547,7 @@
tags:
- Hardsuit
- WhitelistChameleon
- type: DNALocker
- type: DNALocker # Cats edit

#Syndicate Elite Hardsuit
- type: entity
Expand Down Expand Up @@ -582,10 +582,10 @@
Stun: 0.2
- type: Item
size: Huge
- type: DNALocker
- type: ClothingSpeedModifier
walkModifier: 1.0
sprintModifier: 1.0 #backmen-speedoznik
- type: DNALocker # Cats edit
- type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndieElite
Expand Down Expand Up @@ -622,7 +622,8 @@
- type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndieCommander
- type: DNALocker
- type: DNALocker # Cats edit


#Cybersun Juggernaut Hardsuit
- type: entity
Expand Down Expand Up @@ -656,7 +657,7 @@
- type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitCybersun
- type: DNALocker
- type: DNALocker # Cats edit

#Wizard Hardsuit
- type: entity
Expand Down Expand Up @@ -803,6 +804,7 @@
sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertleader.rsi
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitERTLeader
- type: DNALocker # Cats edit

#ERT Chaplain Hardsuit
- type: entity
Expand All @@ -817,6 +819,7 @@
sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertchaplain.rsi
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitERTChaplain
- type: DNALocker # Cats edit

#ERT Engineer Hardsuit
- type: entity
Expand All @@ -832,6 +835,7 @@
sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertengineer.rsi
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitERTEngineer
- type: DNALocker # Cats edit

#ERT Medic Hardsuit
- type: entity
Expand All @@ -846,6 +850,7 @@
sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertmedical.rsi
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitERTMedical
- type: DNALocker # Cats edit

#ERT Security Hardsuit
- type: entity
Expand All @@ -860,6 +865,7 @@
sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertsecurity.rsi
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitERTSecurity
- type: DNALocker # Cats edit

#ERT Janitor Hardsuit
- type: entity
Expand All @@ -874,6 +880,7 @@
sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertjanitor.rsi
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitERTJanitor
- type: DNALocker # Cats edit

#Deathsquad
- type: entity
Expand Down Expand Up @@ -912,6 +919,7 @@
- type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitDeathsquad
- type: DNALocker # Cats edit

#CBURN Hardsuit
- type: entity
Expand Down Expand Up @@ -950,6 +958,7 @@
- type: HeldSpeedModifier
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetCBURN
- type: DNALocker # Cats edit

#MISC. HARDSUITS
#Clown Hardsuit
Expand Down
Loading