mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
864b741942
* Cleanup - remove zombie hardcoding in RevolutionaryRuleSystem * Update Content.Shared/Revolutionary/SharedRevolutionary.cs Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> * fix * review * didnt save for some reason --------- Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>
71 lines
2.6 KiB
C#
71 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.Database;
|
|
using Content.Shared.Implants;
|
|
using Content.Shared.Mindshield.Components;
|
|
using Content.Shared.Revolutionary;
|
|
using Content.Shared.Revolutionary.Components;
|
|
using Content.Shared.Roles.Components;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Server.Mindshield;
|
|
|
|
/// <summary>
|
|
/// System used for adding or removing components with a mindshield implant
|
|
/// as well as checking if the implanted is a Rev or Head Rev.
|
|
/// </summary>
|
|
public sealed partial class MindShieldSystem : EntitySystem
|
|
{
|
|
[Dependency] private IAdminLogManager _adminLogManager = default!;
|
|
[Dependency] private RoleSystem _roleSystem = default!;
|
|
[Dependency] private MindSystem _mindSystem = default!;
|
|
[Dependency] private PopupSystem _popupSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<MindShieldImplantComponent, ImplantImplantedEvent>(OnImplantImplanted);
|
|
SubscribeLocalEvent<MindShieldImplantComponent, ImplantRemovedEvent>(OnImplantRemoved);
|
|
SubscribeLocalEvent<MindShieldComponent, AttemptConvertRevolutionaryEvent>(OnAttemptConvert);
|
|
}
|
|
|
|
private void OnImplantImplanted(Entity<MindShieldImplantComponent> ent, ref ImplantImplantedEvent ev)
|
|
{
|
|
EnsureComp<MindShieldComponent>(ev.Implanted);
|
|
MindShieldRemovalCheck(ev.Implanted, ev.Implant);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if the implanted person was a Rev or Head Rev and remove role or destroy mindshield respectively.
|
|
/// </summary>
|
|
private 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.MindRemoveRole<RevolutionaryRoleComponent>(mindId))
|
|
{
|
|
_adminLogManager.Add(LogType.Mind, LogImpact.Medium, $"{ToPrettyString(implanted)} was deconverted due to being implanted with a Mindshield.");
|
|
}
|
|
}
|
|
|
|
private void OnImplantRemoved(Entity<MindShieldImplantComponent> ent, ref ImplantRemovedEvent args)
|
|
{
|
|
RemComp<MindShieldComponent>(args.Implanted);
|
|
}
|
|
|
|
private void OnAttemptConvert(Entity<MindShieldComponent> ent, ref AttemptConvertRevolutionaryEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
}
|
|
|