* 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
76 lines
3.0 KiB
C#
76 lines
3.0 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using Content.Shared.Body.Metabolism;
|
|
using Content.Shared.Body.Networks;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.FixedPoint;
|
|
using Robust.Shared.Analyzers;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
|
|
|
namespace Content.Server.Body.Metabolism
|
|
{
|
|
/// <summary>
|
|
/// Handles metabolizing various reagents with given effects.
|
|
/// </summary>
|
|
[RegisterComponent, Friend(typeof(MetabolizerSystem))]
|
|
public class MetabolizerComponent : Component
|
|
{
|
|
public override string Name => "Metabolizer";
|
|
|
|
public float AccumulatedFrametime = 0.0f;
|
|
|
|
/// <summary>
|
|
/// How often to metabolize reagents, in seconds.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[DataField("updateFrequency")]
|
|
public float UpdateFrequency = 1.0f;
|
|
|
|
/// <summary>
|
|
/// From which solution will this metabolizer attempt to metabolize chemicals
|
|
/// </summary>
|
|
[DataField("solution")]
|
|
public string SolutionName { get; set; } = SharedBloodstreamComponent.DefaultSolutionName;
|
|
|
|
/// <summary>
|
|
/// Does this component use a solution on it's parent entity (the body) or itself
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Most things will use the parent entity (bloodstream).
|
|
/// </remarks>
|
|
[DataField("solutionOnBody")]
|
|
public bool SolutionOnBody = true;
|
|
|
|
/// <summary>
|
|
/// List of metabolizer types that this organ is. ex. Human, Slime, Felinid, w/e.
|
|
/// </summary>
|
|
[DataField("metabolizerTypes", customTypeSerializer:typeof(PrototypeIdHashSetSerializer<MetabolizerTypePrototype>))]
|
|
public HashSet<string>? MetabolizerTypes = null;
|
|
|
|
/// <summary>
|
|
/// A list of metabolism groups that this metabolizer will act on, in order of precedence.
|
|
/// </summary>
|
|
[DataField("groups", required: true)]
|
|
public List<MetabolismGroupEntry> MetabolismGroups = default!;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Contains data about how a metabolizer will metabolize a single group.
|
|
/// This allows metabolizers to remove certain groups much faster, or not at all.
|
|
/// </summary>
|
|
[DataDefinition]
|
|
public class MetabolismGroupEntry
|
|
{
|
|
[DataField("id", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<MetabolismGroupPrototype>))]
|
|
public string Id = default!;
|
|
|
|
[DataField("rateModifier")]
|
|
public FixedPoint2 MetabolismRateModifier = 1.0;
|
|
}
|
|
}
|