]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
FTL on a spaced tile yeets instead of gibs (#19883)
authorVaren <ychwack@hotmail.it>
Thu, 7 Sep 2023 02:13:31 +0000 (04:13 +0200)
committerGitHub <noreply@github.com>
Thu, 7 Sep 2023 02:13:31 +0000 (22:13 -0400)
* -Changes gibbing on FTL when on a spaced tile to yeeting on FTL if you're not buckled and on a space tile.

* -Throw relative to local shuttle position instead, fine for most cases and more performant
-Use throw code to throw.

* Blanks removal

woops

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Content.Server/Shuttles/Systems/ShuttleSystem.cs

index a10eddff1bf13d8c5b154ee5fa095b1536d51d60..e9895e89aaaaa5257c83b54c078bc265d2158506 100644 (file)
@@ -19,6 +19,7 @@ using Content.Shared.Buckle.Components;
 using Content.Shared.Doors.Components;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Shuttles.Components;
+using Content.Shared.Throwing;
 using JetBrains.Annotations;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
@@ -79,6 +80,7 @@ public sealed partial class ShuttleSystem
 
     private EntityQuery<BodyComponent> _bodyQuery;
     private EntityQuery<BuckleComponent> _buckleQuery;
+    private EntityQuery<PhysicsComponent> _physicsQuery;
     private EntityQuery<StatusEffectsComponent> _statusQuery;
     private EntityQuery<TransformComponent> _xformQuery;
 
@@ -86,6 +88,7 @@ public sealed partial class ShuttleSystem
     {
         _bodyQuery = GetEntityQuery<BodyComponent>();
         _buckleQuery = GetEntityQuery<BuckleComponent>();
+        _physicsQuery = GetEntityQuery<PhysicsComponent>();
         _statusQuery = GetEntityQuery<StatusEffectsComponent>();
         _xformQuery = GetEntityQuery<TransformComponent>();
 
@@ -473,24 +476,21 @@ public sealed partial class ShuttleSystem
     /// </summary>
     private void DoTheDinosaur(TransformComponent xform)
     {
-        // gib anything sitting outside aka on a lattice
-        // this is done before knocking since why knock down if they are gonna be gibbed too
-        var toGib = new ValueList<(EntityUid, BodyComponent)>();
-        GibKids(xform, ref toGib);
-
-        foreach (var (child, body) in toGib)
-        {
-            _bobby.GibBody(child, gibOrgans: false, body);
-        }
-
         // Get enumeration exceptions from people dropping things if we just paralyze as we go
         var toKnock = new ValueList<EntityUid>();
         KnockOverKids(xform, ref toKnock);
 
-        foreach (var child in toKnock)
+        if (TryComp<PhysicsComponent>(xform.GridUid, out var shuttleBody))
         {
-            if (!_statusQuery.TryGetComponent(child, out var status)) continue;
-            _stuns.TryParalyze(child, _hyperspaceKnockdownTime, true, status);
+
+            foreach (var child in toKnock)
+            {
+                if (!_statusQuery.TryGetComponent(child, out var status)) continue;
+                _stuns.TryParalyze(child, _hyperspaceKnockdownTime, true, status);
+
+                // If the guy we knocked down is on a spaced tile, throw them too
+                TossIfSpaced(shuttleBody, child);
+            }
         }
     }
 
@@ -507,25 +507,27 @@ public sealed partial class ShuttleSystem
         }
     }
 
-    private void GibKids(TransformComponent xform, ref ValueList<(EntityUid, BodyComponent)> toGib)
+    /// <summary>
+    /// Throws people who are standing on a spaced tile, tries to throw them towards a neighbouring space tile
+    /// </summary>
+    private void TossIfSpaced(PhysicsComponent shuttleBody, EntityUid tossed)
     {
-        // this is not recursive so people hiding in crates are spared, sadly
-        var childEnumerator = xform.ChildEnumerator;
-        while (childEnumerator.MoveNext(out var child))
-        {
-            if (!_xformQuery.TryGetComponent(child.Value, out var childXform))
-                continue;
 
-            // not something that can be gibbed
-            if (!_bodyQuery.TryGetComponent(child.Value, out var body))
-                continue;
+        if (!_xformQuery.TryGetComponent(tossed, out var childXform))
+            return;
 
-            // only gib if its on lattice/space
-            var tile = childXform.Coordinates.GetTileRef(EntityManager, _mapManager);
-            if (tile != null && !tile.Value.IsSpace())
-                continue;
+        if (!_physicsQuery.TryGetComponent(tossed, out var phys))
+            return;
+
+        // only toss if its on lattice/space
+        var tile = childXform.Coordinates.GetTileRef(EntityManager, _mapManager);
+
+        if (tile != null && tile.Value.IsSpace() && _mapManager.TryGetGrid(tile.Value.GridUid, out var grid))
+        {
+            Vector2 direction = -Vector2.UnitY;
 
-            toGib.Add((child.Value, body));
+            var foo = childXform.LocalPosition - shuttleBody.LocalCenter;
+            _throwing.TryThrow(tossed, foo.Normalized() * 10.0f, 50.0f);
         }
     }
 
index 46eb0fba80f883c3d2776b60139feb4ef9f9f8a1..cc93858948d48944546ef8150b84caf8f64be02a 100644 (file)
@@ -6,6 +6,7 @@ using Content.Server.Stunnable;
 using Content.Shared.GameTicking;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Shuttles.Systems;
+using Content.Shared.Throwing;
 using JetBrains.Annotations;
 using Robust.Server.GameObjects;
 using Robust.Shared.Configuration;
@@ -36,6 +37,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
     [Dependency] private readonly ShuttleConsoleSystem _console = default!;
     [Dependency] private readonly StationSystem _station = default!;
     [Dependency] private readonly StunSystem _stuns = default!;
+    [Dependency] private readonly ThrowingSystem _throwing = default!;
     [Dependency] private readonly ThrusterSystem _thruster = default!;
     [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
     [Dependency] private readonly IConfigurationManager _cfg = default!;