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

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