Пример #1
0
        public static ContractObjectiveGameLogic CreateContractObjective(ObjectiveGameLogic objective)
        {
            ContractObjectiveGameLogic contractObjectiveGameLogic = objective.transform.parent.gameObject.AddComponent <ContractObjectiveGameLogic>();

            contractObjectiveGameLogic.objectiveRefList.Add(new ObjectiveRef(objective));
            return(contractObjectiveGameLogic);
        }
Пример #2
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();
                }
            }
        }
Пример #3
0
        public static ContractObjectiveGameLogic CreateContractObjective(ObjectiveGameLogic objective)
        {
            ContractObjectiveGameLogic contractObjectiveGameLogic = objective.transform.parent.gameObject.AddComponent <ContractObjectiveGameLogic>();

            contractObjectiveGameLogic.encounterObjectGuid = Guid.NewGuid().ToString();
            contractObjectiveGameLogic.objectiveRefList.Add(new ObjectiveRef(objective));
            return(contractObjectiveGameLogic);
        }
Пример #4
0
    public static bool IsAnInactiveContractControlledObjective(this ObjectiveGameLogic objectiveGameLogic)
    {
        EncounterChunkGameLogic chunkGameLogic = objectiveGameLogic.GetComponentInParent <EncounterChunkGameLogic>();

        if ((chunkGameLogic.StartingStatus == EncounterObjectStatus.ControlledByContract) && (chunkGameLogic.GetState() == EncounterObjectStatus.Finished))
        {
            return(true);
        }
        return(false);
    }
 static void Postfix(BattleTech.Building __instance, ObjectiveGameLogic objective)
 {
     if (!ModState.ScaledObjectiveBuildings.Contains(__instance.DistinctId()))
     {
         __instance.ScaleHealth();
         ModState.ScaledObjectiveBuildings.Add(__instance.DistinctId());
     }
     else
     {
         Mod.Log.Info?.Write($" -- building: {__instance.DistinctId()} was already scaled, skipping");
     }
 }
Пример #6
0
        private static void AttachRequiredReferences(ObjectiveGameLogic objectiveGameLogic, string contractObjectiveGuid)
        {
            if (contractObjectiveGuid != null)
            {
                ContractObjectiveGameLogic contractObjectiveGameLogic = MissionControl.Instance.EncounterLayerData.GetContractObjectiveGameLogicByGUID(contractObjectiveGuid);
                ObjectiveRef objectiveRef = new ObjectiveRef(objectiveGameLogic);
                contractObjectiveGameLogic.objectiveRefList.Add(objectiveRef);
            }

            objectiveGameLogic.onSuccessDialogue = new DialogueRef();
            objectiveGameLogic.onFailureDialogue = new DialogueRef();
        }
Пример #7
0
    public static void SetInactiveContractControlledObjectivesNotRequired(this ContractObjectiveGameLogic contractObjectiveGameLogic)
    {
        ItemRegistry itemRegistry = UnityGameInstance.BattleTechGame.Combat.ItemRegistry;

        foreach (ObjectiveRef objectiveRef in contractObjectiveGameLogic.objectiveRefList)
        {
            ObjectiveGameLogic objectiveGameLogic = objectiveRef.GetEncounterObject(itemRegistry);

            if (objectiveGameLogic.IsAnInactiveContractControlledObjective())
            {
                MissionControl.Main.LogDebug($"[SetInactiveContractControlledObjectivesNotRequired] Setting '{objectiveGameLogic.gameObject.name}' as non-primary");
                AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objectiveGameLogic, false);
            }
        }
    }
Пример #8
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);
                }
            }
        }
Пример #9
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));
                }
            }
        }
Пример #10
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[ShowObjectiveResult] Showing objective for object guid '{ObjectiveGuid}'");

            if (IsContractObjective)
            {
                ContractObjectiveGameLogic contractObjectiveGameLogic = MissionControl.Instance.EncounterLayerData.GetContractObjectiveGameLogicByGUID(ObjectiveGuid);
                ShowContractObjective(contractObjectiveGameLogic);
            }
            else
            {
                ObjectiveGameLogic objectiveGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <ObjectiveGameLogic>(ObjectiveGuid);
                if (objectiveGameLogic != null)
                {
                    ShowObjective(objectiveGameLogic);
                }
                else
                {
                    Main.Logger.LogError($"[ShowObjectiveResult] ObjectiveGameLogic not found with objective guid '{ObjectiveGuid}'");
                }
            }
        }
Пример #11
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 });
            }
        }
Пример #12
0
        private void EvaluateChild(string guid, string responseName)
        {
            ObjectiveGameLogic            objectiveGameLogic = this.combat.ItemRegistry.GetItemByGUID <ObjectiveGameLogic>(guid);
            ObjectiveStatusEvaluationType objectiveStatus    = Statuses[guid];

            if (objectiveGameLogic.IsAnInactiveContractControlledObjective())
            {
                Main.LogDebug($"[ObjectiveStatusesConditional] '{objectiveGameLogic.gameObject.name}' is an objective in an inactive contract controlled chunk. Auto-suceeeding objective for this check");
                completedStatus[guid] = true;
                return;
            }

            switch (objectiveStatus)
            {
            case ObjectiveStatusEvaluationType.InProgress: {
                string message2;
                if (objectiveGameLogic.IsInProgress)
                {
                    message2 = string.Format("Objective[{0}] is in progress.", objectiveGameLogic.DisplayName);
                    base.LogEvaluationPassed(message2, responseName);
                    completedStatus[guid] = true;
                    return;
                }
                message2 = string.Format("Objective[{0}] is NOT in progress.", objectiveGameLogic.DisplayName);
                base.LogEvaluationFailed(message2, responseName);
                return;
            }

            case ObjectiveStatusEvaluationType.Complete: {
                string message2;
                if (objectiveGameLogic.IsComplete)
                {
                    message2 = string.Format("Objective[{0}] is Complete.", objectiveGameLogic.DisplayName);
                    base.LogEvaluationPassed(message2, responseName);
                    completedStatus[guid] = true;
                    return;
                }
                message2 = string.Format("Objective[{0}] is NOT Complete.", objectiveGameLogic.DisplayName);
                base.LogEvaluationFailed(message2, responseName);
                return;
            }

            case ObjectiveStatusEvaluationType.Success: {
                string message2;
                if (objectiveGameLogic.CurrentObjectiveStatus == ObjectiveStatus.Succeeded)
                {
                    message2 = string.Format("Objective[{0}] is Succeeded.", objectiveGameLogic.DisplayName);
                    base.LogEvaluationPassed(message2, responseName);
                    completedStatus[guid] = true;
                    return;
                }
                message2 = string.Format("Objective[{0}] is NOT Succeeded.", objectiveGameLogic.DisplayName);
                base.LogEvaluationFailed(message2, responseName);
                return;
            }

            case ObjectiveStatusEvaluationType.Failed: {
                string message2;
                if (objectiveGameLogic.CurrentObjectiveStatus == ObjectiveStatus.Failed)
                {
                    message2 = string.Format("Objective[{0}] is Failed.", objectiveGameLogic.DisplayName);
                    base.LogEvaluationPassed(message2, responseName);
                    completedStatus[guid] = true;
                }
                message2 = string.Format("Objective[{0}] is NOT Failed.", objectiveGameLogic.DisplayName);
                base.LogEvaluationFailed(message2, responseName);
                return;
            }

            case ObjectiveStatusEvaluationType.NotInProgress: {
                string message2;
                if (!objectiveGameLogic.IsInProgress)
                {
                    message2 = string.Format("Objective[{0}] is NOT in progress.", objectiveGameLogic.DisplayName);
                    base.LogEvaluationPassed(message2, responseName);
                    completedStatus[guid] = true;
                    return;
                }
                message2 = string.Format("Objective[{0}] is in progress.", objectiveGameLogic.DisplayName);
                base.LogEvaluationFailed(message2, responseName);
                return;
            }

            default: {
                string message2 = string.Format("Objective[{0}] status is weird! [{1}]", objectiveGameLogic.DisplayName, objectiveStatus);
                base.LogEvaluationFailed(message2, responseName);
                return;
            }
            }
        }
 static void Postfix(ObjectiveGameLogic __instance)
 {
     Main.LogDebug($"[ObjectiveGameLogicActivateObjectivePatch.Postfix] Running...");
     AccessTools.Method(typeof(ObjectiveGameLogic), "OnBuildingSpawned").Invoke(__instance, new object[] { null });
 }
Пример #14
0
 public void ShowObjective(ObjectiveGameLogic objectiveGameLogic)
 {
     objectiveGameLogic.displayToUser = true;
     AccessTools.Method(typeof(ObjectiveGameLogic), "ShowObjective").Invoke(objectiveGameLogic, null);
 }