1
0

CreateGas.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Content.Server.Atmos.EntitySystems;
  2. using Content.Shared.Atmos;
  3. using Content.Shared.Database;
  4. using Content.Shared.EntityEffects;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Server.EntityEffects.Effects;
  7. public sealed partial class CreateGas : EntityEffect
  8. {
  9. [DataField(required: true)]
  10. public Gas Gas = default!;
  11. /// <summary>
  12. /// For each unit consumed, how many moles of gas should be created?
  13. /// </summary>
  14. [DataField]
  15. public float Multiplier = 3f;
  16. public override bool ShouldLog => true;
  17. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  18. {
  19. var atmos = entSys.GetEntitySystem<AtmosphereSystem>();
  20. var gasProto = atmos.GetGas(Gas);
  21. return Loc.GetString("reagent-effect-guidebook-create-gas",
  22. ("chance", Probability),
  23. ("moles", Multiplier),
  24. ("gas", gasProto.Name));
  25. }
  26. public override LogImpact LogImpact => LogImpact.High;
  27. public override void Effect(EntityEffectBaseArgs args)
  28. {
  29. var atmosSys = args.EntityManager.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
  30. var tileMix = atmosSys.GetContainingMixture(args.TargetEntity, false, true);
  31. if (tileMix != null)
  32. {
  33. if (args is EntityEffectReagentArgs reagentArgs)
  34. {
  35. tileMix.AdjustMoles(Gas, reagentArgs.Quantity.Float() * Multiplier);
  36. }
  37. else
  38. {
  39. tileMix.AdjustMoles(Gas, Multiplier);
  40. }
  41. }
  42. }
  43. }