From 1d70875b3d642c325db7f8202d07c8c0943cabb3 Mon Sep 17 00:00:00 2001 From: BIGZi0348 <118811750+BIGZi0348@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:02:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=82=D0=BE=20=D0=B7=D0=B0=D0=BD=D1=8F?= =?UTF-8?q?=D0=BB=D0=BE=20=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=B5=20=D0=B2?= =?UTF-8?q?=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8,=20=D1=87=D0=B5=D0=BC=20?= =?UTF-8?q?=D1=8F=20=D0=B4=D1=83=D0=BC=D0=B0=D0=BB=20(#782)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VoiceActivatedBomb/VoiceActivatedBomb.cs | 53 +++++++++++++++++++ .../Implants/SharedImplanterSystem.cs | 13 +++++ .../SharedVoiceActivatedBombSystem.cs | 35 ++++++++++++ .../_white/implants/voiceactivatedbomb.ftl | 7 +++ .../entities/objects/misc/implanters.ftl | 3 ++ .../Prototypes/_White/Catalog/uplink.yml | 12 +++++ .../Entities/Objects/Misc/implanters.yml | 12 +++++ .../Objects/Misc/subdermal_implants.yml | 21 ++++++++ Resources/Prototypes/_White/tags.yml | 3 ++ 9 files changed, 159 insertions(+) create mode 100644 Content.Server/_White/Implants/VoiceActivatedBomb/VoiceActivatedBomb.cs create mode 100644 Content.Shared/_White/Implants/VoiceActivatedBomb/SharedVoiceActivatedBombSystem.cs create mode 100644 Resources/Locale/ru-RU/_white/implants/voiceactivatedbomb.ftl diff --git a/Content.Server/_White/Implants/VoiceActivatedBomb/VoiceActivatedBomb.cs b/Content.Server/_White/Implants/VoiceActivatedBomb/VoiceActivatedBomb.cs new file mode 100644 index 0000000000..b2d0a96d50 --- /dev/null +++ b/Content.Server/_White/Implants/VoiceActivatedBomb/VoiceActivatedBomb.cs @@ -0,0 +1,53 @@ +using Content.Shared._White.Implants.VoiceActivatedBomb; +using Content.Shared.Implants.Components; +using Content.Server.Explosion.Components; +using Content.Server.Speech.Components; +using Content.Shared.Popups; +using Content.Shared.Implants; + +namespace Content.Server._White.Implants.VoiceActivatedBomb; + +public sealed class VoiceActivatedBombSystem : SharedVoiceActivatedBombSystem +{ + [Dependency] private readonly SharedPopupSystem _popup = default!; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnTryInsertVoiceActivatedBombServer); + SubscribeLocalEvent(OnVoiceActivatedBombInserted); + } + + private void OnTryInsertVoiceActivatedBombServer(Entity ent, ref InsertVoiceActivatedBombEvent args) + { + if (!TryComp(args.Implanter, out var implanterTrigger)) + return; + + if (implanterTrigger.KeyPhrase == null) + { + // TODO find some way to make it look good + // Right now it's overlaps with implanter-component-implant-failed popup + //var message = Loc.GetString("voice-activated-bomb-no-key-phrase"); + //_popup.PopupEntity(message, args.Implanter, args.User); + args.Cancel(); + return; + } + } + + private void OnVoiceActivatedBombInserted(Entity ent, ref ImplanterUsed args) + { + if (!Tag.HasTag(args.Implanter, VoiceActivatedBombTag)) + return; + + if (!TryComp(args.Implanter, out var implanterTrigger)) + return; + + if (!TryComp(args.Implant, out var implantTrigger)) + return; + + implantTrigger.KeyPhrase = implanterTrigger.KeyPhrase; + EnsureComp(args.Implant); + RemComp(args.Implanter); + Tag.RemoveTag(args.Implanter, VoiceActivatedBombTag); + } +} diff --git a/Content.Shared/Implants/SharedImplanterSystem.cs b/Content.Shared/Implants/SharedImplanterSystem.cs index c15d7c445c..2aa696b5f2 100644 --- a/Content.Shared/Implants/SharedImplanterSystem.cs +++ b/Content.Shared/Implants/SharedImplanterSystem.cs @@ -44,6 +44,18 @@ public sealed class SubdermalImplantRemoved(EntityUid user, EntityUid target, Su public SubdermalImplantComponent Component = component; } +public sealed class ImplanterUsed(EntityUid implant, EntityUid implanter) : EventArgs +{ + /// + /// Implant which was used + /// + public EntityUid Implant = implant; + /// + /// Implanter which was used + /// + public EntityUid Implanter = implanter; +} + //WD EDIT END public abstract class SharedImplanterSystem : EntitySystem @@ -113,6 +125,7 @@ public abstract class SharedImplanterSystem : EntitySystem var ev = new TransferDnaEvent { Donor = target, Recipient = implanter }; RaiseLocalEvent(target, ref ev); + RaiseLocalEvent(implant.Value, new ImplanterUsed(implant.Value, implanter)); // WD Dirty(implanter, component); } diff --git a/Content.Shared/_White/Implants/VoiceActivatedBomb/SharedVoiceActivatedBombSystem.cs b/Content.Shared/_White/Implants/VoiceActivatedBomb/SharedVoiceActivatedBombSystem.cs new file mode 100644 index 0000000000..992d37f350 --- /dev/null +++ b/Content.Shared/_White/Implants/VoiceActivatedBomb/SharedVoiceActivatedBombSystem.cs @@ -0,0 +1,35 @@ +using Content.Shared.Body.Components; +using Content.Shared.Implants; +using Content.Shared.Tag; + +namespace Content.Shared._White.Implants.VoiceActivatedBomb; + +public abstract class SharedVoiceActivatedBombSystem : EntitySystem +{ + [Dependency] protected readonly TagSystem Tag = default!; + protected const string VoiceActivatedBombTag = "VoiceActivatedBombImplant"; + public override void Initialize() + { + SubscribeLocalEvent(OnTryInsertVoiceActivatedBomb); + } + + private void OnTryInsertVoiceActivatedBomb(Entity ent, ref AddImplantAttemptEvent args) + { + if (!Tag.HasTag(args.Implant, VoiceActivatedBombTag)) + return; + + var ev = new InsertVoiceActivatedBombEvent(args.User, args.Implant, args.Implanter); + RaiseLocalEvent(args.Implant, ev); + if (ev.Cancelled) + args.Cancel(); + + return; + } +} +public sealed class InsertVoiceActivatedBombEvent(EntityUid user, EntityUid implant, EntityUid implanter) + : CancellableEntityEventArgs +{ + public readonly EntityUid User = user; + public readonly EntityUid Implant = implant; + public readonly EntityUid Implanter = implanter; +} diff --git a/Resources/Locale/ru-RU/_white/implants/voiceactivatedbomb.ftl b/Resources/Locale/ru-RU/_white/implants/voiceactivatedbomb.ftl new file mode 100644 index 0000000000..3b0a3784ad --- /dev/null +++ b/Resources/Locale/ru-RU/_white/implants/voiceactivatedbomb.ftl @@ -0,0 +1,7 @@ +uplink-voice-activated-bomb-implant = Имплант бомбы с голосовым триггером +uplink-voice-activated-bomb-implant-desc = Имплант микробомбы с триггером, заставляющим сработать по заданной голосовой команде. + +ent-VoiceActivatedBombImplant = Имплант бомбы с голосовым триггером + .desc = Имплант микробомбы с триггером, заставляющим сработать по заданной голосовой команде. + +voice-activated-bomb-no-key-phrase = Голосовой триггер не инициализирован, ввод импланта заблокирован. diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/misc/implanters.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/misc/implanters.ftl index 8df980b01a..728e8c9fd6 100644 --- a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/misc/implanters.ftl +++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/misc/implanters.ftl @@ -56,3 +56,6 @@ ent-ImplanterSyndi = { ent-BaseImplanter } .desc = { ent-BaseImplanter.desc } ent-NeuroStabilizationImplanter = { ent-BaseImplanter } .desc = { ent-BaseImplanter.desc } +ent-VoiceActivatedBombImplanter = { ent-BaseImplanter } + .desc = { ent-BaseImplanter.desc } + .suffix = бомба с голосовым триггером diff --git a/Resources/Prototypes/_White/Catalog/uplink.yml b/Resources/Prototypes/_White/Catalog/uplink.yml index 2cdad02829..392a7eb7de 100644 --- a/Resources/Prototypes/_White/Catalog/uplink.yml +++ b/Resources/Prototypes/_White/Catalog/uplink.yml @@ -324,3 +324,15 @@ Telecrystal: 2 categories: - UplinkDisruption + +- type: listing + id: UplinkVoiceActivatedBombImplanter + name: uplink-voice-activated-bomb-implant + description: uplink-voice-activated-bomb-implant-desc + icon: { sprite: /Textures/Actions/Implants/implants.rsi, state: explosive } + productEntity: VoiceActivatedBombImplanter + cost: + Telecrystal: 8 + categories: + - UplinkImplants + saleLimit: 1 diff --git a/Resources/Prototypes/_White/Entities/Objects/Misc/implanters.yml b/Resources/Prototypes/_White/Entities/Objects/Misc/implanters.yml index d229a9c5ed..f099341b1c 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Misc/implanters.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Misc/implanters.yml @@ -51,3 +51,15 @@ components: - type: Implanter implant: GenderSwapImplant + +- type: entity + parent: BaseImplantOnlyImplanterSyndi + id: VoiceActivatedBombImplanter + suffix: voice activated bomb + components: + - type: Implanter + implant: VoiceActivatedBombImplant + - type: TriggerOnVoice + - type: Tag + tags: + - VoiceActivatedBombImplant diff --git a/Resources/Prototypes/_White/Entities/Objects/Misc/subdermal_implants.yml b/Resources/Prototypes/_White/Entities/Objects/Misc/subdermal_implants.yml index 7b75f6d04f..0065aac80e 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Misc/subdermal_implants.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Misc/subdermal_implants.yml @@ -59,3 +59,24 @@ components: - type: SubdermalImplant implantAction: ActionActivateGenderSwapImplant + +- type: entity + parent: BaseSubdermalImplant + id: VoiceActivatedBombImplant + name: voice activated Bomb implant + description: A microbomb implant with a trigger that causes it to go off by vocal keywords. + noSpawn: true + components: + - type: SubdermalImplant + permanent: true + - type: TriggerOnVoice + - type: ExplodeOnTrigger + - type: Explosive + explosionType: MicroBomb + totalIntensity: 150 + intensitySlope: 5 + maxIntensity: 30 + canCreateVacuum: false + - type: Tag + tags: + - VoiceActivatedBombImplant diff --git a/Resources/Prototypes/_White/tags.yml b/Resources/Prototypes/_White/tags.yml index 382fc950ab..7dc0743d05 100644 --- a/Resources/Prototypes/_White/tags.yml +++ b/Resources/Prototypes/_White/tags.yml @@ -102,3 +102,6 @@ - type: Tag id: ClusterBang + +- type: Tag + id: VoiceActivatedBombImplant