public static void Postfix(PowerRelay __instance, ref bool __result, ref float amount, ref float modified) { if (!__result) { IPowerInterface powerInterface = __instance.inboundPowerSources.Find((x) => x is BaseInboundRelay || x is OtherConnectionRelay); if (powerInterface != null) { PowerControl powerControl = null; switch (powerInterface) { case BaseInboundRelay baseConnectionRelay: powerControl = baseConnectionRelay.gameObject.GetComponent <PowerControl>(); break; case OtherConnectionRelay otherConnectionRelay: powerControl = otherConnectionRelay.gameObject.GetComponent <PowerControl>(); break; } PowerRelay endRelay = powerControl.powerRelay.GetEndpoint(); if (endRelay.GetMaxPower() > powerInterface.GetMaxPower()) { __result = endRelay.ModifyPowerFromInbound(amount, out float newModified); modified += newModified; } } } }
public static void Postfix(PowerRelay __instance, ref float __result) { IPowerInterface powerInterface = __instance.inboundPowerSources.Find((x) => x is BaseInboundRelay || x is OtherConnectionRelay); if (powerInterface != null) { PowerControl powerControl = null; switch (powerInterface) { case BaseInboundRelay baseConnectionRelay: powerControl = baseConnectionRelay.gameObject.GetComponent <PowerControl>(); break; case OtherConnectionRelay otherConnectionRelay: powerControl = otherConnectionRelay.gameObject.GetComponent <PowerControl>(); break; } PowerRelay endRelay = powerControl.powerRelay.GetEndpoint(); float endPower = endRelay.GetMaxPower(); float powerHere = powerInterface.GetMaxPower(); if (endPower > powerHere) { __result += endPower - powerHere; } } }
internal void FastUpdate(CyclopsHelmHUDManager cyclopsHelmHUD) { if (!powerIconsInitialized) { AddStatusIcons(cyclopsHelmHUD); } else { UpdateStatusIcons(); } PowerRelay powerRelay = Cyclops.powerRelay; switch (settings.EnergyDisplay) { case HelmEnergyDisplay.PowerCellAmount: cyclopsHelmHUD.powerText.text = NumberFormatter.FormatValue(powerRelay.GetPower()); break; case HelmEnergyDisplay.PercentageOverPowerCells: float percentOver = (powerRelay.GetPower() + this.ChargeManager.GetTotalReservePower()) / powerRelay.GetMaxPower(); cyclopsHelmHUD.powerText.text = $"{NumberFormatter.FormatValue(percentOver * 100f)}%"; break; case HelmEnergyDisplay.CombinedAmount: cyclopsHelmHUD.powerText.text = NumberFormatter.FormatValue(powerRelay.GetPower() + this.ChargeManager.GetTotalReservePower()); break; default: // HelmEnergyDisplay.PowerCellPercentage: float percent = powerRelay.GetPower() / powerRelay.GetMaxPower(); cyclopsHelmHUD.powerText.text = $"{NumberFormatter.FormatValue(percent * 100f)}%"; break; } }
internal void FastUpdate(CyclopsHelmHUDManager cyclopsHelmHUD, int lastPowerInt) { if (!cyclopsHelmHUD.LOD.IsFull() || Player.main.currentSub != Cyclops) { return; // Same early exit } if (totalPowerInfoIcons > 0) { if (!powerIconsInitialized) { AddPowerIcons(cyclopsHelmHUD); } else { UpdatePowerIcons(); } } if (lastPowerInt < 0f) { return; } PowerRelay powerRelay = Cyclops.powerRelay; switch (lastDisplay = settings.EnergyDisplay) { case HelmEnergyDisplay.PowerCellAmount: cyclopsHelmHUD.powerText.text = NumberFormatter.FormatValue(powerRelay.GetPower()); break; case HelmEnergyDisplay.PercentageOverPowerCells: float percentOver = (powerRelay.GetPower() + this.ChargeManager.GetTotalReservePower()) / powerRelay.GetMaxPower(); cyclopsHelmHUD.powerText.text = $"{NumberFormatter.FormatValue(percentOver * 100f)}%"; break; case HelmEnergyDisplay.CombinedAmount: cyclopsHelmHUD.powerText.text = NumberFormatter.FormatValue(powerRelay.GetPower() + this.ChargeManager.GetTotalReservePower()); break; default: // HelmEnergyDisplay.PowerCellPercentage: float percent = powerRelay.GetPower() / powerRelay.GetMaxPower(); cyclopsHelmHUD.powerText.text = $"{NumberFormatter.FormatValue(percent * 100f)}%"; break; } }