Add stunbaton charging, fix other recharger related bugs (#3239)

Co-authored-by: cyclowns <cyclowns@protonmail.ch>
This commit is contained in:
mirrorcult
2021-02-16 01:42:48 -07:00
committed by GitHub
parent 1ab8d3e6e9
commit 788ed8dbd1
3 changed files with 23 additions and 5 deletions

View File

@@ -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()
{

View File

@@ -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;
}
}
}

View File

@@ -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()