mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description This reworks the narcolepsy system: - Before you actually fall asleep, you have a chance to see a warning popup and prepare for the nap. - If you go to sleep normally, and spend more time sleeping than the minimum time of a narcolepsy incident (10 seconds normally), your narcolepsy timer will reset, allowing you to make sure you won't fall asleep mid important work. - Your narcolepsy timer no longer decreases while you are sleeping. - However, if you do fall asleep for any reason while being close to a natural narcolepsy incident (close enough for a warning to be shown - 25 seconds by default), a narcolepsy incident will happen immediately. - When you wake up after sleeping enough to reset the narcolepsy timer, a popup is shown. <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/600bb287-1919-4f55-9672-313b55189aaa  </p> </details> # Changelog 🆑 - add: Narcolepsy has been reworked. You can now know when you're about to fall asleep, and can choose to go to sleep willingly to reset the narcolepsy timer and avoid an incident.
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Numerics;
|
|
|
|
namespace Content.Server.Traits.Assorted;
|
|
|
|
/// <summary>
|
|
/// This is used for the narcolepsy trait.
|
|
/// </summary>
|
|
[RegisterComponent, Access(typeof(NarcolepsySystem))]
|
|
public sealed partial class NarcolepsyComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// The random time between incidents, (min, max).
|
|
/// </summary>
|
|
[DataField("timeBetweenIncidents", required: true)]
|
|
public Vector2 TimeBetweenIncidents { get; private set; }
|
|
|
|
/// <summary>
|
|
/// The duration of incidents, (min, max).
|
|
/// </summary>
|
|
[DataField("durationOfIncident", required: true)]
|
|
public Vector2 DurationOfIncident { get; private set; }
|
|
|
|
[DataField]
|
|
public float NextIncidentTime;
|
|
|
|
/// <summary>
|
|
/// Locales for popups shown when the entity is about to fall asleep/is waking up.
|
|
/// They are fetched in the format of "(base)-(random number between 1 and count)", e.g. "narcolepsy-warning-popup-3".
|
|
/// </summary>
|
|
[DataField]
|
|
public string WarningLocaleBase = "narcolepsy-warning-popup", WakeupLocaleBase = "narcolepsy-wakeup-popup";
|
|
|
|
[DataField]
|
|
public int WarningLocaleCount = 5, WakeupLocaleCount = 3;
|
|
|
|
[DataField]
|
|
public float TimeBeforeWarning = 20f, WarningChancePerSecond = 0.25f;
|
|
|
|
public float LastWarningRollTime = float.MaxValue;
|
|
}
|