]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix locks and deployable barriers (#14063)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Mon, 13 Feb 2023 12:22:37 +0000 (07:22 -0500)
committerGitHub <noreply@github.com>
Mon, 13 Feb 2023 12:22:37 +0000 (12:22 +0000)
Content.Server/Security/Components/DeployableBarrierComponent.cs
Content.Server/Security/Systems/DeployableBarrierSystem.cs
Content.Shared/Lock/LockSystem.cs

index 09753167f363234fb2f52959b554d80d38d6a883..6cf59204398ba01df3d60feef5ef257730ad37c9 100644 (file)
@@ -1,7 +1,7 @@
-namespace Content.Server.Security
+namespace Content.Server.Security.Components;
+
+[RegisterComponent]
+public sealed class DeployableBarrierComponent : Component
 {
-    [RegisterComponent]
-    public sealed class DeployableBarrierComponent : Component
-    {
-    }
 }
+
index db8465a619e180d7fdef63cae32df9a502b385f9..729159a8af54ce347d8af9209e7f42cc312dcbda 100644 (file)
@@ -1,4 +1,7 @@
+using Content.Server.Pulling;
+using Content.Server.Security.Components;
 using Content.Shared.Lock;
+using Content.Shared.Pulling.Components;
 using Content.Shared.Security;
 using Robust.Server.GameObjects;
 
@@ -7,6 +10,7 @@ namespace Content.Server.Security.Systems
     public sealed class DeployableBarrierSystem : EntitySystem
     {
         [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+        [Dependency] private readonly PullingSystem _pulling = default!;
 
         public override void Initialize()
         {
@@ -17,28 +21,28 @@ namespace Content.Server.Security.Systems
 
         private void OnStartup(EntityUid uid, DeployableBarrierComponent component, ComponentStartup args)
         {
-            if (!EntityManager.TryGetComponent(component.Owner, out LockComponent? lockComponent))
+            if (!TryComp(uid, out LockComponent? lockComponent))
                 return;
 
-            ToggleBarrierDeploy(uid, component, lockComponent.Locked);
+            ToggleBarrierDeploy(uid, lockComponent.Locked);
         }
 
         private void OnLockToggled(EntityUid uid, DeployableBarrierComponent component, ref LockToggledEvent args)
         {
-            ToggleBarrierDeploy(uid, component, args.Locked);
+            ToggleBarrierDeploy(uid, args.Locked);
         }
 
-        private void ToggleBarrierDeploy(EntityUid uid, DeployableBarrierComponent component, bool isDeployed)
+        private void ToggleBarrierDeploy(EntityUid uid, bool isDeployed)
         {
-            EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored = isDeployed;
-
-            if (!EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
-                return;
+            Transform(uid).Anchored = isDeployed;
 
             var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle;
-            _appearance.SetData(uid, DeployableBarrierVisuals.State, state, appearance);
+            _appearance.SetData(uid, DeployableBarrierVisuals.State, state);
+
+            if (TryComp<SharedPullableComponent>(uid, out var pullable))
+                _pulling.TryStopPull(pullable);
 
-            if (EntityManager.TryGetComponent(component.Owner, out PointLightComponent? light))
+            if (TryComp(uid, out PointLightComponent? light))
                 light.Enabled = isDeployed;
         }
     }
index b8ae9fdd0795499e2e94e153a5e8006645732d50..2e4bb935ad1958e17b64634d76ff162eb5854aca 100644 (file)
@@ -128,7 +128,8 @@ public sealed class LockSystem : EntitySystem
         _appearanceSystem.SetData(uid, StorageVisuals.Locked, true);
         Dirty(lockComp);
 
-        RaiseLocalEvent(uid, new LockToggledEvent(true), true);
+        var ev = new LockToggledEvent(true);
+        RaiseLocalEvent(uid, ref ev, true);
         return true;
     }
 
@@ -157,7 +158,8 @@ public sealed class LockSystem : EntitySystem
         _appearanceSystem.SetData(uid, StorageVisuals.Locked, false);
         Dirty(lockComp);
 
-        RaiseLocalEvent(uid, new LockToggledEvent(false), true);
+        var ev = new LockToggledEvent(false);
+        RaiseLocalEvent(uid, ref ev, true);
     }