Skip to content

Commit

Permalink
Merge branch 'master' into hardlight-spear
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison authored Oct 11, 2024
2 parents 0db64f4 + a8c9bbf commit 4155ceb
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 104 deletions.
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;
}

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;
}
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!;

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);
}
}
7 changes: 7 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6532,3 +6532,10 @@ Entries:
id: 6364
time: '2024-10-11T04:26:13.0000000+00:00'
url: https://github.com/WWhiteDreamProject/wwdpublic/pull/78
- author: Spatison
changes:
- type: Add
message: Added neuro stabilization Implant / Добавлен имплант нейро стабильности
id: 6365
time: '2024-10-11T05:03:33.0000000+00:00'
url: https://github.com/WWhiteDreamProject/wwdpublic/pull/80
5 changes: 4 additions & 1 deletion Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ uplink-ebow-desc = A fairly quiet weapon that automatically reloads and stuns. I
uplink-hardlight-spear-implant-name = Hardlight spear implanter
uplink-hardlight-spear-implant-desc = An implant injected into the body, and later activated at the user's will. It will summon a spear made out of hardlight that the user can use to wreak havoc.
uplink-implanter-name = Implanter
uplink-neuro-control = Neuro stabilization implanter
uplink-neuro-control-desc = Blocks all of the incoming stamina damage while dealing shock damage instead.
uplink-implanter-name = Имплантер
uplink-implanter-desc = An advanced implant that allows you to quickly insert and remove implants.
uplink-smoke-implant-name = Smoke implant
Expand Down
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
Expand Up @@ -2,6 +2,10 @@ ent-HardlightSpearImplanter = { ent-BaseImplanter }
.desc = { ent-BaseImplanter.desc }
.suffix = световое копьё
ent-NeuroStabilizationImplanter = { ent-BaseImplanter }
.desc = { ent-BaseImplanter.desc }
.suffix = нейро стабилизация
ent-ImplanterSyndi = { ent-BaseImplanter }
.desc = Компактный одноразовый шприц, предназначенный исключительно для введения и извлечения подкожных имплантатов.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ent-HardlightSpearImplant = имплант световое копьё
.desc = Этот имплант создаёт световое копьё в ваших руках.
ent-NeuroStabilizationImplant = имплант нейро стабализации
.desc = Блокирует весь входящий урон по выносливости за счет шока.
ent-SmokeImplant = имплант дыма
.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 @@ -13,6 +13,9 @@ uplink-ebow-desc = Довольно тихое оружие, которое ав
uplink-hardlight-spear-implant-name = Имплант светового копья
uplink-hardlight-spear-implant-desc = Имплант, вводимый в тело и активируемый по желанию пользователя. Он вызывает копье из твердого света, с помощью которого пользователь может сеять хаос.
uplink-neuro-control = Имплант нейро стабилизации
uplink-neuro-control-desc = Блокирует весь входящий урон по выносливости, компенсируя его шоковым зарядом, наносящим урон, пропорциональный заблокированному.
uplink-implanter-name = Имплантер
uplink-implanter-desc = Продвинутый имплантер, позволяющий быстро вкалывать и вытаскивать импланты.
Expand Down
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
Loading

0 comments on commit 4155ceb

Please sign in to comment.