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:
@@ -1,18 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustHealth : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp))
|
||||
return;
|
||||
|
||||
plantHolderComp.Health += Amount;
|
||||
plantHolderComp.CheckHealth();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustMutationLevel : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, false))
|
||||
return;
|
||||
|
||||
plantHolderComp.MutationLevel += Amount * plantHolderComp.MutationMod * customPlantMetabolism;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustMutationMod : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp))
|
||||
return;
|
||||
|
||||
plantHolderComp.MutationMod += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustNutrition : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, false))
|
||||
return;
|
||||
|
||||
plantHolderComp.AdjustNutrient(Amount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustPests : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp))
|
||||
return;
|
||||
|
||||
plantHolderComp.PestLevel += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustToxins : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, false))
|
||||
return;
|
||||
|
||||
plantHolderComp.Toxins += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustWater : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, false))
|
||||
return;
|
||||
|
||||
plantHolderComp.AdjustWater(Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AdjustWeeds : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, false))
|
||||
return;
|
||||
|
||||
plantHolderComp.WeedLevel += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AffectGrowth : AdjustAttribute
|
||||
{
|
||||
public override void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp))
|
||||
return;
|
||||
|
||||
plantHolderComp.AffectGrowth((int) Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Content.Server.Body.Metabolism;
|
||||
using Content.Shared.Body.Metabolism;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffectConditions
|
||||
{
|
||||
/// <summary>
|
||||
/// Requires that the metabolizing organ is or is not tagged with a certain MetabolizerType
|
||||
/// </summary>
|
||||
public class OrganType : ReagentEffectCondition
|
||||
{
|
||||
[DataField("type", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<MetabolizerTypePrototype>))]
|
||||
public string Type = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Does this condition pass when the organ has the type, or when it doesn't have the type?
|
||||
/// </summary>
|
||||
[DataField("shouldHave")]
|
||||
public bool ShouldHave = true;
|
||||
|
||||
public override bool Condition(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (entityManager.TryGetComponent<MetabolizerComponent>(organEntity, out var metabolizer)
|
||||
&& metabolizer.MetabolizerTypes != null
|
||||
&& metabolizer.MetabolizerTypes.Contains(Type))
|
||||
return ShouldHave;
|
||||
return !ShouldHave;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.Chemistry.ReagentEffectConditions
|
||||
[DataField("max")]
|
||||
public FixedPoint2 Max = FixedPoint2.MaxValue;
|
||||
|
||||
public override bool Condition(IEntity solutionEntity, Solution.ReagentQuantity reagent)
|
||||
public override bool Condition(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
return reagent.Quantity >= Min && reagent.Quantity < Max;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
[DataField("damage", required: true)]
|
||||
public DamageSpecifier Damage = default!;
|
||||
|
||||
public override void Metabolize(IEntity solutionEntity, Solution.ReagentQuantity amount)
|
||||
public override void Metabolize(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(solutionEntity.Uid, Damage, true);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(solutionEntity, Damage, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
/// <summary>
|
||||
/// Remove reagent at set rate, changes the movespeed modifiers and adds a MovespeedModifierMetabolismComponent if not already there.
|
||||
/// </summary>
|
||||
public override void Metabolize(IEntity solutionEntity, Solution.ReagentQuantity amount)
|
||||
public override void Metabolize(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
solutionEntity.EnsureComponent(out MovespeedModifierMetabolismComponent status);
|
||||
var status = entityManager.EnsureComponent<MovespeedModifierMetabolismComponent>(solutionEntity);
|
||||
|
||||
// Only refresh movement if we need to.
|
||||
var modified = !status.WalkSpeedModifier.Equals(WalkSpeedModifier) ||
|
||||
@@ -48,10 +48,10 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
status.WalkSpeedModifier = WalkSpeedModifier;
|
||||
status.SprintSpeedModifier = SprintSpeedModifier;
|
||||
|
||||
IncreaseTimer(status, StatusLifetime * amount.Quantity.Float());
|
||||
IncreaseTimer(status, StatusLifetime * reagent.Quantity.Float());
|
||||
|
||||
if (modified)
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(solutionEntity.Uid);
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(solutionEntity);
|
||||
|
||||
}
|
||||
public void IncreaseTimer(MovespeedModifierMetabolismComponent status, float time)
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Botany.Components;
|
||||
using Content.Shared.Botany;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class AdjustAttribute : IPlantMetabolizable
|
||||
public abstract class PlantAdjustAttribute : ReagentEffect
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
|
||||
@@ -21,13 +23,16 @@ namespace Content.Server.Chemistry.PlantMetabolism
|
||||
/// </summary>
|
||||
/// <param name="plantHolder">The entity holding the plant</param>
|
||||
/// <param name="plantHolderComponent">The plant holder component</param>
|
||||
/// <param name="entityManager">The entity manager</param>
|
||||
/// <param name="mustHaveAlivePlant">Whether to check if it has an alive plant or not</param>
|
||||
/// <returns></returns>
|
||||
public bool CanMetabolize(IEntity plantHolder, [NotNullWhen(true)] out PlantHolderComponent? plantHolderComponent, bool mustHaveAlivePlant = true)
|
||||
public bool CanMetabolize(EntityUid plantHolder, [NotNullWhen(true)] out PlantHolderComponent? plantHolderComponent,
|
||||
IEntityManager entityManager,
|
||||
bool mustHaveAlivePlant = true)
|
||||
{
|
||||
plantHolderComponent = null;
|
||||
|
||||
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out plantHolderComponent)
|
||||
if (!entityManager.TryGetComponent(plantHolder, out plantHolderComponent)
|
||||
|| mustHaveAlivePlant && (plantHolderComponent.Seed == null || plantHolderComponent.Dead))
|
||||
return false;
|
||||
|
||||
@@ -36,7 +41,5 @@ namespace Content.Server.Chemistry.PlantMetabolism
|
||||
|
||||
return !(Prob <= 0f) && _robustRandom.Prob(Prob);
|
||||
}
|
||||
|
||||
public abstract void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
public class PlantAdjustHealth : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.Health += Amount;
|
||||
plantHolderComp.CheckHealth();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
public class PlantAdjustMutationLevel : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.MutationLevel += Amount * plantHolderComp.MutationMod;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustMutationMod : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.MutationMod += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustNutrition : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.AdjustNutrient(Amount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustPests : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.PestLevel += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustToxins : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.Toxins += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustWater : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.AdjustWater(Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustWeeds : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.WeedLevel += Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantAffectGrowth : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.AffectGrowth((int) Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,23 @@
|
||||
using System;
|
||||
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.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class Clonexadone : IPlantMetabolizable
|
||||
public class PlantClonexadone : ReagentEffect
|
||||
{
|
||||
public void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1)
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out PlantHolderComponent? plantHolderComp)
|
||||
if (!entityManager.TryGetComponent(plantHolder, out PlantHolderComponent? plantHolderComp)
|
||||
|| plantHolderComp.Seed == null || plantHolderComp.Dead)
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -7,29 +9,29 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class Diethylamine : IPlantMetabolizable
|
||||
public class PlantDiethylamine : ReagentEffect
|
||||
{
|
||||
public void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1)
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out PlantHolderComponent? plantHolderComp)
|
||||
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 * customPlantMetabolism;
|
||||
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 * customPlantMetabolism;
|
||||
chance = MathHelper.Lerp(15f, 125f, plantHolderComp.Seed.Endurance) * 2f;
|
||||
if (random.Prob(chance))
|
||||
{
|
||||
plantHolderComp.CheckForDivergence(true);
|
||||
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -7,22 +9,22 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.PlantMetabolism
|
||||
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class RobustHarvest : IPlantMetabolizable
|
||||
public class RobustHarvest : ReagentEffect
|
||||
{
|
||||
public void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out PlantHolderComponent? plantHolderComp)
|
||||
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, 150f, plantHolderComp.Seed.Potency) * 3.5f * customPlantMetabolism;
|
||||
var chance = MathHelper.Lerp(15f, 150f, plantHolderComp.Seed.Potency) * 3.5f;
|
||||
|
||||
if (random.Prob(chance))
|
||||
{
|
||||
@@ -30,7 +32,7 @@ namespace Content.Server.Chemistry.PlantMetabolism
|
||||
plantHolderComp.Seed.Potency++;
|
||||
}
|
||||
|
||||
chance = MathHelper.Lerp(6f, 2f, plantHolderComp.Seed.Yield) * 0.15f * customPlantMetabolism;
|
||||
chance = MathHelper.Lerp(6f, 2f, plantHolderComp.Seed.Yield) * 0.15f;
|
||||
|
||||
if (random.Prob(chance))
|
||||
{
|
||||
@@ -15,12 +15,12 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
/// <summary>
|
||||
/// How much hunger is satiated when 1u of the reagent is metabolized
|
||||
/// </summary>
|
||||
[DataField("nutritionFactor")] public float NutritionFactor { get; set; } = 3.0f;
|
||||
[DataField("factor")] public float NutritionFactor { get; set; } = 3.0f;
|
||||
|
||||
//Remove reagent at set rate, satiate hunger if a HungerComponent can be found
|
||||
public override void Metabolize(IEntity solutionEntity, Solution.ReagentQuantity amount)
|
||||
public override void Metabolize(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (solutionEntity.TryGetComponent(out HungerComponent? hunger))
|
||||
if (entityManager.TryGetComponent(solutionEntity, out HungerComponent? hunger))
|
||||
hunger.UpdateFood(NutritionFactor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
/// How much thirst is satiated each metabolism tick. Not currently tied to
|
||||
/// rate or anything.
|
||||
[DataField("hydrationFactor")]
|
||||
[DataField("factor")]
|
||||
public float HydrationFactor { get; set; } = 3.0f;
|
||||
|
||||
/// Satiate thirst if a ThirstComponent can be found
|
||||
public override void Metabolize(IEntity solutionEntity, Solution.ReagentQuantity amount)
|
||||
public override void Metabolize(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
{
|
||||
if (solutionEntity.TryGetComponent(out ThirstComponent? thirst))
|
||||
if (entityManager.TryGetComponent(solutionEntity, out ThirstComponent? thirst))
|
||||
thirst.UpdateThirst(HydrationFactor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user