@@ -1,6 +1,6 @@
|
|||||||
using Content.Server.Nutrition.EntitySystems;
|
|
||||||
using Content.Shared.Chemistry.Reagent;
|
using Content.Shared.Chemistry.Reagent;
|
||||||
using Content.Shared.Nutrition.Components;
|
using Content.Shared.Nutrition.Components;
|
||||||
|
using Content.Shared.Nutrition.EntitySystems;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.Chemistry.ReagentEffects
|
namespace Content.Server.Chemistry.ReagentEffects
|
||||||
@@ -21,8 +21,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
|||||||
/// Satiate thirst if a ThirstComponent can be found
|
/// Satiate thirst if a ThirstComponent can be found
|
||||||
public override void Effect(ReagentEffectArgs args)
|
public override void Effect(ReagentEffectArgs args)
|
||||||
{
|
{
|
||||||
if (args.EntityManager.TryGetComponent(args.SolutionEntity, out ThirstComponent? thirst))
|
var uid = args.SolutionEntity;
|
||||||
EntitySystem.Get<ThirstSystem>().UpdateThirst(thirst, HydrationFactor);
|
if (args.EntityManager.TryGetComponent(uid, out ThirstComponent? thirst))
|
||||||
|
EntitySystem.Get<ThirstSystem>().ModifyThirst(uid, thirst, HydrationFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Content.Server.Medical
|
|||||||
_hunger.ModifyHunger(uid, hungerAdded, hunger);
|
_hunger.ModifyHunger(uid, hungerAdded, hunger);
|
||||||
|
|
||||||
if (TryComp<ThirstComponent>(uid, out var thirst))
|
if (TryComp<ThirstComponent>(uid, out var thirst))
|
||||||
_thirst.UpdateThirst(thirst, thirstAdded);
|
_thirst.ModifyThirst(uid, thirst, thirstAdded);
|
||||||
|
|
||||||
// It fully empties the stomach, this amount from the chem stream is relatively small
|
// It fully empties the stomach, this amount from the chem stream is relatively small
|
||||||
var solutionSize = (MathF.Abs(thirstAdded) + MathF.Abs(hungerAdded)) / 6;
|
var solutionSize = (MathF.Abs(thirstAdded) + MathF.Abs(hungerAdded)) / 6;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Content.Server.Nutrition.EntitySystems;
|
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
|
using Content.Shared.Nutrition.EntitySystems;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using JetBrains.Annotations;
|
|||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Server.Nutrition.EntitySystems;
|
namespace Content.Shared.Nutrition.EntitySystems;
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class ThirstSystem : EntitySystem
|
public sealed class ThirstSystem : EntitySystem
|
||||||
@@ -27,12 +27,12 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
_sawmill = Logger.GetSawmill("thirst");
|
_sawmill = Logger.GetSawmill("thirst");
|
||||||
|
|
||||||
SubscribeLocalEvent<ThirstComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
SubscribeLocalEvent<ThirstComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||||
SubscribeLocalEvent<ThirstComponent, ComponentStartup>(OnComponentStartup);
|
SubscribeLocalEvent<ThirstComponent, MapInitEvent>(OnMapInit);
|
||||||
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
|
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
SubscribeLocalEvent<ThirstComponent, EntityUnpausedEvent>(OnUnpaused);
|
SubscribeLocalEvent<ThirstComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args)
|
private void OnMapInit(EntityUid uid, ThirstComponent component, MapInitEvent args)
|
||||||
{
|
{
|
||||||
// Do not change behavior unless starting value is explicitly defined
|
// Do not change behavior unless starting value is explicitly defined
|
||||||
if (component.CurrentThirst < 0)
|
if (component.CurrentThirst < 0)
|
||||||
@@ -41,6 +41,7 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
(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.NextUpdateTime = _timing.CurTime;
|
||||||
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.
|
||||||
@@ -59,7 +60,7 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnRejuvenate(EntityUid uid, ThirstComponent component, RejuvenateEvent args)
|
private void OnRejuvenate(EntityUid uid, ThirstComponent component, RejuvenateEvent args)
|
||||||
{
|
{
|
||||||
ResetThirst(component);
|
SetThirst(uid, component, component.ThirstThresholds[ThirstThreshold.Okay]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThirstThreshold GetThirstThreshold(ThirstComponent component, float amount)
|
private ThirstThreshold GetThirstThreshold(ThirstComponent component, float amount)
|
||||||
@@ -78,14 +79,18 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateThirst(ThirstComponent component, float amount)
|
public void ModifyThirst(EntityUid uid, ThirstComponent component, float amount)
|
||||||
{
|
{
|
||||||
component.CurrentThirst = Math.Clamp(component.CurrentThirst + amount, component.ThirstThresholds[ThirstThreshold.Dead], component.ThirstThresholds[ThirstThreshold.OverHydrated]);
|
SetThirst(uid, component, component.CurrentThirst + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetThirst(ThirstComponent component)
|
public void SetThirst(EntityUid uid, ThirstComponent component, float amount)
|
||||||
{
|
{
|
||||||
component.CurrentThirst = component.ThirstThresholds[ThirstThreshold.Okay];
|
component.CurrentThirst = Math.Clamp(amount,
|
||||||
|
component.ThirstThresholds[ThirstThreshold.Dead],
|
||||||
|
component.ThirstThresholds[ThirstThreshold.OverHydrated]
|
||||||
|
);
|
||||||
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsMovementThreshold(ThirstThreshold threshold)
|
private bool IsMovementThreshold(ThirstThreshold threshold)
|
||||||
@@ -166,7 +171,7 @@ public sealed class ThirstSystem : EntitySystem
|
|||||||
|
|
||||||
thirst.NextUpdateTime += thirst.UpdateRate;
|
thirst.NextUpdateTime += thirst.UpdateRate;
|
||||||
|
|
||||||
UpdateThirst(thirst, -thirst.ActualDecayRate);
|
ModifyThirst(uid, thirst, -thirst.ActualDecayRate);
|
||||||
var calculatedThirstThreshold = GetThirstThreshold(thirst, thirst.CurrentThirst);
|
var calculatedThirstThreshold = GetThirstThreshold(thirst, thirst.CurrentThirst);
|
||||||
|
|
||||||
if (calculatedThirstThreshold == thirst.CurrentThirstThreshold)
|
if (calculatedThirstThreshold == thirst.CurrentThirstThreshold)
|
||||||
|
|||||||
Reference in New Issue
Block a user