//public static bool Prepare() { return false; } public static void Postfix(CombatHUDSidePanelHoverElement __instance) { Log.TWL(0, "CombatHUDSidePanelHoverElement.OnPointerClick " + __instance.Title.ToString()); if (CombatHUDEquipmentPanel.Instance != null) { CombatHUDEquipmentPanel.Instance.ProcessOnPointerClick(__instance); } ; }
public static void Postfix(CombatHUDMechwarriorTray __instance, CombatGameState Combat, CombatHUD HUD) { if (modSettings.usingCACabilitySelector == false && (modSettings.extraAbilities > 0 || modSettings.nonTreeAbilities > 0)) { if (modSettings.cleanUpCombatUI == true) { GameObject.Find("AT_OuterFrameL").SetActive(false); GameObject.Find("AT_OuterFrameR").SetActive(false); GameObject.Find("braceL (1)").SetActive(false); GameObject.Find("braceR (1)").SetActive(false); GameObject.Find("actionButton_DLine1").SetActive(false); GameObject.Find("actionButton_DLine2").SetActive(false); GameObject.Find("actionButton_DLine3").SetActive(false); } for (int i = 1; i <= modSettings.extraAbilities + modSettings.nonTreeAbilities; i++) { //thanks to kmission for doing the hard part of writing all this, and letting me use my elite copypaste skills// GameObject[] ActionButtonHolders = new GameObject[__instance.ActionButtonHolders.Length + 1]; __instance.ActionButtonHolders.CopyTo(ActionButtonHolders, 0); CombatHUDActionButton[] ActionButtons = new CombatHUDActionButton[__instance.ActionButtons.Length + 1]; __instance.ActionButtons.CopyTo(ActionButtons, 0); CombatHUDActionButton[] oldAbilityButtons = (CombatHUDActionButton[])typeof(CombatHUDMechwarriorTray).GetProperty("AbilityButtons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance, null); CombatHUDActionButton[] AbilityButtons = new CombatHUDActionButton[oldAbilityButtons.Length + 1]; oldAbilityButtons.CopyTo(AbilityButtons, 0); GameObject sourceButtonObject = __instance.ActionButtonHolders[9]; CombatHUDActionButton sourceButton = sourceButtonObject.GetComponentInChildren <CombatHUDActionButton>(true); GameObject newButtonObject = UnityEngine.Object.Instantiate <GameObject>(sourceButtonObject, sourceButtonObject.transform.parent); CombatHUDActionButton newButton = newButtonObject.GetComponentInChildren <CombatHUDActionButton>(true); ActionButtonHolders[__instance.ActionButtonHolders.Length] = newButtonObject; Vector3[] corners = new Vector3[4]; sourceButtonObject.GetComponent <RectTransform>().GetWorldCorners(corners); float width = corners[2].x - corners[0].x; newButtonObject.transform.localPosition.Set(newButtonObject.transform.localPosition.x + (width), newButtonObject.transform.localPosition.y, newButtonObject.transform.localPosition.z); CombatHUDSidePanelHoverElement panelHoverElement = newButton.GetComponentInChildren <CombatHUDSidePanelHoverElement>(true); if (panelHoverElement == null) { panelHoverElement = newButton.gameObject.AddComponent <CombatHUDSidePanelHoverElement>(); } panelHoverElement.Init(HUD); newButton.Init(Combat, HUD, BTInput.Instance.Key_None(), true); ActionButtonHolders[__instance.ActionButtonHolders.Length] = newButtonObject; ActionButtons[__instance.ActionButtons.Length] = newButton; AbilityButtons[oldAbilityButtons.Length] = newButton; __instance.ActionButtonHolders = ActionButtonHolders; PropertyInfo ActionButtonsProperty = typeof(CombatHUDMechwarriorTray).GetProperty("ActionButtons"); ActionButtonsProperty.GetSetMethod(true).Invoke(__instance, new object[] { ActionButtons }); typeof(CombatHUDMechwarriorTray).GetProperty("AbilityButtons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, AbilityButtons, null); } } }
public static void ColorEvasivePips(CombatHUDEvasiveBarPips evasiveDisplay, bool willJumpOrHasJumped, int sustainablePips, bool suppressCoilPips = false) { List <Graphic> ____Pips = (List <Graphic>) typeof(CombatHUDPipBar).GetProperty("Pips", AccessTools.all).GetValue(evasiveDisplay, null); CombatHUD ___HUD = (CombatHUD)AccessTools.Property(typeof(CombatHUDEvasiveBarPips), "HUD").GetValue(evasiveDisplay, null); float ___Current = (float)AccessTools.Property(typeof(CombatHUDEvasiveBarPips), "Current").GetValue(evasiveDisplay, null); int currentEvasivePips = (int)___Current; int currentSustainablePips = willJumpOrHasJumped ? 0 : Math.Min(currentEvasivePips, sustainablePips); Logger.Info($"[Utilities_ColorEvasivePips] ____Pips.Count: {____Pips.Count}"); Logger.Info($"[Utilities_ColorEvasivePips] evasiveDisplay.TotalPips: {evasiveDisplay.TotalPips}"); Logger.Info($"[Utilities_ColorEvasivePips] currentEvasivePips: {currentEvasivePips}"); Logger.Info($"[Utilities_ColorEvasivePips] currentSustainablePips: {currentSustainablePips}"); bool ___ActorHasCOIL = Traverse.Create(evasiveDisplay).Field("ActorHasCOIL").GetValue <bool>(); bool ___ShouldShowCOILPips = Traverse.Create(evasiveDisplay).Field("ShouldShowCOILPips").GetValue <bool>(); int ___floorCurrent = Traverse.Create(evasiveDisplay).Field("floorCurrent").GetValue <int>(); //bool showCoilPips = (___ActorHasCOIL && ___ShouldShowCOILPips) && ((float)___floorCurrent >= ___HUD.Combat.Constants.CombatUIConstants.COIL_Footstep_Charge_Med); bool showCoilPips = (___ActorHasCOIL && ___ShouldShowCOILPips) && (___floorCurrent > 1) && !suppressCoilPips; Logger.Info($"[Utilities_ColorEvasivePips] ___ActorHasCOIL: {___ActorHasCOIL}"); Logger.Info($"[Utilities_ColorEvasivePips] ___ShouldShowCOILPips: {___ShouldShowCOILPips}"); Logger.Info($"[Utilities_ColorEvasivePips] ___floorCurrent: {___floorCurrent}"); Logger.Info($"[Utilities_ColorEvasivePips] showCoilPips: {showCoilPips}"); int ___AssassinPipIgnoreCount = Traverse.Create(evasiveDisplay).Field("AssassinPipIgnoreCount").GetValue <int>(); Logger.Info($"[Utilities_ColorEvasivePips] ___AssassinPipIgnoreCount: {___AssassinPipIgnoreCount}"); //List<HBSDOTweenButton> ___PipButtons = (List<HBSDOTweenButton>)AccessTools.Property(typeof(CombatHUDEvasiveBarPips), "PipButtons").GetValue(evasiveDisplay, null); //Logger.Info($"[Utilities_ColorEvasivePips] ___PipButtons.Count: {___PipButtons.Count}"); Color coilPipColor = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.EvasivePipsCharged.color; //Color ignoreColor = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.EvasivePipsIgnored.color; Color ignoreColor = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.whiteHalf; Color sustainablePipColor = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.green; Color defaultPipColor = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.white; for (int i = 0; i < evasiveDisplay.TotalPips; i++) { // Evasive display in CombatHUDMechTray.ActorInfo does not have the tween buttons available so it seems... // Need to check for existence to circumvent reference error if (____Pips[i].gameObject.GetComponent <HBSDOTweenButton>() != null) { ____Pips[i].gameObject.GetComponent <HBSDOTweenButton>().BlockDOTweenAnimations = true; } if (showCoilPips) { UIHelpers.SetImageColor(____Pips[i], coilPipColor); // Reenable tweens? //if (____Pips[i].gameObject.GetComponent<HBSDOTweenButton>() != null) //{ // ____Pips[i].gameObject.GetComponent<HBSDOTweenButton>().BlockDOTweenAnimations = false; //} } else if (i < ___AssassinPipIgnoreCount) { UIHelpers.SetImageColor(____Pips[i], ignoreColor); // Reenable tweens? //if (____Pips[i].gameObject.GetComponent<HBSDOTweenButton>() != null) //{ // ____Pips[i].gameObject.GetComponent<HBSDOTweenButton>().BlockDOTweenAnimations = false; //} } else if (i < currentSustainablePips) { UIHelpers.SetImageColor(____Pips[i], sustainablePipColor); } else if (i < currentEvasivePips) { UIHelpers.SetImageColor(____Pips[i], defaultPipColor); } } CombatHUDSidePanelHoverElement ___sidePanelTip = (CombatHUDSidePanelHoverElement)AccessTools.Property(typeof(CombatHUDEvasiveBarPips), "sidePanelTip").GetValue(evasiveDisplay, null); if (___sidePanelTip != null) { ___sidePanelTip.Title = new Localize.Text("EVASIVE", new object[0]); int num = (int)___Current - 1; string[] toHitMovingTargetStrings = new string[] { "1 EVASIVE Charge: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "2 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "3 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "4 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "5 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "6 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "7 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}", "8 EVASIVE Charges: +{0} Difficulty to hit this unit with ranged attacks. {1}{2}" }; if (currentEvasivePips > 0 && num < toHitMovingTargetStrings.Length) { ___sidePanelTip.Description = new Localize.Text(toHitMovingTargetStrings[num], new object[] { ___HUD.Combat.ToHit.GetEvasivePipsModifier((int)___Current, null), currentSustainablePips > 0 ? "\n<color=#" + ColorUtility.ToHtmlStringRGBA(sustainablePipColor) + ">" + currentSustainablePips.ToString() + " SUSTAINABLE Evasion: These can only be removed by melee or sensor lock.</color>" : "", showCoilPips ? $"\n<color=#{ColorUtility.ToHtmlStringRGBA(coilPipColor)}>{currentEvasivePips.ToString()} COIL Charges generated.</color>" : "" }); } } }