2025-06-09 07:36:04 -07:00
using Content.Shared.Body.Systems ;
2023-09-05 09:55:10 +12:00
using Content.Shared.Chemistry.Components ;
using Content.Shared.Chemistry.Reagent ;
2025-06-09 07:36:04 -07:00
using Content.Shared.Nutrition.EntitySystems ;
2023-05-03 19:49:25 -07:00
using Content.Shared.Whitelist ;
2025-06-09 07:36:04 -07:00
using Robust.Shared.GameStates ;
2024-03-28 01:48:37 +01:00
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom ;
2021-11-11 16:10:57 -07:00
2025-06-09 07:36:04 -07:00
namespace Content.Shared.Body.Components
2021-11-11 16:10:57 -07:00
{
2025-06-09 07:36:04 -07:00
[RegisterComponent, NetworkedComponent, Access(typeof(StomachSystem), typeof(FoodSystem))]
2023-08-22 18:14:33 -07:00
public sealed partial class StomachComponent : Component
2021-11-11 16:10:57 -07:00
{
2024-03-28 01:48:37 +01:00
/// <summary>
/// The next time that the stomach will try to digest its contents.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextUpdate ;
2021-11-11 16:10:57 -07:00
/// <summary>
2024-03-28 01:48:37 +01:00
/// The interval at which this stomach digests its contents.
2021-11-11 16:10:57 -07:00
/// </summary>
2023-12-29 04:47:43 -08:00
[DataField]
2024-03-28 01:48:37 +01:00
public TimeSpan UpdateInterval = TimeSpan . FromSeconds ( 1 ) ;
2021-11-11 16:10:57 -07:00
2025-07-05 20:59:31 -04:00
/// <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 ;
2023-12-29 04:47:43 -08:00
/// <summary>
/// The solution inside of this stomach this transfers reagents to the body.
/// </summary>
2025-01-12 07:22:29 +11:00
[ViewVariables]
public Entity < SolutionComponent > ? Solution ;
2023-12-29 04:47:43 -08:00
2021-11-11 16:10:57 -07:00
/// <summary>
/// What solution should this stomach push reagents into, on the body?
/// </summary>
2023-12-29 04:47:43 -08:00
[DataField]
2025-06-09 07:36:04 -07:00
public string BodySolutionName = "chemicals" ;
2021-11-11 16:10:57 -07:00
/// <summary>
2024-03-28 01:48:37 +01:00
/// Time between reagents being ingested and them being
2021-11-30 16:47:21 -07:00
/// transferred to <see cref="BloodstreamComponent"/>
2021-11-11 16:10:57 -07:00
/// </summary>
2023-12-29 04:47:43 -08:00
[DataField]
2024-03-28 01:48:37 +01:00
public TimeSpan DigestionDelay = TimeSpan . FromSeconds ( 20 ) ;
2021-11-11 16:10:57 -07:00
2023-05-03 19:49:25 -07:00
/// <summary>
/// A whitelist for what special-digestible-required foods this stomach is capable of eating.
/// </summary>
2023-12-29 04:47:43 -08:00
[DataField]
2023-05-03 19:49:25 -07:00
public EntityWhitelist ? SpecialDigestible = null ;
2025-05-16 12:05:49 -07:00
/// <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 ;
2021-11-11 16:10:57 -07:00
/// <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>
2022-02-16 00:23:23 -07:00
public sealed class ReagentDelta
2021-11-11 16:10:57 -07:00
{
2023-09-05 09:55:10 +12:00
public readonly ReagentQuantity ReagentQuantity ;
2024-03-28 01:48:37 +01:00
public TimeSpan Lifetime { get ; private set ; }
2021-11-11 16:10:57 -07:00
2023-09-05 09:55:10 +12:00
public ReagentDelta ( ReagentQuantity reagentQuantity )
2021-11-11 16:10:57 -07:00
{
2023-09-05 09:55:10 +12:00
ReagentQuantity = reagentQuantity ;
2024-03-28 01:48:37 +01:00
Lifetime = TimeSpan . Zero ;
2021-11-11 16:10:57 -07:00
}
2024-03-28 01:48:37 +01:00
public void Increment ( TimeSpan delta ) = > Lifetime + = delta ;
2021-11-11 16:10:57 -07:00
}
}
}