forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
Content.Server/SS220/AddSleepAction/AddSleepActionComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
namespace Content.Server.SS220.AddSleepAction; | ||
|
||
[RegisterComponent] | ||
public sealed partial class AddSleepActionComponent : Component | ||
{ | ||
[DataField("sleepAction")] public EntityUid? SleepAction; | ||
} |
34 changes: 34 additions & 0 deletions
34
Content.Server/SS220/AddSleepAction/AddSleepActionSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Content.Server.Actions; | ||
using Content.Server.Bed.Sleep; | ||
using Content.Shared.Buckle.Components; | ||
|
||
namespace Content.Server.SS220.AddSleepAction; | ||
|
||
public sealed class AddSleepActionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ActionsSystem _actionsSystem = default!; | ||
[Dependency] private readonly SleepingSystem _sleepingSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<AddSleepActionComponent, BuckleChangeEvent>(OnBuckleChanged); | ||
} | ||
|
||
private void OnBuckleChanged(EntityUid uid, AddSleepActionComponent component, BuckleChangeEvent args) | ||
{ | ||
// Partially yoinked from BedSystem | ||
|
||
if (args.Buckling) | ||
{ | ||
_actionsSystem.AddAction(args.BuckledEntity, ref component.SleepAction, SleepingSystem.SleepActionId, uid); | ||
return; | ||
} | ||
|
||
_actionsSystem.RemoveAction(args.BuckledEntity, component.SleepAction); | ||
_sleepingSystem.TryWaking(args.BuckledEntity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters