using Robust.Shared.Containers;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Kitchen.Components;
+using Content.Server.Power.EntitySystems;
using Content.Server.UserInterface;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Popups;
using Content.Shared.Rejuvenate;
-using Content.Shared.UserInterface;
-using Robust.Server.GameObjects;
namespace Content.Server.PowerCell;
public sealed class PowerCellSystem : SharedPowerCellSystem
{
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ActivatableUISystem _activatable = default!;
+ [Dependency] private readonly BatterySystem _battery = default!;
[Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!;
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
- [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _sharedAppearanceSystem = default!;
if (!TryGetBatteryFromSlot(uid, out var battery, slot))
continue;
- if (battery.TryUseCharge(comp.DrawRate * frameTime))
+ if (_battery.TryUseCharge(uid, comp.DrawRate * frameTime, battery))
continue;
comp.Enabled = false;
if (slot.Item == null)
return;
- RaiseLocalEvent(slot.Item.Value, args, false);
+ RaiseLocalEvent(slot.Item.Value, args);
}
}
&& _itemSlotsSystem.TryGetSlot(container.Owner, slot.CellSlotId, out ItemSlot? itemSlot))
{
if (itemSlot.Item == uid)
- RaiseLocalEvent(container.Owner, new PowerCellChangedEvent(false), false);
+ RaiseLocalEvent(container.Owner, new PowerCellChangedEvent(false));
}
}
/// <param name="user">Popup to this user with the relevant detail if specified.</param>
public bool HasActivatableCharge(EntityUid uid, PowerCellDrawComponent? battery = null, PowerCellSlotComponent? cell = null, EntityUid? user = null)
{
+ // Default to true if we don't have the components.
if (!Resolve(uid, ref battery, ref cell, false))
- return false;
+ return true;
return HasCharge(uid, battery.UseRate, cell, user);
}
/// <param name="user">Popup to this user with the relevant detail if specified.</param>
public bool TryUseActivatableCharge(EntityUid uid, PowerCellDrawComponent? battery = null, PowerCellSlotComponent? cell = null, EntityUid? user = null)
{
+ // Default to true if we don't have the components.
if (!Resolve(uid, ref battery, ref cell, false))
- return false;
+ return true;
if (TryUseCharge(uid, battery.UseRate, cell, user))
{
return false;
}
- if (!battery.TryUseCharge(charge))
+ if (!_battery.TryUseCharge(uid, charge, battery))
{
if (user != null)
_popup.PopupEntity(Loc.GetString("power-cell-insufficient"), uid, user.Value);