private void UpdatePowerIcons() { if (!powerIconsInitialized) { return; } if (Time.time < iconUpdateDelay) { return; } iconUpdateDelay = Time.time + delayInterval; HidePowerIcons(); if (settings.HidePowerIcons) { return; } CyclopsCharger[] cyclopsChargers = this.ChargeManager.Chargers; bool isEven = true; for (int i = 0; i < cyclopsChargers.Length; i++) { if (cyclopsChargers[i].ShowStatusIcon) { isEven = !isEven; } } PowerIndicatorIcon[] helmRow = isEven ? HelmIndicatorsEven : HelmIndicatorsOdd; PowerIndicatorIcon[] healthBarRow = isEven ? HealthBarIndicatorsEven : HealthBarIndicatorsOdd; bool showIconsOnHoloDisplay = settings.ShowIconsOnHoloDisplay; bool showIconsWhilePiloting = settings.ShowIconsWhilePiloting; int iconIndex = 0; for (int c = 0; c < cyclopsChargers.Length; c++) { CyclopsCharger charger = cyclopsChargers[c]; if (!charger.ShowStatusIcon) { continue; } PowerIndicatorIcon helmIcon = helmRow[iconIndex]; PowerIndicatorIcon hpIcon = healthBarRow[iconIndex++]; hpIcon.SetEnabled(showIconsOnHoloDisplay); helmIcon.SetEnabled(showIconsWhilePiloting); hpIcon.Icon.sprite = helmIcon.Icon.sprite = charger.StatusSprite(); hpIcon.Text.enabled = powerIconTextVisibility; hpIcon.Text.text = helmIcon.Text.text = charger.StatusText(); if (charger.ProvidingPower) { hpIcon.Text.color = helmIcon.Text.color = charger.StatusTextColor(); } else { hpIcon.Text.color = helmIcon.Text.color = Color.white; } } }
private void AddPowerIcons(CyclopsHelmHUDManager cyclopsHelmHUD) { cyclopsHelmHUD.powerText.resizeTextForBestFit = true; QuickLogger.Debug($"CyclopsHUDManager Adding Power Info Icons for '{totalPowerInfoIcons}' CyclopsChargers"); holographicHUD = cyclopsHelmHUD.subRoot.GetComponentInChildren <CyclopsHolographicHUD>(); Canvas pilotingCanvas = cyclopsHelmHUD.powerText.canvas; Canvas holoCanvas = holographicHUD.healthBar.canvas; const float spacingUnit = 35; const float helmzoffset = 0.05f; const float helmyoffset = -225; const float helmscale = 1.35f; const float healthbarxoffset = 120f; const float thermometerxoffset = healthbarxoffset * 1.96f; const float healthbarzoffset = 0.05f; const float healthbaryoffset = -300f; const float healthbarscale = 0.65f; const float thermometerscale = healthbarscale * 1.25f; /* --- 3-1-2 --- */ /* ---- 1-2 ---- */ if (totalPowerInfoIcons == 1) { HelmIndicatorsOdd = new PowerIndicatorIcon[1]; HelmIndicatorsEven = new PowerIndicatorIcon[0]; HealthBarIndicatorsOdd = new PowerIndicatorIcon[1]; HealthBarIndicatorsEven = new PowerIndicatorIcon[0]; HelmIndicatorsOdd[0] = IconCreator.CreatePowerIndicatorIcon(pilotingCanvas, 0, helmyoffset, helmzoffset, helmscale); HealthBarIndicatorsOdd[0] = IconCreator.CreatePowerIndicatorIcon(holoCanvas, healthbarxoffset + 0, healthbaryoffset, healthbarzoffset, healthbarscale); } else { int totalIcons = totalPowerInfoIcons; if (totalIcons % 2 != 0) { totalIcons--; } HelmIndicatorsOdd = new PowerIndicatorIcon[totalIcons + 1]; HelmIndicatorsEven = new PowerIndicatorIcon[totalIcons]; HealthBarIndicatorsOdd = new PowerIndicatorIcon[totalIcons + 1]; HealthBarIndicatorsEven = new PowerIndicatorIcon[totalIcons]; HelmIndicatorsOdd[0] = IconCreator.CreatePowerIndicatorIcon(pilotingCanvas, 0, helmyoffset, helmzoffset, helmscale); HealthBarIndicatorsOdd[0] = IconCreator.CreatePowerIndicatorIcon(holoCanvas, healthbarxoffset + 0, healthbaryoffset, healthbarzoffset, healthbarscale); int index = 0; float healtBarSpacing = 0f; float helmSpacing = 0f; do { healtBarSpacing += spacingUnit; helmSpacing += spacingUnit * 2f; // Add even icons first HelmIndicatorsEven[index + 0] = IconCreator.CreatePowerIndicatorIcon(pilotingCanvas, -helmSpacing, helmyoffset, helmzoffset, helmscale); HelmIndicatorsEven[index + 1] = IconCreator.CreatePowerIndicatorIcon(pilotingCanvas, helmSpacing, helmyoffset, helmzoffset, helmscale); HealthBarIndicatorsEven[index + 0] = IconCreator.CreatePowerIndicatorIcon(holoCanvas, healthbarxoffset + -healtBarSpacing, healthbaryoffset, healthbarzoffset, healthbarscale); HealthBarIndicatorsEven[index + 1] = IconCreator.CreatePowerIndicatorIcon(holoCanvas, healthbarxoffset + healtBarSpacing, healthbaryoffset, healthbarzoffset, healthbarscale); healtBarSpacing += spacingUnit; helmSpacing += spacingUnit * 2f; // Add odd icons next HelmIndicatorsOdd[index + 1] = IconCreator.CreatePowerIndicatorIcon(pilotingCanvas, -helmSpacing, helmyoffset, helmzoffset, helmscale); HelmIndicatorsOdd[index + 2] = IconCreator.CreatePowerIndicatorIcon(pilotingCanvas, helmSpacing, helmyoffset, helmzoffset, helmscale); HealthBarIndicatorsOdd[index + 1] = IconCreator.CreatePowerIndicatorIcon(holoCanvas, healthbarxoffset + -healtBarSpacing, healthbaryoffset, healthbarzoffset, healthbarscale); HealthBarIndicatorsOdd[index + 2] = IconCreator.CreatePowerIndicatorIcon(holoCanvas, healthbarxoffset + healtBarSpacing, healthbaryoffset, healthbarzoffset, healthbarscale); index += 2; } while (totalIcons > index); } TemperatureReadout = IconCreator.CreatePowerIndicatorIcon(holoCanvas, thermometerxoffset, -2.5f, healthbarzoffset, thermometerscale); TemperatureReadout.Icon.sprite = CyclopsThermometer ?? SpriteManager.Get(TechType.CyclopsThermalReactorModule); powerIconsInitialized = true; QuickLogger.Debug("Linked CyclopsHUDManager to HelmHUD"); }