From: Krunklehorn <42424291+Krunklehorn@users.noreply.github.com> Date: Thu, 8 May 2025 14:28:11 +0000 (-0400) Subject: Fix borg chassis gibbing not dropping items (#37276) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=1ee9b259271de78c5797151ef9640092a76fca5b;p=space-station-14.git Fix borg chassis gibbing not dropping items (#37276) BeingGibbedEvent and TryEjectPowerCell --- diff --git a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs index 9f9977cddc..191b226421 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs @@ -40,15 +40,8 @@ public sealed partial class BorgSystem private void OnEjectBatteryBuiMessage(EntityUid uid, BorgChassisComponent component, BorgEjectBatteryBuiMessage args) { - if (!TryComp(uid, out var slotComp) || - !Container.TryGetContainer(uid, slotComp.CellSlotId, out var container) || - !container.ContainedEntities.Any()) - { - return; - } - - var ents = Container.EmptyContainer(container); - _hands.TryPickupAnyHand(args.Actor, ents.First()); + if (TryEjectPowerCell(uid, component, out var ents)) + _hands.TryPickupAnyHand(args.Actor, ents.First()); } private void OnSetNameBuiMessage(EntityUid uid, BorgChassisComponent component, BorgSetNameBuiMessage args) diff --git a/Content.Server/Silicons/Borgs/BorgSystem.cs b/Content.Server/Silicons/Borgs/BorgSystem.cs index 7c096f1729..e9d8a08c6f 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.cs @@ -1,11 +1,13 @@ using Content.Server.Actions; using Content.Server.Administration.Logs; using Content.Server.Administration.Managers; +using Content.Server.Body.Components; using Content.Server.DeviceNetwork.Systems; using Content.Server.Explosion.EntitySystems; using Content.Server.Hands.Systems; using Content.Server.PowerCell; using Content.Shared.Alert; +using Content.Shared.Containers.ItemSlots; using Content.Shared.Database; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; @@ -29,6 +31,8 @@ using Robust.Shared.Containers; using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Timing; +using System.Diagnostics.CodeAnalysis; +using System.Linq; namespace Content.Server.Silicons.Borgs; @@ -45,6 +49,7 @@ public sealed partial class BorgSystem : SharedBorgSystem [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly TriggerSystem _trigger = default!; [Dependency] private readonly HandsSystem _hands = default!; + [Dependency] private readonly ItemSlotsSystem _itemSlots = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly SharedMindSystem _mind = default!; [Dependency] private readonly MobStateSystem _mobState = default!; @@ -69,6 +74,7 @@ public sealed partial class BorgSystem : SharedBorgSystem SubscribeLocalEvent(OnMindAdded); SubscribeLocalEvent(OnMindRemoved); SubscribeLocalEvent(OnMobStateChanged); + SubscribeLocalEvent(OnBeingGibbed); SubscribeLocalEvent(OnPowerCellChanged); SubscribeLocalEvent(OnPowerCellSlotEmpty); SubscribeLocalEvent(OnGetDeadIC); @@ -195,6 +201,14 @@ public sealed partial class BorgSystem : SharedBorgSystem } } + private void OnBeingGibbed(EntityUid uid, BorgChassisComponent component, ref BeingGibbedEvent args) + { + TryEjectPowerCell(uid, component, out var _); + + _container.EmptyContainer(component.BrainContainer); + _container.EmptyContainer(component.ModuleContainer); + } + private void OnPowerCellChanged(EntityUid uid, BorgChassisComponent component, PowerCellChangedEvent args) { UpdateBatteryAlert((uid, component)); @@ -294,6 +308,20 @@ public sealed partial class BorgSystem : SharedBorgSystem _alerts.ShowAlert(ent, ent.Comp.BatteryAlert, chargePercent); } + public bool TryEjectPowerCell(EntityUid uid, BorgChassisComponent component, [NotNullWhen(true)] out List? ents) + { + ents = null; + + if (!TryComp(uid, out var slotComp) || + !Container.TryGetContainer(uid, slotComp.CellSlotId, out var container) || + !container.ContainedEntities.Any()) + return false; + + ents = Container.EmptyContainer(container); + + return true; + } + /// /// Activates a borg when a player occupies it ///