mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
32 lines
1.4 KiB
C#
32 lines
1.4 KiB
C#
using Content.Shared.Body.Components;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
|
|
namespace Content.Shared.Body.Systems;
|
|
|
|
public sealed partial class StomachSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
|
|
|
public const string DefaultSolutionName = "stomach";
|
|
|
|
public bool CanTransferSolution(Entity<StomachComponent?, SolutionManagerComponent?> entity, Solution solution)
|
|
{
|
|
return Resolve(entity, ref entity.Comp1, logMissing: false)
|
|
&& _solutionContainerSystem.ResolveSolution((entity, entity.Comp2), DefaultSolutionName, ref entity.Comp1.Solution, out var stomachSolution)
|
|
// TODO: For now no partial transfers. Potentially change by design
|
|
&& stomachSolution.CanAddSolution(solution);
|
|
}
|
|
|
|
public bool TryTransferSolution(Entity<StomachComponent?, SolutionManagerComponent?> entity, Solution solution)
|
|
{
|
|
if (!Resolve(entity, ref entity.Comp1, logMissing: false)
|
|
|| !_solutionContainerSystem.ResolveSolution((entity, entity.Comp2), DefaultSolutionName, ref entity.Comp1.Solution)
|
|
|| !CanTransferSolution(entity, solution))
|
|
return false;
|
|
|
|
_solutionContainerSystem.TryAddSolution(entity.Comp1.Solution.Value, solution);
|
|
return true;
|
|
}
|
|
}
|