From 894f66eb74309219ef7b0366e66aed43fcd116ef Mon Sep 17 00:00:00 2001 From: Vigers Ray Date: Mon, 21 Apr 2025 08:44:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D1=81=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B8=20=D0=BE=D0=B4=D0=BD=D0=BE=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BA=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Server/Bed/BedSystem.cs | 24 +++++++++---------- Content.Shared/Bed/Sleep/CanSleepComponent.cs | 12 ++++++++++ .../Buckle/SharedBuckleSystem.Buckle.cs | 5 +++- Resources/Changelog/ChangelogSunrise.yml | 13 ++++++++++ Resources/Prototypes/Actions/types.yml | 1 - 5 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 Content.Shared/Bed/Sleep/CanSleepComponent.cs diff --git a/Content.Server/Bed/BedSystem.cs b/Content.Server/Bed/BedSystem.cs index 46092b2f7e..0419f51438 100644 --- a/Content.Server/Bed/BedSystem.cs +++ b/Content.Server/Bed/BedSystem.cs @@ -3,6 +3,7 @@ using Content.Server.Bed.Components; using Content.Server.Body.Systems; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; +using Content.Shared.Actions; using Content.Shared.Bed; using Content.Shared.Bed.Sleep; using Content.Shared.Body.Components; @@ -11,6 +12,7 @@ using Content.Shared.Damage; using Content.Shared.Emag.Systems; using Content.Shared.Mobs.Systems; using Content.Shared.Power; +using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -25,6 +27,7 @@ namespace Content.Server.Bed [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly ActionContainerSystem _actionContainer = default!; public override void Initialize() { @@ -50,22 +53,19 @@ namespace Content.Server.Bed // Sunrise-Start private void OnStrapped(Entity bed, ref StrappedEvent args) { - EntityUid? action = null; - _actionsSystem.AddAction(args.Buckle, ref action, SleepingSystem.SleepActionId, args.Buckle.Owner); - if (action != null) - bed.Comp.SleepAction.TryAdd(args.Buckle.Owner, action.Value); - - // Single action entity, cannot strap multiple entities to the same bed. - //DebugTools.AssertEqual(args.Strap.Comp.BuckledEntities.Count, 1); + var canSleep = EnsureComp(args.Buckle); + _actionsSystem.AddAction(args.Buckle.Owner, ref canSleep.SleepAction, SleepingSystem.SleepActionId, args.Buckle.Owner); } private void OnUnstrapped(Entity bed, ref UnstrappedEvent args) { - if (bed.Comp.SleepAction.TryGetValue(args.Buckle.Owner, out var action)) - { - _actionsSystem.RemoveAction(args.Buckle.Owner, action); - bed.Comp.SleepAction.Remove(args.Buckle.Owner); - } + if (!TryComp(args.Buckle.Owner, out var canSleep)) + return; + + RemComp(args.Buckle.Owner); + _actionsSystem.RemoveAction(args.Buckle.Owner, canSleep.SleepAction); + if (canSleep.SleepAction != null) + _actionContainer.RemoveAction(canSleep.SleepAction.Value); } // Sunrise-End diff --git a/Content.Shared/Bed/Sleep/CanSleepComponent.cs b/Content.Shared/Bed/Sleep/CanSleepComponent.cs new file mode 100644 index 0000000000..6933c166e4 --- /dev/null +++ b/Content.Shared/Bed/Sleep/CanSleepComponent.cs @@ -0,0 +1,12 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Bed.Sleep; + +[NetworkedComponent, RegisterComponent] +[AutoGenerateComponentState, AutoGenerateComponentPause(Dirty = true)] +public sealed partial class CanSleepComponent : Component +{ + [DataField] + [AutoNetworkedField] + public EntityUid? SleepAction; +} diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index ef07a91042..9402b9935e 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -140,6 +140,9 @@ public abstract partial class SharedBuckleSystem } // Sunrise-Start + if (strapComp.BuckleOffsets.Count == 0) + return; + var isValid = false; foreach (var offset in strapComp.BuckleOffsets) { @@ -421,7 +424,7 @@ public abstract partial class SharedBuckleSystem if (TryComp(buckle, out var physics)) _physics.ResetDynamics(buckle, physics); - DebugTools.AssertEqual(xform.ParentUid, strap.Owner); + //DebugTools.AssertEqual(xform.ParentUid, strap.Owner); } /// diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index 0f3560546c..e31f7a84e9 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -15193,3 +15193,16 @@ id: 1039 time: '2025-04-21T04:45:52.0000000+00:00' url: https://github.com/space-sunrise/sunrise-station/pull/1888 +- author: VigersRay + changes: + - message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E \u043F\u0440\ + \u0438\u0441\u0442\u0435\u0433\u0438\u0432\u0430\u043D\u0438\u0435 \u043A \u043E\ + \u0431\u044B\u0447\u043D\u044B\u043C \u043A\u0440\u043E\u0432\u0430\u0442\u044F\ + \u043C." + type: Fix + - message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u044B \u0431\u0430\ + \u0433\u0438 \u0441 \u044D\u043A\u0448\u0435\u043D\u043E\u043C \u0441\u043D\u0430\ + ." + type: Fix + id: 1040 + time: '2025-04-21T05:44:21.909478+00:00' diff --git a/Resources/Prototypes/Actions/types.yml b/Resources/Prototypes/Actions/types.yml index dff04bd325..ed8ce963ac 100644 --- a/Resources/Prototypes/Actions/types.yml +++ b/Resources/Prototypes/Actions/types.yml @@ -307,7 +307,6 @@ description: Go to sleep. components: - type: InstantAction - temporary: true # Sunrise-Edit checkCanInteract: false checkConsciousness: false icon: { sprite: Clothing/Head/Hats/pyjamasyndicatered.rsi, state: icon }