]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Welding airlocks changes their layer (#13440)
authorRane <60792108+Elijahrane@users.noreply.github.com>
Mon, 13 Mar 2023 19:26:20 +0000 (15:26 -0400)
committerGitHub <noreply@github.com>
Mon, 13 Mar 2023 19:26:20 +0000 (15:26 -0400)
Content.Server/Tools/Components/LayerChangeOnWeldComponent.cs [new file with mode: 0644]
Content.Server/Tools/Systems/WeldableSystem.cs
Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml
Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_structureairlocks.yml

diff --git a/Content.Server/Tools/Components/LayerChangeOnWeldComponent.cs b/Content.Server/Tools/Components/LayerChangeOnWeldComponent.cs
new file mode 100644 (file)
index 0000000..d7da170
--- /dev/null
@@ -0,0 +1,17 @@
+using Content.Server.Tools.Systems;
+using Content.Shared.Physics;
+
+namespace Content.Server.Tools.Components;
+
+[RegisterComponent]
+[Access(typeof(WeldableSystem))]
+public sealed class LayerChangeOnWeldComponent : Component
+{
+    [DataField("unWeldedLayer")]
+    [ViewVariables]
+    public CollisionGroup UnWeldedLayer = CollisionGroup.AirlockLayer;
+
+    [DataField("weldedLayer")]
+    [ViewVariables]
+    public CollisionGroup WeldedLayer = CollisionGroup.WallLayer;
+}
index ced618ad024bc47daf58bd04e2153acc8c37d189..994a4c5e8fa2fa0c69ade9868743a877769cd314 100644 (file)
@@ -5,6 +5,8 @@ using Content.Shared.Examine;
 using Content.Shared.Interaction;
 using Content.Shared.Tools;
 using Content.Shared.Tools.Components;
+using Robust.Shared.Physics;
+using Robust.Shared.Physics.Systems;
 
 namespace Content.Server.Tools.Systems;
 
@@ -13,6 +15,7 @@ public sealed class WeldableSystem : EntitySystem
     [Dependency] private readonly IAdminLogManager _adminLogger = default!;
     [Dependency] private readonly SharedToolSystem _toolSystem = default!;
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+    [Dependency] private readonly SharedPhysicsSystem _physics = default!;
 
     public override void Initialize()
     {
@@ -20,6 +23,7 @@ public sealed class WeldableSystem : EntitySystem
         SubscribeLocalEvent<WeldableComponent, InteractUsingEvent>(OnInteractUsing);
         SubscribeLocalEvent<WeldableComponent, WeldFinishedEvent>(OnWeldFinished);
         SubscribeLocalEvent<WeldableComponent, WeldCancelledEvent>(OnWeldCanceled);
+        SubscribeLocalEvent<LayerChangeOnWeldComponent, WeldableChangedEvent>(OnWeldChanged);
         SubscribeLocalEvent<WeldableComponent, ExaminedEvent>(OnExamine);
     }
 
@@ -96,6 +100,26 @@ public sealed class WeldableSystem : EntitySystem
         component.BeingWelded = false;
     }
 
+    private void OnWeldChanged(EntityUid uid, LayerChangeOnWeldComponent component, WeldableChangedEvent args)
+    {
+        if (!TryComp<FixturesComponent>(uid, out var fixtures))
+            return;
+
+        foreach (var fixture in fixtures.Fixtures.Values)
+        {
+            switch (args.IsWelded)
+            {
+                case true when fixture.CollisionLayer == (int) component.UnWeldedLayer:
+                    _physics.SetCollisionLayer(uid, fixture, (int) component.WeldedLayer);
+                    break;
+
+                case false when fixture.CollisionLayer == (int) component.WeldedLayer:
+                    _physics.SetCollisionLayer(uid, fixture, (int) component.UnWeldedLayer);
+                    break;
+            }
+        }
+    }
+
     private void UpdateAppearance(EntityUid uid, WeldableComponent? component = null)
     {
         if (!Resolve(uid, ref component))
index ac839411534b1ee6fc90908b6194ffdd2bc0dfeb..6d7324edf76d5db4bc48b9b1ef2baacb1f56d006 100644 (file)
       - FullTileMask
       layer:     #removed opaque from the layer, allowing lasers to pass through glass airlocks
       - GlassAirlockLayer
+  - type: LayerChangeOnWeld
+    unWeldedLayer: GlassAirlockLayer
+    weldedLayer: GlassLayer
   - type: Construction
     graph: Airlock
     node: glassAirlock
index 87ae5619e0d28b9eb2597e90a7a9fee78664b1d3..97a4023a01d0efe52ae8889dcc2bd652bba10c28 100644 (file)
@@ -41,6 +41,9 @@
       - FullTileMask
       layer:
       - AirlockLayer
+  - type: LayerChangeOnWeld
+    unWeldedLayer: AirlockLayer
+    weldedLayer: WallLayer
   - type: ContainerFill
     containers:
       board: [ DoorElectronics ]