Ejemplo n.º 1
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[SetTeamByTagResult] Setting Team '{Team}' with tags '{String.Concat(Tags)}'");
            List <ICombatant> combatants = ObjectiveGameLogic.GetTaggedCombatants(UnityGameInstance.BattleTechGame.Combat, new TagSet(Tags));

            Main.LogDebug($"[SetTeamByTagResult] Found '{combatants.Count}' combatants");
            Team  newTeam  = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(TeamUtils.GetTeamGuid(Team));
            Lance newLance = new Lance(newTeam);

            newLance.team = newTeam;

            foreach (ICombatant combatant in combatants)
            {
                if (combatant is AbstractActor)
                {
                    /*
                     * AbstractActor actor = combatant as AbstractActor;
                     *
                     * actor.lance.RemoveUnitGUID(actor.GUID);
                     * actor.RemoveFromLance();
                     * actor.team.RemoveUnit(actor);
                     *
                     * actor.AddToTeam(newTeam);
                     * newLance.AddUnitGUID(actor.GUID);
                     * actor.AddToLance(newLance);
                     * newLance.team.AddUnit(actor);
                     *
                     * actor.team.lances.Add(newLance);
                     */
                    Main.Logger.LogError($"[SetTeamByTagResult] Using this result with AbstractActors isn't supported yet");
                }
                else
                {
                    combatant.RemoveFromTeam();
                    combatant.AddToTeam(newTeam);
                }

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

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

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

            if (newLance.unitGuids.Count > 0)
            {
                newTeam.lances.Add(newLance);
                UnityGameInstance.BattleTechGame.Combat.ItemRegistry.AddItem(newLance);

                if (this.AlertLance)
                {
                    newLance.BroadcastAlert();
                }
            }
        }
Ejemplo n.º 2
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[SetTemporaryUnitPhaseInitiativeByTagResult] Setting Initiative '{Initiative}' on units with tags '{String.Concat(Tags)}'");
            List <ICombatant> combatants = ObjectiveGameLogic.GetTaggedCombatants(UnityGameInstance.BattleTechGame.Combat, new TagSet(Tags));

            Main.LogDebug($"[SetTemporaryUnitPhaseInitiativeByTagResult] Found '{combatants.Count}' units");
            foreach (ICombatant combatant in combatants)
            {
                AbstractActor actor = combatant as AbstractActor;
                if (actor != null)
                {
                    int oldInitiative  = actor.Initiative;
                    int initiativeDiff = Initiative - oldInitiative;
                    actor.Initiative = Initiative;
                    UnityGameInstance.BattleTechGame.Combat.MessageCenter.PublishMessage(new ActorPhaseInfoChanged(actor.GUID));
                    actor.StatCollection.Set <int>(AbstractActorConstants.STAT_PHASEMOD, initiativeDiff);
                }
            }
        }
Ejemplo n.º 3
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[SetLanceEvasionTicksByTagResult] Setting evasion '{Amount}' on combatants with tags '{String.Concat(Tags)}'");
            List <ICombatant> combatants = ObjectiveGameLogic.GetTaggedCombatants(UnityGameInstance.BattleTechGame.Combat, new TagSet(Tags));

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

            foreach (ICombatant combatant in combatants)
            {
                if (combatant is AbstractActor)
                {
                    AbstractActor actor = combatant as AbstractActor;

                    actor.EvasivePipsCurrent = Amount;
                    AccessTools.Property(typeof(AbstractActor), "EvasivePipsTotal").SetValue(actor, actor.EvasivePipsCurrent, null);
                    UnityGameInstance.BattleTechGame.Combat.MessageCenter.PublishMessage(new EvasiveChangedMessage(actor.GUID, actor.EvasivePipsCurrent));
                }
            }
        }
Ejemplo n.º 4
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 });
            }
        }