Это заняло больше времени, чем я думал (#782)
This commit is contained in:
@@ -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<SubdermalImplantComponent, InsertVoiceActivatedBombEvent>(OnTryInsertVoiceActivatedBombServer);
|
||||
SubscribeLocalEvent<SubdermalImplantComponent, ImplanterUsed>(OnVoiceActivatedBombInserted);
|
||||
}
|
||||
|
||||
private void OnTryInsertVoiceActivatedBombServer(Entity<SubdermalImplantComponent> ent, ref InsertVoiceActivatedBombEvent args)
|
||||
{
|
||||
if (!TryComp<TriggerOnVoiceComponent>(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<SubdermalImplantComponent> ent, ref ImplanterUsed args)
|
||||
{
|
||||
if (!Tag.HasTag(args.Implanter, VoiceActivatedBombTag))
|
||||
return;
|
||||
|
||||
if (!TryComp<TriggerOnVoiceComponent>(args.Implanter, out var implanterTrigger))
|
||||
return;
|
||||
|
||||
if (!TryComp<TriggerOnVoiceComponent>(args.Implant, out var implantTrigger))
|
||||
return;
|
||||
|
||||
implantTrigger.KeyPhrase = implanterTrigger.KeyPhrase;
|
||||
EnsureComp<ActiveListenerComponent>(args.Implant);
|
||||
RemComp<TriggerOnVoiceComponent>(args.Implanter);
|
||||
Tag.RemoveTag(args.Implanter, VoiceActivatedBombTag);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Implant which was used
|
||||
/// </summary>
|
||||
public EntityUid Implant = implant;
|
||||
/// <summary>
|
||||
/// Implanter which was used
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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<BodyComponent, AddImplantAttemptEvent>(OnTryInsertVoiceActivatedBomb);
|
||||
}
|
||||
|
||||
private void OnTryInsertVoiceActivatedBomb(Entity<BodyComponent> 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;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
uplink-voice-activated-bomb-implant = Имплант бомбы с голосовым триггером
|
||||
uplink-voice-activated-bomb-implant-desc = Имплант микробомбы с триггером, заставляющим сработать по заданной голосовой команде.
|
||||
|
||||
ent-VoiceActivatedBombImplant = Имплант бомбы с голосовым триггером
|
||||
.desc = Имплант микробомбы с триггером, заставляющим сработать по заданной голосовой команде.
|
||||
|
||||
voice-activated-bomb-no-key-phrase = Голосовой триггер не инициализирован, ввод импланта заблокирован.
|
||||
@@ -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 = бомба с голосовым триггером
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -102,3 +102,6 @@
|
||||
|
||||
- type: Tag
|
||||
id: ClusterBang
|
||||
|
||||
- type: Tag
|
||||
id: VoiceActivatedBombImplant
|
||||
|
||||
Reference in New Issue
Block a user