* Prototype that's mostly borked rather than completely borked * ECS inserting mats * Partial ECS mostly done, needs cleanup and visualizer * Replace timers * Power visualizes at least * First ""working"" version * Clean up all lathes * Colors * Fix animation timing * Fixes greyscale, adds a bunch of colors * Give every (used) material a color * Made most lathes take long enough you can at least see there's some sort of animation * Insertion feedback popup * Sound for circuit printer and uniform printer * Fix queueing, optimize update * Remove mono crash * cleanup * Fix test failure * Techfab inserting sprite * Cleanup and commenting * Fix bug in CanProduce check * Fix UI resolves * Mirror review stuff
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using Content.Shared.Research.Prototypes;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Lathe
|
|
{
|
|
[NetworkedComponent()]
|
|
[Virtual]
|
|
public class SharedLatheComponent : Component
|
|
{
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
|
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
|
public bool CanProduce(LatheRecipePrototype recipe, int quantity = 1)
|
|
{
|
|
if (!_entMan.TryGetComponent(Owner, out SharedMaterialStorageComponent? storage)
|
|
|| !_entMan.TryGetComponent(Owner, out SharedLatheDatabaseComponent? database)) return false;
|
|
|
|
if (!database.Contains(recipe)) return false;
|
|
|
|
foreach (var (material, amount) in recipe.RequiredMaterials)
|
|
{
|
|
if (storage[material] < (amount * quantity)) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool CanProduce(string id, int quantity = 1)
|
|
{
|
|
return PrototypeManager.TryIndex(id, out LatheRecipePrototype? recipe) && CanProduce(recipe, quantity);
|
|
}
|
|
}
|
|
}
|