Skip to content

Commit

Permalink
Added sleeping on chairs (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
DexlerXD authored Feb 15, 2024
1 parent 674082e commit 43ef594
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
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 Content.Server/SS220/AddSleepAction/AddSleepActionSystem.cs
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
collection: MetalBreak
- type: StaticPrice
price: 10
- type: AddSleepAction #SS220-chair-sleep

- type: entity
name: chair
Expand Down

0 comments on commit 43ef594

Please sign in to comment.