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>
This commit is contained in:
PrPleGoo
2023-09-23 15:14:06 +02:00
committed by GitHub
parent dae18c981f
commit 1a13884961
19 changed files with 335 additions and 151 deletions

View File

@@ -9,12 +9,14 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic;
namespace Content.Shared.Nutrition.Components;
[RegisterComponent, NetworkedComponent, Access(typeof(HungerSystem))]
[AutoGenerateComponentState]
public sealed partial class HungerComponent : Component
{
/// <summary>
/// The current hunger amount of the entity
/// </summary>
[DataField("currentHunger"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float CurrentHunger;
/// <summary>
@@ -28,6 +30,7 @@ public sealed partial class HungerComponent : Component
/// Affected by <seealso cref="CurrentThreshold"/>
/// </summary>
[DataField("actualDecayRate"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float ActualDecayRate;
/// <summary>
@@ -35,18 +38,21 @@ public sealed partial class HungerComponent : Component
/// Stored in order to prevent recalculating
/// </summary>
[DataField("lastThreshold"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public HungerThreshold LastThreshold;
/// <summary>
/// The current hunger threshold the entity is at
/// </summary>
[DataField("currentThreshold"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public HungerThreshold CurrentThreshold;
/// <summary>
/// A dictionary relating HungerThreshold to the amount of <see cref="CurrentHunger"/> needed for each one
/// </summary>
[DataField("thresholds", customTypeSerializer: typeof(DictionarySerializer<HungerThreshold, float>))]
[AutoNetworkedField(cloneData: true)]
public Dictionary<HungerThreshold, float> Thresholds = new()
{
{ HungerThreshold.Overfed, 200.0f },
@@ -60,6 +66,7 @@ public sealed partial class HungerComponent : Component
/// A dictionary relating hunger thresholds to corresponding alerts.
/// </summary>
[DataField("hungerThresholdAlerts", customTypeSerializer: typeof(DictionarySerializer<HungerThreshold, AlertType>))]
[AutoNetworkedField(cloneData: true)]
public Dictionary<HungerThreshold, AlertType> HungerThresholdAlerts = new()
{
{ HungerThreshold.Peckish, AlertType.Peckish },
@@ -71,6 +78,7 @@ public sealed partial class HungerComponent : Component
/// A dictionary relating HungerThreshold to how much they modify <see cref="BaseDecayRate"/>.
/// </summary>
[DataField("hungerThresholdDecayModifiers", customTypeSerializer: typeof(DictionarySerializer<HungerThreshold, float>))]
[AutoNetworkedField(cloneData: true)]
public Dictionary<HungerThreshold, float> HungerThresholdDecayModifiers = new()
{
{ HungerThreshold.Overfed, 1.2f },
@@ -84,6 +92,7 @@ public sealed partial class HungerComponent : Component
/// The amount of slowdown applied when an entity is starving
/// </summary>
[DataField("starvingSlowdownModifier"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float StarvingSlowdownModifier = 0.75f;
/// <summary>
@@ -96,50 +105,17 @@ public sealed partial class HungerComponent : Component
/// 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);
}
[Serializable, NetSerializable]
public sealed class HungerComponentState : ComponentState
{
public float CurrentHunger;
public float BaseDecayRate;
public float ActualDecayRate;
public HungerThreshold LastHungerThreshold;
public HungerThreshold CurrentThreshold;
public float StarvingSlowdownModifier;
public TimeSpan NextUpdateTime;
public HungerComponentState(float currentHunger,
float baseDecayRate,
float actualDecayRate,
HungerThreshold lastHungerThreshold,
HungerThreshold currentThreshold,
float starvingSlowdownModifier,
TimeSpan nextUpdateTime)
{
CurrentHunger = currentHunger;
BaseDecayRate = baseDecayRate;
ActualDecayRate = actualDecayRate;
LastHungerThreshold = lastHungerThreshold;
CurrentThreshold = currentThreshold;
StarvingSlowdownModifier = starvingSlowdownModifier;
NextUpdateTime = nextUpdateTime;
}
}
[Serializable, NetSerializable]
public enum HungerThreshold : byte
{