# Conflicts: # Content.Server/Access/Systems/AgentIDCardSystem.cs # Content.Server/GameTicking/Rules/ChangelingRuleSystem.cs # Content.Server/GameTicking/Rules/ThiefRuleSystem.cs # Content.Server/Medical/SuitSensors/SuitSensorSystem.cs # Content.Server/Zombies/ZombieSystem.cs # Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs # Content.Shared/Standing/StandingStateComponent.cs # Content.Shared/Standing/StandingStateSystem.cs # Content.Shared/Stunnable/SharedStunSystem.Knockdown.cs # Content.Shared/Stunnable/SharedStunSystem.cs # Resources/Locale/en-US/_strings/game-ticking/game-presets/preset-changeling.ftl # Resources/Locale/en-US/_strings/ghost/observer-role.ftl # Resources/Locale/en-US/_strings/robotics/borg_modules.ftl # Resources/Prototypes/Entities/Clothing/Ears/specific.yml # Resources/Prototypes/Entities/Clothing/Eyes/specific.yml # Resources/Prototypes/Entities/Clothing/Hands/specific.yml # Resources/Prototypes/Entities/Clothing/Head/specific.yml # Resources/Prototypes/Entities/Clothing/Neck/specific.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/specific.yml # Resources/Prototypes/Entities/Clothing/Shoes/specific.yml # Resources/Prototypes/Entities/Clothing/Uniforms/specific.yml # Resources/Prototypes/Entities/Mobs/NPCs/animals.yml # Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml # Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml # Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml # Resources/Prototypes/Entities/Objects/Materials/parts.yml # Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml
78 lines
2.9 KiB
C#
78 lines
2.9 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.Implants.Components;
|
|
using Content.Shared.Mindshield.Components;
|
|
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 class MindShieldSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IAdminLogManager _adminLogManager = default!;
|
|
[Dependency] private readonly RoleSystem _roleSystem = default!;
|
|
[Dependency] private readonly MindSystem _mindSystem = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<MindShieldImplantComponent, ImplantImplantedEvent>(OnImplantImplanted);
|
|
SubscribeLocalEvent<MindShieldImplantComponent, EntGotRemovedFromContainerMessage>(OnImplantDraw);
|
|
SubscribeLocalEvent<SubdermalImplantComponent, ImplantEjectEvent>(ImplantCheck);
|
|
}
|
|
|
|
private void OnImplantImplanted(Entity<MindShieldImplantComponent> ent, ref ImplantImplantedEvent ev)
|
|
{
|
|
if (ev.Implanted == null)
|
|
return;
|
|
|
|
EnsureComp<MindShieldComponent>(ev.Implanted.Value);
|
|
MindShieldRemovalCheck(ev.Implanted.Value, ev.Implant);
|
|
}
|
|
|
|
// Sunrise-Start
|
|
public void ImplantCheck(EntityUid uid, SubdermalImplantComponent comp, ref ImplantEjectEvent ev)
|
|
{
|
|
if (HasComp<MindShieldImplantComponent>(ev.Implant) && ev.Implanted != null)
|
|
{
|
|
RemCompDeferred<MindShieldComponent>(ev.Implanted.Value);
|
|
}
|
|
}
|
|
// Sunrise-End
|
|
|
|
/// <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 OnImplantDraw(Entity<MindShieldImplantComponent> ent, ref EntGotRemovedFromContainerMessage args)
|
|
{
|
|
RemComp<MindShieldComponent>(args.Container.Owner);
|
|
}
|
|
}
|
|
|