fix: Adds a cooldown when attempting to wake up someone else (#11847)
This commit is contained in:
@@ -141,7 +141,15 @@ namespace Content.Server.Bed.Sleep
|
|||||||
private void OnInteractHand(EntityUid uid, SleepingComponent component, InteractHandEvent args)
|
private void OnInteractHand(EntityUid uid, SleepingComponent component, InteractHandEvent args)
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|
||||||
|
var curTime = _gameTiming.CurTime;
|
||||||
|
if (curTime < component.CoolDownEnd)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TryWaking(args.Target, user: args.User);
|
TryWaking(args.Target, user: args.User);
|
||||||
|
component.CoolDownEnd = curTime + component.Cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamined(EntityUid uid, SleepingComponent component, ExaminedEvent args)
|
private void OnExamined(EntityUid uid, SleepingComponent component, ExaminedEvent args)
|
||||||
|
|||||||
@@ -2,13 +2,22 @@ using Robust.Shared.GameStates;
|
|||||||
|
|
||||||
namespace Content.Shared.Bed.Sleep;
|
namespace Content.Shared.Bed.Sleep;
|
||||||
|
|
||||||
[NetworkedComponent, RegisterComponent]
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Added to entities when they go to sleep.
|
/// Added to entities when they go to sleep.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[NetworkedComponent, RegisterComponent]
|
||||||
public sealed class SleepingComponent : Component
|
public sealed class SleepingComponent : Component
|
||||||
{
|
{
|
||||||
// How much damage of any type it takes to wake this entity.
|
// How much damage of any type it takes to wake this entity.
|
||||||
[DataField("wakeThreshold")]
|
[DataField("wakeThreshold")]
|
||||||
public float WakeThreshold = 2;
|
public float WakeThreshold = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cooldown time between users hand interaction.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("cooldown")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public TimeSpan Cooldown = TimeSpan.FromSeconds(1f);
|
||||||
|
|
||||||
|
public TimeSpan CoolDownEnd;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user