private static bool Prefix(uGUI_BuilderMenu __instance) { __instance.iconGrid.Clear(); __instance.items.Clear(); List <TechType> techTypesForGroup = __instance.GetTechTypesForGroup(__instance.selected); int num = 0; for (int i = 0; i < techTypesForGroup.Count; i++) { TechType techType = techTypesForGroup[i]; if (!Core.RecipeBlacklist.Contains(techType.AsString())) { TechUnlockState techUnlockState = KnownTech.GetTechUnlockState(techType); if (techUnlockState == TechUnlockState.Available || techUnlockState == TechUnlockState.Locked) { string stringForInt = IntStringCache.GetStringForInt(num); __instance.items.Add(stringForInt, techType); __instance.iconGrid.AddItem(stringForInt, SpriteManager.Get(techType), SpriteManager.GetBackground(techType), techUnlockState == TechUnlockState.Locked, num); __instance.iconGrid.RegisterNotificationTarget(stringForInt, NotificationManager.Group.Builder, techType.EncodeKey()); num++; } } } return(false); }
public static void Postfix(uGUI_SeaTruckHUD __instance) { if (Player.main != null && Player.main.IsPilotingSeatruck()) { if (TemperatureSuffix == null) { TemperatureSuffix = __instance.gameObject.transform.Find("Content/Seatruck/Indicators/Temperature/TemperatureValue/TemperatureSuffix").gameObject; textTemperatureSuffix = TemperatureSuffix.GetComponent <TextMeshProUGUI>(); textTemperatureSuffix.color = textColor; } int celsius = (int)__instance.GetPrivateField("lastTemperature"); if (Main.FahrenheitEnabled) { int fahrenheit = Mathf.CeilToInt(celsius * 1.8f + 32); __instance.textTemperature.text = IntStringCache.GetStringForInt(fahrenheit); textTemperatureSuffix.text = "\u00b0F"; } else { __instance.textTemperature.text = IntStringCache.GetStringForInt(celsius); textTemperatureSuffix.text = "\u00b0C"; } } }
public static void Postfix(ThermalPlant __instance) { if (Main.FahrenheitEnabled) { int fahrenheit = Mathf.CeilToInt(__instance.temperature * 1.8f + 32); __instance.temperatureText.text = $"{IntStringCache.GetStringForInt(fahrenheit)}\u00b0F"; } else { __instance.temperatureText.text = $"{IntStringCache.GetStringForInt(Mathf.CeilToInt(__instance.temperature))}\u00b0C"; } }
public static void Postfix(uGUI_ExosuitHUD __instance) { Player main = Player.main; if (main != null && main.inExosuit) { int celsius = (int)__instance.GetPrivateField("lastTemperature"); int fahrenheit = Mathf.CeilToInt(celsius * 1.8f + 32); __instance.textTemperature.text = IntStringCache.GetStringForInt(fahrenheit); __instance.textTemperatureSuffix.color = textColor; __instance.textTemperatureSuffix.text = "\u00b0F"; } }
/// <summary> /// Updates the console HUD using data from all equipment modules across all upgrade consoles. /// </summary> /// <param name="hudManager">The console HUD manager.</param> internal void SlowUpdate(CyclopsUpgradeConsoleHUDManager hudManager) { if (!Cyclops.LOD.IsFull() || Player.main.currentSub != Cyclops || !Cyclops.live.IsAlive()) { return; // Same early exit } hudManager.healthCur.text = IntStringCache.GetStringForInt(Mathf.FloorToInt(hudManager.liveMixin.health)); int maxHealth = Mathf.CeilToInt(hudManager.liveMixin.health); if (hudManager.lastHealthMaxDisplayed != maxHealth) { hudManager.healthMax.text = "/" + IntStringCache.GetStringForInt(maxHealth); hudManager.lastHealthMaxDisplayed = maxHealth; } int currentReservePower = this.ChargeManager.GetTotalReservePower(); float currentBatteryPower = Cyclops.powerRelay.GetPower(); int TotalPowerUnits = Mathf.CeilToInt(currentBatteryPower + currentReservePower); float normalMaxPower = Cyclops.powerRelay.GetMaxPower(); int normalMaxPowerInt = Mathf.CeilToInt(normalMaxPower); hudManager.energyCur.color = NumberFormatter.GetNumberColor(currentBatteryPower, normalMaxPower, 0f); hudManager.energyCur.text = NumberFormatter.FormatValue(TotalPowerUnits); if (hudManager.lastMaxSubPowerDisplayed != normalMaxPowerInt) { hudManager.energyMax.text = "/" + NumberFormatter.FormatValue(normalMaxPowerInt); hudManager.lastMaxSubPowerDisplayed = normalMaxPowerInt; } settings.UpdateCyclopsMaxPower(normalMaxPower); if (totalPowerInfoIcons > 0) { powerIconTextVisibility = Player.main.currentSub == Cyclops && holographicHUD != null && Mathf.Abs(Vector3.Distance(holographicHUD.transform.position, Player.main.transform.position)) <= 4f; if (lastKnownTextVisibility != powerIconTextVisibility) { UpdatePowerIcons(); lastKnownTextVisibility = powerIconTextVisibility; } } }
public static void PostUpdate(uGUI_ExosuitHUD __instance) { if (__instance == null || !Main.config.bHUDAbsoluteValues || Player.main == null) { return; } exosuit = Player.main.GetVehicle() as Exosuit; if (exosuit == null) { return; } if (exosuit.liveMixin == null) { return; } //Log.LogDebug($"ExosuitHUDPatches.PostUpdate() begin"); int charge; //float capacity; if (__instance.textHealth != null) { int health = Mathf.RoundToInt(exosuit.liveMixin.health); __instance.textHealth.text = IntStringCache.GetStringForInt(health); } if (__instance.textPower != null) { EnergyInterface energy = (EnergyInterface)(ExosuitPatches.energyInterfaceField.GetValue(exosuit)); if (energy == null) { return; } //energy.GetValues(out charge, out capacity); charge = Mathf.RoundToInt(energy.TotalCanProvide(out int i)); //ErrorMessage.AddMessage($"Current Charge {charge}"); __instance.textPower.text = IntStringCache.GetStringForInt(charge); __instance.textPower.fontSize = (charge > 9999 ? 28 : 36); } //Log.LogDebug($"ExosuitHUDPatches.PostUpdate() finish"); }
/// <summary> /// Updates the console HUD using data from all equipment modules across all upgrade consoles. /// </summary> /// <param name="hudManager">The console HUD manager.</param> /// <param name="coreModules">The core modules.</param> /// <param name="auxUpgradeConsoles">The aux upgrade consoles.</param> internal static void UpdateConsoleHUD(CyclopsUpgradeConsoleHUDManager hudManager, Equipment coreModules, IList <AuxUpgradeConsole> auxUpgradeConsoles) { int currentReservePower = GetTotalReservePower(coreModules, auxUpgradeConsoles); float currentBatteryPower = hudManager.subRoot.powerRelay.GetPower(); if (currentReservePower > 0f) { hudManager.energyCur.color = Color.cyan; // Distinct color for when reserve power is available } else { hudManager.energyCur.color = Color.white; // Normal color } int totalPower = Mathf.CeilToInt(currentBatteryPower + currentReservePower); hudManager.energyCur.text = IntStringCache.GetStringForInt(totalPower); NuclearModuleConfig.SetCyclopsMaxPower(hudManager.subRoot.powerRelay.GetMaxPower()); }
private void UpdateDebugHUD() { //UpdateSeatruckPosition(); //UpdateSeatruckState(); surfaceText.text = $"{IntStringCache.GetStringForInt((int)distanceFromSurface)} m"; surfaceLeftText.text = $"{IntStringCache.GetStringForInt((int)FLeftDist)} m"; surfaceRightText.text = $"{IntStringCache.GetStringForInt((int)FRightDist)} m"; isFlyingText.text = isFlying.value.ToString(); FCenterRay.SetPosition(0, Vector3.zero); FCenterRay.SetPosition(1, Vector3.down * 5f); FLeftRay.SetPosition(0, Vector3.zero); FLeftRay.SetPosition(1, LeftDown * 5); FRightRay.SetPosition(0, Vector3.zero); FRightRay.SetPosition(1, RightDown * 5); }
/// <summary> /// Updates the console HUD using data from all equipment modules across all upgrade consoles. /// </summary> /// <param name="hudManager">The console HUD manager.</param> internal void UpdateConsoleHUD(CyclopsUpgradeConsoleHUDManager hudManager) { int currentReservePower = GetTotalReservePower(); float currentBatteryPower = this.Cyclops.powerRelay.GetPower(); if (currentReservePower > 0) { hudManager.energyCur.color = Color.cyan; // Distinct color for when reserve power is available } else { hudManager.energyCur.color = Color.white; // Normal color } int TotalPowerUnits = Mathf.CeilToInt(currentBatteryPower + currentReservePower); hudManager.energyCur.text = IntStringCache.GetStringForInt(TotalPowerUnits); NuclearModuleConfig.SetCyclopsMaxPower(this.Cyclops.powerRelay.GetMaxPower()); }
public static void Postfix(ThermalPlant __instance) { int fahrenheit = Mathf.CeilToInt(__instance.temperature * 1.8f + 32); __instance.temperatureText.text = IntStringCache.GetStringForInt(fahrenheit); }
private void UpdateBlips() { Camera camera = MainCamera.camera; Vector3 position = camera.transform.position; Vector3 forward = camera.transform.forward; int num = 0; foreach (ResourceTrackerDatabase.ResourceInfo resourceInfo in nodes) { if (Vector3.Dot(resourceInfo.position - position, forward) > 0f) { if (num >= blips.Count) { GameObject blipClone = Instantiate(blip, Vector3.zero, Quaternion.identity); RectTransform rt = blipClone.GetComponent <RectTransform>(); rt.SetParent(canvasRect, false); rt.localScale = blipRect.localScale; Blip newBlip = new Blip { gameObject = blipClone, rect = rt, text = blipClone.transform.Find("text").GetComponent <TextMeshProUGUI>(), distanceText = blipClone.transform.Find("distanceText").GetComponent <TextMeshProUGUI>(), techType = TechType.None }; blips.Add(newBlip); } Blip blip2 = blips[num]; blip2.gameObject.SetActive(true); Vector2 vector = camera.WorldToViewportPoint(resourceInfo.position); blip2.rect.anchorMin = vector; blip2.rect.anchorMax = vector; if (blip2.techType != resourceInfo.techType) { blip2.text.text = Language.main.Get(resourceInfo.techType.AsString(false)); blip2.techType = resourceInfo.techType; } if (showDistance) { float distance = Vector3.Distance(camera.transform.position, resourceInfo.position); blip2.distanceText.text = $"{IntStringCache.GetStringForInt((int)distance)} m"; if (!blip2.distanceText.gameObject.activeSelf) { blip2.distanceText.gameObject.SetActive(true); } } else if (blip2.distanceText.gameObject.activeSelf) { blip2.distanceText.gameObject.SetActive(false); } num++; } } for (int i = num; i < blips.Count; i++) { blips[i].gameObject.SetActive(false); } }