PlantRestoreSeeds.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 restoral of seeds on a plant.
  9. /// </summary>
  10. public sealed partial class PlantRestoreSeeds : 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)
  24. {
  25. plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp);
  26. popupSystem.PopupEntity(Loc.GetString("botany-plant-seedsrestored"), args.TargetEntity);
  27. plantHolderComp.Seed.Seedless = false;
  28. }
  29. }
  30. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
  31. Loc.GetString("reagent-effect-guidebook-plant-seeds-add", ("chance", Probability));
  32. }