diff --git a/Content.Shared/Bed/Sleep/SleepingSystem.cs b/Content.Shared/Bed/Sleep/SleepingSystem.cs index eca6a8befa..27e11bc878 100644 --- a/Content.Shared/Bed/Sleep/SleepingSystem.cs +++ b/Content.Shared/Bed/Sleep/SleepingSystem.cs @@ -59,6 +59,8 @@ public sealed partial class SleepingSystem : EntitySystem SubscribeLocalEvent(OnZombified); SubscribeLocalEvent(OnMobStateChanged); SubscribeLocalEvent(OnCompInit); + SubscribeLocalEvent(OnComponentRemoved); + SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(OnSpeakAttempt); SubscribeLocalEvent(OnSeeAttempt); SubscribeLocalEvent(OnPointAttempt); @@ -69,7 +71,6 @@ public sealed partial class SleepingSystem : EntitySystem SubscribeLocalEvent(OnInteractHand); SubscribeLocalEvent(OnStunEndAttempt); SubscribeLocalEvent(OnStandUpAttempt); - SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(OnStatusEffectApplied); SubscribeLocalEvent(OnUnbuckleAttempt); @@ -102,6 +103,12 @@ public sealed partial class SleepingSystem : EntitySystem TrySleeping((ent, ent.Comp)); } + private void OnRejuvenate(Entity ent, ref RejuvenateEvent args) + { + // WAKE UP!!! + RemComp(ent); + } + /// /// when sleeping component is added or removed, we do some stuff with other components. /// @@ -143,6 +150,16 @@ public sealed partial class SleepingSystem : EntitySystem _actionsSystem.AddAction(ent, ref ent.Comp.WakeAction, WakeActionId, ent); } + private void OnComponentRemoved(Entity ent, ref ComponentRemove args) + { + _actionsSystem.RemoveAction(ent.Owner, ent.Comp.WakeAction); + + var ev = new SleepStateChangedEvent(false); + RaiseLocalEvent(ent, ref ev); + + _blindableSystem.UpdateIsBlind(ent.Owner); + } + private void OnSpeakAttempt(Entity ent, ref SpeakAttemptEvent args) { // TODO reduce duplication of this behavior with MobStateSystem somehow @@ -187,11 +204,6 @@ public sealed partial class SleepingSystem : EntitySystem args.Cancelled = true; } - private void OnRejuvenate(Entity ent, ref RejuvenateEvent args) - { - TryWaking((ent.Owner, ent.Comp), true); - } - private void OnExamined(Entity ent, ref ExaminedEvent args) { if (args.IsInDetailsRange) @@ -275,17 +287,6 @@ public sealed partial class SleepingSystem : EntitySystem TrySleeping(args.Target); } - private void Wake(Entity ent) - { - RemComp(ent); - _actionsSystem.RemoveAction(ent.Owner, ent.Comp.WakeAction); - - var ev = new SleepStateChangedEvent(false); - RaiseLocalEvent(ent, ref ev); - - _blindableSystem.UpdateIsBlind(ent.Owner); - } - /// /// Try sleeping. Only mobs can sleep. /// @@ -345,8 +346,7 @@ public sealed partial class SleepingSystem : EntitySystem _popupSystem.PopupClient(Loc.GetString("wake-other-success", ("target", Identity.Entity(ent, EntityManager))), ent, user); } - Wake((ent, ent.Comp)); - return true; + return RemComp(ent); } ///