Files
OldThink/Content.Server/Mindshield/MindShieldSystem.cs
Aviu00 883623e448 Всякое (#271)
* - tweak: Something.

* - tweak: Tweaks.

* - tweak: Death to autoklickers.

* - tweak: Warop tweak.

* - tweak: Neuro tweaks.

* - add: Translate animal accents.

* - fix: Embeddable projectiles miss corpses.

* - tweak: More sniper ammo.

* - tweak: Free clothes in uplink.

* - tweak: Less speed up from stuff.

* - tweak: Ammo counter and toggleable clothing stuff.

* - add: More emag stuff.

* - tweak: No neuro blunt stamina damage.

* - fix: Fix name.

* - fix: Fix desc.
2024-04-06 15:30:40 +03:00

73 lines
2.6 KiB
C#

using Content.Server.Administration.Logs;
using Content.Server.Mind;
using Content.Server.Popups;
using Content.Server.Roles;
using Content.Shared._White.Implants.NeuroControl;
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.Mindshield;
/// <summary>
/// System used for checking if the implanted is a Rev or Head Rev.
/// </summary>
public sealed class MindShieldSystem : 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>]
public const string MindShieldTag = "MindShield";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SubdermalImplantComponent, ImplantImplantedEvent>(ImplantCheck);
}
/// <summary>
/// Checks if the implant was a mindshield or not
/// </summary>
public void ImplantCheck(EntityUid uid, SubdermalImplantComponent comp, ref ImplantImplantedEvent ev)
{
if (_tag.HasTag(ev.Implant, MindShieldTag) && ev.Implanted != null)
{
EnsureComp<MindShieldComponent>(ev.Implanted.Value);
MindShieldRemovalCheck(ev.Implanted.Value, ev.Implant);
}
// WD START
if (_tag.HasTag(ev.Implant, NeuroStabilizationComponent.NeuroStabilizationTag) && ev.Implanted != null)
{
EnsureComp<NeuroStabilizationComponent>(ev.Implanted.Value);
}
// WD END
}
/// <summary>
/// Checks if the implanted person was a Rev or Head Rev and remove role or destroy mindshield respectively.
/// </summary>
public void MindShieldRemovalCheck(EntityUid implanted, EntityUid implant)
{
if (HasComp<HeadRevolutionaryComponent>(implanted))
{
_popupSystem.PopupEntity(Loc.GetString("head-rev-break-mindshield"), implanted);
QueueDel(implant);
return;
}
if (_mindSystem.TryGetMind(implanted, out var mindId, out _) &&
_roleSystem.MindTryRemoveRole<RevolutionaryRoleComponent>(mindId))
{
_adminLogManager.Add(LogType.Mind, LogImpact.Medium, $"{ToPrettyString(implanted)} was deconverted due to being implanted with a Mindshield.");
}
}
}