CatStation/Content.Shared/EntityEffects/Effects/Solution/AddReagentToSolutionEntityEffectSystem.cs
Princess Cheeseballs ef3a0ecc2a
Solutions Refactor Part 1 - Solution Prototypes (#43412)
* Everything except the YAML slop...

* She solution on my manager till I sajfslkahfsjakfhaskjfshajksafhfsakhfasjfas

* another 1000 lines

* fix chem dispenser size

* go my shnelf

* Implicit ass

* rider is being mean for some reason

* dasdas

* borger

* better formatting go!

* clothes/bloodstream

* Cartons

* cups and bottles

* mmm soder

* bar drinks

* Spray bottles and some size tweaks with hindsight

* 99 bottles of beer on the wall I hate YAML

* push that shit

* mmm burger

* Sneed

* sheets

* condiments

* mmm yummy

* fridge yummyfood

* meat...

* sub 300

* burger...

* bready

* let them eat cake

* does she know how to make a grilled cheese?

* pizza pie!

* misc shit

* soup or salad

* Food and drinks, vanquished

* the cubes!!!

* Almost free from YAML...

* fix test fails and some yaml issues

* fix prediction, almost done

* fix all test fails

* remove master merge artifacts and undo autonetworking

* review and compatibility

* graaah

* unfuck master merge I hate github

* merg conflicts

* sfsa

* ehoop

* sadas

* afsafsaasf

* merge conflicts

* fucked up the merge conflicts

* merge conflict is fucked I might need to completely redo this branch

* test fail

* no calcium????

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-04-25 02:00:34 +00:00

59 lines
2.1 KiB
C#

using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects.Solution;
// TODO: This should be removed and changed to an "AbsorbentSolutionComponent"
/// <summary>
/// Creates a reagent in a specified solution owned by this entity.
/// Quantity is modified by scale.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T,TEffect}"/>
public sealed class AddReagentToSolutionEntityEffectSystem : EntityEffectSystem<SolutionManagerComponent, AddReagentToSolution>
{
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
protected override void Effect(Entity<SolutionManagerComponent> entity, ref EntityEffectEvent<AddReagentToSolution> args)
{
var solution = args.Effect.Solution;
var reagent = args.Effect.Reagent;
if (!_solutionContainer.TryGetSolution((entity, entity), solution, out var solutionContainer))
return;
_solutionContainer.TryAddReagent(solutionContainer.Value, reagent, args.Scale * args.Effect.StrengthModifier);
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class AddReagentToSolution : EntityEffectBase<AddReagentToSolution>
{
/// <summary>
/// Prototype of the reagent we're adding.
/// </summary>
[DataField(required: true)]
public ProtoId<ReagentPrototype> Reagent;
///<summary>
/// Solution we're looking for
/// </summary>
[DataField(required: true)]
public string Solution = "reagents";
///<summary>
/// A modifier for how much reagent we're creating.
/// </summary>
[DataField]
public float StrengthModifier = 1.0f;
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return prototype.Resolve(Reagent, out ReagentPrototype? proto)
? Loc.GetString("entity-effect-guidebook-add-to-solution-reaction",
("chance", Probability),
("reagent", proto.LocalizedName))
: null;
}
}