From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 20 Apr 2023 12:09:48 +0000 (+1000) Subject: Fix accidentally selling mobs (#15578) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=e75d9d7e33dd67eed6ca288953108b8b67703e47;p=space-station-14.git Fix accidentally selling mobs (#15578) --- diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index 6796cf2676..f9cc9e6dcf 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -405,8 +405,8 @@ public sealed partial class CargoSystem // - anything anchored (e.g. light fixtures) // - anything blacklisted (e.g. players). if (toSell.Contains(ent) || - (xformQuery.TryGetComponent(ent, out var xform) && xform.Anchored) || - !CanSell(ent, mobStateQuery)) + xformQuery.TryGetComponent(ent, out var xform) && + (xform.Anchored || !CanSell(ent, xform, mobStateQuery, xformQuery))) { continue; } @@ -423,7 +423,7 @@ public sealed partial class CargoSystem } } - private bool CanSell(EntityUid uid, EntityQuery mobStateQuery) + private bool CanSell(EntityUid uid, TransformComponent xform, EntityQuery mobStateQuery, EntityQuery xformQuery) { if (mobStateQuery.TryGetComponent(uid, out var mobState) && mobState.CurrentState != MobState.Dead) @@ -431,6 +431,14 @@ public sealed partial class CargoSystem return false; } + // Recursively check for mobs at any point. + var children = xform.ChildEnumerator; + while (children.MoveNext(out var child)) + { + if (!CanSell(child.Value, xformQuery.GetComponent(child.Value), mobStateQuery, xformQuery)) + return false; + } + return true; }