From 7ef08a766b53596ec8b42245f086553b3f5bb2db Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Fri, 4 Nov 2022 10:36:18 +0100 Subject: [PATCH 1/8] Independent Kamea in the Leopard --- src/Core/Actions.cs | 49 +++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/Core/Actions.cs b/src/Core/Actions.cs index 26aa1b2..b407ff4 100644 --- a/src/Core/Actions.cs +++ b/src/Core/Actions.cs @@ -17,6 +17,8 @@ namespace ExtendedConversations.Core { public class Actions { + public static bool MovedKameraInLeopard = false; + public static object TimeSkip(TsEnvironment env, object[] inputs) { int daysToSkip = env.ToInt(inputs[0]); Main.Logger.Log($"[TimeSkip] Triggered with days to skip '{daysToSkip}'"); @@ -45,11 +47,11 @@ public static object SetCurrentSystem(TsEnvironment env, object[] inputs) { ReflectionHelper.SetReadOnlyProperty(simulation, "CurSystem", systemNode.System); simulation.SetCurrentSystem(systemNode.System, true, false); } - + Main.Logger.Log($"[SetCurrentSystem] Travel complete"); return null; } - + public static object ModifyFunds(TsEnvironment env, object[] inputs) { int operation = env.ToInt(inputs[0]); int amount = env.ToInt(inputs[1]); @@ -65,26 +67,39 @@ public static object ModifyFunds(TsEnvironment env, object[] inputs) { Main.Logger.LogError($"[ModifyFunds] Unknown operation type of '{operation}'"); return null; } - + Main.Logger.Log($"[ModifyFunds] Funds modified."); return null; } public static object SetCharactersVisible(TsEnvironment env, object[] inputs) { - bool isVisible = env.ToBool(inputs[0]); - string crewNamesGrouped = env.ToString(inputs[1]); - Main.Logger.Log($"[SetCharactersVisible] crewnames '{crewNamesGrouped}' will be visible status {isVisible}."); - - string[] crewNames = crewNamesGrouped.Split(','); - - foreach (string crewName in crewNames) { - SimGameState.SimGameCharacterType character = (SimGameState.SimGameCharacterType)Enum.Parse(typeof(SimGameState.SimGameCharacterType), crewName, true); - SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; - simulation.SetCharacterVisibility(character, isVisible); + bool isVisible = env.ToBool(inputs[0]); + string crewNamesGrouped = env.ToString(inputs[1]); + Main.Logger.Log($"[SetCharactersVisible] crewnames '{crewNamesGrouped}' will be visible status {isVisible}."); + + string[] crewNames = crewNamesGrouped.Split(','); + + // Fix for Leopard Kamea/Alex structure being wrong + if (!MovedKameraInLeopard) { + if (UnityGameInstance.Instance.Game.Simulation.CurDropship == DropshipType.Leopard && UnityGameInstance.Instance.Game.Simulation.CurRoomState == DropshipLocation.CMD_CENTER) { + if (crewNamesGrouped.Contains("Kamea") || crewNamesGrouped.Contains("Alexander")) { + // Move Kamea GO out of Alex + Main.Logger.Log("[SetCharactersVisible] Moving Kamera so she can be enabled on her own"); + Transform kameraTransform = GameObject.Find("LeopardHub").transform.Find("chrPrfCrew_alexander/chrPrfCrew_kamea (2)"); + kameraTransform.parent = kameraTransform.parent.parent; + MovedKameraInLeopard = true; + } } + } - Main.Logger.Log($"[SetCharactersVisible] Finished"); - return null; + foreach (string crewName in crewNames) { + SimGameState.SimGameCharacterType character = (SimGameState.SimGameCharacterType)Enum.Parse(typeof(SimGameState.SimGameCharacterType), crewName, true); + SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; + simulation.SetCharacterVisibility(character, isVisible); + } + + Main.Logger.Log($"[SetCharactersVisible] Finished"); + return null; } public static object StartConversation(TsEnvironment env, object[] inputs) { @@ -95,7 +110,7 @@ public static object StartConversation(TsEnvironment env, object[] inputs) { SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; Conversation conversation = null; - + try { conversation = simulation.DataManager.SimGameConversations.Get(conversationId); } catch (KeyNotFoundException) { @@ -135,7 +150,7 @@ public static object AddContract(TsEnvironment env, object[] inputs) { global = true; location = possibleLocation; } - + SimGameState.AddContractData contractData = new SimGameState.AddContractData(); contractData.ContractName = contractId; // "SimpleBattle_LastMechStanding" contractData.Target = target; // "TaurianConcordat" From 1b1e07ec37f2d8a2db27b1feb15e49709070ab3d Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Fri, 4 Nov 2022 10:38:07 +0100 Subject: [PATCH 2/8] Add support for 1-on-1 conversations with Kamea in the command center --- ...mControllerCmdCenterCharacterClickedOnPatch.cs | 15 +++++++++++++++ ...ontrollerCmdCenterIsDiegeticInThisRoomPatch.cs | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterCharacterClickedOnPatch.cs create mode 100644 src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterIsDiegeticInThisRoomPatch.cs diff --git a/src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterCharacterClickedOnPatch.cs b/src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterCharacterClickedOnPatch.cs new file mode 100644 index 0000000..4ce4d12 --- /dev/null +++ b/src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterCharacterClickedOnPatch.cs @@ -0,0 +1,15 @@ +using Harmony; + +using BattleTech; +using BattleTech.UI; + +namespace ExtendedConversations { + [HarmonyPatch(typeof(SGRoomController_CmdCenter), "CharacterClickedOn")] + public class SGRoomControllerCmdCenterCharacterClickedOnPatch { + static void Postfix(SGRoomController_CmdCenter __instance, SimGameState.SimGameCharacterType characterClicked) { + if (characterClicked == SimGameState.SimGameCharacterType.KAMEA) { + UnityGameInstance.Instance.Game.Simulation.ConversationManager.BeginCharacterConversation(SimGameState.SimGameCharacterType.KAMEA); + } + } + } +} \ No newline at end of file diff --git a/src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterIsDiegeticInThisRoomPatch.cs b/src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterIsDiegeticInThisRoomPatch.cs new file mode 100644 index 0000000..a0652e3 --- /dev/null +++ b/src/Patches/KameaTalkingOnCommand/SGRoomControllerCmdCenterIsDiegeticInThisRoomPatch.cs @@ -0,0 +1,13 @@ +using Harmony; + +using BattleTech; +using BattleTech.UI; + +namespace ExtendedConversations { + [HarmonyPatch(typeof(SGRoomController_CmdCenter), "IsDiegeticInThisRoom")] + public class SGRoomControllerCmdCenterIsDiegeticInThisRoomPatch { + static void Postfix(SGRoomController_CmdCenter __instance, SimGameState.SimGameCharacterType diegetic, ref bool __result) { + if (diegetic == SimGameState.SimGameCharacterType.KAMEA) __result = true; + } + } +} \ No newline at end of file From 7a14d05f736f7fe1fb22dda8b2806f6e9d699aed Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Fri, 4 Nov 2022 15:38:02 +0100 Subject: [PATCH 3/8] Added Kamea and Alex to FP conference room (along with lights) --- src/Core/Actions.cs | 44 ++++++++++-- ...GameStateRespondToUXSystemsCreatedPatch.cs | 69 +++++++++++++++++++ 2 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 src/Patches/KameraAlexInFPConference/SimGameStateRespondToUXSystemsCreatedPatch.cs diff --git a/src/Core/Actions.cs b/src/Core/Actions.cs index b407ff4..dfe0a54 100644 --- a/src/Core/Actions.cs +++ b/src/Core/Actions.cs @@ -17,7 +17,7 @@ namespace ExtendedConversations.Core { public class Actions { - public static bool MovedKameraInLeopard = false; + public static bool MovedKameraInLeopardCommandCenter = false; public static object TimeSkip(TsEnvironment env, object[] inputs) { int daysToSkip = env.ToInt(inputs[0]); @@ -77,17 +77,51 @@ public static object SetCharactersVisible(TsEnvironment env, object[] inputs) { string crewNamesGrouped = env.ToString(inputs[1]); Main.Logger.Log($"[SetCharactersVisible] crewnames '{crewNamesGrouped}' will be visible status {isVisible}."); + SimGameState simGameState = UnityGameInstance.Instance.Game.Simulation; string[] crewNames = crewNamesGrouped.Split(','); // Fix for Leopard Kamea/Alex structure being wrong - if (!MovedKameraInLeopard) { - if (UnityGameInstance.Instance.Game.Simulation.CurDropship == DropshipType.Leopard && UnityGameInstance.Instance.Game.Simulation.CurRoomState == DropshipLocation.CMD_CENTER) { + if (!MovedKameraInLeopardCommandCenter) { + if (simGameState.CurDropship == DropshipType.Leopard && simGameState.CurRoomState == DropshipLocation.CMD_CENTER) { if (crewNamesGrouped.Contains("Kamea") || crewNamesGrouped.Contains("Alexander")) { // Move Kamea GO out of Alex Main.Logger.Log("[SetCharactersVisible] Moving Kamera so she can be enabled on her own"); Transform kameraTransform = GameObject.Find("LeopardHub").transform.Find("chrPrfCrew_alexander/chrPrfCrew_kamea (2)"); - kameraTransform.parent = kameraTransform.parent.parent; - MovedKameraInLeopard = true; + + GameObject kameaContainer = new GameObject("Kamea"); + kameaContainer.transform.parent = kameraTransform.parent.parent; + + kameraTransform.parent = kameaContainer.transform; + MovedKameraInLeopardCommandCenter = true; + } + } + } + + if (simGameState.CurRoomState == DropshipLocation.CONFERENCE) { + if (simGameState.CameraController.flashPoint == simGameState.CameraController.CurrentRoomProps) { + if (crewNamesGrouped.Contains("Kamea") || crewNamesGrouped.Contains("Alexander")) { + // Check if Kamea and Alex exist, if not - copy them from another Conferernce Room + // GameObject flashpointConferenceRoomGO = GameObject.Find("FlashpointConference"); + // bool charactersExist = flashpointConferenceRoomGO.transform.Find("Kamea") != null; + + // if (!charactersExist) { + // GameObject originalKamea = GameObject.Find("LeopardConference").transform.Find("Kamea").gameObject; + // GameObject originalAlexander = GameObject.Find("LeopardConference").transform.Find("Alexander").gameObject; + + // GameObject copiedKamea = GameObject.Instantiate(originalKamea, flashpointConferenceRoomGO.transform); + // copiedKamea.name = "Kamea"; + // copiedKamea.transform.position = new Vector3(copiedKamea.transform.position.x, -20.317f, copiedKamea.transform.position.z); + // foreach (Transform child in copiedKamea.transform) { + // child.gameObject.SetActive(true); + // } + + // GameObject copiedAlexander = GameObject.Instantiate(originalAlexander, flashpointConferenceRoomGO.transform); + // copiedAlexander.name = "Alexander"; + // copiedAlexander.transform.position = new Vector3(copiedAlexander.transform.position.x, -20.317f, copiedAlexander.transform.position.z); + // foreach (Transform child in copiedAlexander.transform) { + // child.gameObject.SetActive(true); + // } + // } } } } diff --git a/src/Patches/KameraAlexInFPConference/SimGameStateRespondToUXSystemsCreatedPatch.cs b/src/Patches/KameraAlexInFPConference/SimGameStateRespondToUXSystemsCreatedPatch.cs new file mode 100644 index 0000000..e02f9a3 --- /dev/null +++ b/src/Patches/KameraAlexInFPConference/SimGameStateRespondToUXSystemsCreatedPatch.cs @@ -0,0 +1,69 @@ +using UnityEngine; + +using Harmony; + +using BattleTech; +using BattleTech.UI; + +using System.Collections; + +namespace ExtendedConversations { + [HarmonyPatch(typeof(SimGameState), "RespondToUXSystemsCreated")] + public class SimGameStateAttachUXPatch { + static void Postfix(SimGameState __instance) { + GameObject flashpointConferenceRoomGO = GameObject.Find("FlashpointConference"); + bool charactersExist = flashpointConferenceRoomGO.transform.Find("Kamea") != null; + + if (!charactersExist) { + GameObject leopardConferenceRoomGO = GameObject.Find("LeopardConference"); + + GameObject originalKamea = leopardConferenceRoomGO.transform.Find("Kamea").gameObject; + GameObject originalAlexander = leopardConferenceRoomGO.transform.Find("Alexander").gameObject; + + GameObject copiedKamea = GameObject.Instantiate(originalKamea, flashpointConferenceRoomGO.transform); + copiedKamea.name = "Kamea"; + copiedKamea.transform.position = new Vector3(copiedKamea.transform.position.x, -20.39f, copiedKamea.transform.position.z); + foreach (Transform child in copiedKamea.transform) { + child.gameObject.SetActive(true); + } + + GameObject copiedAlexander = GameObject.Instantiate(originalAlexander, flashpointConferenceRoomGO.transform); + copiedAlexander.name = "Alexander"; + copiedAlexander.transform.position = new Vector3(0.35f, -20.317f, copiedAlexander.transform.position.z); + foreach (Transform child in copiedAlexander.transform) { + child.gameObject.SetActive(true); + } + + // Copy lights + Transform flashpointLightsTransform = flashpointConferenceRoomGO.transform.Find("Lights"); + GameObject originalLight8 = leopardConferenceRoomGO.transform.Find("Lights/Light (8)").gameObject; + GameObject originalLight9 = leopardConferenceRoomGO.transform.Find("Lights/Light (9)").gameObject; + + GameObject copiedLight8 = GameObject.Instantiate(originalLight8, flashpointLightsTransform); + copiedLight8.name = "Light (8) Copied"; + copiedLight8.transform.localPosition = new Vector3(-2.016f, 0.9379997f, 3.953f); + copiedLight8.SetActive(false); + + GameObject copiedLight9 = GameObject.Instantiate(originalLight9, flashpointLightsTransform); + copiedLight9.name = "Light (9) Copied"; + copiedLight9.transform.localPosition = new Vector3(0.26f, 0.9379997f, 7.018f); + copiedLight8.SetActive(false); + + UnityGameInstance.Instance.StartCoroutine(DisableCharactersByDefault(copiedKamea, copiedAlexander)); + } + } + + static IEnumerator DisableCharactersByDefault(GameObject copiedKamea, GameObject copiedAlexander) { + yield return new WaitForEndOfFrame(); + yield return new WaitForEndOfFrame(); + + foreach (Transform child in copiedKamea.transform) { + child.gameObject.SetActive(false); + } + + foreach (Transform child in copiedAlexander.transform) { + child.gameObject.SetActive(false); + } + } + } +} \ No newline at end of file From afacb30b41a90c5abdf8a9412dfd7b3ba78919be Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Wed, 16 Nov 2022 11:28:48 +0100 Subject: [PATCH 4/8] Support forcing the conversation action to start in the non-fp conf room --- operations/start_conversation.json | 20 ++++++++++++++++++- src/Core/Actions.cs | 4 ++++ .../SimGameStateIsInFlashpointPatch.cs | 16 +++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs diff --git a/operations/start_conversation.json b/operations/start_conversation.json index 5e7439d..1398c4e 100644 --- a/operations/start_conversation.json +++ b/operations/start_conversation.json @@ -18,6 +18,24 @@ { "label": "Conversation Sub Header", "types": ["string"] + }, + { + "label": "Force Non-FP Conference Room", + "types": ["int"], + "tooltip": "If this is true, when a conversation is triggered it will force the non-FP version of the conference room", + "values": [ + { + "viewlabel": "in the appropriate conference room (FP vs non-FP)", + "text": "False", + "value": 0 + }, + { + "viewlabel": "always in the non-FP conference room ", + "text": "True", + "value": 1 + } + ], + "defaultValue": 1 } ] -} \ No newline at end of file +} diff --git a/src/Core/Actions.cs b/src/Core/Actions.cs index dfe0a54..b1af383 100644 --- a/src/Core/Actions.cs +++ b/src/Core/Actions.cs @@ -18,6 +18,7 @@ namespace ExtendedConversations.Core { public class Actions { public static bool MovedKameraInLeopardCommandCenter = false; + public static bool ForceNextIsInFlashpointCheckFalse = false; public static object TimeSkip(TsEnvironment env, object[] inputs) { int daysToSkip = env.ToInt(inputs[0]); @@ -140,6 +141,7 @@ public static object StartConversation(TsEnvironment env, object[] inputs) { string conversationId = env.ToString(inputs[0]); string groupHeader = env.ToString(inputs[1]); string groupSubHeader = env.ToString(inputs[2]); + bool forceNonFPConferenceRoom = (inputs.Length == 4) ? env.ToBool(inputs[3]) : false; Main.Logger.Log($"[StartConversation] conversationId '{conversationId}' with groupHeader '{groupHeader}' and groupSubHeader '{groupSubHeader}'."); SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; @@ -159,6 +161,8 @@ public static object StartConversation(TsEnvironment env, object[] inputs) { Main.Logger.Log($"[StartConversation] Conversaton queued for immediate start."); } + ForceNextIsInFlashpointCheckFalse = forceNonFPConferenceRoom; + return null; } diff --git a/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs b/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs new file mode 100644 index 0000000..1befd9c --- /dev/null +++ b/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs @@ -0,0 +1,16 @@ +using Harmony; + +using BattleTech; + +using ExtendedConversations.Core; + +namespace ExtendedConversations { + [HarmonyPatch(typeof(SimGameState), "IsInFlashpoint", MethodType.Getter)] + public class SimGameStateIsInFlashpointPatch { + static void Postfix(SimGameState __instance, ref bool __result) { + if (Actions.ForceNextIsInFlashpointCheckFalse) { + __result = false; + } + } + } +} \ No newline at end of file From d0a3c74442f2de250e893da1727e3c244dc18eff Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Wed, 16 Nov 2022 12:06:01 +0100 Subject: [PATCH 5/8] Added better support for forcing non-fp conference room --- src/Core/Actions.cs | 2 ++ ...ConversationManagerEndConversationPatch.cs | 20 +++++++++++++++++++ .../SimGameStateIsInFlashpointPatch.cs | 1 + 3 files changed, 23 insertions(+) create mode 100644 src/Patches/ForceNonFPConferenceRoom/SimGameConversationManagerEndConversationPatch.cs diff --git a/src/Core/Actions.cs b/src/Core/Actions.cs index b1af383..5155c51 100644 --- a/src/Core/Actions.cs +++ b/src/Core/Actions.cs @@ -19,6 +19,7 @@ namespace ExtendedConversations.Core { public class Actions { public static bool MovedKameraInLeopardCommandCenter = false; public static bool ForceNextIsInFlashpointCheckFalse = false; + public static Conversation ActiveConversation = null; public static object TimeSkip(TsEnvironment env, object[] inputs) { int daysToSkip = env.ToInt(inputs[0]); @@ -162,6 +163,7 @@ public static object StartConversation(TsEnvironment env, object[] inputs) { } ForceNextIsInFlashpointCheckFalse = forceNonFPConferenceRoom; + ActiveConversation = conversation; return null; } diff --git a/src/Patches/ForceNonFPConferenceRoom/SimGameConversationManagerEndConversationPatch.cs b/src/Patches/ForceNonFPConferenceRoom/SimGameConversationManagerEndConversationPatch.cs new file mode 100644 index 0000000..bc6f035 --- /dev/null +++ b/src/Patches/ForceNonFPConferenceRoom/SimGameConversationManagerEndConversationPatch.cs @@ -0,0 +1,20 @@ +using Harmony; + +using BattleTech; +using isogame; + +using ExtendedConversations.Core; + +namespace ExtendedConversations { + [HarmonyPatch(typeof(SimGameConversationManager), "EndConversation")] + public class SimGameConversationManagerEndConversationPatch { + static void Prefix(SimGameConversationManager __instance) { + Conversation conversation = (Conversation)AccessTools.Field(typeof(SimGameConversationManager), "thisConvoDef").GetValue(__instance); + + if (Actions.ActiveConversation == conversation) { + Actions.ForceNextIsInFlashpointCheckFalse = false; + Actions.ActiveConversation = null; + } + } + } +} \ No newline at end of file diff --git a/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs b/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs index 1befd9c..e30f322 100644 --- a/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs +++ b/src/Patches/ForceNonFPConferenceRoom/SimGameStateIsInFlashpointPatch.cs @@ -9,6 +9,7 @@ namespace ExtendedConversations { public class SimGameStateIsInFlashpointPatch { static void Postfix(SimGameState __instance, ref bool __result) { if (Actions.ForceNextIsInFlashpointCheckFalse) { + Main.Logger.Log("[SimGameStateIsInFlashpointPatch] Forcing to use non-FP conference room"); __result = false; } } From 15d225c86c44546c4a33da6985d1baf8ad25d877 Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Wed, 16 Nov 2022 15:44:19 +0100 Subject: [PATCH 6/8] Remove commented out code --- src/Core/Actions.cs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/Core/Actions.cs b/src/Core/Actions.cs index 5155c51..09e26a4 100644 --- a/src/Core/Actions.cs +++ b/src/Core/Actions.cs @@ -99,35 +99,6 @@ public static object SetCharactersVisible(TsEnvironment env, object[] inputs) { } } - if (simGameState.CurRoomState == DropshipLocation.CONFERENCE) { - if (simGameState.CameraController.flashPoint == simGameState.CameraController.CurrentRoomProps) { - if (crewNamesGrouped.Contains("Kamea") || crewNamesGrouped.Contains("Alexander")) { - // Check if Kamea and Alex exist, if not - copy them from another Conferernce Room - // GameObject flashpointConferenceRoomGO = GameObject.Find("FlashpointConference"); - // bool charactersExist = flashpointConferenceRoomGO.transform.Find("Kamea") != null; - - // if (!charactersExist) { - // GameObject originalKamea = GameObject.Find("LeopardConference").transform.Find("Kamea").gameObject; - // GameObject originalAlexander = GameObject.Find("LeopardConference").transform.Find("Alexander").gameObject; - - // GameObject copiedKamea = GameObject.Instantiate(originalKamea, flashpointConferenceRoomGO.transform); - // copiedKamea.name = "Kamea"; - // copiedKamea.transform.position = new Vector3(copiedKamea.transform.position.x, -20.317f, copiedKamea.transform.position.z); - // foreach (Transform child in copiedKamea.transform) { - // child.gameObject.SetActive(true); - // } - - // GameObject copiedAlexander = GameObject.Instantiate(originalAlexander, flashpointConferenceRoomGO.transform); - // copiedAlexander.name = "Alexander"; - // copiedAlexander.transform.position = new Vector3(copiedAlexander.transform.position.x, -20.317f, copiedAlexander.transform.position.z); - // foreach (Transform child in copiedAlexander.transform) { - // child.gameObject.SetActive(true); - // } - // } - } - } - } - foreach (string crewName in crewNames) { SimGameState.SimGameCharacterType character = (SimGameState.SimGameCharacterType)Enum.Parse(typeof(SimGameState.SimGameCharacterType), crewName, true); SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; From da374abe73d1b132fc366435c19801fa9cf2314f Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Fri, 2 Dec 2022 12:57:12 +0100 Subject: [PATCH 7/8] Added 'Add Flashpoint' action --- operations/add_flashpoint.json | 21 +++++++++++++++++++++ src/Core/Actions.cs | 27 +++++++++++++++++++++++++++ src/Core/ConversationUpgrades.cs | 32 +++++++++++++++++++------------- 3 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 operations/add_flashpoint.json diff --git a/operations/add_flashpoint.json b/operations/add_flashpoint.json new file mode 100644 index 0000000..0ad3ae4 --- /dev/null +++ b/operations/add_flashpoint.json @@ -0,0 +1,21 @@ +{ + "key": "Add Flashpoint", + "label": "Add a flashpoint", + "view": ["label", "inputs"], + "scope": "action", + "category": "primary", + "inputs": [ + { + "label": "Flashpoint Id", + "types": ["operation", "string"], + "viewLabel": "with id '{value}'", + "tooltip": "Flashpoint Id (e.g. fp_allianceDavion). Can be empty to select a random Flashpoint." + }, + { + "label": "System Name", + "types": ["operation", "string"], + "viewLabel": "in system '{value}'", + "tooltip": "Should be in the format of 'starsystemdef_Smithon' but can work with just 'Smithon'. Can be empty for a random system selection. Can be 'local' for local system." + } + ] +} diff --git a/src/Core/Actions.cs b/src/Core/Actions.cs index 09e26a4..5c678fc 100644 --- a/src/Core/Actions.cs +++ b/src/Core/Actions.cs @@ -172,5 +172,32 @@ public static object AddContract(TsEnvironment env, object[] inputs) { return null; } + + /* + Both flashpointId and systemId can be null/empty. + Vanilla code for flashpoints handles by: + - flashpointId = null/empty will pick a random non-completed flashpoint + - systemId = null/empty will pick a random system + */ + public static object AddFlashpoint(TsEnvironment env, object[] inputs) { + string flashpointId = env.ToString(inputs[0]); + string systemId = env.ToString(inputs[1]); + + Main.Logger.Log($"[AddFlashpoint] Received flashpointId '{flashpointId}' and systemId '{systemId}'"); + + if (flashpointId == "0") flashpointId = null; + if (systemId == "0") systemId = null; + + if (!string.IsNullOrEmpty(systemId) && !systemId.StartsWith("starsystemdef_") && !systemId.StartsWith("local")) { + systemId = $"starsystemdef_{systemId}"; + } + + Main.Logger.Log($"[AddFlashpoint] Using flashpointId '{flashpointId}' and systemId '{systemId}'"); + + SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; + simulation.GenerateFlashpointCommand(flashpointId, systemId); + + return null; + } } } \ No newline at end of file diff --git a/src/Core/ConversationUpgrades.cs b/src/Core/ConversationUpgrades.cs index 4b97a01..1816879 100644 --- a/src/Core/ConversationUpgrades.cs +++ b/src/Core/ConversationUpgrades.cs @@ -38,37 +38,37 @@ public static void Declare(TsEnvironment env) { // `Evaluate BattleTech String` condition Main.Logger.Log("Declaring 'Evaluate BattleTech String' condition"); tsOp = env.DeclareOp("ConditionFunction", "Evaluate BattleTech String", boolType, new TsOp.EvalDelegate(Conditions.EvaluateBattleTechString)); - tsOp.DeclareInput("scope", SimGameScopeType); - tsOp.DeclareInput("param", stringType); + tsOp.DeclareInput("scope", SimGameScopeType); + tsOp.DeclareInput("param", stringType); tsOp.DeclareInput("operation", intType); - tsOp.DeclareInput("value", stringType); + tsOp.DeclareInput("value", stringType); // `Evaluate BattleTech Int` condition Main.Logger.Log("Declaring 'Evaluate BattleTech Int' condition"); tsOp = env.DeclareOp("ConditionFunction", "Evaluate BattleTech Int", boolType, new TsOp.EvalDelegate(Conditions.EvaluateBattleTechInt)); - tsOp.DeclareInput("scope", SimGameScopeType); - tsOp.DeclareInput("param", stringType); + tsOp.DeclareInput("scope", SimGameScopeType); + tsOp.DeclareInput("param", stringType); tsOp.DeclareInput("operation", intType); - tsOp.DeclareInput("value", intType); + tsOp.DeclareInput("value", intType); // `Evaluate BattleTech Float` condition Main.Logger.Log("Declaring 'Evaluate BattleTech Float' condition"); tsOp = env.DeclareOp("ConditionFunction", "Evaluate BattleTech Float", boolType, new TsOp.EvalDelegate(Conditions.EvaluateBattleTechFloat)); - tsOp.DeclareInput("scope", SimGameScopeType); - tsOp.DeclareInput("param", stringType); + tsOp.DeclareInput("scope", SimGameScopeType); + tsOp.DeclareInput("param", stringType); tsOp.DeclareInput("operation", intType); - tsOp.DeclareInput("value", floatType); + tsOp.DeclareInput("value", floatType); // Evaluate Funds Main.Logger.Log("Declaring 'Evaluate Funds' condition"); tsOp = env.DeclareOp("ConditionFunction", "Evaluate Funds", boolType, new TsOp.EvalDelegate(Conditions.EvaluateFunds)); tsOp.DeclareInput("operation", intType); - tsOp.DeclareInput("value", intType); + tsOp.DeclareInput("value", intType); /* * ACTIONS */ - + // `TimeSkip` action Main.Logger.Log("Declaring 'Time Skip' action"); tsOp = env.DeclareOp("EffectFunctions", "Time Skip", voidType, new TsOp.EvalDelegate(Actions.TimeSkip)); @@ -91,7 +91,7 @@ public static void Declare(TsEnvironment env) { tsOp = env.DeclareOp("EffectFunctions", "Set Characters Visible", voidType, new TsOp.EvalDelegate(Actions.SetCharactersVisible)); tsOp.DeclareInput("isVisible", intType); tsOp.DeclareInput("crewNames", stringType); - + // 'Start Conversation' action Main.Logger.Log("Declaring 'Start Conversation' action"); tsOp = env.DeclareOp("EffectFunctions", "Start Conversation Custom", voidType, new TsOp.EvalDelegate(Actions.StartConversation)); @@ -107,10 +107,16 @@ public static void Declare(TsEnvironment env) { tsOp.DeclareInput("employer", stringType); tsOp.DeclareInput("possibleLocation", stringType); + // 'Add Flashpoint' action + Main.Logger.Log("Declaring 'Add Flashpoint' action"); + tsOp = env.DeclareOp("EffectFunctions", "Add Flashpoint", voidType, new TsOp.EvalDelegate(Actions.AddFlashpoint)); + tsOp.DeclareInput("flashpointId", stringType); + tsOp.DeclareInput("systemId", stringType); + /* * VALUE GETTERS */ - + // `Get BattleTech String` value getter Main.Logger.Log("Declaring 'Get BattleTech String' value getter"); tsOp = env.DeclareOp("ValueGetterFunctions", "Get BattleTech String", stringType, new TsOp.EvalDelegate(ValueGetters.GetBattleTechString)); From 31c0d1b20423df0e9c521821dff7d79efe762aad Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Fri, 2 Dec 2022 12:59:48 +0100 Subject: [PATCH 8/8] Version bump --- mod.json | 2 +- src/ExtendedConversations.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod.json b/mod.json index a1f24d3..659aec9 100644 --- a/mod.json +++ b/mod.json @@ -2,7 +2,7 @@ "Name": "ExtendedConversations", "Enabled": true, - "Version": "0.4.4", + "Version": "0.4.5", "Description": "Extended Conversations is a utility mod to provide more conversation conditions, actions and other functionality", "Author": "CWolf", "Website": "https://github.com/CWolfs/ExtendedConversations/", diff --git a/src/ExtendedConversations.csproj b/src/ExtendedConversations.csproj index c5e4fc6..332c1d6 100644 --- a/src/ExtendedConversations.csproj +++ b/src/ExtendedConversations.csproj @@ -1,6 +1,6 @@ - 0.4.4 + 0.4.5 Library net471