CureZombieInfection.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Content.Server.Zombies;
  2. using Content.Shared.EntityEffects;
  3. using Robust.Shared.Prototypes;
  4. using Content.Shared.Zombies;
  5. namespace Content.Server.EntityEffects.Effects;
  6. public sealed partial class CureZombieInfection : EntityEffect
  7. {
  8. [DataField]
  9. public bool Innoculate;
  10. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  11. {
  12. if(Innoculate)
  13. return Loc.GetString("reagent-effect-guidebook-innoculate-zombie-infection", ("chance", Probability));
  14. return Loc.GetString("reagent-effect-guidebook-cure-zombie-infection", ("chance", Probability));
  15. }
  16. // Removes the Zombie Infection Components
  17. public override void Effect(EntityEffectBaseArgs args)
  18. {
  19. var entityManager = args.EntityManager;
  20. if (entityManager.HasComponent<IncurableZombieComponent>(args.TargetEntity))
  21. return;
  22. entityManager.RemoveComponent<ZombifyOnDeathComponent>(args.TargetEntity);
  23. entityManager.RemoveComponent<PendingZombieComponent>(args.TargetEntity);
  24. if (Innoculate)
  25. {
  26. entityManager.EnsureComponent<ZombieImmuneComponent>(args.TargetEntity);
  27. }
  28. }
  29. }