Metabolism tweaks / metabolism 4.0 (#5246)
* Metabolism tweaks
* use MetabolismArgs and convert ReagentEntityReactions into ReagentEffects
* fork forgor 💀
* fixes
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class AddToSolutionReaction : ReagentEffect
|
||||
{
|
||||
[DataField("solution")]
|
||||
private string _solution = "reagents";
|
||||
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
// TODO see if this is correct
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(args.SolutionEntity, _solution, out var solutionContainer))
|
||||
return;
|
||||
|
||||
if (EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryAddReagent(args.SolutionEntity, solutionContainer, args.Reagent.ID, args.Metabolizing, out var accepted))
|
||||
args.Source?.RemoveReagent(args.Reagent.ID, accepted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ExtinguishReaction : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out FlammableComponent? flammable)) return;
|
||||
|
||||
var flammableSystem = EntitySystem.Get<FlammableSystem>();
|
||||
flammableSystem.Extinguish(args.SolutionEntity, flammable);
|
||||
flammableSystem.AdjustFireStacks(args.SolutionEntity, -1.5f * (float) args.Metabolizing, flammable);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Content.Server/Chemistry/ReagentEffects/FlammableReaction.cs
Normal file
25
Content.Server/Chemistry/ReagentEffects/FlammableReaction.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class FlammableReaction : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out FlammableComponent? flammable)) return;
|
||||
|
||||
EntitySystem.Get<FlammableSystem>().AdjustFireStacks(args.SolutionEntity, args.Metabolizing.Float() / 5f, flammable);
|
||||
args.Source?.RemoveReagent(args.Reagent.ID, args.Metabolizing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
[DataField("damage", required: true)]
|
||||
public DamageSpecifier Damage = default!;
|
||||
|
||||
public override void Metabolize(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(solutionEntity, Damage, true);
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(args.SolutionEntity, Damage * args.Metabolizing, 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(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
var status = entityManager.EnsureComponent<MovespeedModifierMetabolismComponent>(solutionEntity);
|
||||
var status = args.EntityManager.EnsureComponent<MovespeedModifierMetabolismComponent>(args.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 * reagent.Quantity.Float());
|
||||
IncreaseTimer(status, StatusLifetime * args.Metabolizing.Float());
|
||||
|
||||
if (modified)
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(solutionEntity);
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(args.SolutionEntity);
|
||||
|
||||
}
|
||||
public void IncreaseTimer(MovespeedModifierMetabolismComponent status, float time)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -6,9 +7,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
public class PlantAdjustHealth : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.Health += Amount;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -6,9 +7,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
{
|
||||
public class PlantAdjustMutationLevel : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.MutationLevel += Amount * plantHolderComp.MutationMod;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustMutationMod : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.MutationMod += Amount;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustNutrition : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.AdjustNutrient(Amount);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustPests : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.PestLevel += Amount;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustToxins : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.Toxins += Amount;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustWater : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.AdjustWater(Amount);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAdjustWeeds : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.WeedLevel += Amount;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -7,9 +8,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[UsedImplicitly]
|
||||
public class PlantAffectGrowth : PlantAdjustAttribute
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!CanMetabolize(plantHolder, out var plantHolderComp, entityManager))
|
||||
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
|
||||
return;
|
||||
|
||||
plantHolderComp.AffectGrowth((int) Amount);
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[DataDefinition]
|
||||
public class PlantClonexadone : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(plantHolder, out PlantHolderComponent? plantHolderComp)
|
||||
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out PlantHolderComponent? plantHolderComp)
|
||||
|| plantHolderComp.Seed == null || plantHolderComp.Dead)
|
||||
return;
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[DataDefinition]
|
||||
public class PlantDiethylamine : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(plantHolder, out PlantHolderComponent? plantHolderComp)
|
||||
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out PlantHolderComponent? plantHolderComp)
|
||||
|| plantHolderComp.Seed == null || plantHolderComp.Dead ||
|
||||
plantHolderComp.Seed.Immutable)
|
||||
return;
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
|
||||
[DataDefinition]
|
||||
public class RobustHarvest : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(EntityUid plantHolder, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(plantHolder, out PlantHolderComponent? plantHolderComp)
|
||||
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out PlantHolderComponent? plantHolderComp)
|
||||
|| plantHolderComp.Seed == null || plantHolderComp.Dead ||
|
||||
plantHolderComp.Seed.Immutable)
|
||||
return;
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
[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(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (entityManager.TryGetComponent(solutionEntity, out HungerComponent? hunger))
|
||||
hunger.UpdateFood(NutritionFactor);
|
||||
if (args.EntityManager.TryGetComponent(args.SolutionEntity, out HungerComponent? hunger))
|
||||
hunger.UpdateFood(NutritionFactor * (float) args.Metabolizing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
public float HydrationFactor { get; set; } = 3.0f;
|
||||
|
||||
/// Satiate thirst if a ThirstComponent can be found
|
||||
public override void Metabolize(EntityUid solutionEntity, EntityUid organEntity, Solution.ReagentQuantity reagent, IEntityManager entityManager)
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (entityManager.TryGetComponent(solutionEntity, out ThirstComponent? thirst))
|
||||
thirst.UpdateThirst(HydrationFactor);
|
||||
if (args.EntityManager.TryGetComponent(args.SolutionEntity, out ThirstComponent? thirst))
|
||||
thirst.UpdateThirst(HydrationFactor * (float) args.Metabolizing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class WashCreamPieReaction : ReagentEffect
|
||||
{
|
||||
public override void Metabolize(ReagentEffectArgs args)
|
||||
{
|
||||
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out CreamPiedComponent? creamPied)) return;
|
||||
|
||||
EntitySystem.Get<CreamPieSystem>().SetCreamPied(args.SolutionEntity, creamPied, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user