예제 #1
0
        public static bool CombatHUDInWorldElementMgr_AddFloatieMessage_Prefix(CombatHUDInWorldElementMgr __instance, MessageCenterMessage message, CombatGameState ___combat)
        {
            Traverse       showFloatieT   = Traverse.Create(__instance).Method("ShowFloatie", new Type[] { typeof(FloatieMessage) });
            FloatieMessage floatieMessage = message as FloatieMessage;

            switch (floatieMessage.nature)
            {
            case MessageNature.ArmorDamage:
            case MessageNature.StructureDamage:
            case MessageNature.Buff:
            case MessageNature.Debuff:
                showFloatieT.GetValue(new object[] { floatieMessage });
                break;

            case MessageNature.Miss:
            case MessageNature.MeleeMiss:
            case MessageNature.Dodge:
                //__instance.ShowFloatie(floatieMessage);
                break;

            default:
                //__instance.ShowStackedFloatie(floatieMessage);
                break;
            }

            return(false);
        }
예제 #2
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;
            }
        }
        static bool Prefix(CombatHUDInWorldElementMgr __instance, ICombatant combatant)
        {
            if (MissionControl.Instance.IsCustomContractType && combatant.team.GUID == TeamUtils.NEUTRAL_TO_ALL_TEAM_ID)
            {
                Main.LogDebug($"[CombatHUDInWorldElementMgrAddInWorldActorElementsPatch.Prefix] Disabling InWorldActorElements for NeutralToAll - {combatant.DisplayName}");
                return(false);
            }

            return(true);
        }
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[SetTeamByLanceSpawnerGuid] Setting Team '{Team}' with Spawner Guid '{LanceSpawnerGuid}'");
            LanceSpawnerGameLogic spawnerGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <LanceSpawnerGameLogic>(LanceSpawnerGuid);
            Lance lance = spawnerGameLogic.GetLance();
            List <AbstractActor> lanceUnits = spawnerGameLogic.GetLance().GetLanceUnits();

            Main.LogDebug($"[SetTeamByLanceSpawnerGuid] Found '{lanceUnits.Count}' lance units");
            Team oldTeam = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(spawnerGameLogic.teamDefinitionGuid);
            Team newTeam = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(TeamUtils.GetTeamGuid(Team));

            spawnerGameLogic.teamDefinitionGuid = TeamUtils.GetTeamGuid(Team);
            spawnerGameLogic.encounterTags.Remove(oldTeam.Name);
            spawnerGameLogic.encounterTags.Add(newTeam.Name);

            oldTeam.lances.Remove(lance);
            newTeam.lances.Add(lance);

            foreach (AbstractActor actor in lanceUnits)
            {
                oldTeam.RemoveUnit(actor);
                actor.AddToTeam(newTeam);
                newTeam.AddUnit(actor);

                actor.EncounterTags.Remove(oldTeam.Name);
                actor.EncounterTags.Add(newTeam.Name);

                if (ApplyTags != null)
                {
                    actor.EncounterTags.AddRange(ApplyTags);
                }

                CombatHUDInWorldElementMgr inworldElementManager = GameObject.Find("uixPrfPanl_HUD(Clone)").GetComponent <CombatHUDInWorldElementMgr>();
                if (oldTeam.GUID == TeamUtils.NEUTRAL_TO_ALL_TEAM_ID)
                {
                    AccessTools.Method(typeof(CombatHUDInWorldElementMgr), "AddInWorldActorElements").Invoke(inworldElementManager, new object[] { actor });
                }
                else if (newTeam.GUID == TeamUtils.NEUTRAL_TO_ALL_TEAM_ID)
                {
                    AccessTools.Method(typeof(CombatHUDInWorldElementMgr), "RemoveInWorldUI").Invoke(inworldElementManager, new object[] { actor.GUID });
                }

                CombatantSwitchedTeams message = new CombatantSwitchedTeams(actor.GUID, newTeam.GUID);
                this.combat.MessageCenter.PublishMessage(message);

                LazySingletonBehavior <FogOfWarView> .Instance.FowSystem.Rebuild();
            }

            if (this.AlertLance)
            {
                lance.BroadcastAlert();
            }
        }
예제 #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();
                }
            }
        }
예제 #6
0
        public static bool Prefix(CombatHUDInWorldElementMgr __instance, MessageCenterMessage message)
        {
            try
            {
                FloatieMessage floatieMessage = message as FloatieMessage;

                if (floatieMessage.nature == FloatieMessage.MessageNature.Suppression)
                {
                    Traverse ShowFloatie = Traverse.Create(__instance).Method("ShowFloatie", floatieMessage);
                    ShowFloatie.GetValue();

                    return(false);
                }

                return(true);
            }
            catch (Exception e)
            {
                Logger.Error(e);

                return(true);
            }
        }
예제 #7
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[SetIsObjectiveTargetByTagResult] Setting IsObjectiveTarget '{IsObjectiveTarget}' with tags '{String.Concat(Tags)}'");
            List <ICombatant> combatants = ObjectiveGameLogic.GetTaggedCombatants(UnityGameInstance.BattleTechGame.Combat, new TagSet(Tags));

            Main.LogDebug($"[SetIsObjectiveTargetByTagResult] Found '{combatants.Count}' combatants");

            foreach (ICombatant combatant in combatants)
            {
                BattleTech.Building building = combatant as BattleTech.Building;

                if (building != null)
                {
                    Main.LogDebug($"[SetIsObjectiveTargetByTagResult] Found building '{building.GameRep.name} - {building.DisplayName}'");
                    ObstructionGameLogic obstructionGameLogic = building.GameRep.GetComponent <ObstructionGameLogic>();
                    obstructionGameLogic.isObjectiveTarget = true;
                    AccessTools.Field(typeof(BattleTech.Building), "isObjectiveTarget").SetValue(combatant, 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 });
            }
        }
    public static CombatHUDFloatieStackActor GetFloatieStackForCombatant(this CombatHUDInWorldElementMgr combatHUDInWorldElementMgr, ICombatant combatant)
    {
        List <CombatHUDFloatieStackActor> FloatieStacks = (List <CombatHUDFloatieStackActor>)AccessTools.Field(typeof(CombatHUDInWorldElementMgr), "FloatieStacks").GetValue(combatHUDInWorldElementMgr);

        return(FloatieStacks.Find((CombatHUDFloatieStackActor x) => x.DisplayedCombatant == combatant));
    }