using Content.Shared._Sunrise.Bed; using Content.Shared.Actions; using Content.Shared.Bed.Components; using Content.Shared.Bed.Sleep; using Content.Shared.Buckle.Components; using Robust.Shared.Timing; namespace Content.Shared.Bed; public abstract class SharedBedSystem : EntitySystem { [Dependency] protected readonly IGameTiming Timing = default!; [Dependency] private readonly ActionContainerSystem _actConts = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SleepingSystem _sleepingSystem = default!; public override void Initialize() { base.Initialize(); // Sunrise-Start SubscribeLocalEvent(OnUnstrapped); SubscribeLocalEvent(OnStrapped); // Sunrise-End // Sunrise-Edit //SubscribeLocalEvent(OnHealMapInit); SubscribeLocalEvent(OnStrapped); SubscribeLocalEvent(OnUnstrapped); } // Sunrise-Start private void OnStrapped(Entity bed, ref StrappedEvent args) { 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 (!TryComp(args.Buckle.Owner, out var canSleep)) return; RemComp(args.Buckle.Owner); _actionsSystem.RemoveAction(args.Buckle.Owner, canSleep.SleepAction); _sleepingSystem.TryWaking(args.Buckle.Owner); if (canSleep.SleepAction != null) _actConts.RemoveAction(canSleep.SleepAction.Value); } // Sunrise-End // Sunrise-Edit // private void OnHealMapInit(Entity ent, ref MapInitEvent args) // { // _actConts.EnsureAction(ent.Owner, ref ent.Comp.SleepAction, SleepingSystem.SleepActionId); // Dirty(ent); // } private void OnStrapped(Entity bed, ref StrappedEvent args) { EnsureComp(bed); bed.Comp.NextHealTime = Timing.CurTime + TimeSpan.FromSeconds(bed.Comp.HealTime); } private void OnUnstrapped(Entity bed, ref UnstrappedEvent args) { // Sunrise-Edit //_actionsSystem.RemoveAction(args.Buckle.Owner, bed.Comp.SleepAction); //_sleepingSystem.TryWaking(args.Buckle.Owner); RemComp(bed); } }