AddToSolutionReaction.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Shared.Chemistry.EntitySystems;
  2. using Content.Shared.EntityEffects;
  3. using JetBrains.Annotations;
  4. using Robust.Shared.Prototypes;
  5. namespace Content.Server.EntityEffects.Effects
  6. {
  7. [UsedImplicitly]
  8. public sealed partial class AddToSolutionReaction : EntityEffect
  9. {
  10. [DataField("solution")]
  11. private string _solution = "reagents";
  12. public override void Effect(EntityEffectBaseArgs args)
  13. {
  14. if (args is EntityEffectReagentArgs reagentArgs) {
  15. if (reagentArgs.Reagent == null)
  16. return;
  17. // TODO see if this is correct
  18. var solutionContainerSystem = reagentArgs.EntityManager.System<SharedSolutionContainerSystem>();
  19. if (!solutionContainerSystem.TryGetSolution(reagentArgs.TargetEntity, _solution, out var solutionContainer))
  20. return;
  21. if (solutionContainerSystem.TryAddReagent(solutionContainer.Value, reagentArgs.Reagent.ID, reagentArgs.Quantity, out var accepted))
  22. reagentArgs.Source?.RemoveReagent(reagentArgs.Reagent.ID, accepted);
  23. return;
  24. }
  25. // TODO: Someone needs to figure out how to do this for non-reagent effects.
  26. throw new NotImplementedException();
  27. }
  28. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
  29. Loc.GetString("reagent-effect-guidebook-add-to-solution-reaction", ("chance", Probability));
  30. }
  31. }