PlantCryoxadone.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. using Content.Server.Botany.Components;
  2. using Content.Shared.EntityEffects;
  3. using JetBrains.Annotations;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Random;
  6. namespace Content.Server.EntityEffects.Effects.PlantMetabolism;
  7. [UsedImplicitly]
  8. [DataDefinition]
  9. public sealed partial class PlantCryoxadone : EntityEffect
  10. {
  11. public override void Effect(EntityEffectBaseArgs args)
  12. {
  13. if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp)
  14. || plantHolderComp.Seed == null || plantHolderComp.Dead)
  15. return;
  16. var deviation = 0;
  17. var seed = plantHolderComp.Seed;
  18. var random = IoCManager.Resolve<IRobustRandom>();
  19. if (plantHolderComp.Age > seed.Maturation)
  20. deviation = (int) Math.Max(seed.Maturation - 1, plantHolderComp.Age - random.Next(7, 10));
  21. else
  22. deviation = (int) (seed.Maturation / seed.GrowthStages);
  23. plantHolderComp.Age -= deviation;
  24. plantHolderComp.SkipAging++;
  25. plantHolderComp.ForceUpdate = true;
  26. }
  27. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-cryoxadone", ("chance", Probability));
  28. }