@@ -57,13 +57,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
public bool Activated => _activated;
|
||||
|
||||
[ViewVariables]
|
||||
private PowerCellComponent Cell
|
||||
private BatteryComponent Cell
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cellContainer.ContainedEntity == null) return null;
|
||||
|
||||
_cellContainer.ContainedEntity.TryGetComponent(out PowerCellComponent cell);
|
||||
_cellContainer.ContainedEntity.TryGetComponent(out BatteryComponent cell);
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
@@ -88,9 +88,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
public override bool OnHitEntities(IReadOnlyList<IEntity> entities)
|
||||
{
|
||||
var cell = Cell;
|
||||
if (!Activated || entities.Count == 0 || cell == null || !cell.CanDeductCharge(EnergyPerUse))
|
||||
if (!Activated || entities.Count == 0 || cell == null)
|
||||
return false;
|
||||
|
||||
if (!cell.TryUseCharge(EnergyPerUse))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/weapons/egloves.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
|
||||
|
||||
foreach (var entity in entities)
|
||||
@@ -108,9 +111,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
else
|
||||
stunnable.Slowdown(_slowdownTime);
|
||||
}
|
||||
|
||||
cell.DeductCharge(EnergyPerUse);
|
||||
if(cell.Charge < EnergyPerUse)
|
||||
if(cell.CurrentCharge < EnergyPerUse)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
|
||||
TurnOff();
|
||||
@@ -169,7 +170,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
return;
|
||||
}
|
||||
|
||||
if (cell.Charge < EnergyPerUse)
|
||||
if (cell.CurrentCharge < EnergyPerUse)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
|
||||
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
|
||||
@@ -192,7 +193,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
|
||||
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Using.HasComponent<PowerCellComponent>()) return false;
|
||||
if (!eventArgs.Using.HasComponent<BatteryComponent>()) return false;
|
||||
|
||||
if (Cell != null) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user