main cult
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
namespace Content.Server.White.Cult.HolyWater;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class BibleWaterConvertComponent : Component
|
||||
{
|
||||
[DataField("convertedId"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string ConvertedId = "Water";
|
||||
|
||||
[DataField("ConvertedToId"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string ConvertedToId = "HolyWater";
|
||||
}
|
||||
54
Content.Server/_White/Cult/HolyWater/DeconvertCultist.cs
Normal file
54
Content.Server/_White/Cult/HolyWater/DeconvertCultist.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Threading;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.White.Cult;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Timer = Robust.Shared.Timing.Timer;
|
||||
|
||||
namespace Content.Server.White.Cult.HolyWater;
|
||||
|
||||
[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);
|
||||
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;
|
||||
entityManager.RemoveComponent<CultistComponent>(uid);
|
||||
entityManager.RemoveComponent<PentagramComponent>(uid);
|
||||
}
|
||||
}
|
||||
54
Content.Server/_White/Cult/HolyWater/HolyWaterSystem.cs
Normal file
54
Content.Server/_White/Cult/HolyWater/HolyWaterSystem.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.White.Cult.HolyWater;
|
||||
|
||||
public sealed class HolyWaterSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly StunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BibleWaterConvertComponent, AfterInteractEvent>(OnBibleInteract);
|
||||
}
|
||||
|
||||
private void OnBibleInteract(EntityUid uid, BibleWaterConvertComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (HasComp<MobStateComponent>(uid))
|
||||
return;
|
||||
|
||||
if (!TryComp<SolutionContainerManagerComponent>(args.Target, out var container))
|
||||
return;
|
||||
|
||||
foreach (var solution in container.Solutions.Values.Where(solution => solution.ContainsReagent(component.ConvertedId, null)))
|
||||
{
|
||||
foreach (var reagent in solution.Contents)
|
||||
{
|
||||
if (reagent.Reagent.Prototype != component.ConvertedId)
|
||||
continue;
|
||||
|
||||
var amount = reagent.Quantity;
|
||||
|
||||
solution.RemoveReagent(reagent.Reagent.Prototype, reagent.Quantity);
|
||||
solution.AddReagent(component.ConvertedToId, amount);
|
||||
|
||||
if (args.Target == null)
|
||||
return;
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("holy-water-converted"), args.Target.Value, args.User);
|
||||
_audio.PlayPvs("/Audio/Effects/holy.ogg", args.Target.Value);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user