Files
space-station-14/Content.Shared/Body/Components/StomachComponent.cs
Nikovnik 0e76d4e5ed Metabolizing bloodstream (#35071)
* merged chemical into bloodstream

* changed injectable to bloodstream

* separated bleeding and direct blood removal

* removed blood gain from protein

* reduced blood gain from saline

* rejuvenating fills to reference volume

* fixed blood regulation

* red mead requires stirring to make

* reverted accidental line deletion

* cleared the skeletons from the closet

* additional routing

* field rename for xeno

* removed mention of chemstream and field rename for asteroid mobs

* minor optimizations

* Revert "reduced blood gain from saline"

This reverts commit de26fd1c0d.

* Revert "removed blood gain from protein"

This reverts commit 7a1648caf3.

* removed unused component fetch

* dead check mini refactor

* eventized blood exclusion

* quick fix

* Pain

* Commit of doom

* COMMIT

* renamed bloodMaxFactor to MaxVolumeFactor

* addressed floating point error

* returned vomiting chemicals

* blood reagent always skips the flush

* no need to mention blood reagent

* fixed passing blood flush

* adadsafasfasfassfasf

* whoops

* merge fixed injectors

* Revert "adadsafasfasfassfasf"

This reverts commit 0a5313a68d.

* simplify reagent removal

* enabled foreign blood transfusion

* Revert "COMMIT"

This reverts commit 19abd679cd.

* simplified reagent removal when modifying blood level

* removed misleading coment since the changes

* documented MetabolismExclusionEvent

* fixed negative negative modification of blood level

* fixed hypervolemia not normalizing

* constrainted blood modification

* returned bloodpack stop on fully healed

* forgot to stage this

* band aid for diona blood

* swapping GetReagent with GetPrototype

* optimize blood filtering

* multiplicative multi reagent blood level calculation

* removed unused stuff

* optimized blood calculation a tiny bit

* added per reagent blood regulation

* optimized (referenceVolume + bloodReagents) into referenceSolution

* polished coded to proper function

* forgot to stage rootable system change

* clean up, unnecessary GetBloodLevel call

* rename method name to TryAddToBloodstream instead of Chemicals

* placed overfill safety

* cleanup and final touches

* final touch

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2025-12-17 19:21:16 +00:00

93 lines
3.4 KiB
C#

using Content.Shared.Body.Systems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Whitelist;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Body.Components
{
[RegisterComponent, NetworkedComponent, Access(typeof(StomachSystem))]
public sealed partial class StomachComponent : Component
{
/// <summary>
/// The next time that the stomach will try to digest its contents.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextUpdate;
/// <summary>
/// The interval at which this stomach digests its contents.
/// </summary>
[DataField]
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(1);
/// <summary>
/// Multiplier applied to <see cref="UpdateInterval"/> for adjusting based on metabolic rate multiplier.
/// </summary>
[DataField]
public float UpdateIntervalMultiplier = 1f;
/// <summary>
/// Adjusted update interval based off of the multiplier value.
/// </summary>
[ViewVariables]
public TimeSpan AdjustedUpdateInterval => UpdateInterval * UpdateIntervalMultiplier;
/// <summary>
/// The solution inside of this stomach this transfers reagents to the body.
/// </summary>
[ViewVariables]
public Entity<SolutionComponent>? Solution;
/// <summary>
/// What solution should this stomach push reagents into, on the body?
/// </summary>
[DataField]
public string BodySolutionName = BloodstreamComponent.DefaultBloodSolutionName;
/// <summary>
/// Time between reagents being ingested and them being
/// transferred to <see cref="BloodstreamComponent"/>
/// </summary>
[DataField]
public TimeSpan DigestionDelay = TimeSpan.FromSeconds(20);
/// <summary>
/// A whitelist for what special-digestible-required foods this stomach is capable of eating.
/// </summary>
[DataField]
public EntityWhitelist? SpecialDigestible = null;
/// <summary>
/// Controls whitelist behavior. If true, this stomach can digest <i>only</i> food that passes the whitelist. If false, it can digest normal food <i>and</i> any food that passes the whitelist.
/// </summary>
[DataField]
public bool IsSpecialDigestibleExclusive = true;
/// <summary>
/// Used to track how long each reagent has been in the stomach
/// </summary>
[ViewVariables]
public readonly List<ReagentDelta> ReagentDeltas = new();
/// <summary>
/// Used to track quantity changes when ingesting & digesting reagents
/// </summary>
public sealed class ReagentDelta
{
public readonly ReagentQuantity ReagentQuantity;
public TimeSpan Lifetime { get; private set; }
public ReagentDelta(ReagentQuantity reagentQuantity)
{
ReagentQuantity = reagentQuantity;
Lifetime = TimeSpan.Zero;
}
public void Increment(TimeSpan delta) => Lifetime += delta;
}
}
}