From 635057fb7ac3b477f751b32eed6077b8e702092a Mon Sep 17 00:00:00 2001 From: Francesco Date: Sat, 15 Oct 2022 06:13:24 +0200 Subject: [PATCH] fix: Adds a cooldown when attempting to wake up someone else (#11847) --- Content.Server/Bed/Sleep/SleepingSystem.cs | 8 ++++++++ Content.Shared/Bed/Sleep/SleepingComponent.cs | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Content.Server/Bed/Sleep/SleepingSystem.cs b/Content.Server/Bed/Sleep/SleepingSystem.cs index ae6cd54140..c7f7e4f036 100644 --- a/Content.Server/Bed/Sleep/SleepingSystem.cs +++ b/Content.Server/Bed/Sleep/SleepingSystem.cs @@ -141,7 +141,15 @@ namespace Content.Server.Bed.Sleep private void OnInteractHand(EntityUid uid, SleepingComponent component, InteractHandEvent args) { args.Handled = true; + + var curTime = _gameTiming.CurTime; + if (curTime < component.CoolDownEnd) + { + return; + } + TryWaking(args.Target, user: args.User); + component.CoolDownEnd = curTime + component.Cooldown; } private void OnExamined(EntityUid uid, SleepingComponent component, ExaminedEvent args) diff --git a/Content.Shared/Bed/Sleep/SleepingComponent.cs b/Content.Shared/Bed/Sleep/SleepingComponent.cs index b35132929c..76ced65b89 100644 --- a/Content.Shared/Bed/Sleep/SleepingComponent.cs +++ b/Content.Shared/Bed/Sleep/SleepingComponent.cs @@ -2,13 +2,22 @@ using Robust.Shared.GameStates; namespace Content.Shared.Bed.Sleep; -[NetworkedComponent, RegisterComponent] /// /// Added to entities when they go to sleep. /// +[NetworkedComponent, RegisterComponent] public sealed class SleepingComponent : Component { // How much damage of any type it takes to wake this entity. [DataField("wakeThreshold")] public float WakeThreshold = 2; + + /// + /// Cooldown time between users hand interaction. + /// + [DataField("cooldown")] + [ViewVariables(VVAccess.ReadWrite)] + public TimeSpan Cooldown = TimeSpan.FromSeconds(1f); + + public TimeSpan CoolDownEnd; }