using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Chemistry.Components; using Content.Shared.Kitchen.Components; using JetBrains.Annotations; namespace Content.Shared.Kitchen.EntitySystems; [UsedImplicitly] public abstract class SharedReagentGrinderSystem : EntitySystem { [Dependency] private readonly SharedSolutionContainerSystem _solutionContainersSystem = default!; /// /// Gets the solutions from an entity using the specified Grinder program. /// /// The entity which we check for solutions. /// The grinder program. /// The solution received, or null if none. public Solution? GetGrinderSolution(Entity ent, GrinderProgram program) { if (!Resolve(ent, ref ent.Comp, false)) return null; switch (program) { case GrinderProgram.Grind: if (_solutionContainersSystem.TryGetSolution(ent.Owner, ent.Comp.GrindableSolution, out _, out var solution)) { return solution; } break; case GrinderProgram.Juice: return ent.Comp.JuiceSolution; } return null; } /// /// Checks whether the entity can be ground using a ReagentGrinder. /// /// The entity to check. /// True if it can be ground, otherwise false. public bool CanGrind(Entity ent) { if (!Resolve(ent, ref ent.Comp, false)) return false; if (ent.Comp.GrindableSolution == null) return false; return _solutionContainersSystem.TryGetSolution(ent.Owner, ent.Comp.GrindableSolution, out _, out _); } /// /// Checks whether the entity can be juiced using a ReagentGrinder. /// /// The entity to check. /// True if it can be juiced, otherwise false. public bool CanJuice(Entity ent) { if (!Resolve(ent, ref ent.Comp, false)) return false; return ent.Comp.JuiceSolution is not null; } }