mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 23:02:22 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using Content.Server.Botany.Components;
|
|
using Content.Shared.EntityEffects;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.FixedPoint;
|
|
|
|
namespace Content.Server.Botany.Systems;
|
|
|
|
public sealed partial class BotanySystem
|
|
{
|
|
[Dependency] private SharedEntityEffectsSystem _entityEffects = default!;
|
|
|
|
public void ProduceGrown(EntityUid uid, ProduceComponent produce)
|
|
{
|
|
if (!TryGetSeed(produce, out var seed))
|
|
return;
|
|
|
|
foreach (var mutation in seed.Mutations)
|
|
{
|
|
if (mutation.AppliesToProduce)
|
|
_entityEffects.TryApplyEffect(uid, mutation.Effect);
|
|
}
|
|
|
|
_solutionContainerSystem.EnsureSolution(uid, produce.SolutionName, out var solution);
|
|
|
|
solution.Comp.Solution.RemoveAllSolution();
|
|
foreach (var (chem, quantity) in seed.Chemicals)
|
|
{
|
|
var amount = quantity.Min;
|
|
if (quantity.PotencyDivisor > 0 && seed.Potency > 0)
|
|
amount += seed.Potency / quantity.PotencyDivisor;
|
|
amount = FixedPoint2.Clamp(amount, quantity.Min, quantity.Max);
|
|
solution.Comp.Solution.MaxVolume += amount;
|
|
solution.Comp.Solution.AddReagent(chem, amount);
|
|
}
|
|
}
|
|
|
|
public void OnProduceExamined(EntityUid uid, ProduceComponent comp, ExaminedEvent args)
|
|
{
|
|
if (comp.Seed == null)
|
|
return;
|
|
|
|
using (args.PushGroup(nameof(ProduceComponent)))
|
|
{
|
|
foreach (var m in comp.Seed.Mutations)
|
|
{
|
|
// Don't show mutations that have no effect on produce (sentience)
|
|
if (!m.AppliesToProduce)
|
|
continue;
|
|
|
|
if (m.Description != null)
|
|
args.PushMarkup(Loc.GetString(m.Description));
|
|
}
|
|
}
|
|
}
|
|
}
|