mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
* init * API * testing * review * return * good enough, fix later TODO: Proper prototype DoAfter Sounds * "proper" prototype TODO DoAfter Sprite * proper protos, mortar sprite * juicer sprites TODO: Juicer sounds Makeshift crafting recipes Add regular to vendors * sprite tweak * juicing sound, cleanup, construction * vendors * line end * attribution newline * small balance tweak * Let it be known id never webedit * meta * item size * review * handhelds * partial review * cache solution, looping * graph * review * popup --------- Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
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!;
|
|
|
|
/// <summary>
|
|
/// Gets the solutions from an entity using the specified Grinder program.
|
|
/// </summary>
|
|
/// <param name="ent">The entity which we check for solutions.</param>
|
|
/// <param name="program">The grinder program.</param>
|
|
/// <returns>The solution received, or null if none.</returns>
|
|
public Solution? GetGrinderSolution(Entity<ExtractableComponent?> 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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks whether the entity can be ground using a ReagentGrinder.
|
|
/// </summary>
|
|
/// <param name="ent">The entity to check.</param>
|
|
/// <returns>True if it can be ground, otherwise false.</returns>
|
|
public bool CanGrind(Entity<ExtractableComponent?> 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 _);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks whether the entity can be juiced using a ReagentGrinder.
|
|
/// </summary>
|
|
/// <param name="ent">The entity to check.</param>
|
|
/// <returns>True if it can be juiced, otherwise false.</returns>
|
|
public bool CanJuice(Entity<ExtractableComponent?> ent)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp, false))
|
|
return false;
|
|
|
|
return ent.Comp.JuiceSolution is not null;
|
|
}
|
|
}
|