Beispiel #1
0
        private void SetIsTargetObjective(ICombatant combatant)
        {
            Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Setting isObjectiveTarget '{IsObjectiveTarget}' for '{combatant.GameRep.name} - {combatant.DisplayName}'");
            ObstructionGameLogic obstructionGameLogic = combatant.GameRep.GetComponent <ObstructionGameLogic>();

            obstructionGameLogic.isObjectiveTarget = true;

            if (Type == "Building")
            {
                BattleTech.Building building = combatant as BattleTech.Building;
                AccessTools.Field(typeof(BattleTech.Building), "isObjectiveTarget").SetValue(building, true);
                building.BuildingRep.IsTargetable = true;
            }

            CombatHUDInWorldElementMgr inworldElementManager = GameObject.Find("uixPrfPanl_HUD(Clone)").GetComponent <CombatHUDInWorldElementMgr>();

            AccessTools.Method(typeof(CombatHUDInWorldElementMgr), "AddTickMark").Invoke(inworldElementManager, new object[] { combatant });
            AccessTools.Method(typeof(CombatHUDInWorldElementMgr), "AddInWorldActorElements").Invoke(inworldElementManager, new object[] { combatant });

            if (Type == "Building")
            {
                CombatHUDNumFlagHex        numFlagEx = inworldElementManager.GetNumFlagForCombatant(combatant);
                CombatHUDFloatieStackActor floatie   = inworldElementManager.GetFloatieStackForCombatant(combatant);

                numFlagEx.anchorPosition = CombatHUDInWorldScalingActorInfo.AnchorPosition.Feet;
                floatie.anchorPosition   = CombatHUDInWorldScalingActorInfo.AnchorPosition.Feet;
            }
        }
 public static void Postfix(CombatHUDNumFlagHex __instance)
 {
     if (__instance.DisplayedActor != null && __instance.DisplayedActor.IsActorOnScreen())
     {
         PilotableActorRepresentation par = (PilotableActorRepresentation)__instance.DisplayedActor.GameRep;
         if (par != null && par.VisibleObject.activeSelf && par.BlipObjectUnknown.activeSelf)
         {
             __instance.anchorPosition = CombatHUDInWorldScalingActorInfo.AnchorPosition.Feet;
         }
         else
         {
             __instance.anchorPosition = CombatHUDInWorldScalingActorInfo.AnchorPosition.Head;
         }
     }
 }
 public static void SetArmorBarOwner(CombatHUDNumFlagHex __instance)
 {
     try {
         ICombatant            owner = __instance.DisplayedCombatant;
         CombatHUDArmorBarPips bar   = __instance.ActorInfo?.ArmorBar;
         if (bar == null)
         {
             return;
         }
         if (owner != null)
         {
             BarOwners[bar] = owner;
             bar.RefreshUIColors();
         }
         else if (BarOwners.ContainsKey(bar))
         {
             BarOwners.Remove(bar);
         }
     }                 catch (Exception ex) { Error(ex); }
 }
 public static void SetNameplateColor(CombatHUDNumFlagHex __instance)
 {
     try {
         Color?colour = GetTeamColour(__instance.DisplayedCombatant, NameplateColours);
         if (!colour.HasValue)
         {
             return;
         }
         CombatHUDActorNameDisplay names = __instance.ActorInfo?.NameDisplay;
         if (names == null)
         {
             return;
         }
         names.PilotNameText.faceColor = colour.Value;
         if (colour != Color.black)
         {
             names.MechNameText.outlineWidth = 0.2f;
             names.MechNameText.outlineColor = Color.black;
         }
         names.MechNameText.faceColor = colour.Value;
     }                 catch (Exception ex) { Error(ex); }
 }
Beispiel #5
0
        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();
                }
            }
        }