Beispiel #1
0
        private void SetStateAtRandom()
        {
            string encounterGuid = EncounterGuids.GetRandom();
            EncounterObjectGameLogic encounterGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <EncounterObjectGameLogic>(encounterGuid);

            if (encounterGameLogic != null)
            {
                // A chunk has been disabled by the contract override so ignore it and remove it from the list of choices
                if ((encounterGameLogic.StartingStatus == EncounterObjectStatus.ControlledByContract) && (encounterGameLogic.GetState() == EncounterObjectStatus.Finished))
                {
                    Main.LogDebug($"[SetStateAtRandomResult] Avoiding '{encounterGameLogic.gameObject.name}' due to it not being an active chunk in the contract overrides");
                    EncounterGuids.Remove(encounterGuid);
                    SetStateAtRandom();
                }
                else
                {
                    Main.LogDebug($"[SetStateAtRandomResult] Setting '{encounterGameLogic.gameObject.name}' state '{State}'");
                    encounterGameLogic.SetState(State);
                }
            }
            else
            {
                Main.LogDebug($"[SetStateAtRandomResult] Cannot find EncounterObjectGameLogic with Guid '{encounterGuid}'");
            }
        }
        private void SetChunkState(string guid)
        {
            Main.LogDebug($"[SetChunkStateAtRandomActivator]) Setting chunk state");
            EncounterObjectGameLogic chunk = MissionControl.Instance.EncounterLayerData.gameObject.GetEncounterObjectGameLogic(guid);

            if (chunk is EncounterChunkGameLogic)
            {
                Main.LogDebug($"[SetChunkStateAtRandomActivator]) Setting chunk state for '{guid}:{chunk.gameObject.name}'");
                ((EncounterObjectGameLogic)chunk).SetState(State);
            }
        }
        private void ActivateDialogue()
        {
            Main.LogDebug($"[DialogueActivator.ActivateDialogue]) Activating dialogue...");
            EncounterObjectGameLogic dialogue = MissionControl.Instance.EncounterLayerData.gameObject.GetEncounterObjectGameLogic(dialogueGuid);

            if (dialogue is DialogueGameLogic)
            {
                Main.LogDebug($"[DialogueActivator.ActivateDialogue]) Activating dialogue for '{dialogueGuid}:{dialogue.gameObject.name}'");
                ((DialogueGameLogic)dialogue).TriggerDialogue(true);
            }
        }
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug("[ExecuteGameLogicResult] Executing Game Logic...");

            if (ChunkGuid != null)
            {
                EncounterChunkGameLogic chunkGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <EncounterChunkGameLogic>(ChunkGuid);
                if (chunkGameLogic != null)
                {
                    MonoBehaviour[] monoBehaviours = chunkGameLogic.GetComponentsInChildren <MonoBehaviour>();
                    foreach (MonoBehaviour monoBehaviour in monoBehaviours)
                    {
                        if (monoBehaviour is ExecutableGameLogic)
                        {
                            ((ExecutableGameLogic)monoBehaviour).Execute();
                        }
                    }
                }
                else
                {
                    Main.LogDebug($"[ExecuteGameLogicResult] Cannot find ChunkGameLogic with Guid '{ChunkGuid}'");
                }
            }
            else if (EncounterGuid != null)
            {
                EncounterObjectGameLogic encounterGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <EncounterObjectGameLogic>(EncounterGuid);

                if (encounterGameLogic != null)
                {
                    MonoBehaviour[] monoBehaviours = encounterGameLogic.GetComponents <MonoBehaviour>();
                    foreach (MonoBehaviour monoBehaviour in monoBehaviours)
                    {
                        if (monoBehaviour is ExecutableGameLogic)
                        {
                            ((ExecutableGameLogic)monoBehaviour).Execute();
                        }
                    }
                }
                else
                {
                    Main.LogDebug($"[ExecuteGameLogicResult] Cannot find EncounterObjectGameLogic with Guid '{EncounterGuid}'");
                }
            }
        }
        private void SwapPlacement()
        {
            EncounterObjectGameLogic targetGameLogic1 = MissionControl.Instance.EncounterLayerData.gameObject.GetEncounterObjectGameLogic(swapTarget1Guid);
            EncounterObjectGameLogic targetGameLogic2 = MissionControl.Instance.EncounterLayerData.gameObject.GetEncounterObjectGameLogic(swapTarget2Guid);

            GameObject target1Go = targetGameLogic1.gameObject;
            GameObject target2Go = targetGameLogic2.gameObject;

            Main.LogDebug($"[SwapPlacementGameLogic.SwapPlacement]) Swapping position and rotation between '{target1Go.name}' and '{target2Go.name}'");

            Vector3    target1Position = target1Go.transform.position;
            Vector3    target2Position = target2Go.transform.position;
            Quaternion target1Rotation = target1Go.transform.rotation;
            Quaternion target2Rotation = target2Go.transform.rotation;

            target1Go.transform.position = target2Position;
            target2Go.transform.position = target1Position;
            target1Go.transform.rotation = target2Rotation;
            target2Go.transform.rotation = target1Rotation;
        }
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug("[SetStateResult] Setting state...");

            EncounterObjectGameLogic encounterGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <EncounterObjectGameLogic>(EncounterGuid);

            if (encounterGameLogic != null)
            {
                if ((encounterGameLogic.StartingStatus == EncounterObjectStatus.ControlledByContract) && (encounterGameLogic.GetState() == EncounterObjectStatus.Finished))
                {
                    Main.LogDebug($"[SetStateResult] Avoiding '{encounterGameLogic.gameObject.name}' due to it not being an active chunk in the contract overrides");
                }
                else
                {
                    Main.LogDebug($"[SetStateResult] Setting '{encounterGameLogic.gameObject.name}' state '{State}'");
                    encounterGameLogic.SetState(State);
                }
            }
            else
            {
                Main.LogDebug($"[SetStateResult] Cannot find EncounterObjectGameLogic with Guid '{EncounterGuid}'");
            }
        }
        static void Prefix(EncounterObjectGameLogic __instance, EncounterObjectStatus status)
        {
            EncounterObjectStateChangeMessage message = new EncounterObjectStateChangeMessage(__instance.encounterObjectGuid, status);

            UnityGameInstance.BattleTechGame.Combat.MessageCenter.PublishMessage(message);
        }