]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Predict BedSystem (#41686)
authorPok <113675512+Pok27@users.noreply.github.com>
Wed, 3 Dec 2025 19:44:17 +0000 (21:44 +0200)
committerGitHub <noreply@github.com>
Wed, 3 Dec 2025 19:44:17 +0000 (19:44 +0000)
* BedSystem-move-to-shared

* dependency

* dirty!!!

Content.Client/Bed/BedSystem.cs [deleted file]
Content.Server/Bed/BedSystem.cs [deleted file]
Content.Shared/Bed/BedSystem.cs [moved from Content.Shared/Bed/SharedBedSystem.cs with 72% similarity]
Content.Shared/Bed/Components/StasisBedBuckledComponent.cs
Content.Shared/Bed/Components/StasisBedComponent.cs

diff --git a/Content.Client/Bed/BedSystem.cs b/Content.Client/Bed/BedSystem.cs
deleted file mode 100644 (file)
index 9c6f282..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-using Content.Shared.Bed;
-
-namespace Content.Client.Bed;
-
-public sealed class BedSystem : SharedBedSystem
-{
-
-}
diff --git a/Content.Server/Bed/BedSystem.cs b/Content.Server/Bed/BedSystem.cs
deleted file mode 100644 (file)
index f6c2862..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-using Content.Shared.Bed;
-using Content.Shared.Bed.Components;
-using Content.Shared.Bed.Sleep;
-using Content.Shared.Buckle.Components;
-using Content.Shared.Damage.Systems;
-using Content.Shared.Mobs.Systems;
-
-namespace Content.Server.Bed
-{
-    public sealed class BedSystem : SharedBedSystem
-    {
-        [Dependency] private readonly DamageableSystem _damageableSystem = default!;
-        [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
-
-        private EntityQuery<SleepingComponent> _sleepingQuery;
-
-        public override void Initialize()
-        {
-            base.Initialize();
-
-            _sleepingQuery = GetEntityQuery<SleepingComponent>();
-        }
-
-        public override void Update(float frameTime)
-        {
-            base.Update(frameTime);
-
-            var query = EntityQueryEnumerator<HealOnBuckleHealingComponent, HealOnBuckleComponent, StrapComponent>();
-            while (query.MoveNext(out var uid, out _, out var bedComponent, out var strapComponent))
-            {
-                if (Timing.CurTime < bedComponent.NextHealTime)
-                    continue;
-
-                bedComponent.NextHealTime += TimeSpan.FromSeconds(bedComponent.HealTime);
-
-                if (strapComponent.BuckledEntities.Count == 0)
-                    continue;
-
-                foreach (var healedEntity in strapComponent.BuckledEntities)
-                {
-                    if (_mobStateSystem.IsDead(healedEntity))
-                        continue;
-
-                    var damage = bedComponent.Damage;
-
-                    if (_sleepingQuery.HasComp(healedEntity))
-                        damage *= bedComponent.SleepMultiplier;
-
-                    _damageableSystem.TryChangeDamage(healedEntity, damage, true, origin: uid);
-                }
-            }
-        }
-    }
-}
similarity index 72%
rename from Content.Shared/Bed/SharedBedSystem.cs
rename to Content.Shared/Bed/BedSystem.cs
index 0518f05fdff3fd23ac5e636b91d84c7af2ff8508..229c3a9bed64766ec7725ce30925ac2cb5d10d37 100644 (file)
@@ -4,7 +4,9 @@ using Content.Shared.Bed.Sleep;
 using Content.Shared.Body.Events;
 using Content.Shared.Body.Systems;
 using Content.Shared.Buckle.Components;
+using Content.Shared.Damage.Systems;
 using Content.Shared.Emag.Systems;
+using Content.Shared.Mobs.Systems;
 using Content.Shared.Power;
 using Content.Shared.Power.EntitySystems;
 using Robust.Shared.Timing;
@@ -12,16 +14,20 @@ using Robust.Shared.Utility;
 
 namespace Content.Shared.Bed;
 
-public abstract class SharedBedSystem : EntitySystem
+public sealed class BedSystem : EntitySystem
 {
-    [Dependency] protected readonly IGameTiming Timing = default!;
     [Dependency] private readonly ActionContainerSystem _actConts = default!;
-    [Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
+    [Dependency] private readonly DamageableSystem _damageableSystem = default!;
     [Dependency] private readonly EmagSystem _emag = default!;
+    [Dependency] private readonly IGameTiming _timing = default!;
+    [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
+    [Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
     [Dependency] private readonly SharedMetabolizerSystem _metabolizer = default!;
     [Dependency] private readonly SharedPowerReceiverSystem _powerReceiver = default!;
     [Dependency] private readonly SleepingSystem _sleepingSystem = default!;
 
+    private EntityQuery<SleepingComponent> _sleepingQuery;
+
     public override void Initialize()
     {
         base.Initialize();
@@ -35,6 +41,8 @@ public abstract class SharedBedSystem : EntitySystem
         SubscribeLocalEvent<StasisBedComponent, GotEmaggedEvent>(OnStasisEmagged);
         SubscribeLocalEvent<StasisBedComponent, PowerChangedEvent>(OnPowerChanged);
         SubscribeLocalEvent<StasisBedBuckledComponent, GetMetabolicMultiplierEvent>(OnStasisGetMetabolicMultiplier);
+
+        _sleepingQuery = GetEntityQuery<SleepingComponent>();
     }
 
     private void OnHealMapInit(Entity<HealOnBuckleComponent> ent, ref MapInitEvent args)
@@ -46,7 +54,7 @@ public abstract class SharedBedSystem : EntitySystem
     private void OnStrapped(Entity<HealOnBuckleComponent> bed, ref StrappedEvent args)
     {
         EnsureComp<HealOnBuckleHealingComponent>(bed);
-        bed.Comp.NextHealTime = Timing.CurTime + TimeSpan.FromSeconds(bed.Comp.HealTime);
+        bed.Comp.NextHealTime = _timing.CurTime + TimeSpan.FromSeconds(bed.Comp.HealTime);
         _actionsSystem.AddAction(args.Buckle, ref bed.Comp.SleepAction, SleepingSystem.SleepActionId, bed);
         Dirty(bed);
 
@@ -62,7 +70,7 @@ public abstract class SharedBedSystem : EntitySystem
             _actionsSystem.RemoveAction(args.Buckle.Owner, bed.Comp.SleepAction);
             _sleepingSystem.TryWaking(args.Buckle.Owner);
         }
-        
+
         RemComp<HealOnBuckleHealingComponent>(bed);
     }
 
@@ -112,7 +120,7 @@ public abstract class SharedBedSystem : EntitySystem
         args.Multiplier *= stasis.Multiplier;
     }
 
-    protected void UpdateMetabolisms(Entity<StrapComponent?> ent)
+    private void UpdateMetabolisms(Entity<StrapComponent?> ent)
     {
         if (!Resolve(ent, ref ent.Comp, false))
             return;
@@ -122,4 +130,36 @@ public abstract class SharedBedSystem : EntitySystem
             _metabolizer.UpdateMetabolicMultiplier(buckledEntity);
         }
     }
+
+    public override void Update(float frameTime)
+    {
+        base.Update(frameTime);
+
+        var query = EntityQueryEnumerator<HealOnBuckleHealingComponent, HealOnBuckleComponent, StrapComponent>();
+        while (query.MoveNext(out var uid, out _, out var bedComponent, out var strapComponent))
+        {
+            if (_timing.CurTime < bedComponent.NextHealTime)
+                continue;
+
+            bedComponent.NextHealTime += TimeSpan.FromSeconds(bedComponent.HealTime);
+
+            Dirty(uid, bedComponent);
+
+            if (strapComponent.BuckledEntities.Count == 0)
+                continue;
+
+            foreach (var healedEntity in strapComponent.BuckledEntities)
+            {
+                if (_mobStateSystem.IsDead(healedEntity))
+                    continue;
+
+                var damage = bedComponent.Damage;
+
+                if (_sleepingQuery.HasComp(healedEntity))
+                    damage *= bedComponent.SleepMultiplier;
+
+                _damageableSystem.TryChangeDamage(healedEntity, damage, true, origin: uid);
+            }
+        }
+    }
 }
index 3a1c991b1eabebd4879c4dde2fd866586141ffdc..09759f71efa6a9fef6ae3626a618f411ecc417f4 100644 (file)
@@ -6,5 +6,5 @@ namespace Content.Shared.Bed.Components;
 /// Tracking component added to entities buckled to stasis beds.
 /// </summary>
 [RegisterComponent, NetworkedComponent]
-[Access(typeof(SharedBedSystem))]
+[Access(typeof(BedSystem))]
 public sealed partial class StasisBedBuckledComponent : Component;
index 97936261d60bd3da8ad50fffaf89a67979702c8a..fdc720c34fd168bf7845774c8fd93b8caa2e6f44 100644 (file)
@@ -7,7 +7,7 @@ namespace Content.Shared.Bed.Components;
 /// A <see cref="StrapComponent"/> that modifies a strapped entity's metabolic rate by the given multiplier
 /// </summary>
 [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
-[Access(typeof(SharedBedSystem))]
+[Access(typeof(BedSystem))]
 public sealed partial class StasisBedComponent : Component
 {
     /// <summary>