2024-03-28 01:48:37 +01:00
|
|
|
using Content.Server.Body.Systems;
|
2023-05-03 19:49:25 -07:00
|
|
|
using Content.Server.Nutrition.EntitySystems;
|
2023-09-05 09:55:10 +12:00
|
|
|
using Content.Shared.Chemistry.Components;
|
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2023-05-03 19:49:25 -07:00
|
|
|
using Content.Shared.Whitelist;
|
2024-03-28 01:48:37 +01:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
2021-11-11 16:10:57 -07:00
|
|
|
|
|
|
|
|
namespace Content.Server.Body.Components
|
|
|
|
|
{
|
2023-05-03 19:49:25 -07:00
|
|
|
[RegisterComponent, 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
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
/// <summary>
|
|
|
|
|
/// The solution inside of this stomach this transfers reagents to the body.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField]
|
|
|
|
|
public Entity<SolutionComponent>? Solution = null;
|
|
|
|
|
|
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]
|
2022-02-17 15:00:41 -07:00
|
|
|
public string BodySolutionName = BloodstreamComponent.DefaultChemicalsSolutionName;
|
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;
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|