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)
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;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
namespace Content.Server.Silicons.Borgs;
[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!;
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);
}
}
+ 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));
_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>