private void UpdateStatusIcons() { if (!powerIconsInitialized) { return; } if (Time.time < iconUpdateDelay) { return; } iconUpdateDelay = Time.time + delayInterval; HidePowerIcons(); if (settings.ShowThermometer) { float temperature = Cyclops.GetTemperature(); TemperatureReadout.Text.text = NumberFormatter.FormatValue(temperature) + "°C"; TemperatureReadout.Text.color = GetHeatColor(temperature); TemperatureReadout.SetEnabled(true); } else { TemperatureReadout.SetEnabled(false); } if (settings.HidePowerIcons) { return; } bool isEven = true; for (int i = 0; i < StatusIcons.Count; i++) { if (StatusIcons[i].ShowStatusIcon) { isEven = !isEven; } } IndicatorIcon[] helmRow = isEven ? HelmIndicatorsEven : HelmIndicatorsOdd; IndicatorIcon[] healthBarRow = isEven ? HealthBarIndicatorsEven : HealthBarIndicatorsOdd; bool showIconsOnHoloDisplay = settings.ShowIconsOnHoloDisplay; bool showIconsWhilePiloting = settings.ShowIconsWhilePiloting; int iconIndex = 0; for (int c = 0; c < StatusIcons.Count; c++) { CyclopsStatusIcon statusIcon = StatusIcons[c]; if (!statusIcon.ShowStatusIcon) { continue; } IndicatorIcon helmIcon = helmRow[iconIndex]; IndicatorIcon hpIcon = healthBarRow[iconIndex++]; hpIcon.SetEnabled(showIconsOnHoloDisplay); helmIcon.SetEnabled(showIconsWhilePiloting); hpIcon.Icon.sprite = helmIcon.Icon.sprite = statusIcon.StatusSprite(); hpIcon.Text.enabled = powerIconTextVisibility; hpIcon.Text.text = helmIcon.Text.text = statusIcon.StatusText(); hpIcon.Text.color = helmIcon.Text.color = statusIcon.StatusTextColor(); } }
private void AddStatusIcons(CyclopsHelmHUDManager cyclopsHelmHUD) { TooLateToRegister = true; for (int i = 0; i < StatusIconCreators.Count; i++) { StatusIconCreator creator = StatusIconCreators[i]; QuickLogger.Debug($"CyclopsHUDManager creating standalone status icon '{creator.StatusIconName}'"); CyclopsStatusIcon statusIcon = creator.Creator.Invoke(Cyclops); if (statusIcon == null) { QuickLogger.Warning($"CyclopsHUDManager '{creator.StatusIconName}' was null"); } else { StatusIcons.Add(statusIcon); QuickLogger.Debug($"Created CyclopsStatusIcon '{creator.StatusIconName}'"); } } int totalPowerInfoIcons = Math.Max(StatusIcons.Count, 1); // Include a minimum of 1 for the vanilla thermal charger cyclopsHelmHUD.powerText.resizeTextForBestFit = true; QuickLogger.Debug($"CyclopsHUDManager Adding '{totalPowerInfoIcons}' Status Info Icons"); 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 IndicatorIcon[1]; HelmIndicatorsEven = new IndicatorIcon[0]; HealthBarIndicatorsOdd = new IndicatorIcon[1]; HealthBarIndicatorsEven = new IndicatorIcon[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 IndicatorIcon[totalIcons + 1]; HelmIndicatorsEven = new IndicatorIcon[totalIcons]; HealthBarIndicatorsOdd = new IndicatorIcon[totalIcons + 1]; HealthBarIndicatorsEven = new IndicatorIcon[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"); }