Add stunbaton charging, fix other recharger related bugs (#3239)
Co-authored-by: cyclowns <cyclowns@protonmail.ch>
This commit is contained in:
@@ -229,7 +229,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
/// </summary>
|
||||
protected abstract bool IsEntityCompatible(IEntity entity);
|
||||
|
||||
protected abstract BatteryComponent GetBatteryFrom(IEntity entity);
|
||||
protected abstract BatteryComponent? GetBatteryFrom(IEntity entity);
|
||||
|
||||
private void UpdateStatus()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Barrels;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -17,12 +17,29 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
|
||||
protected override bool IsEntityCompatible(IEntity entity)
|
||||
{
|
||||
return entity.HasComponent<ServerBatteryBarrelComponent>();
|
||||
return entity.TryGetComponent(out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null ||
|
||||
entity.TryGetComponent(out PowerCellSlotComponent? slot) && slot.HasCell;
|
||||
}
|
||||
|
||||
protected override BatteryComponent GetBatteryFrom(IEntity entity)
|
||||
protected override BatteryComponent? GetBatteryFrom(IEntity entity)
|
||||
{
|
||||
return entity.GetComponent<ServerBatteryBarrelComponent>().PowerCell;
|
||||
if (entity.TryGetComponent(out PowerCellSlotComponent? slot))
|
||||
{
|
||||
if (slot.Cell != null)
|
||||
{
|
||||
return slot.Cell;
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out ServerBatteryBarrelComponent? battery))
|
||||
{
|
||||
if (battery.PowerCell != null)
|
||||
{
|
||||
return battery.PowerCell;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, _powerCellContainer.ContainedEntity != null);
|
||||
_appearanceComponent?.SetData(AmmoVisuals.AmmoCount, ShotsLeft);
|
||||
_appearanceComponent?.SetData(AmmoVisuals.AmmoMax, Capacity);
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public override IEntity PeekAmmo()
|
||||
|
||||
Reference in New Issue
Block a user