Change the hunger and thirst values of animals (#12780)
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Shared.Movement.Components;
|
|||||||
using Content.Shared.Movement.Systems;
|
using Content.Shared.Movement.Systems;
|
||||||
using Content.Shared.Nutrition.Components;
|
using Content.Shared.Nutrition.Components;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic;
|
||||||
|
|
||||||
namespace Content.Server.Nutrition.Components
|
namespace Content.Server.Nutrition.Components
|
||||||
{
|
{
|
||||||
@@ -44,11 +45,14 @@ namespace Content.Server.Nutrition.Components
|
|||||||
get => _currentHunger;
|
get => _currentHunger;
|
||||||
set => _currentHunger = value;
|
set => _currentHunger = value;
|
||||||
}
|
}
|
||||||
private float _currentHunger;
|
[DataField("startingHunger")]
|
||||||
|
private float _currentHunger = -1f;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
public Dictionary<HungerThreshold, float> HungerThresholds => _hungerThresholds;
|
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.Overfed, 200.0f },
|
||||||
{ HungerThreshold.Okay, 150.0f },
|
{ HungerThreshold.Okay, 150.0f },
|
||||||
@@ -123,10 +127,15 @@ namespace Content.Server.Nutrition.Components
|
|||||||
protected override void Startup()
|
protected override void Startup()
|
||||||
{
|
{
|
||||||
base.Startup();
|
base.Startup();
|
||||||
|
// 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.
|
// Similar functionality to SS13. Should also stagger people going to the chef.
|
||||||
_currentHunger = _random.Next(
|
_currentHunger = _random.Next(
|
||||||
(int) _hungerThresholds[HungerThreshold.Peckish] + 10,
|
(int) _hungerThresholds[HungerThreshold.Peckish] + 10,
|
||||||
(int) _hungerThresholds[HungerThreshold.Okay] - 1);
|
(int) _hungerThresholds[HungerThreshold.Okay] - 1);
|
||||||
|
}
|
||||||
|
|
||||||
_currentHungerThreshold = GetHungerThreshold(_currentHunger);
|
_currentHungerThreshold = GetHungerThreshold(_currentHunger);
|
||||||
_lastHungerThreshold = HungerThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
_lastHungerThreshold = HungerThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
||||||
HungerThresholdEffect(true);
|
HungerThresholdEffect(true);
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ namespace Content.Server.Nutrition.Components
|
|||||||
public ThirstThreshold LastThirstThreshold;
|
public ThirstThreshold LastThirstThreshold;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float CurrentThirst;
|
[DataField("startingThirst")]
|
||||||
|
public float CurrentThirst = -1f;
|
||||||
|
|
||||||
|
[DataField("thresholds")]
|
||||||
public Dictionary<ThirstThreshold, float> ThirstThresholds { get; } = new()
|
public Dictionary<ThirstThreshold, float> ThirstThresholds { get; } = new()
|
||||||
{
|
{
|
||||||
{ThirstThreshold.OverHydrated, 600.0f},
|
{ThirstThreshold.OverHydrated, 600.0f},
|
||||||
|
|||||||
@@ -29,10 +29,14 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
|
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
}
|
}
|
||||||
private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args)
|
private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args)
|
||||||
|
{
|
||||||
|
// Do not change behavior unless starting value is explicitly defined
|
||||||
|
if (component.CurrentThirst < 0)
|
||||||
{
|
{
|
||||||
component.CurrentThirst = _random.Next(
|
component.CurrentThirst = _random.Next(
|
||||||
(int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
(int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
||||||
(int) component.ThirstThresholds[ThirstThreshold.Okay] - 1);
|
(int) component.ThirstThresholds[ThirstThreshold.Okay] - 1);
|
||||||
|
}
|
||||||
component.CurrentThirstThreshold = GetThirstThreshold(component, component.CurrentThirst);
|
component.CurrentThirstThreshold = GetThirstThreshold(component, component.CurrentThirst);
|
||||||
component.LastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
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.
|
// TODO: Check all thresholds make sense and throw if they don't.
|
||||||
|
|||||||
@@ -50,6 +50,22 @@
|
|||||||
Piercing: 8
|
Piercing: 8
|
||||||
- type: Body
|
- type: Body
|
||||||
prototype: Rat
|
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: Appearance
|
||||||
- type: DamageStateVisuals
|
- type: DamageStateVisuals
|
||||||
rotate: true
|
rotate: true
|
||||||
@@ -209,6 +225,22 @@
|
|||||||
Piercing: 3
|
Piercing: 3
|
||||||
- type: Body
|
- type: Body
|
||||||
prototype: Rat
|
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: Appearance
|
||||||
- type: DamageStateVisuals
|
- type: DamageStateVisuals
|
||||||
rotate: true
|
rotate: true
|
||||||
|
|||||||
@@ -163,7 +163,21 @@
|
|||||||
- type: InputMover
|
- type: InputMover
|
||||||
- type: MobMover
|
- type: MobMover
|
||||||
- type: Hunger
|
- 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
|
- type: Thirst
|
||||||
|
thresholds:
|
||||||
|
OverHydrated: 200
|
||||||
|
Okay: 150
|
||||||
|
Thirsty: 100
|
||||||
|
Parched: 50
|
||||||
|
Dead: 0
|
||||||
|
baseDecayRate: 0.04
|
||||||
- type: Barotrauma
|
- type: Barotrauma
|
||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
|
|||||||
Reference in New Issue
Block a user