Files
crystall-punk-14/Content.Shared/_CP14/WeatherEffect/Effects/RefillSolutions.cs
Red 322a3f11c1 Mini fix pack (#1440)
* Update CP14PriceScannerSystem.cs

* Update CP14PriceScannerSystem.cs

* fix #1435

* fix #1393
2025-06-18 12:37:18 +03:00

38 lines
1.2 KiB
C#

using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Nutrition.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared._CP14.WeatherEffect.Effects;
public sealed partial class RefillSolutions : CP14WeatherEffect
{
[DataField(required: true)]
public Dictionary<ProtoId<ReagentPrototype>, float> Reagents = new();
public override void ApplyEffect(IEntityManager entManager, IRobustRandom random, EntityUid target)
{
if (!random.Prob(Prob))
return;
if (!entManager.TryGetComponent<CP14WeatherRefillableComponent>(target, out var refillable))
return;
if (entManager.TryGetComponent<OpenableComponent>(target, out var openable) && !openable.Opened)
return;
var solutionSystem = entManager.System<SharedSolutionContainerSystem>();
solutionSystem.TryGetSolution(target, refillable.Solution, out var ent, out var solution);
if (ent is null)
return;
foreach (var r in Reagents)
{
solutionSystem.TryAddReagent(ent.Value, r.Key, r.Value);
}
}
}