Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports EE Narcolepsy #2197

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Conversation

Lyndomen
Copy link
Contributor

@Lyndomen Lyndomen commented Nov 15, 2024

About the PR

Ports EE's Simple-Station/Einstein-Engines#967

Before you actually fall asleep, you have a chance to see a warning popup and prepare for the nap.
Your narcolepsy timer no longer decreases while you are sleeping.
However, if you do fall asleep for any reason a narcolepsy incident will happen immediately.
When you wake up after sleeping, a popup is shown.

Why / Balance

Falling asleep randomly isnt always fun.

Technical details

Ports C#. EE has a different sleep system so this took a lil bit of work.

Media

image
image
image

Requirements

  • I have tested all added content and changes.
  • I have added media to this PR or it does not require an ingame showcase.

Breaking changes

Changelog
🆑

  • tweak: Narcolepsy rework has been ported from EE. 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.

@github-actions github-actions bot added Changes: C# Changes any cs files Changes: Localization Changes any ftl files labels Nov 15, 2024
@Lyndomen Lyndomen marked this pull request as ready for review November 17, 2024 02:10
@Lyndomen Lyndomen requested a review from a team as a code owner November 17, 2024 02:10
@Unkn0wnGh0st333
Copy link
Contributor

Does this include your sentence being cutoff when you fall asleep? I see a lot of narcoleptic players sad to not have that.

Content.Server/Traits/Assorted/NarcolepsyComponent.cs Outdated Show resolved Hide resolved
@@ -20,5 +20,21 @@ public sealed partial class NarcolepsyComponent : Component
[DataField("durationOfIncident", required: true)]
public Vector2 DurationOfIncident { get; private set; }

[DataField] // # DeltaV begin Narcolepsy port from EE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autopausedfield + timeoffsetserializer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this requires i turn a float into a timespan and i am lamenting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it's a fucking float-
why...
this should be stored as a timespan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it compares against a billion floats, and also compares against frameTime which is a float i cant turn into a TimeSpan

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it'd be better to get it as a TimeSpan.FromSeconds() inside of PrepareNextIncident() and just refactor everything else to use timespans (or get it from seconds for the ResetNarcolepsy method)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, upstream has NextIncidentTime as a float, and if this is absolutely a requirement ok- but this would be a better PR there then.

image

Refactoring the entire thing is beyond my ability- so please close this out if so

Content.Server/Traits/Assorted/NarcolepsyComponent.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Shared/Bed/Sleep/SleepingComponent.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
@MilonPL MilonPL added S: Awaiting Changes Do not merge due to requested changes and removed Status: Needs Review labels Nov 17, 2024
@Lyndomen Lyndomen requested a review from a team as a code owner November 18, 2024 00:54
@Lyndomen Lyndomen closed this Nov 18, 2024
@Lyndomen Lyndomen deleted the wakeupjoebiden branch November 18, 2024 14:10
@Lyndomen Lyndomen restored the wakeupjoebiden branch November 18, 2024 14:16
@Lyndomen Lyndomen reopened this Nov 18, 2024
@Lyndomen Lyndomen closed this Nov 20, 2024
@Lyndomen Lyndomen deleted the wakeupjoebiden branch November 20, 2024 20:36
@Lyndomen Lyndomen restored the wakeupjoebiden branch November 20, 2024 21:57
@Lyndomen Lyndomen reopened this Nov 20, 2024
@alterae
Copy link
Contributor

alterae commented Nov 26, 2024

plssss one of my main chars has narcolepsy and she is so, so much more playable on EE servers bc of this feature. i wholeheartedly support this PR and if there's some way i can actually help make it real pls let me know !!

@github-actions github-actions bot added the size/M 64-255 lines label Dec 10, 2024
@Lyndomen Lyndomen requested a review from deltanedas January 7, 2025 15:12
@github-actions github-actions bot added S: Needs Review and removed S: Awaiting Changes Do not merge due to requested changes labels Jan 7, 2025
@Lyndomen
Copy link
Contributor Author

Lyndomen commented Jan 7, 2025

Worth refactoring NextIncidentTime to float? Would be upstream chance

Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Server/Traits/Assorted/NarcolepsySystem.cs Outdated Show resolved Hide resolved
Content.Shared/Bed/Sleep/SleepingComponent.cs Outdated Show resolved Hide resolved
Comment on lines 339 to 352
public sealed class SleepStateChangedEvent : EntityEventArgs
{
public bool FellAsleep = false;

/// <summary>
/// The amount of time this entity slept for. Null if <see cref="FellAsleep"/> is true.
/// </summary>
public TimeSpan? TimeSlept;

public SleepStateChangedEvent(bool fellAsleep)
{
FellAsleep = fellAsleep;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont do this, add , TimeSpan? TimeSlept = null and instead of setting .TimeSlept = ... pass it as extra param
then add deltav comment on the line

Resources/Prototypes/DeltaV/Datasets/narcolepsywakeup.yml Outdated Show resolved Hide resolved
Resources/Prototypes/DeltaV/Datasets/narcolepsywarning.yml Outdated Show resolved Hide resolved
Content.Shared/Bed/Sleep/SleepingComponent.cs Outdated Show resolved Hide resolved
Comment on lines 331 to 354
public record struct SleepStateChangedEvent(bool FellAsleep);
public sealed class SleepStateChangedEvent : EntityEventArgs
{
public bool FellAsleep;

/// <summary>
/// The amount of time this entity slept for. Null if <see cref="FellAsleep"/> is true.
/// </summary>
public TimeSpan? TimeSlept;

/// <summary>
/// Initializes a new instance of the <see cref="SleepStateChangedEvent"/> class.
/// </summary>
/// <param name="fellAsleep">True if the entity fell asleep, false if it woke up.</param>
/// <param name="timeSlept">The duration of sleep, or null if the entity just fell asleep.</param>
public SleepStateChangedEvent(bool fellAsleep, TimeSpan? timeSlept = null) // DeltaV
{
FellAsleep = fellAsleep;
TimeSlept = timeSlept;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous review still stands, keep this a struct and just add a field to the list

@Lyndomen
Copy link
Contributor Author

maybe updated, im trying to figure out why i can still run around and emote while sleeping

@github-actions github-actions bot added the S: Merge Conflict Fix your PR! label Jan 29, 2025
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@dvir001
Copy link
Contributor

dvir001 commented Jan 29, 2025

maybe updated, im trying to figure out why i can still run around and emote while sleeping

Sleep walking trait when?

@Lyndomen Lyndomen marked this pull request as draft February 15, 2025 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes: C# Changes any cs files Changes: Localization Changes any ftl files Changes: YML Changes any yml files S: Merge Conflict Fix your PR! S: Needs Review size/M 64-255 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants