PlantDestroySeeds.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Content.Server.Botany.Components;
  2. using Content.Server.Botany.Systems;
  3. using Content.Shared.EntityEffects;
  4. using Content.Shared.Popups;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Server.EntityEffects.Effects.PlantMetabolism;
  7. /// <summary>
  8. /// Handles removal of seeds on a plant.
  9. /// </summary>
  10. public sealed partial class PlantDestroySeeds : EntityEffect
  11. {
  12. public override void Effect(EntityEffectBaseArgs args)
  13. {
  14. if (
  15. !args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp)
  16. || plantHolderComp.Seed == null
  17. || plantHolderComp.Dead
  18. || plantHolderComp.Seed.Immutable
  19. )
  20. return;
  21. var plantHolder = args.EntityManager.System<PlantHolderSystem>();
  22. var popupSystem = args.EntityManager.System<SharedPopupSystem>();
  23. if (plantHolderComp.Seed.Seedless == false)
  24. {
  25. plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);
  26. popupSystem.PopupEntity(
  27. Loc.GetString("botany-plant-seedsdestroyed"),
  28. args.TargetEntity,
  29. PopupType.SmallCaution
  30. );
  31. plantHolderComp.Seed.Seedless = true;
  32. }
  33. }
  34. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
  35. Loc.GetString("reagent-effect-guidebook-plant-seeds-remove", ("chance", Probability));
  36. }