Metabolism refactor (#4395)

* metabolism -> respirator, add reageanteffect and reagenteffectcondition, start on metabolizercomp/system

* move LiverBehavior metabolism logic to Metabolizer

* minor tweaks and update all YAML

* how about actually taking conditions into account

* off by one

* removals

* reviews
This commit is contained in:
mirrorcult
2021-07-31 04:50:32 -07:00
committed by GitHub
parent dc18997bf8
commit 8aa4f998de
36 changed files with 572 additions and 558 deletions

View File

@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Shared.Chemistry.Reagent
{
/// <summary>
/// Reagent effects describe behavior that occurs when a reagent is ingested and metabolized by some
/// organ. They only trigger when their conditions (<see cref="ReagentEffectCondition"/>
/// </summary>
[ImplicitDataDefinitionForInheritors]
public abstract class ReagentEffect
{
/// <summary>
/// The list of conditions required for the effect to activate. Not required.
/// </summary>
[DataField("conditions")]
public ReagentEffectCondition[]? Conditions;
public abstract void Metabolize(IEntity solutionEntity, Solution.Solution.ReagentQuantity amount);
}
}

View File

@@ -0,0 +1,13 @@
using Content.Shared.Body.Components;
using Content.Shared.Chemistry.Solution;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Shared.Chemistry.Reagent
{
[ImplicitDataDefinitionForInheritors]
public abstract class ReagentEffectCondition
{
public abstract bool Condition(IEntity solutionEntity, Solution.Solution.ReagentQuantity reagent);
}
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using Content.Shared.Botany;
using Content.Shared.Chemistry.Metabolizable;
using Content.Shared.Chemistry.Reaction;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
@@ -16,9 +15,6 @@ namespace Content.Shared.Chemistry.Reagent
[DataDefinition]
public class ReagentPrototype : IPrototype
{
[DataField("metabolism", serverOnly: true)]
private readonly List<IMetabolizable> _metabolism = new() {new DefaultMetabolizable()};
[DataField("tileReactions", serverOnly: true)]
private readonly List<ITileReaction> _tileReactions = new(0);
@@ -60,7 +56,6 @@ namespace Content.Shared.Chemistry.Reagent
public string SpriteReplacementPath { get; } = string.Empty;
//List of metabolism effects this reagent has, should really only be used server-side.
public IReadOnlyList<IMetabolizable> Metabolism => _metabolism;
public IReadOnlyList<ITileReaction> TileReactions => _tileReactions;
public IReadOnlyList<IPlantMetabolizable> PlantMetabolism => _plantMetabolism;