mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* port 35190 * HungerProduction * SolutionProducer * update * move to server * small tweak for Shearable * fix * ProductionAttemptEvent * EntityProducer * update EggLayer * EntityTable * no more actions on EggLayer * move popups to comp * kill EggLayer * new locale * rename field * upd * SatiationType * rename to SatiationProduction and lil docs * EntityQuery * more docs for god of docs * small fix * more queries
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using Content.Server.Animals.Components;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.FixedPoint;
|
|
|
|
namespace Content.Server.Animals.Systems;
|
|
|
|
/// <inheritdoc cref="SolutionProducerComponent"/>
|
|
public sealed partial class SolutionProducerSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedSolutionContainerSystem _solutionContainer = default!;
|
|
|
|
[Dependency] private EntityQuery<SolutionComponent> _solutionQuery;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnProduce(Entity<SolutionProducerComponent> ent, ref ProductionAttemptEvent args)
|
|
{
|
|
if (!_solutionQuery.TryComp(ent, out var solution))
|
|
return;
|
|
|
|
var amount = FixedPoint2.Min(solution.Solution.AvailableVolume, ent.Comp.Generated.Volume);
|
|
if (amount <= FixedPoint2.Zero)
|
|
return;
|
|
|
|
var generated = amount == ent.Comp.Generated.Volume
|
|
? ent.Comp.Generated
|
|
: ent.Comp.Generated.Clone().SplitSolution(amount);
|
|
|
|
if (!_solutionContainer.TryAddSolution((ent.Owner, solution), generated))
|
|
return;
|
|
|
|
args.Produced = true;
|
|
}
|
|
}
|