2022-04-16 17:32:35 +12:00
|
|
|
using Content.Server.Botany.Components;
|
2022-02-06 13:14:41 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Botany.Systems;
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed partial class BotanySystem
|
2022-02-06 13:14:41 -07:00
|
|
|
{
|
|
|
|
|
public void ProduceGrown(EntityUid uid, ProduceComponent produce)
|
|
|
|
|
{
|
2022-04-16 17:32:35 +12:00
|
|
|
if (!TryGetSeed(produce, out var seed))
|
2022-02-06 13:14:41 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (TryComp(uid, out SpriteComponent? sprite))
|
|
|
|
|
{
|
|
|
|
|
sprite.LayerSetRSI(0, seed.PlantRsi);
|
|
|
|
|
sprite.LayerSetState(0, seed.PlantIconState);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 04:11:13 +03:00
|
|
|
var solutionContainer = _solutionContainerSystem.EnsureSolution(uid, produce.SolutionName);
|
|
|
|
|
|
|
|
|
|
solutionContainer.RemoveAllSolution();
|
2022-02-06 13:14:41 -07:00
|
|
|
foreach (var (chem, quantity) in seed.Chemicals)
|
|
|
|
|
{
|
|
|
|
|
var amount = FixedPoint2.New(quantity.Min);
|
|
|
|
|
if (quantity.PotencyDivisor > 0 && seed.Potency > 0)
|
|
|
|
|
amount += FixedPoint2.New(seed.Potency / quantity.PotencyDivisor);
|
|
|
|
|
amount = FixedPoint2.New((int) MathHelper.Clamp(amount.Float(), quantity.Min, quantity.Max));
|
2023-03-06 04:11:13 +03:00
|
|
|
solutionContainer.MaxVolume += amount;
|
|
|
|
|
solutionContainer.AddReagent(chem, amount);
|
2022-02-06 13:14:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|