Files
tbd-station-14/Content.Shared/Nutrition/Components/ThirstComponent.cs
PrPleGoo 1a13884961 Task/food hud (#19312)
* security HUD now shows a job icon on entities with a body

* thirst goggles

* set starting hud gear

* fix build

* remove from starting gear

* remove

* replace

* fix thirst and hunger icons

* update icons

* space

* space

* ]

* ]

* fix build

* fix comments

* fix

* spacing

* field

* move more namespaces

* use AutoGenerateComponentState

* comments

* fix build

* not all fields

* comments

* unpaused

* fix Dirty warning

---------

Co-authored-by: Slava0135 <super.novalskiy_0135@inbox.ru>
2023-09-23 16:14:06 +03:00

79 lines
2.3 KiB
C#

using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Alert;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Nutrition.Components;
[RegisterComponent, NetworkedComponent, Access(typeof(ThirstSystem))]
[AutoGenerateComponentState]
public sealed partial class ThirstComponent : Component
{
// Base stuff
[ViewVariables(VVAccess.ReadWrite)]
[DataField("baseDecayRate")]
[AutoNetworkedField]
public float BaseDecayRate = 0.1f;
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float ActualDecayRate;
// Thirst
[ViewVariables(VVAccess.ReadOnly)]
[AutoNetworkedField]
public ThirstThreshold CurrentThirstThreshold;
[ViewVariables(VVAccess.ReadOnly)]
[AutoNetworkedField]
public ThirstThreshold LastThirstThreshold;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("startingThirst")]
[AutoNetworkedField]
public float CurrentThirst = -1f;
/// <summary>
/// The time when the hunger will update next.
/// </summary>
[DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public TimeSpan NextUpdateTime;
/// <summary>
/// The time between each update.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public TimeSpan UpdateRate = TimeSpan.FromSeconds(1);
[DataField("thresholds")]
[AutoNetworkedField(cloneData: true)]
public Dictionary<ThirstThreshold, float> ThirstThresholds = new()
{
{ThirstThreshold.OverHydrated, 600.0f},
{ThirstThreshold.Okay, 450.0f},
{ThirstThreshold.Thirsty, 300.0f},
{ThirstThreshold.Parched, 150.0f},
{ThirstThreshold.Dead, 0.0f},
};
public static readonly Dictionary<ThirstThreshold, AlertType> ThirstThresholdAlertTypes = new()
{
{ThirstThreshold.Thirsty, AlertType.Thirsty},
{ThirstThreshold.Parched, AlertType.Parched},
{ThirstThreshold.Dead, AlertType.Parched},
};
}
[Flags]
public enum ThirstThreshold : byte
{
// Hydrohomies
Dead = 0,
Parched = 1 << 0,
Thirsty = 1 << 1,
Okay = 1 << 2,
OverHydrated = 1 << 3,
}