public static void OnCombatHUDInit(CombatGameState combat, CombatHUD combatHUD) { Mod.Log.Trace("Coordinator::OCHUDI - entered."); Coordinator.Combat = combat; Coordinator.MessageCenter = combat.MessageCenter; Coordinator.SideStack = combatHUD.DialogSideStack; if (Coordinator.CallSigns == null) { string filePath = Path.Combine(Mod.ModDir, Mod.Config.Dialogue.CallsignsPath); Mod.Log.Debug($"Reading files from {filePath}"); try { Coordinator.CallSigns = File.ReadAllLines(filePath).ToList(); } catch (Exception e) { Mod.Log.Error("Failed to read callsigns from BT directory!"); Mod.Log.Error(e); Coordinator.CallSigns = new List <string> { "Alpha", "Beta", "Gamma" }; } Mod.Log.Debug($"Callsign count is: {Coordinator.CallSigns.Count}"); } Mod.Log.Trace("Coordinator::OCHUDI - exiting."); }
void Start() { #region Spawn timer spawnTimer = new Timer(1000); spawnTimer.Elapsed += new ElapsedEventHandler(CanSpawn); #endregion #region Next Round Timer nextRound = new Timer(1000); nextRound.Elapsed += new ElapsedEventHandler(NextRound); #endregion patternNames = new List<string>(); chosenPattern = new List<Waypoint>(); minionTags = new List<string>(); minionWeak = Resources.Load("Spaceships/MinionWeak", typeof(GameObject)) as GameObject; minionNormal = Resources.Load("Spaceships/MinionNormal", typeof(GameObject)) as GameObject; minionStrong = Resources.Load("Spaceships/MinionStrong", typeof(GameObject)) as GameObject; boss = Resources.Load("Spaceships/Boss", typeof(GameObject)) as GameObject; bossAI = Resources.Load("Spaceships/BossAI", typeof(GameObject)) as GameObject; combatHUDScript = GameObject.Find("CombatHUD(Clone)").GetComponent<CombatHUD>(); gameControllerScript = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>(); countTimer = 10; countMinions = 0; credits += 1000; patternNames.Add("wave"); patternNames.Add("pulse"); patternNames.Add("loop"); }
public static bool Prefix(CombatHUD __instance, MessageCenterMessage message) { try { TriggerDialog triggerDialog = message as TriggerDialog; if (triggerDialog == null) { return(false); } if ( triggerDialog.DialogID == __instance.Combat.Constants.RavenTutorialDialogID || triggerDialog.DialogID == __instance.Combat.Constants.Story2TutorialSlides1ID || triggerDialog.DialogID == __instance.Combat.Constants.Story2TutorialSlides2ID || triggerDialog.DialogID == __instance.Combat.Constants.Story2TutorialSlides3ID || triggerDialog.DialogID == __instance.Combat.Constants.Story2TutorialSlides4ID ) { Logger.Debug("[CombatHUD_OnTriggerDialog_PREFIX] Supress tutorial: " + triggerDialog.DialogID); return(false); } return(true); } catch (Exception e) { Logger.Error(e); return(true); } }
private static void RunCombatEnds(CombatHUD __instance) { CallAllModules(module => module.CombatEnds()); CombatConstants = null; Combat = null; HUD = null; }
public static void ShowComponents(CombatHUD HUD) { Log.Debug?.TWL(0, "ShowComponents"); //if (HUD.SelectedActor == null) { return; }; typeof(CombatHUDWeaponPanel).GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUD.WeaponPanel, new object[] { weaponPanelState?WPStates["Unloading"] : WPStates["Loading"] }); weaponPanelState = !weaponPanelState; }
public static void Postfix(AbstractActor __instance, ref int __result, StatCollection ___statCollection) { CombatGameState ___Combat = (CombatGameState)Traverse.Create(__instance).Property("Combat").GetValue(); if (___Combat.TurnDirector.IsInterleaved) { CombatHUD ___HUD = (CombatHUD)Traverse.Create(__instance).Property("HUD").GetValue(); int baseInit = ___statCollection.GetValue <int>("BaseInitiative"); int phaseMod = ___statCollection.GetValue <int>("PhaseModifier"); int modifiedInit = baseInit + phaseMod; //SkillBasedInit.Logger.LogIfDebug($"Actor:({__instance.DisplayName}_{__instance.GetPilot().Name}) has stats BaseInit:{baseInit} / PhaseMod:{phaseMod}"); if (modifiedInit < Mod.MinPhase) { Mod.Log.Info($"Actor:({CombatantHelper.LogLabel(__instance)}) being set to {Mod.MinPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}"); __result = Mod.MinPhase; } else if (modifiedInit > Mod.MaxPhase) { Mod.Log.Info($"Actor:({CombatantHelper.LogLabel(__instance)}) being set to {Mod.MaxPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}"); __result = Mod.MaxPhase; } else { __result = modifiedInit; //SkillBasedInit.Logger.Log($"Actor:({__instance.DisplayName}_{__instance.GetPilot().Name}) has stats BaseInit:{baseInit} + PhaseMod:{phaseMod} = modifiedInit:{modifiedInit}."); } } }
public static void CombatHUD_Init_Postfix(CombatHUD __instance, CombatGameState Combat) { Mod.Log.Trace("CHUD:I:post - entered."); CombatLog.infoSidePanel = LazySingletonBehavior <UIManager> .Instance.GetOrCreateUIModule <CombatHUDInfoSidePanel>("", true); infoSidePanel.Init(); infoSidePanel.Visible = false; // Combat Chat module CombatLog.combatChatModule = LazySingletonBehavior <UIManager> .Instance.GetOrCreateUIModule <CombatChatModule>("", true); if (CombatLog.combatChatModule == null) { Mod.Log.Error("Error creating combat chat module"); } else { CombatLog.combatChatModule.CombatInit(); CombatLog.infoSidePanel.BumpUp(); } Mod.Log.Info($"CombatChatModule pos: {CombatLog.combatChatModule.gameObject.transform.position}"); Mod.Log.Info($"RetreatEscMenu pos: {__instance.RetreatEscMenu.gameObject.transform.position}"); Vector3 newPos = CombatLog.combatChatModule.gameObject.transform.position; newPos.x = __instance.RetreatEscMenu.gameObject.transform.position.x * 1.25f; newPos.y = __instance.RetreatEscMenu.gameObject.transform.position.y - 120f; //newPos.z = __instance.WeaponPanel.gameObject.transform.position.z; CombatLog.combatChatModule.gameObject.transform.position = newPos; Mod.Log.Info($"new CombatChatModule pos: {newPos}"); // Move the chat button into the menu Transform chatBtnT = CombatLog.combatChatModule.gameObject.transform.Find("Representation/chat_panel/uixPrf_chatButton"); Mod.Log.Info($"ChatButton base pos: {newPos}"); if (chatBtnT != null) { if (__instance.Combat.BattleTechGame.Simulation == null) { newPos.x -= 620f; // skirmish, no withdraw button } else { newPos.x -= 740f; // simgame, has withdraw button } newPos.y += 80f; chatBtnT.position = newPos; Mod.Log.Info($"ChatButton new pos: {newPos}"); } else { Mod.Log.Info("Could not find chatButton to change position!"); } combat = Combat; }
public static void Postfix(CombatHUD __instance) { HUD = null; CGS = null; CGC = null; WEAPON = null; TARGET = null; }
public static void Postfix(CombatHUD __instance, bool shouldAdd) { if (__instance != null) { __instance.Combat.MessageCenter.Subscribe( (MessageCenterMessageType)MessageTypes.OnCustomDialog, new ReceiveMessageCenterMessage(Coordinator.OnCustomDialogMessage), shouldAdd); } }
public new void Init(CombatHUD HUD) { CombatHUD = HUD; this.Title = new Localize.Text(new Localize.Text(Mod.LocalizedText.Tooltips[ModText.CHUD_TT_Title])); this.Description = new Localize.Text($"Heat: 0 / 0"); this.WarningText = new Localize.Text(""); base.Init(CombatHUD); }
public static void Postfix(CombatHUD __instance, CombatGameState Combat) { try { foreach (AbstractActor unit in Combat.AllActors) { } } catch (Exception e) { Log.WriteCritical(e.ToString() + "\n"); } }
public static void Prefix(CombatHUDWeaponPanel __instance, AbstractActor ___displayedActor) { if (__instance == null || ___displayedActor == null) { return; } Mod.Log.Trace?.Write("CHUDWP:RDW - entered."); Traverse targetT = Traverse.Create(__instance).Property("target"); Traverse hoveredTargetT = Traverse.Create(__instance).Property("hoveredTarget"); Traverse HUDT = Traverse.Create(__instance).Property("HUD"); CombatHUD HUD = HUDT.GetValue <CombatHUD>(); SelectionState activeState = HUD.SelectionHandler.ActiveState; ICombatant target; if (activeState != null && activeState is SelectionStateMove) { target = hoveredTargetT.GetValue <ICombatant>(); if (target == null) { target = targetT.GetValue <ICombatant>(); } } else { target = targetT.GetValue <ICombatant>(); if (target == null) { target = hoveredTargetT.GetValue <ICombatant>(); } } if (target == null) { return; } EWState attackerState = new EWState(___displayedActor); Mod.Log.Debug?.Write($"Attacker ({CombatantUtils.Label(___displayedActor)} => EWState: {attackerState}"); bool canSpotTarget = VisualLockHelper.CanSpotTarget(___displayedActor, ___displayedActor.CurrentPosition, target, target.CurrentPosition, target.CurrentRotation, ___displayedActor.Combat.LOS); SensorScanType sensorScan = SensorLockHelper.CalculateSharedLock(target, ___displayedActor); Mod.Log.Debug?.Write($" canSpotTarget: {canSpotTarget} sensorScan: {sensorScan}"); if (target is AbstractActor targetActor) { EWState targetState = new EWState(targetActor); Mod.Log.Debug?.Write($"Target ({CombatantUtils.Label(targetActor)} => EWState: {targetState}"); } }
public static void Postfix(CombatHUD __instance) { try { if (spawnedActors.Count > 0) { AbstractActor unit = spawnedActors.Dequeue(); unit.ActiveDefaultComponents(); } } catch (Exception e) { Log.WriteCritical(e.ToString() + "\n"); } }
private static void RunCombatStarts(CombatHUD __instance) { HUD = __instance; Combat = BattleTechGame?.Combat; CombatConstants = Combat?.Constants; if (!CalledCombatStartsOnce) { CallAllModules(module => module.CombatStartsOnce()); CalledCombatStartsOnce = true; } CallAllModules(module => module.CombatStarts()); }
static void Postfix(CombatHUD ___combatHUD) { if (___combatHUD.SelectedTarget != null && ___combatHUD.SelectedTarget is Mech targetMech) { Mod.UILog.Info?.Write($"Adding {Mod.Config.Heat.MaxHeat} external heat to targetMech: {CombatantUtils.Label(targetMech)} "); targetMech.AddExternalHeat("CBTBE_DEBUG", Mod.Config.Developer.DebugHeatToAdd); } else if (___combatHUD.SelectedActor != null && ___combatHUD.SelectedActor is Mech actorMech) { Mod.UILog.Info?.Write($"Adding {Mod.Config.Heat.MaxHeat} external heat to actorMech: {CombatantUtils.Label(actorMech)} "); actorMech.AddExternalHeat("CBTBE_DEBUG", Mod.Config.Developer.DebugHeatToAdd); } }
// Token: 0x06000025 RID: 37 private static void Postfix(ToHit __instance, ref float __result, AbstractActor attacker, Weapon weapon, ICombatant target, Vector3 attackPosition, Vector3 targetPosition, LineOfFireLevel lofLevel, bool isCalledShot) { if (UnityGameInstance.BattleTechGame.Simulation != null && weapon != null) { Mod.Log.Trace("TH:GAM entered"); bool flag3; if (!attacker.HasMovedThisRound || !attacker.JumpedLastRound || attacker.SkillTactics >= Mod.Config.TacticsSkillNegateJump) { CombatHUD combatHUD = ModState.CombatHUD; bool flag2; if (combatHUD == null) { flag2 = false; } else { CombatSelectionHandler selectionHandler = combatHUD.SelectionHandler; flag2 = (((selectionHandler != null) ? selectionHandler.ActiveState : null) != null); } if (flag2) { CombatHUD combatHUD2 = ModState.CombatHUD; object obj; if (combatHUD2 == null) { obj = null; } else { CombatSelectionHandler selectionHandler2 = combatHUD2.SelectionHandler; obj = ((selectionHandler2 != null) ? selectionHandler2.ActiveState : null); } if (obj is SelectionStateJump) { flag3 = (attacker.SkillTactics < Mod.Config.TacticsSkillNegateJump); goto IL_D8; } } flag3 = false; } else { flag3 = true; } IL_D8: if (flag3) { __result += (float)Mod.Config.ToHitSelfJumped; } } }
public static void Reset() { // Reinitialize state WithdrawStarted = false; CanWithdrawOnRound = -1; CanWithdrawOnRound = -1; RetreatButton = null; RetreatButtonText = null; HUD = null; CombatDamage = 0f; }
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 OnCombatHUDInit(CombatGameState combat, CombatHUD combatHUD) { Combat = combat; MessageCenter = combat.MessageCenter; SideStack = combatHUD.DialogSideStack; if (CallSigns == null) { string filePath = Path.Combine(PanicSystem.modDirectory, PanicSystem.modSettings.Dialogue.CallsignsPath); //LogDebug($"Reading files from {filePath}"); CallSigns = File.ReadAllLines(filePath).ToList(); } //LogDebug($"Callsign count is: {CallSigns.Count}"); }
//public static bool Prepare() { return false; } public static void Postfix(CombatHUDActionButton __instance, ref bool __result) { CombatHUDEquipmentSlot slot = __instance as CombatHUDEquipmentSlot; if (slot == null) { return; } Log.TWL(0, "CombatHUDEquipmentSlot.TryActivate GUID:" + __instance.GUID + " selection type:" + (SelectionType)typeof(CombatHUDEquipmentSlot).GetProperty("SelectionType", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(slot) + " result:" + __result); if (__result) { CombatHUD HUD = (CombatHUD)p_HUD.GetValue(slot); HUD.AttackModeSelector.FireButton.FireText.SetText(slot.Ability.Def.Description.Name); } }
public static void Postfix(CombatHUD __instance) { try { // Only relevant for Precision Strike if (__instance.SelectionHandler.ActiveState == null || __instance.SelectionHandler.ActiveState.SelectionType != SelectionType.FireMorale) { return; } // No headshots from behind if (__instance.CalledShotPopUp.ShownAttackDirection == AttackDirection.FromBack) { return; } Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] Clear confirmed called headshot if enabled weapons change to an invalid amount..."); bool isCalledShotPopupVisible = __instance.CalledShotPopUp.Visible; Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] isCalledShotPopupVisible: " + isCalledShotPopupVisible); int enabledWeaponCount = Utilities.GetReadiedWeaponCount(__instance.SelectedActor.Weapons, __instance.SelectedTarget, true); Pilot selectedPilot = __instance.SelectedActor.GetPilot(); int maxAllowedWeapons = Utilities.GetMaxAllowedWeaponCountForHeadshots(selectedPilot); bool validWeaponCountForPrecisionStrike = enabledWeaponCount <= maxAllowedWeapons ? true : false; Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] enabledWeaponCount: " + enabledWeaponCount); Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] validWeaponCountForPrecisionStrike: " + validWeaponCountForPrecisionStrike); ArmorLocation baseCalledShotLocation = (ArmorLocation)typeof(SelectionStateFire).GetField("calledShotLocation", AccessTools.all).GetValue(__instance.SelectionHandler.ActiveState); bool headIsTargeted = baseCalledShotLocation == ArmorLocation.Head; Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] headIsTargeted: " + headIsTargeted); //bool isMoraleAttack = __instance.SelectionHandler.ActiveState is SelectionStateMoraleAttack; //Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] isMoraleAttack: " + isMoraleAttack); bool shouldBackOut = headIsTargeted && !isCalledShotPopupVisible && !validWeaponCountForPrecisionStrike; Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] shouldBackOut: " + shouldBackOut); if (shouldBackOut) { Logger.Debug("[CombatHUD_OnWeaponModified_POSTFIX] " + __instance.SelectionHandler.ActiveState.ToString() + ".BackOut()"); __instance.SelectionHandler.ActiveState.BackOut(); } } catch (Exception e) { Logger.Error(e); } }
public static void Postfix(CombatHUDMechTray __instance, CombatHUD ___HUD) { Mod.Log.Trace("CHUDMT::Init - entered."); if (__instance.gameObject.GetComponentInChildren <CombatHUDHeatDisplay>() == null) { Mod.Log.Warn("COULD NOT FIND HEAT DISPLAY"); } else { CombatHUDHeatDisplay heatDisplay = __instance.gameObject.GetComponentInChildren <CombatHUDHeatDisplay>(); HoverElement = heatDisplay.gameObject.AddComponent <CombatHUDSidePanelHeatHoverElement>(); HoverElement.name = "CBTBE_Hover_Element"; HoverElement.Init(___HUD); } HUD = ___HUD; }
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); } }
public static void AddLine(VerticalLayoutGroup layout, CombatHUD HUD, LocalizableText src, ComponentLine dataline, bool error) { //LocalizableText upline = AddLine(layout, src, new string('_', dataline.length()), TMPro.TextAlignmentOptions.TopLeft); LocalizableText atextline = AddLine(layout, src, dataline.ToString(false), TMPro.TextAlignmentOptions.TopLeft); //LocalizableText btline = AddLine(layout, src, new string('_', dataline.length()), TMPro.TextAlignmentOptions.TopLeft); if (error) { dataline.error = true; } ; if ((error == false) && (dataline.error == false)) { ActivatbleMenuTriggers trigger = atextline.gameObject.GetComponent <ActivatbleMenuTriggers>(); if (trigger == null) { trigger = atextline.gameObject.AddComponent <ActivatbleMenuTriggers>(); } trigger.Init(atextline, dataline); } }
public static void Postfix(CombatHUDStatusPanel __instance, Mech mech) { Mod.UILog.Trace?.Write("CHUBSP:SSDI:POST entered."); var type = __instance.GetType(); MethodInfo methodInfo = type.GetMethod("ShowDebuff", (BindingFlags.NonPublic | BindingFlags.Instance), null, new Type[] { typeof(SVGAsset), typeof(Text), typeof(Text), typeof(Vector3), typeof(bool) }, new ParameterModifier[5]); Traverse HUDT = Traverse.Create(__instance).Property("HUD"); CombatHUD HUD = HUDT.GetValue <CombatHUD>(); CalculatedHeat calculatedHeat = HeatHelper.CalculateHeat(mech, HUD.SelectionHandler.ProjectedHeatForState); Mod.UILog.Debug?.Write($"In ShutdownIndicator, projectedHeat {HUD.SelectionHandler.ProjectedHeatForState} => calculatedHeat: {calculatedHeat.ThresholdHeat} vs {Mod.Config.Heat.WarnAtHeat}"); Mod.UILog.Debug?.Write($" current: {calculatedHeat.CurrentHeat} projected: {calculatedHeat.ProjectedHeat} temp: {calculatedHeat.TempHeat} " + $"sinkable: {calculatedHeat.SinkableHeat} sinkCapacity: {calculatedHeat.OverallSinkCapacity} future: {calculatedHeat.FutureHeat} threshold: {calculatedHeat.ThresholdHeat}"); Mod.UILog.Debug?.Write($" CACTerrainHeat{ calculatedHeat.CACTerrainHeat} CurrentPathNodes: {calculatedHeat.CurrentPathNodes} isProjectedHeat: {calculatedHeat.IsProjectedHeat}"); if (mech.IsShutDown) { Mod.UILog.Info?.Write($" Mech {CombatantUtils.Label(mech)} is shutdown, displaying the shutdown warning"); methodInfo.Invoke(__instance, new object[] { LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StatusShutDownIcon, new Text(Mod.LocalizedText.Tooltips[ModText.CHUDSP_TT_WARN_SHUTDOWN_TITLE]), new Text(Mod.LocalizedText.Tooltips[ModText.CHUDSP_TT_WARN_SHUTDOWN_TEXT]), __instance.defaultIconScale, false }); } else if (calculatedHeat.ThresholdHeat >= Mod.Config.Heat.WarnAtHeat) { Mod.UILog.Info?.Write($"Mech {mech.DistinctId()} has thresholdHeat {calculatedHeat.ThresholdHeat} >= warningHeat: {Mod.Config.Heat.WarnAtHeat}. Displaying heat warning."); methodInfo.Invoke(__instance, new object[] { LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StatusOverheatingIcon, new Text(Mod.LocalizedText.Tooltips[ModText.CHUDSP_TT_WARN_OVERHEAT_TITLE]), new Text(Mod.LocalizedText.Tooltips[ModText.CHUDSP_TT_WARN_OVERHEAT_TEXT]), __instance.defaultIconScale, false }); } }
public static void Postfix(CombatHUD __instance, bool shouldAdd) { if (shouldAdd) { Combat = __instance.Combat; ShowTargetMethod = Traverse.Create(__instance).Method("ShowTarget", new Type[] { typeof(ICombatant) }); __instance.Combat.MessageCenter.Subscribe(MessageCenterMessageType.ActorTargetedMessage, new ReceiveMessageCenterMessage(OnActorTargeted), shouldAdd); // Disable the previous registration __instance.Combat.MessageCenter.Subscribe(MessageCenterMessageType.ActorTargetedMessage, new ReceiveMessageCenterMessage(__instance.OnActorTargetedMessage), false); } else { Combat = null; ShowTargetMethod = null; __instance.Combat.MessageCenter.Subscribe(MessageCenterMessageType.ActorTargetedMessage, new ReceiveMessageCenterMessage(OnActorTargeted), shouldAdd); } }
public static void ForceNameRefresh(CombatGameState combat) { CombatHUD combatHUD = VisRangeIndicator.Instance.HUD; CombatHUDInWorldElementMgr inWorldMgr = combatHUD?.InWorldMgr; if (combat == null || combatHUD == null || inWorldMgr == null) { Mod.Log.Warn?.Write("CombatGameState, CombatHUD, or InWorldManager was null when a ForceNameRefresh call was made - skipping!"); return; } // Force an update of visibility state to try to get the mech labels to update foreach (ICombatant combatant in combat.GetAllImporantCombatants()) { CombatHUDNumFlagHex flagHex = inWorldMgr.GetNumFlagForCombatant(combatant); // Can be null in CWolf's blackout contracts. He intentionally disables the flagHex in those cases. if (flagHex != null) { flagHex.ActorInfo.NameDisplay.RefreshInfo(); } } }
// TODO: Dangerous PREFIX false here! public static bool Prefix(CombatHUDTargetingComputer __instance, CombatHUD ___HUD) { //Mod.Log.Trace?.Write("CHUDTC:U:pre - entered."); CombatGameState Combat = ___HUD?.Combat; UIModule_Update(__instance); if (__instance.ActorInfo != null) { __instance.ActorInfo.DisplayedCombatant = __instance.ActivelyShownCombatant; } if (__instance.ActivelyShownCombatant == null || (__instance.ActivelyShownCombatant.team != Combat.LocalPlayerTeam && !Combat.HostilityMatrix.IsFriendly(__instance.ActivelyShownCombatant.team.GUID, Combat.LocalPlayerTeamGuid) && Combat.LocalPlayerTeam.VisibilityToTarget(__instance.ActivelyShownCombatant) < VisibilityLevel.Blip0Minimum) ) { if (__instance.Visible) { __instance.Visible = false; } } else { if (!__instance.Visible) { __instance.Visible = true; } if (__instance.ActivelyShownCombatant != null) { Traverse method = Traverse.Create(__instance).Method("UpdateStructureAndArmor", new Type[] { }); method.GetValue(); } } return(false); }
public static void Postfix(CombatHUDAttackModeSelector __instance) { Mod.UILog.Trace?.Write("CHUDAMS:U - entered."); Traverse HUDT = Traverse.Create(__instance).Property("HUD"); CombatHUD HUD = HUDT.GetValue <CombatHUD>(); if (HUD != null && HUD.SelectedActor != null && HUD.SelectedActor is Mech) { Traverse showHeatWarningsT = Traverse.Create(__instance).Field("showHeatWarnings"); bool showHeatWarnings = showHeatWarningsT.GetValue <bool>(); if (showHeatWarnings) { CalculatedHeat calculatedHeat = HeatHelper.CalculateHeat(HUD.SelectedActor as Mech, HUD.SelectionHandler.ProjectedHeatForState); //Mod.UILog.Debug?.Write($" In CombatHUDAttackModeSelector, projectedHeat: {calculatedHeat.ThresholdHeat} vs {Mod.Config.Heat.WarnAtHeat}"); bool isOverheated = calculatedHeat.ThresholdHeat >= Mod.Config.Heat.WarnAtHeat; bool isShutdown = calculatedHeat.ThresholdHeat >= Mod.Config.Heat.MaxHeat; Traverse updateOverheatWarningsT = Traverse.Create(__instance).Method("UpdateOverheatWarnings", new object[] { isOverheated, isShutdown }); updateOverheatWarningsT.GetValue(); } } }
public static void Postfix(CombatHUD __instance) { bool key = Input.GetKey(KeyCode.A); bool mod = Input.GetKey(KeyCode.LeftControl); bool res = key && mod; if (keypressed != res) { keypressed = res; if (keypressed) { switch (hideReticles) { case AuraShowState.Default: hideReticles = AuraShowState.HideAll; break; case AuraShowState.HideAll: hideReticles = AuraShowState.ShowAll; break; case AuraShowState.ShowAll: hideReticles = AuraShowState.Default; break; } } ; } }
public static void Postfix(CombatHUDStealthBarPips __instance, float current, float projected) { Mod.Log.Trace?.Write("CHUDSBP:SV entered"); Mod.Log.Trace?.Write($"StealthBarPips incoming count is: {current} with projected: {projected}"); Traverse HUDT = Traverse.Create(__instance).Property("HUD"); CombatHUD HUD = HUDT.GetValue <CombatHUD>(); Traverse actorT = Traverse.Create(HUD).Field("selectedUnit"); AbstractActor selectedActor = actorT.GetValue <AbstractActor>(); Mod.Log.Trace?.Write($" selectedActor: ({CombatantUtils.Label(selectedActor)})"); Traverse floorCurrentT = Traverse.Create(__instance).Field("floorCurrent"); int floorCurrent = floorCurrentT.GetValue <int>(); Traverse floorLockedT = Traverse.Create(__instance).Field("floorLocked"); int floorLocked = floorLockedT.GetValue <int>(); Traverse floorProjectedT = Traverse.Create(__instance).Field("floorProjected"); int floorProjected = floorProjectedT.GetValue <int>(); Traverse remainderT = Traverse.Create(__instance).Field("remainder"); float remainder = remainderT.GetValue <float>(); Mod.Log.Trace?.Write($" floorCurrent: {floorCurrent} floorLocked: {floorLocked} floorProjected: {floorProjected} remainder: {remainder}"); Traverse pipsT = Traverse.Create(__instance).Property("Pips"); List <Graphic> pips = pipsT.GetValue <List <Graphic> >(); for (int i = 0; i < pips.Count; i++) { Mod.Log.Trace?.Write($" -- pips graphic: {i} isEnabled: {pips[i].IsActive()}"); } }