1
0

PlantMutateGases.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Content.Server.Botany.Components;
  2. using Content.Shared.Atmos;
  3. using Content.Shared.EntityEffects;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Random;
  6. using System.Linq;
  7. namespace Content.Server.EntityEffects.Effects;
  8. /// <summary>
  9. /// changes the gases that a plant or produce create.
  10. /// </summary>
  11. public sealed partial class PlantMutateExudeGasses : EntityEffect
  12. {
  13. [DataField]
  14. public float MinValue = 0.01f;
  15. [DataField]
  16. public float MaxValue = 0.5f;
  17. public override void Effect(EntityEffectBaseArgs args)
  18. {
  19. var plantholder = args.EntityManager.GetComponent<PlantHolderComponent>(args.TargetEntity);
  20. if (plantholder.Seed == null)
  21. return;
  22. var random = IoCManager.Resolve<IRobustRandom>();
  23. var gasses = plantholder.Seed.ExudeGasses;
  24. // Add a random amount of a random gas to this gas dictionary
  25. float amount = random.NextFloat(MinValue, MaxValue);
  26. Gas gas = random.Pick(Enum.GetValues(typeof(Gas)).Cast<Gas>().ToList());
  27. if (gasses.ContainsKey(gas))
  28. {
  29. gasses[gas] += amount;
  30. }
  31. else
  32. {
  33. gasses.Add(gas, amount);
  34. }
  35. }
  36. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  37. {
  38. return "TODO";
  39. }
  40. }
  41. /// <summary>
  42. /// changes the gases that a plant or produce consumes.
  43. /// </summary>
  44. public sealed partial class PlantMutateConsumeGasses : EntityEffect
  45. {
  46. [DataField]
  47. public float MinValue = 0.01f;
  48. [DataField]
  49. public float MaxValue = 0.5f;
  50. public override void Effect(EntityEffectBaseArgs args)
  51. {
  52. var plantholder = args.EntityManager.GetComponent<PlantHolderComponent>(args.TargetEntity);
  53. if (plantholder.Seed == null)
  54. return;
  55. var random = IoCManager.Resolve<IRobustRandom>();
  56. var gasses = plantholder.Seed.ConsumeGasses;
  57. // Add a random amount of a random gas to this gas dictionary
  58. float amount = random.NextFloat(MinValue, MaxValue);
  59. Gas gas = random.Pick(Enum.GetValues(typeof(Gas)).Cast<Gas>().ToList());
  60. if (gasses.ContainsKey(gas))
  61. {
  62. gasses[gas] += amount;
  63. }
  64. else
  65. {
  66. gasses.Add(gas, amount);
  67. }
  68. }
  69. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  70. {
  71. return "TODO";
  72. }
  73. }