Fix borg chassis gibbing not dropping items (#37276)

BeingGibbedEvent and TryEjectPowerCell
This commit is contained in:
Krunklehorn
2025-05-08 10:28:11 -04:00
committed by GitHub
parent 0973218054
commit 1ee9b25927
2 changed files with 30 additions and 9 deletions

View File

@@ -40,15 +40,8 @@ public sealed partial class BorgSystem
private void OnEjectBatteryBuiMessage(EntityUid uid, BorgChassisComponent component, BorgEjectBatteryBuiMessage args)
{
if (!TryComp<PowerCellSlotComponent>(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)

View File

@@ -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<BorgChassisComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<BorgChassisComponent, MindRemovedMessage>(OnMindRemoved);
SubscribeLocalEvent<BorgChassisComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<BorgChassisComponent, BeingGibbedEvent>(OnBeingGibbed);
SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
SubscribeLocalEvent<BorgChassisComponent, GetCharactedDeadIcEvent>(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<EntityUid>? ents)
{
ents = null;
if (!TryComp<PowerCellSlotComponent>(uid, out var slotComp) ||
!Container.TryGetContainer(uid, slotComp.CellSlotId, out var container) ||
!container.ContainedEntities.Any())
return false;
ents = Container.EmptyContainer(container);
return true;
}
/// <summary>
/// Activates a borg when a player occupies it
/// </summary>