diff --git a/Content.Server/_Cats/DNALocker/Components/DNALockerComponent.cs b/Content.Server/_Cats/DNALocker/Components/DNALockerComponent.cs new file mode 100644 index 00000000000..c01e9fbde53 --- /dev/null +++ b/Content.Server/_Cats/DNALocker/Components/DNALockerComponent.cs @@ -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"); +} \ No newline at end of file diff --git a/Content.Server/_Cats/DNALocker/DNALockComponent.cs b/Content.Server/_Cats/DNALocker/DNALockComponent.cs deleted file mode 100644 index ecc36dd9023..00000000000 --- a/Content.Server/_Cats/DNALocker/DNALockComponent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Robust.Shared.Audio; - -namespace Content.Server.DNALocker; - -[RegisterComponent] -public sealed partial class DNALockerComponent : Component -{ - [DataField] - public string? DNA; - - [DataField] - public bool Locked = false; - - [DataField("lockSound")] - public SoundSpecifier LockSound = new SoundPathSpecifier("/Audio/_Cats/dna-lock.ogg"); -} diff --git a/Content.Server/_Cats/DNALocker/DNALockerSystem.cs b/Content.Server/_Cats/DNALocker/DNALockerSystem.cs deleted file mode 100644 index 958e452d841..00000000000 --- a/Content.Server/_Cats/DNALocker/DNALockerSystem.cs +++ /dev/null @@ -1,62 +0,0 @@ -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; - -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(OnEquip); - SubscribeLocalEvent(OnGotEmagged); - } - - private void OnEquip(EntityUid uid, DNALockerComponent component, GotEquippedEvent args) - { - if (component.Locked == false) - { - var dna = EnsureComp(args.Equipee); - component.DNA = dna.DNA; - component.Locked = true; - _audioSystem.PlayPvs(component.LockSound, uid); - var selfMessage = Loc.GetString("dna-locker-success"); - _popup.PopupEntity(selfMessage, args.Equipee, args.Equipee); - } - - if (component.Locked == true) - { - var dna = EnsureComp(args.Equipee); - - if (component.DNA != null && component.DNA != dna.DNA) - { - var selfMessage = Loc.GetString("dna-locker-explode"); - _popup.PopupEntity(selfMessage, args.Equipee, args.Equipee, PopupType.LargeCaution); - _explosion.QueueExplosion(args.Equipee, "Default", 200f, 10f, 100f, 1f); - QueueDel(uid); - } - } - } - - private void OnGotEmagged(EntityUid uid, DNALockerComponent component, ref GotEmaggedEvent args) - { - component.Locked = false; - _audioSystem.PlayPvs(component.LockSound, uid); - var selfMessage = Loc.GetString("dna-locker-unlock"); - _popup.PopupEntity(selfMessage, uid, args.UserUid); - - args.Repeatable = true; - args.Handled = true; - } -} diff --git a/Content.Server/_Cats/DNALocker/Systems/DNALockerSystem.cs b/Content.Server/_Cats/DNALocker/Systems/DNALockerSystem.cs new file mode 100644 index 00000000000..8d5f0412431 --- /dev/null +++ b/Content.Server/_Cats/DNALocker/Systems/DNALockerSystem.cs @@ -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>(OnAltVerb); + SubscribeLocalEvent(OnEquip); + SubscribeLocalEvent(OnGotEmagged); + } + + public void LockEntity(EntityUid uid, DNALockerComponent component, EntityUid equipee) + { + if (!TryComp(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(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(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 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(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); + } + } +} \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_Cats/actions/syndicate.ftl b/Resources/Locale/ru-RU/_Cats/actions/syndicate.ftl new file mode 100644 index 00000000000..6b7c43f3e76 --- /dev/null +++ b/Resources/Locale/ru-RU/_Cats/actions/syndicate.ftl @@ -0,0 +1,6 @@ +dna-locker-success = Ваш ДНК установлен в качестве основного для данного скафандра. +dna-locker-failure = Ваш ДНК не совпал с требуемым! +dna-locker-unlock = Требуемые ДНК были сброшены. +dna-locker-unremoveable = Замок заблокирован. Скафандр впивается в вашу кожу и сжимает вас. +dna-locker-equipped = Замок издает странный звук и искры, но ничего не происходит. Кажется нужно снять скафандр. +dna-locker-verb-name = Разблокировать замок \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_Cats/syndicate.ftl b/Resources/Locale/ru-RU/_Cats/syndicate.ftl index aca68237c4e..1a41b67a9a1 100644 --- a/Resources/Locale/ru-RU/_Cats/syndicate.ftl +++ b/Resources/Locale/ru-RU/_Cats/syndicate.ftl @@ -1,5 +1 @@ -dna-locker-success = Ваш ДНК установлен в качестве основного для данного скафандра. -dna-locker-explode = Ваш ДНК не совпал с требуемым! -dna-locker-unlock = Требуемые ДНК были сброшены. - swarmer-round-end-agent-name = S.W.A.R.M.E.R \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml index cb467f8a1ff..3b850ddb4cc 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml @@ -528,7 +528,7 @@ - MonkeyWearable - Hardsuit - WhitelistChameleon - - type: DNALocker + - type: DNALocker # Cats edit # Syndicate Medic Hardsuit - type: entity @@ -547,7 +547,7 @@ tags: - Hardsuit - WhitelistChameleon - - type: DNALocker + - type: DNALocker # Cats edit #Syndicate Elite Hardsuit - type: entity @@ -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 @@ -622,7 +622,8 @@ - type: HeldSpeedModifier - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitSyndieCommander - - type: DNALocker + - type: DNALocker # Cats edit + #Cybersun Juggernaut Hardsuit - type: entity @@ -656,7 +657,7 @@ - type: HeldSpeedModifier - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitCybersun - - type: DNALocker + - type: DNALocker # Cats edit #Wizard Hardsuit - type: entity @@ -803,6 +804,7 @@ sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertleader.rsi - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitERTLeader + - type: DNALocker # Cats edit #ERT Chaplain Hardsuit - type: entity @@ -817,6 +819,7 @@ sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertchaplain.rsi - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitERTChaplain + - type: DNALocker # Cats edit #ERT Engineer Hardsuit - type: entity @@ -832,6 +835,7 @@ sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertengineer.rsi - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitERTEngineer + - type: DNALocker # Cats edit #ERT Medic Hardsuit - type: entity @@ -846,6 +850,7 @@ sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertmedical.rsi - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitERTMedical + - type: DNALocker # Cats edit #ERT Security Hardsuit - type: entity @@ -860,6 +865,7 @@ sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertsecurity.rsi - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitERTSecurity + - type: DNALocker # Cats edit #ERT Janitor Hardsuit - type: entity @@ -874,6 +880,7 @@ sprite: Clothing/OuterClothing/Hardsuits/ERTSuits/ertjanitor.rsi - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitERTJanitor + - type: DNALocker # Cats edit #Deathsquad - type: entity @@ -912,6 +919,7 @@ - type: HeldSpeedModifier - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetHardsuitDeathsquad + - type: DNALocker # Cats edit #CBURN Hardsuit - type: entity @@ -950,6 +958,7 @@ - type: HeldSpeedModifier - type: ToggleableClothing clothingPrototype: ClothingHeadHelmetCBURN + - type: DNALocker # Cats edit #MISC. HARDSUITS #Clown Hardsuit