Updated PowerHandler
Calculates consumption and peak consumption
This commit is contained in:
parent
47fdfdbc66
commit
a70bd626a6
|
@ -8,6 +8,7 @@ namespace AsteroidGame.Handlers
|
||||||
{
|
{
|
||||||
[Header("State")]
|
[Header("State")]
|
||||||
[SerializeField] private int _powerConsumption;
|
[SerializeField] private int _powerConsumption;
|
||||||
|
[SerializeField] private int _powerConsumptionPeak;
|
||||||
[SerializeField] private int _powerCapacity;
|
[SerializeField] private int _powerCapacity;
|
||||||
[SerializeField] private float _powerFactor;
|
[SerializeField] private float _powerFactor;
|
||||||
|
|
||||||
|
@ -17,12 +18,14 @@ namespace AsteroidGame.Handlers
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
_powerConsumption = 0;
|
_powerConsumption = 0;
|
||||||
|
_powerConsumptionPeak = 0;
|
||||||
_powerCapacity = 0;
|
_powerCapacity = 0;
|
||||||
foreach (var structure in _activeStructures._list)
|
foreach (var structure in _activeStructures._list)
|
||||||
{
|
{
|
||||||
if (structure.IsConsumer)
|
if (structure.IsConsumer)
|
||||||
{
|
{
|
||||||
_powerConsumption += structure.GetMaxPower();
|
_powerConsumption += structure.GetCurrentPower();
|
||||||
|
_powerConsumptionPeak += structure.GetMaxPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (structure.IsGenerator)
|
if (structure.IsGenerator)
|
||||||
|
@ -46,14 +49,9 @@ namespace AsteroidGame.Handlers
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetCurrentPower()
|
public int GetCurrentPower() => _powerConsumption;
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
public float GetPowerFactor() => _powerFactor;
|
||||||
}
|
|
||||||
|
|
||||||
public float GetPowerFactor()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue