From 9e60e0db8811712ba9930e2ac0c447010efe14bf Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:16:10 +0100 Subject: [PATCH] gib hitchhikers on ftl (#19793) Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Systems/ShuttleSystem.FasterThanLight.cs | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index e9b4283599..a10eddff1b 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -1,5 +1,7 @@ using Content.Server.Shuttles.Components; using Content.Server.Station.Systems; +using Content.Shared.Body.Components; +using Content.Shared.Maps; using Content.Shared.Parallax; using Content.Shared.Shuttles.Systems; using Content.Shared.StatusEffect; @@ -75,8 +77,18 @@ public sealed partial class ShuttleSystem /// public const float FTLDestinationMass = 500f; + private EntityQuery _bodyQuery; + private EntityQuery _buckleQuery; + private EntityQuery _statusQuery; + private EntityQuery _xformQuery; + private void InitializeFTL() { + _bodyQuery = GetEntityQuery(); + _buckleQuery = GetEntityQuery(); + _statusQuery = GetEntityQuery(); + _xformQuery = GetEntityQuery(); + SubscribeLocalEvent(OnStationGridAdd); } @@ -461,34 +473,62 @@ public sealed partial class ShuttleSystem /// private void DoTheDinosaur(TransformComponent xform) { - var buckleQuery = GetEntityQuery(); - var statusQuery = GetEntityQuery(); + // 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(); - - KnockOverKids(xform, buckleQuery, statusQuery, ref toKnock); + KnockOverKids(xform, ref toKnock); foreach (var child in toKnock) { - if (!statusQuery.TryGetComponent(child, out var status)) continue; + if (!_statusQuery.TryGetComponent(child, out var status)) continue; _stuns.TryParalyze(child, _hyperspaceKnockdownTime, true, status); } } - private void KnockOverKids(TransformComponent xform, EntityQuery buckleQuery, EntityQuery statusQuery, ref ValueList toKnock) + private void KnockOverKids(TransformComponent xform, ref ValueList toKnock) { // Not recursive because probably not necessary? If we need it to be that's why this method is separate. var childEnumerator = xform.ChildEnumerator; - while (childEnumerator.MoveNext(out var child)) { - if (!buckleQuery.TryGetComponent(child.Value, out var buckle) || buckle.Buckled) + if (!_buckleQuery.TryGetComponent(child.Value, out var buckle) || buckle.Buckled) continue; toKnock.Add(child.Value); } } + private void GibKids(TransformComponent xform, ref ValueList<(EntityUid, BodyComponent)> toGib) + { + // 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; + + // only gib if its on lattice/space + var tile = childXform.Coordinates.GetTileRef(EntityManager, _mapManager); + if (tile != null && !tile.Value.IsSpace()) + continue; + + toGib.Add((child.Value, body)); + } + } + /// /// Tries to dock with the target grid, otherwise falls back to proximity. ///