2024-01-27 15:19:52 +03:00
|
|
|
using System.Threading;
|
2024-06-14 14:01:26 +00:00
|
|
|
using Content.Server._White.Cult.GameRule;
|
2024-01-27 15:19:52 +03:00
|
|
|
using Content.Server.Popups;
|
|
|
|
|
using Content.Server.Stunnable;
|
2024-07-14 12:27:20 +00:00
|
|
|
using Content.Shared._White.Antag;
|
2024-01-27 15:19:52 +03:00
|
|
|
using Content.Shared.Chemistry.Reagent;
|
|
|
|
|
using Content.Shared.IdentityManagement;
|
2024-06-14 14:01:26 +00:00
|
|
|
using Content.Shared.Jittering;
|
2024-01-27 15:19:52 +03:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
2024-01-29 01:02:37 +07:00
|
|
|
using CultistComponent = Content.Shared._White.Cult.Components.CultistComponent;
|
2024-01-27 15:19:52 +03:00
|
|
|
using Timer = Robust.Shared.Timing.Timer;
|
|
|
|
|
|
2024-01-28 18:18:54 +07:00
|
|
|
namespace Content.Server._White.Cult.HolyWater;
|
2024-01-27 15:19:52 +03:00
|
|
|
|
|
|
|
|
[ImplicitDataDefinitionForInheritors]
|
|
|
|
|
[MeansImplicitUse]
|
|
|
|
|
public sealed partial class DeconvertCultist : ReagentEffect
|
|
|
|
|
{
|
|
|
|
|
public override bool ShouldLog => true;
|
|
|
|
|
|
|
|
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
|
|
|
|
{
|
|
|
|
|
return Loc.GetString("reagent-effect-guidebook-deconvert-cultist");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Effect(ReagentEffectArgs args)
|
|
|
|
|
{
|
|
|
|
|
var uid = args.SolutionEntity;
|
|
|
|
|
|
|
|
|
|
if (!args.EntityManager.TryGetComponent(uid, out CultistComponent? component))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (component.HolyConvertToken != null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
args.EntityManager.System<StunSystem>()
|
|
|
|
|
.TryParalyze(uid, TimeSpan.FromSeconds(component.HolyConvertTime + 5f), true);
|
2024-06-14 14:01:26 +00:00
|
|
|
args.EntityManager.System<SharedJitteringSystem>()
|
|
|
|
|
.DoJitter(uid, TimeSpan.FromSeconds(component.HolyConvertTime + 5f), true);
|
2024-01-27 15:19:52 +03:00
|
|
|
var target = Identity.Name(uid, args.EntityManager);
|
|
|
|
|
args.EntityManager.System<PopupSystem>()
|
|
|
|
|
.PopupEntity(Loc.GetString("holy-water-started-converting", ("target", target)), uid);
|
|
|
|
|
|
|
|
|
|
component.HolyConvertToken = new CancellationTokenSource();
|
|
|
|
|
Timer.Spawn(TimeSpan.FromSeconds(component.HolyConvertTime), () => ConvertCultist(uid, args.EntityManager),
|
|
|
|
|
component.HolyConvertToken.Token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConvertCultist(EntityUid uid, IEntityManager entityManager)
|
|
|
|
|
{
|
|
|
|
|
if (!entityManager.TryGetComponent<CultistComponent>(uid, out var cultist))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
cultist.HolyConvertToken = null;
|
2024-01-28 08:05:01 +03:00
|
|
|
|
2024-02-29 15:10:30 +09:00
|
|
|
entityManager.RemoveComponent<CultistComponent>(uid);
|
|
|
|
|
entityManager.RemoveComponent<PentagramComponent>(uid);
|
2024-07-14 12:27:20 +00:00
|
|
|
entityManager.RemoveComponent<GlobalAntagonistComponent>(uid);
|
2024-04-08 03:22:48 +09:00
|
|
|
|
2024-06-14 14:01:26 +00:00
|
|
|
var cultRuleSystem = entityManager.System<CultRuleSystem>();
|
|
|
|
|
cultRuleSystem.RemoveObjectiveAndRole(uid);
|
2024-01-27 15:19:52 +03:00
|
|
|
}
|
|
|
|
|
}
|