Metabolism 3.0 (#5157)
* basic system + convert all plantmetabolism * stragglers * convert all old metabolisms over * fix YAML errors + dumb serialization issue * remove unused thingy * reimplement * add organ type condition * organtype condition but real * cleanups + test fix * metabolismtype -> metabolizertype * solution resilience * fixes * serializer + use entityuid + hashset * this is apparently an entirely different thing * turns out it just works * oops
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using Content.Server.Botany.Components;
|
||||
using Content.Shared.Botany;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class PlantDiethylamine : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(plantHolder, out PlantHolderComponent? plantHolderComp)
|
||||
|| plantHolderComp.Seed == null || plantHolderComp.Dead ||
|
||||
plantHolderComp.Seed.Immutable)
|
||||
return;
|
||||
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
var chance = MathHelper.Lerp(15f, 125f, plantHolderComp.Seed.Lifespan) * 2f;
|
||||
if (random.Prob(chance))
|
||||
{
|
||||
plantHolderComp.CheckForDivergence(true);
|
||||
plantHolderComp.Seed.Lifespan++;
|
||||
}
|
||||
|
||||
chance = MathHelper.Lerp(15f, 125f, plantHolderComp.Seed.Endurance) * 2f;
|
||||
if (random.Prob(chance))
|
||||
{
|
||||
plantHolderComp.CheckForDivergence(true);
|
||||
plantHolderComp.Seed.Endurance++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user