fix infinite power gen bug (#12688)
This commit is contained in:
@@ -71,23 +71,24 @@ public sealed class UpgradePowerSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnSupplierRefreshParts(EntityUid uid, UpgradePowerSupplierComponent component, RefreshPartsEvent args)
|
private void OnSupplierRefreshParts(EntityUid uid, UpgradePowerSupplierComponent component, RefreshPartsEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<PowerSupplierComponent>(uid, out var powa))
|
var supply = component.BaseSupplyRate;
|
||||||
return;
|
|
||||||
|
|
||||||
var rating = args.PartRatings[component.MachinePartPowerSupply];
|
var rating = args.PartRatings[component.MachinePartPowerSupply];
|
||||||
switch (component.Scaling)
|
switch (component.Scaling)
|
||||||
{
|
{
|
||||||
case MachineUpgradeScalingType.Linear:
|
case MachineUpgradeScalingType.Linear:
|
||||||
powa.MaxSupply += component.BaseSupplyRate * (rating - 1);
|
supply += component.BaseSupplyRate * (rating - 1);
|
||||||
break;
|
break;
|
||||||
case MachineUpgradeScalingType.Exponential:
|
case MachineUpgradeScalingType.Exponential:
|
||||||
powa.MaxSupply *= MathF.Pow(component.PowerSupplyMultiplier, rating - 1);
|
supply *= MathF.Pow(component.PowerSupplyMultiplier, rating - 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Logger.Error($"invalid power scaling type for {ToPrettyString(uid)}.");
|
Logger.Error($"invalid power scaling type for {ToPrettyString(uid)}.");
|
||||||
powa.MaxSupply = component.BaseSupplyRate;
|
supply = component.BaseSupplyRate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TryComp<PowerSupplierComponent>(uid, out var powa))
|
||||||
|
powa.MaxSupply = supply;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSupplierUpgradeExamine(EntityUid uid, UpgradePowerSupplierComponent component, UpgradeExamineEvent args)
|
private void OnSupplierUpgradeExamine(EntityUid uid, UpgradePowerSupplierComponent component, UpgradeExamineEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user