forked from EphemeralSpace/ephemeral-space
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThirstComponent.cs
More file actions
85 lines (73 loc) · 2.52 KB
/
ThirstComponent.cs
File metadata and controls
85 lines (73 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Content.Shared.Alert;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Nutrition.Components;
[RegisterComponent, NetworkedComponent, Access(typeof(ThirstSystem))]
[AutoGenerateComponentState(fieldDeltas: true), AutoGenerateComponentPause]
public sealed partial class ThirstComponent : Component
{
// Base stuff
[ViewVariables(VVAccess.ReadWrite)]
[DataField("baseDecayRate")]
[AutoNetworkedField]
// ES START
public float BaseDecayRate = 0.3f;
// ES END
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float ActualDecayRate;
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public ThirstThreshold CurrentThirstThreshold;
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
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]
[AutoPausedField]
public TimeSpan NextUpdateTime;
/// <summary>
/// The time between each update.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField, AutoNetworkedField]
public TimeSpan UpdateRate = TimeSpan.FromSeconds(1);
[DataField("thresholds")]
[AutoNetworkedField]
// ES START
[Access(Other = AccessPermissions.ReadExecute)]
// ES END
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},
};
[DataField]
public ProtoId<AlertCategoryPrototype> ThirstyCategory = "Thirst";
public static readonly Dictionary<ThirstThreshold, ProtoId<AlertPrototype>> ThirstThresholdAlertTypes = new()
{
{ThirstThreshold.Thirsty, "Thirsty"},
{ThirstThreshold.Parched, "Parched"},
{ThirstThreshold.Dead, "Parched"},
};
}
[Flags]
public enum ThirstThreshold : byte
{
// Hydrohomies
Dead = 0,
Parched = 1 << 0,
Thirsty = 1 << 1,
Okay = 1 << 2,
OverHydrated = 1 << 3,
}