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:
mirrorcult
2021-11-08 15:33:45 -07:00
committed by GitHub
parent f5b11d6af8
commit 31d622f941
53 changed files with 969 additions and 912 deletions

View File

@@ -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;
}
}
}

View File

@@ -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;
}