From 0c94a1c39e8fda6e1db73deda8b21ca850d27c81 Mon Sep 17 00:00:00 2001
From: Whatstone <166147148+whatston3@users.noreply.github.com>
Date: Tue, 10 Dec 2024 17:51:40 -0500
Subject: [PATCH] Restore AutoWakeUpComponent function (#2540)
* Restore AutoWakeUpComponent function
* AutoWakeUp: cure drowsiness
---
.../Bed/Sleep/AutoWakeUpComponent.cs | 13 -----------
Content.Shared/Bed/Sleep/SleepingSystem.cs | 23 +++++++++++++++++++
Content.Shared/_NF/Bed/AutoWakeUpComponent.cs | 19 +++++++++++++++
3 files changed, 42 insertions(+), 13 deletions(-)
delete mode 100644 Content.Shared/Bed/Sleep/AutoWakeUpComponent.cs
create mode 100644 Content.Shared/_NF/Bed/AutoWakeUpComponent.cs
diff --git a/Content.Shared/Bed/Sleep/AutoWakeUpComponent.cs b/Content.Shared/Bed/Sleep/AutoWakeUpComponent.cs
deleted file mode 100644
index f2fa75ca4a2..00000000000
--- a/Content.Shared/Bed/Sleep/AutoWakeUpComponent.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Content.Shared.FixedPoint;
-using Robust.Shared.GameStates;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
-
-namespace Content.Shared.Bed.Sleep;
-
-///
-/// Frontier - Added to AI to allow auto waking up after 5 secs.
-///
-[NetworkedComponent, RegisterComponent]
-public sealed partial class AutoWakeUpComponent : Component
-{
-}
diff --git a/Content.Shared/Bed/Sleep/SleepingSystem.cs b/Content.Shared/Bed/Sleep/SleepingSystem.cs
index 90e1fd38e86..a7b3cea0a7f 100644
--- a/Content.Shared/Bed/Sleep/SleepingSystem.cs
+++ b/Content.Shared/Bed/Sleep/SleepingSystem.cs
@@ -22,6 +22,7 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
+using Content.Shared._NF.Bed.Sleep; // Frontier
namespace Content.Shared.Bed.Sleep;
@@ -261,6 +262,10 @@ public bool TrySleeping(Entity ent)
return false;
EnsureComp(ent);
+ // Frontier: set auto-wakeup time
+ if (TryComp(ent, out var autoWakeUp))
+ autoWakeUp.NextWakeUp = _gameTiming.CurTime + autoWakeUp.Length;
+ // End Frontier: auto-wakeup
return true;
}
@@ -317,6 +322,24 @@ public void OnEmoteAttempt(Entity ent, ref EmoteAttemptEvent
{
args.Cancel();
}
+
+ ///
+ /// Frontier: handle auto-wakeup
+ ///
+ public override void Update(float frameTime)
+ {
+ var query = EntityQueryEnumerator();
+ var curTime = _gameTiming.CurTime;
+ while (query.MoveNext(out var uid, out var wakeUp, out var sleeping))
+ {
+ if (curTime >= wakeUp.NextWakeUp)
+ {
+ Wake((uid, sleeping));
+ _statusEffectsSystem.TryRemoveStatusEffect(uid, "Drowsiness");
+ }
+ }
+ }
+
}
diff --git a/Content.Shared/_NF/Bed/AutoWakeUpComponent.cs b/Content.Shared/_NF/Bed/AutoWakeUpComponent.cs
new file mode 100644
index 00000000000..63e9c2d755d
--- /dev/null
+++ b/Content.Shared/_NF/Bed/AutoWakeUpComponent.cs
@@ -0,0 +1,19 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared._NF.Bed.Sleep;
+
+///
+/// Frontier - Added to AI to allow auto waking up after 5 secs.
+///
+[NetworkedComponent, RegisterComponent]
+[AutoGenerateComponentState, AutoGenerateComponentPause(Dirty = true)]
+public sealed partial class AutoWakeUpComponent : Component
+{
+ // The length of time, in seconds, to sleep
+ [DataField]
+ public TimeSpan Length = TimeSpan.FromSeconds(5);
+
+ [ViewVariables]
+ [AutoNetworkedField, AutoPausedField]
+ public TimeSpan NextWakeUp = TimeSpan.Zero;
+}