Power Rework (#863)

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-06-28 09:23:26 -06:00
committed by GitHub
parent ffe25de723
commit 23cc6b1d4e
154 changed files with 11253 additions and 3913 deletions

View File

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