Change the hunger and thirst values of animals (#12780)

This commit is contained in:
dontbetank
2022-12-07 01:56:14 +03:00
committed by GitHub
parent d9a26c76e0
commit 0951db243e
5 changed files with 71 additions and 10 deletions

View File

@@ -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<HungerThreshold, float> HungerThresholds => _hungerThresholds;
private readonly Dictionary<HungerThreshold, float> _hungerThresholds = new()
[DataField("thresholds", customTypeSerializer: typeof(DictionarySerializer<HungerThreshold, float>))]
private Dictionary<HungerThreshold, float> _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);