diff --git a/Content.Server/GameObjects/Components/Body/Behavior/LungBehaviorComponent.cs b/Content.Server/GameObjects/Components/Body/Behavior/LungBehaviorComponent.cs index e9c6238ef7..019ed6a4dc 100644 --- a/Content.Server/GameObjects/Components/Body/Behavior/LungBehaviorComponent.cs +++ b/Content.Server/GameObjects/Components/Body/Behavior/LungBehaviorComponent.cs @@ -7,6 +7,8 @@ using Content.Server.Utility; using Content.Shared.Atmos; using Content.Shared.GameObjects.Components.Body.Behavior; using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.Timing; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -17,14 +19,20 @@ namespace Content.Server.GameObjects.Components.Body.Behavior [ComponentReference(typeof(SharedLungBehaviorComponent))] public class LungBehaviorComponent : SharedLungBehaviorComponent { + [Dependency] private readonly IGameTiming _gameTiming = default!; + private float _accumulatedFrameTime; + [ViewVariables] private TimeSpan _lastGaspPopupTime; + [ViewVariables] public GasMixture Air { get; set; } = default!; [ViewVariables] public override float Temperature => Air.Temperature; [ViewVariables] public override float Volume => Air.Volume; + [ViewVariables] public TimeSpan GaspPopupCooldown { get; private set; } + public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); @@ -42,11 +50,22 @@ namespace Content.Server.GameObjects.Components.Body.Behavior Atmospherics.NormalBodyTemperature, temp => Air.Temperature = temp, () => Air.Temperature); + + serializer.DataReadWriteFunction( + "gaspPopupCooldown", + 8f, + delay => GaspPopupCooldown = TimeSpan.FromSeconds(delay), + () => GaspPopupCooldown.TotalSeconds); } public override void Gasp() { - Owner.PopupMessageEveryone(Loc.GetString("Gasp")); + if (_gameTiming.CurTime >= _lastGaspPopupTime + GaspPopupCooldown) + { + _lastGaspPopupTime = _gameTiming.CurTime; + Owner.PopupMessageEveryone(Loc.GetString("Gasp")); + } + Inhale(CycleDelay); } diff --git a/Content.Server/GameObjects/EntitySystems/HeartSystem.cs b/Content.Server/GameObjects/EntitySystems/HeartSystem.cs index c0ef5b225f..e1da130db4 100644 --- a/Content.Server/GameObjects/EntitySystems/HeartSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HeartSystem.cs @@ -12,7 +12,7 @@ namespace Content.Server.GameObjects.EntitySystems { base.Initialize(); - UpdatesBefore.Add(typeof(SharedMetabolismSystem)); + UpdatesBefore.Add(typeof(MetabolismSystem)); } public override void Update(float frameTime) diff --git a/Content.Server/GameObjects/EntitySystems/LungSystem.cs b/Content.Server/GameObjects/EntitySystems/LungSystem.cs index 07c1414f58..6b04f5f0d1 100644 --- a/Content.Server/GameObjects/EntitySystems/LungSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/LungSystem.cs @@ -12,7 +12,7 @@ namespace Content.Server.GameObjects.EntitySystems { base.Initialize(); - UpdatesBefore.Add(typeof(SharedMetabolismSystem)); + UpdatesBefore.Add(typeof(MetabolismSystem)); } public override void Update(float frameTime) diff --git a/Content.Server/GameObjects/EntitySystems/MetabolismSystem.cs b/Content.Server/GameObjects/EntitySystems/MetabolismSystem.cs new file mode 100644 index 0000000000..7c33138ee6 --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/MetabolismSystem.cs @@ -0,0 +1,20 @@ +using Content.Server.GameObjects.Components.Metabolism; +using JetBrains.Annotations; +using Robust.Shared.GameObjects.Systems; + +namespace Content.Server.GameObjects.EntitySystems +{ + [UsedImplicitly] + public class MetabolismSystem : EntitySystem + { + public override void Update(float frameTime) + { + base.Update(frameTime); + + foreach (var metabolism in ComponentManager.EntityQuery()) + { + metabolism.Update(frameTime); + } + } + } +} diff --git a/Content.Shared/GameObjects/EntitySystems/SharedMetabolismSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedMetabolismSystem.cs deleted file mode 100644 index 827f933877..0000000000 --- a/Content.Shared/GameObjects/EntitySystems/SharedMetabolismSystem.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JetBrains.Annotations; -using Robust.Shared.GameObjects.Systems; - -namespace Content.Shared.GameObjects.EntitySystems -{ - [UsedImplicitly] - public class SharedMetabolismSystem : EntitySystem - { - // TODO move metabolism updates here from body entity system - } -}