1
0

FlammableReaction.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Content.Server.Atmos.Components;
  2. using Content.Server.Atmos.EntitySystems;
  3. using Content.Shared.Database;
  4. using Content.Shared.EntityEffects;
  5. using JetBrains.Annotations;
  6. using Robust.Shared.Prototypes;
  7. namespace Content.Server.EntityEffects.Effects
  8. {
  9. [UsedImplicitly]
  10. public sealed partial class FlammableReaction : EntityEffect
  11. {
  12. [DataField]
  13. public float Multiplier = 0.05f;
  14. // The fire stack multiplier if fire stacks already exist on target, only works if 0 or greater
  15. [DataField]
  16. public float MultiplierOnExisting = -1f;
  17. public override bool ShouldLog => true;
  18. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  19. => Loc.GetString("reagent-effect-guidebook-flammable-reaction", ("chance", Probability));
  20. public override LogImpact LogImpact => LogImpact.Medium;
  21. public override void Effect(EntityEffectBaseArgs args)
  22. {
  23. if (!args.EntityManager.TryGetComponent(args.TargetEntity, out FlammableComponent? flammable))
  24. return;
  25. // Sets the multiplier for FireStacks to MultiplierOnExisting is 0 or greater and target already has FireStacks
  26. var multiplier = flammable.FireStacks != 0f && MultiplierOnExisting >= 0 ? MultiplierOnExisting : Multiplier;
  27. var quantity = 1f;
  28. if (args is EntityEffectReagentArgs reagentArgs)
  29. {
  30. quantity = reagentArgs.Quantity.Float();
  31. reagentArgs.EntityManager.System<FlammableSystem>().AdjustFireStacks(args.TargetEntity, quantity * multiplier, flammable);
  32. if (reagentArgs.Reagent != null)
  33. reagentArgs.Source?.RemoveReagent(reagentArgs.Reagent.ID, reagentArgs.Quantity);
  34. }
  35. else
  36. {
  37. args.EntityManager.System<FlammableSystem>().AdjustFireStacks(args.TargetEntity, multiplier, flammable);
  38. }
  39. }
  40. }
  41. }