public static void SetArmorBarColour(CombatHUDPipBar __instance, ref Color shownColor) { if (!(__instance is CombatHUDArmorBarPips) || !BarOwners.TryGetValue(__instance, out ICombatant owner)) { return; } Color?colour = GetTeamColour(owner, FloatingArmorColours); if (colour.HasValue) { shownColor = colour.Value; } }
static void Postfix(CombatHUDPipBar __instance, float current, float projected, Color shownColor, Color shownColorProjectedHigh) { try { if (__instance.GetComponentInParent(typeof(CombatHUDStabilityDisplay)) != null) { Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] THIS CombatHUDPipBar is a child of CombatHUDStabilityDisplay"); CombatHUDStabilityDisplay combatHUDStabilityDisplay = __instance.GetComponentInParent <CombatHUDStabilityDisplay>(); Mech displayedMech = combatHUDStabilityDisplay.DisplayedActor as Mech; if (!displayedMech.team.IsLocalPlayer || displayedMech == null) { return; } Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] displayedMech.DisplayName: " + displayedMech.DisplayName); float unsteadyThreshold = displayedMech.UnsteadyThreshold; float maxStability = displayedMech.MaxStability; Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] displayedMech.UnsteadyThreshold: " + displayedMech.UnsteadyThreshold); Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] displayedMech.MaxStability: " + displayedMech.MaxStability); Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] current: " + current); Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] projected: " + projected); if (projected > current) { Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] INSTABILITY RISES: Fixing pips-preview"); float ___pointsPerPip = (float)typeof(CombatHUDPipBar).GetProperty("PointsPerPip", AccessTools.all).GetValue(__instance, null); int pipCount = __instance.PipCount; Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] ___pointsPerPip: " + ___pointsPerPip); Logger.Info("[CombatHUDPipBar_ShowValue_POSTFIX] pipCount: " + pipCount); //float calculatedMaxStability = pipCount * ___pointsPerPip; //Logger.Debug("[CombatHUDPipBar_ShowValue_POSTFIX] calculatedMaxStability: " + calculatedMaxStability); Color increaseStabilityWarningColor = Color.Lerp(shownColor, shownColorProjectedHigh, Mathf.Sin(Time.realtimeSinceStartup * __instance.TimeSinFactor) * 0.5f + 0.5f); Color c = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.red; Color maxStabilityWarningColor = Color.Lerp(c, shownColorProjectedHigh, Mathf.Sin(Time.realtimeSinceStartup * __instance.TimeSinFactor) * 0.5f + 0.5f); //Color stabilityWarningColor = projected >= calculatedMaxStability ? maxStabilityWarningColor : increaseStabilityWarningColor; Color stabilityWarningColor = projected >= maxStability ? maxStabilityWarningColor : increaseStabilityWarningColor; List <Graphic> ___pips = (List <Graphic>) typeof(CombatHUDPipBar).GetProperty("Pips", AccessTools.all).GetValue(__instance, null); for (int i = 0; i < ___pips.Count; i++) { ___pips[i].transform.localScale = Vector3.one; if (((i + 1) * ___pointsPerPip > current) && ((i + 1) * ___pointsPerPip <= projected)) { UIHelpers.SetImageColor(___pips[i], stabilityWarningColor); } } } // Toggle additional warning icon if (projected > unsteadyThreshold) { combatHUDStabilityDisplay.StabilityIcon.SetActive(true); } else { combatHUDStabilityDisplay.StabilityIcon.SetActive(false); } } } catch (Exception e) { Logger.Error(e); } }