PlantDiethylamine.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Server.Botany.Components;
  2. using Content.Server.Botany.Systems;
  3. using Content.Shared.EntityEffects;
  4. using JetBrains.Annotations;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Random;
  7. namespace Content.Server.EntityEffects.Effects.PlantMetabolism;
  8. [UsedImplicitly]
  9. [DataDefinition]
  10. public sealed partial class PlantDiethylamine : EntityEffect
  11. {
  12. public override void Effect(EntityEffectBaseArgs args)
  13. {
  14. if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp)
  15. || plantHolderComp.Seed == null || plantHolderComp.Dead ||
  16. plantHolderComp.Seed.Immutable)
  17. return;
  18. var plantHolder = args.EntityManager.System<PlantHolderSystem>();
  19. var random = IoCManager.Resolve<IRobustRandom>();
  20. if (random.Prob(0.1f))
  21. {
  22. plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);
  23. plantHolderComp.Seed.Lifespan++;
  24. }
  25. if (random.Prob(0.1f))
  26. {
  27. plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);
  28. plantHolderComp.Seed.Endurance++;
  29. }
  30. }
  31. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-diethylamine", ("chance", Probability));
  32. }