public static void CleanupBossHead(CombatHUDCalledShotPopUp __instance) { if (head <= 0) { return; } Dictionary <ArmorLocation, int> currentHitTable = (Dictionary <ArmorLocation, int>)currentHitTableProp.GetValue(__instance, null); currentHitTable[ArmorLocation.Head] = head; head = 0; }
public static void FixBossHead(CombatHUDCalledShotPopUp __instance) { if (__instance.DisplayedActor?.CanBeHeadShot ?? true) { return; } Dictionary <ArmorLocation, int> currentHitTable = (Dictionary <ArmorLocation, int>)currentHitTableProp.GetValue(__instance, null); if (currentHitTable == null || !currentHitTable.TryGetValue(ArmorLocation.Head, out head)) { return; } currentHitTable[ArmorLocation.Head] = 0; }
static void Postfix(CombatHUDCalledShotPopUp __instance, CombatHUD ___HUD) { if (__instance.Visible && ___HUD.SelectionHandler.ActiveState is SelectionStateFire selectionStateFire && selectionStateFire.SelectionType == SelectionType.FireMorale) { bool attackerCanAlwaysMakeCalledShot = ___HUD.SelectedActor.CanAlwaysUseCalledShot(); bool targetCanBeCalledShot = __instance.DisplayedActor.IsShutDown || __instance.DisplayedActor.IsProne || attackerCanAlwaysMakeCalledShot; if (!targetCanBeCalledShot && Mod.Config.Combat.CalledShot.DisableAllLocations) { Mod.Log.Info?.Write($" Disabling called shot popup from attacker: {___HUD.SelectedActor.DistinctId()} against target vehicle: {__instance.DisplayedActor.DistinctId()}"); __instance.Visible = false; } } }
public static void ShowCalledLocationHP(CombatHUDCalledShotPopUp __instance) { try { if (title == null) { title = UnityEngine.GameObject.Find("calledShot_Title")?.GetComponent <TMPro.TextMeshProUGUI>(); title.enableAutoSizing = false; if (title == null) { return; } } /* * public void SetText(StringBuilder text); * public void SetText(string text, float arg0, float arg1, float arg2); * public void SetText(string text, float arg0, float arg1); * public void SetText(string text, float arg0); * public void SetText(string text, bool syncTextInputBox); * public void SetText(string text);*/ CombatHUDCalledShotPopUp me = __instance; ArmorLocation hoveredArmor = me.MechArmorDisplay.HoveredArmor; if (me.locationNameText.text.StartsWith("-")) { title.SetText("Called Shot"); } else if (me.DisplayedActor is Mech mech) { float hp = mech.GetCurrentStructure(MechStructureRules.GetChassisLocationFromArmorLocation(hoveredArmor)); if (hp <= 0) { title.SetText("Called Shot"); me.locationNameText.SetText("-choose target-", ZeroObjects); } else { float mhp = mech.GetMaxStructure(MechStructureRules.GetChassisLocationFromArmorLocation(hoveredArmor)), armour = mech.GetCurrentArmor(hoveredArmor), marmour = mech.GetMaxArmor(hoveredArmor); title.text = me.locationNameText.text; me.locationNameText.text = string.Format("{0:0}/{1:0} <#FFFFFF>{2:0}/{3:0}", hp, mhp, armour, marmour); } } } catch (Exception ex) { Error(ex); } }
public static void Postfix(CombatHUDCalledShotPopUp __instance, CombatHUD ___HUD, AbstractActor ___displayedActor, AttackDirection ___shownAttackDirection) { try { //Logger.Debug("[CombatHUDCalledShotPopUp_UpdateMechDisplay_POSTFIX] Visually disabling head display if it may not be targeted..."); if (__instance.ShownAttackDirection == AttackDirection.FromBack) { return; } int enabledWeaponCount = Utilities.GetReadiedWeaponCount(___HUD.SelectedActor.Weapons, ___HUD.SelectedTarget); Pilot selectedPilot = ___HUD.SelectedActor.GetPilot(); int maxAllowedWeapons = Utilities.GetMaxAllowedWeaponCountForHeadshots(selectedPilot); bool validWeaponCountForPrecisionStrike = enabledWeaponCount <= maxAllowedWeapons ? true : false; bool headCanBeTargeted = ___HUD.SelectedTarget.IsShutDown || ___HUD.SelectedTarget.IsProne || validWeaponCountForPrecisionStrike; if (!headCanBeTargeted) { Color cOutline = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.darkGray; Color cFill = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.darkGray; UIHelpers.SetImageColor(__instance.MechArmorDisplay.ArmorOutline[0], cOutline); UIHelpers.SetImageColor(__instance.MechArmorDisplay.Armor[0], cFill); UIHelpers.SetImageColor(__instance.MechArmorDisplay.Structure[0], cFill); __instance.ShownTargetReticles[0].SetActive(false); } else { if (___displayedActor.UnitType == UnitType.Mech) { __instance.MechArmorDisplay.UpdateMechStructureAndArmor(___shownAttackDirection); } __instance.ShownTargetReticles[0].SetActive(true); } } catch (Exception e) { Logger.Error(e); } }