diff --git a/Content.Server/Nutrition/Components/HungerComponent.cs b/Content.Server/Nutrition/Components/HungerComponent.cs index 5d32b71be3..a02b620e4e 100644 --- a/Content.Server/Nutrition/Components/HungerComponent.cs +++ b/Content.Server/Nutrition/Components/HungerComponent.cs @@ -3,6 +3,7 @@ using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; using Content.Shared.Nutrition.Components; using Robust.Shared.Random; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic; namespace Content.Server.Nutrition.Components { @@ -44,11 +45,14 @@ namespace Content.Server.Nutrition.Components get => _currentHunger; set => _currentHunger = value; } - private float _currentHunger; + [DataField("startingHunger")] + private float _currentHunger = -1f; [ViewVariables(VVAccess.ReadOnly)] public Dictionary HungerThresholds => _hungerThresholds; - private readonly Dictionary _hungerThresholds = new() + + [DataField("thresholds", customTypeSerializer: typeof(DictionarySerializer))] + private Dictionary _hungerThresholds = new() { { HungerThreshold.Overfed, 200.0f }, { HungerThreshold.Okay, 150.0f }, @@ -123,10 +127,15 @@ namespace Content.Server.Nutrition.Components protected override void Startup() { base.Startup(); - // Similar functionality to SS13. Should also stagger people going to the chef. - _currentHunger = _random.Next( - (int)_hungerThresholds[HungerThreshold.Peckish] + 10, - (int)_hungerThresholds[HungerThreshold.Okay] - 1); + // Do not change behavior unless starting hunger is explicitly defined + if (_currentHunger < 0) + { + // Similar functionality to SS13. Should also stagger people going to the chef. + _currentHunger = _random.Next( + (int) _hungerThresholds[HungerThreshold.Peckish] + 10, + (int) _hungerThresholds[HungerThreshold.Okay] - 1); + } + _currentHungerThreshold = GetHungerThreshold(_currentHunger); _lastHungerThreshold = HungerThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects. HungerThresholdEffect(true); diff --git a/Content.Server/Nutrition/Components/ThirstComponent.cs b/Content.Server/Nutrition/Components/ThirstComponent.cs index aedf75a59f..d0fbd00abe 100644 --- a/Content.Server/Nutrition/Components/ThirstComponent.cs +++ b/Content.Server/Nutrition/Components/ThirstComponent.cs @@ -31,8 +31,10 @@ namespace Content.Server.Nutrition.Components public ThirstThreshold LastThirstThreshold; [ViewVariables(VVAccess.ReadWrite)] - public float CurrentThirst; + [DataField("startingThirst")] + public float CurrentThirst = -1f; + [DataField("thresholds")] public Dictionary ThirstThresholds { get; } = new() { {ThirstThreshold.OverHydrated, 600.0f}, diff --git a/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs b/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs index 902505b407..ab966e3e90 100644 --- a/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/ThirstSystem.cs @@ -30,9 +30,13 @@ namespace Content.Server.Nutrition.EntitySystems } private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args) { - component.CurrentThirst = _random.Next( - (int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10, - (int) component.ThirstThresholds[ThirstThreshold.Okay] - 1); + // Do not change behavior unless starting value is explicitly defined + if (component.CurrentThirst < 0) + { + component.CurrentThirst = _random.Next( + (int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10, + (int) component.ThirstThresholds[ThirstThreshold.Okay] - 1); + } component.CurrentThirstThreshold = GetThirstThreshold(component, component.CurrentThirst); component.LastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects. // TODO: Check all thresholds make sense and throw if they don't. diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml b/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml index d24e4f8207..1324c2f577 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml @@ -50,6 +50,22 @@ Piercing: 8 - type: Body prototype: Rat + - type: Hunger # probably should be prototyped + thresholds: + Overfed: 200 + Okay: 150 + Peckish: 100 + Starving: 50 + Dead: 0 + baseDecayRate: 0.01666666666 + - type: Thirst + thresholds: + OverHydrated: 600 + Okay: 450 + Thirsty: 300 + Parched: 150 + Dead: 0 + baseDecayRate: 0.1 - type: Appearance - type: DamageStateVisuals rotate: true @@ -209,6 +225,22 @@ Piercing: 3 - type: Body prototype: Rat + - type: Hunger # probably should be prototyped + thresholds: + Overfed: 200 + Okay: 150 + Peckish: 100 + Starving: 50 + Dead: 0 + baseDecayRate: 0.01666666666 + - type: Thirst + thresholds: + OverHydrated: 600 + Okay: 450 + Thirsty: 300 + Parched: 150 + Dead: 0 + baseDecayRate: 0.1 - type: Appearance - type: DamageStateVisuals rotate: true diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml index e13e013040..45625cae98 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml @@ -163,7 +163,21 @@ - type: InputMover - type: MobMover - type: Hunger + thresholds: # only animals and rats are derived from this prototype so let's override it here and in rats' proto + Overfed: 100 + Okay: 50 + Peckish: 25 + Starving: 10 + Dead: 0 + baseDecayRate: 0.00925925925926 # it is okay for animals to eat and drink less than humans, but more frequently - type: Thirst + thresholds: + OverHydrated: 200 + Okay: 150 + Thirsty: 100 + Parched: 50 + Dead: 0 + baseDecayRate: 0.04 - type: Barotrauma damage: types: