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

[Port | Tweak] Neuro Stabilization Implant / Имплант Нейро Стабильности #80

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<VoiceMaskerComponent, ImplantImplantedEvent>(OnInsert);
SubscribeLocalEvent<VoiceMaskerComponent, SubdermalImplantInserted>(OnInsert); // WD EDIT
SubscribeLocalEvent<SyrinxVoiceMaskComponent, TransformSpeakerNameEvent>(OnSpeakerNameTransform);
SubscribeLocalEvent<SyrinxVoiceMaskComponent, VoiceMaskChangeNameMessage>(OnChangeName);
// We need to remove the SyrinxVoiceMaskComponent from the owner before the implant
// is removed, so we need to execute before the SubdermalImplantSystem.
SubscribeLocalEvent<VoiceMaskerComponent, EntGotRemovedFromContainerMessage>(OnRemove, before: new[] { typeof(SubdermalImplantSystem) });
}

private void OnInsert(EntityUid uid, VoiceMaskerComponent component, ImplantImplantedEvent args)
// WD EDIT START
private void OnInsert(EntityUid uid, VoiceMaskerComponent component, SubdermalImplantInserted args)
{
if (!args.Implanted.HasValue ||
!_tag.HasTag(args.Implant, BionicSyrinxImplant))
if (_tag.HasTag(uid, BionicSyrinxImplant))
return;

var voicemask = EnsureComp<SyrinxVoiceMaskComponent>(args.Implanted.Value);
voicemask.VoiceName = MetaData(args.Implanted.Value).EntityName;
Dirty(args.Implanted.Value, voicemask);
var voicemask = EnsureComp<SyrinxVoiceMaskComponent>(args.Target);
voicemask.VoiceName = MetaData(args.Target).EntityName;
Dirty(args.Target, voicemask);
}
// WD EDIT END

private void OnRemove(EntityUid uid, VoiceMaskerComponent component, EntGotRemovedFromContainerMessage args)
{
Expand Down
64 changes: 0 additions & 64 deletions Content.Server/Mindshield/MindShieldSystem.cs

This file was deleted.

76 changes: 76 additions & 0 deletions Content.Server/_White/Implants/ImplantsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Content.Server.Administration.Logs;
using Content.Server.Mind;
using Content.Server.Popups;
using Content.Server.Roles;
using Content.Shared._White.Implants.NeuroStabilization;
using Content.Shared.Database;
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Shared.Mindshield.Components;
using Content.Shared.Revolutionary.Components;
using Content.Shared.Tag;

namespace Content.Server._White.Implants;

public sealed class ImplantsSystem : EntitySystem
{
[Dependency] private readonly IAdminLogManager _adminLogManager = default!;
[Dependency] private readonly RoleSystem _roleSystem = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;

[ValidatePrototypeId<TagPrototype>]
private const string MindShieldTag = "MindShield";

[ValidatePrototypeId<TagPrototype>]
private const string NeuroStabilizationTag = "NeuroStabilization";

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SubdermalImplantComponent, SubdermalImplantInserted>(OnImplantInserted);
SubscribeLocalEvent<SubdermalImplantComponent, SubdermalImplantRemoved>(OnImplantRemoved);
}

private void OnImplantInserted(EntityUid uid, SubdermalImplantComponent component, SubdermalImplantInserted args)
{
if (_tag.HasTag(uid, MindShieldTag)
&& RevolutionCheck(uid, args.Target))
EnsureComp<MindShieldComponent>(args.Target);

if (_tag.HasTag(uid, NeuroStabilizationTag))
EnsureComp<NeuroStabilizationComponent>(args.Target);
}

private void OnImplantRemoved(EntityUid uid, SubdermalImplantComponent component, SubdermalImplantRemoved args)
{
if (_tag.HasTag(uid, MindShieldTag))
RemComp<MindShieldComponent>(args.Target);

if (_tag.HasTag(uid, NeuroStabilizationTag))
RemComp<NeuroStabilizationComponent>(args.Target);
}

/// <summary>
/// Checks if the implanted person was a Rev or Head Rev and remove role or destroy mindshield respectively.
/// </summary>
private bool RevolutionCheck(EntityUid uid, EntityUid target)
{
if (HasComp<HeadRevolutionaryComponent>(target))
{
_popupSystem.PopupEntity(Loc.GetString("head-rev-break-mindshield"), target);
QueueDel(uid);
return false;
}
Spatison marked this conversation as resolved.
Show resolved Hide resolved

if (_mindSystem.TryGetMind(target, out var mindId, out _)
&& _roleSystem.MindTryRemoveRole<RevolutionaryRoleComponent>(mindId))
{
_adminLogManager.Add(LogType.Mind, LogImpact.Medium,
$"{ToPrettyString(target)} was deconverted due to being implanted with a Mindshield.");
}

return true;
}
}
32 changes: 32 additions & 0 deletions Content.Shared/Implants/SharedImplanterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public void Implant(EntityUid user, EntityUid target, EntityUid implanter, Impla
implantContainer.OccludesLight = false;
_container.Insert(implant.Value, implantContainer);

RaiseLocalEvent(implant.Value, new SubdermalImplantInserted(user, target)); // WD EDIT

if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly)
DrawMode(implanter, component);
else
Expand Down Expand Up @@ -146,6 +148,8 @@ public void Draw(EntityUid implanter, EntityUid user, EntityUid target, Implante
_container.Insert(implant, implanterContainer);
permanentFound = implantComp.Permanent;

RaiseLocalEvent(implant, new SubdermalImplantRemoved(user, target)); // WD EDIT

var ev = new TransferDnaEvent { Donor = target, Recipient = implanter };
RaiseLocalEvent(target, ref ev);

Expand Down Expand Up @@ -225,3 +229,31 @@ public AddImplantAttemptEvent(EntityUid user, EntityUid target, EntityUid implan
Implanter = implanter;
}
}

// WD EDIT START
public sealed class SubdermalImplantInserted(EntityUid user, EntityUid target)
{
/// <summary>
/// Entity who implants
/// </summary>
public EntityUid User = user;

/// <summary>
/// Entity being implanted
/// </summary>
public EntityUid Target = target;
}

public sealed class SubdermalImplantRemoved(EntityUid user, EntityUid target)
{
/// <summary>
/// Entity who removes implant
/// </summary>
public EntityUid User = user;

/// <summary>
/// Entity which implant is removing
/// </summary>
public EntityUid Target = target;
}
// WD EDIT END
25 changes: 2 additions & 23 deletions Content.Shared/Implants/SharedSubdermalImplantSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ private void OnInsert(EntityUid uid, SubdermalImplantComponent component, EntGot
}
}
}

var ev = new ImplantImplantedEvent(uid, component.ImplantedEntity.Value);
RaiseLocalEvent(uid, ref ev);
}

private void OnRemoveAttempt(EntityUid uid, SubdermalImplantComponent component, ContainerGettingRemovedAttemptEvent args)
Expand Down Expand Up @@ -125,6 +122,8 @@ public void ForceImplant(EntityUid target, EntityUid implant, SubdermalImplantCo

component.ImplantedEntity = target;
_container.Insert(implant, implantContainer);

RaiseLocalEvent(implant, new SubdermalImplantInserted(target, target)); // WD EDIT
}

/// <summary>
Expand Down Expand Up @@ -185,23 +184,3 @@ public ImplantRelayEvent(T ev)
Event = ev;
}
}

/// <summary>
/// Event that is raised whenever someone is implanted with any given implant.
/// Raised on the the implant entity.
/// </summary>
/// <remarks>
/// implant implant implant implant
/// </remarks>
[ByRefEvent]
public readonly struct ImplantImplantedEvent
{
public readonly EntityUid Implant;
public readonly EntityUid? Implanted;

public ImplantImplantedEvent(EntityUid implant, EntityUid? implanted)
{
Implant = implant;
Implanted = implanted;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Shared._White.Implants.NeuroStabilization;

[RegisterComponent]
public sealed partial class NeuroStabilizationComponent : Component
{
[DataField]
public bool Electrocution = true;

[DataField]
public TimeSpan TimeElectrocution = TimeSpan.FromSeconds(1);

[DataField]
public float DamageModifier = 0.66f;
Spatison marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Shared.Electrocution;
using Content.Shared.Damage.Systems;

namespace Content.Shared._White.Implants.NeuroStabilization;

public sealed class NeuroStabilizationSystem : EntitySystem
{
[Dependency] private readonly SharedElectrocutionSystem _electrocution = default!;
Spatison marked this conversation as resolved.
Show resolved Hide resolved

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

SubscribeLocalEvent<NeuroStabilizationComponent, BeforeStaminaDamageEvent>(BeforeStaminaDamage);
}

private void BeforeStaminaDamage(EntityUid uid, NeuroStabilizationComponent component, ref BeforeStaminaDamageEvent args)
{
args.Cancelled = true;

if (!component.Electrocution)
return;

var damage = (int) MathF.Round(args.Value * component.DamageModifier);
_electrocution.TryDoElectrocution(uid, null, damage, component.TimeElectrocution,
false, 0.5f, null, true);
}
}
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ uplink-betrayal-knife-desc = Syndicate teleporter, when used, moves 3-8 meters f

uplink-ebow-name = Small energy crossbow
uplink-ebow-desc = A fairly quiet weapon that automatically reloads and stuns. It goes well with other types of weapons.

uplink-neuro-control = Neuro stabilization implanter
uplink-neuro-control-desc = Blocks all incoming stamina damage, compensating for it with a heat damage proportional to the blocked one.
Remuchi marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 0 additions & 5 deletions Resources/Locale/ru-RU/_white/implants/neurostabilization.ftl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ent-NeuroStabilizationImplanter = { ent-BaseImplanter }
.desc = { ent-BaseImplanter.desc }
Spatison marked this conversation as resolved.
Show resolved Hide resolved
.suffix = нейро стабилизация
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-NeuroStabilizationImplant = имплант нейро стабализации
.desc = Блокирует весь входящий урон по выносливости за счет шока.
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ uplink-experimental-syndicate-teleporter-desc = Телепортер синди

uplink-ebow-name = Маленький энергетический арбалет
uplink-ebow-desc = Довольно тихое оружие, которое автоматически перезаряжается и оглушает. Хорошо сочетается с другими видами оружия.

uplink-neuro-control = Имплант нейро стабилизации
uplink-neuro-control-desc = Блокирует весь входящий урон по выносливости, компенсируя его шоковым зарядом, наносящим урон, пропорциональный заблокированному.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@
noSpawn: true
components:
- type: SubdermalImplant
permanent: true
- type: Tag
tags:
- MindShield
15 changes: 12 additions & 3 deletions Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
id: UplinkBetrayalKnife
name: uplink-betrayal-knife-name
description: uplink-betrayal-knife-desc
icon: { sprite: /Textures/_White/Objects/Weapons/Melee/Daggers/betrayal_knife.rsi, state: icon }
productEntity: BetrayalKnife
cost:
Telecrystal: 10
Expand All @@ -39,7 +38,6 @@
id: UplinkMiniEbow
name: uplink-ebow-name
description: uplink-ebow-desc
icon: { sprite: /Textures/_White/Objects/Weapons/Guns/Battery/mini-ebow.rsi, state: icon }
productEntity: EnergyCrossbowMini
cost:
Telecrystal: 10
Expand All @@ -50,4 +48,15 @@
blacklist:
tags:
- NukeOpsUplink
saleLimit: 1
saleLimit: 1

- type: listing
id: NeuroControlImplanter
name: uplink-neuro-control
description: uplink-neuro-control-desc
icon: { sprite: /Textures/Interface/Alerts/stamina.rsi, state: stamina5 }
productEntity: NeuroStabilizationImplanter
cost:
Telecrystal: 2
categories:
- UplinkImplants
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- type: entity
parent: BaseImplantOnlyImplanterSyndi
id: NeuroStabilizationImplanter
suffix: neuro stabilization
components:
- type: Implanter
implant: NeuroStabilizationImplant
Loading
Loading