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;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Projectiles;
@@ -33,7 +33,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
[ViewVariables] private string _ammoPrototype;
[ViewVariables] public IEntity PowerCellEntity => _powerCellContainer.ContainedEntity;
public PowerCellComponent PowerCell => _powerCellContainer.ContainedEntity.GetComponent<PowerCellComponent>();
public BatteryComponent PowerCell => _powerCellContainer.ContainedEntity.GetComponent<BatteryComponent>();
private ContainerSlot _powerCellContainer;
private ContainerSlot _ammoContainer;
private string _powerCellPrototype;
@@ -50,7 +50,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return 0;
}
return (int) Math.Ceiling(powerCell.GetComponent<PowerCellComponent>().Charge / _baseFireCost);
return (int) Math.Ceiling(powerCell.GetComponent<BatteryComponent>().CurrentCharge / _baseFireCost);
}
}
@@ -65,7 +65,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return 0;
}
return (int) Math.Ceiling(powerCell.GetComponent<PowerCellComponent>().Capacity / _baseFireCost);
return (int) Math.Ceiling((float) (powerCell.GetComponent<BatteryComponent>().MaxCharge / _baseFireCost));
}
}
@@ -144,8 +144,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return null;
}
var capacitor = powerCellEntity.GetComponent<PowerCellComponent>();
if (capacitor.Charge < _lowerChargeLimit)
var capacitor = powerCellEntity.GetComponent<BatteryComponent>();
if (capacitor.CurrentCharge < _lowerChargeLimit)
{
return null;
}
@@ -153,8 +153,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
// Can fire confirmed
// Multiply the entity's damage / whatever by the percentage of charge the shot has.
IEntity entity;
var chargeChange = Math.Min(capacitor.Charge, _baseFireCost);
capacitor.DeductCharge(chargeChange);
var chargeChange = Math.Min(capacitor.CurrentCharge, _baseFireCost);
capacitor.UseCharge(chargeChange);
var energyRatio = chargeChange / _baseFireCost;
if (_ammoContainer.ContainedEntity != null)
@@ -201,7 +201,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return false;
}
if (!entity.HasComponent<PowerCellComponent>())
if (!entity.HasComponent<BatteryComponent>())
{
return false;
}
@@ -264,7 +264,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public override bool InteractUsing(InteractUsingEventArgs eventArgs)
{
if (!eventArgs.Using.HasComponent<PowerStorageComponent>())
if (!eventArgs.Using.HasComponent<BatteryComponent>())
{
return false;
}