gib hitchhikers on ftl (#19793)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-04 15:16:10 +01:00
committed by GitHub
parent 7368adcfa5
commit 9e60e0db88

View File

@@ -1,5 +1,7 @@
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Shared.Body.Components;
using Content.Shared.Maps;
using Content.Shared.Parallax; using Content.Shared.Parallax;
using Content.Shared.Shuttles.Systems; using Content.Shared.Shuttles.Systems;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
@@ -75,8 +77,18 @@ public sealed partial class ShuttleSystem
/// </summary> /// </summary>
public const float FTLDestinationMass = 500f; public const float FTLDestinationMass = 500f;
private EntityQuery<BodyComponent> _bodyQuery;
private EntityQuery<BuckleComponent> _buckleQuery;
private EntityQuery<StatusEffectsComponent> _statusQuery;
private EntityQuery<TransformComponent> _xformQuery;
private void InitializeFTL() private void InitializeFTL()
{ {
_bodyQuery = GetEntityQuery<BodyComponent>();
_buckleQuery = GetEntityQuery<BuckleComponent>();
_statusQuery = GetEntityQuery<StatusEffectsComponent>();
_xformQuery = GetEntityQuery<TransformComponent>();
SubscribeLocalEvent<StationGridAddedEvent>(OnStationGridAdd); SubscribeLocalEvent<StationGridAddedEvent>(OnStationGridAdd);
} }
@@ -461,34 +473,62 @@ public sealed partial class ShuttleSystem
/// </summary> /// </summary>
private void DoTheDinosaur(TransformComponent xform) private void DoTheDinosaur(TransformComponent xform)
{ {
var buckleQuery = GetEntityQuery<BuckleComponent>(); // gib anything sitting outside aka on a lattice
var statusQuery = GetEntityQuery<StatusEffectsComponent>(); // 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 // Get enumeration exceptions from people dropping things if we just paralyze as we go
var toKnock = new ValueList<EntityUid>(); var toKnock = new ValueList<EntityUid>();
KnockOverKids(xform, ref toKnock);
KnockOverKids(xform, buckleQuery, statusQuery, ref toKnock);
foreach (var child in 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); _stuns.TryParalyze(child, _hyperspaceKnockdownTime, true, status);
} }
} }
private void KnockOverKids(TransformComponent xform, EntityQuery<BuckleComponent> buckleQuery, EntityQuery<StatusEffectsComponent> statusQuery, ref ValueList<EntityUid> toKnock) private void KnockOverKids(TransformComponent xform, ref ValueList<EntityUid> toKnock)
{ {
// Not recursive because probably not necessary? If we need it to be that's why this method is separate. // Not recursive because probably not necessary? If we need it to be that's why this method is separate.
var childEnumerator = xform.ChildEnumerator; var childEnumerator = xform.ChildEnumerator;
while (childEnumerator.MoveNext(out var child)) 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; continue;
toKnock.Add(child.Value); 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));
}
}
/// <summary> /// <summary>
/// Tries to dock with the target grid, otherwise falls back to proximity. /// Tries to dock with the target grid, otherwise falls back to proximity.
/// </summary> /// </summary>