using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Bounce.Singletons; using ModdingTales; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BeyondLinkViaChromePlugin")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BeyondLinkViaChromePlugin")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("BeyondLinkViaChromePlugin")] [assembly: ComVisible(false)] [assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")] [assembly: AssemblyFileVersion("3.1.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("3.1.1.0")] namespace LordAshes; [BepInPlugin("org.lordashes.plugins.beyondlinkviachrome", "Beyond Link Via Chrome Plug-In", "3.1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BeyondLinkViaChromePlugin : BaseUnityPlugin { public static class Utility { public static bool isBoardLoaded() { return SimpleSingletonBehaviour.HasInstance && SingletonStateMBehaviour>.HasInstance && !BoardSessionManager.IsLoading; } public static string GetCreatureName(string nameBlock) { if (nameBlock == null) { return "(Unknown)"; } if (!nameBlock.Contains("")) { return nameBlock; } return nameBlock.Substring(0, nameBlock.IndexOf("")).Trim(); } public static float ParseFloat(string value) { return float.Parse(value, CultureInfo.InvariantCulture); } public static GameObject FindInHierarchy(GameObject start, string seekName) { List results = new List(); bool done = false; Traverse(start.transform, seekName, null, single: true, ref results, ref done); return (results.Count > 0) ? results.ElementAt(0) : null; } public static GameObject FindInHierarchyViaPartialName(GameObject start, string seekName) { List results = new List(); bool done = false; Traverse(start.transform, seekName, null, single: true, ref results, ref done, partial: true); return (results.Count > 0) ? results.ElementAt(0) : null; } public static GameObject[] FindAllInHierarchy(GameObject start, string seekName) { List results = new List(); bool done = false; Traverse(start.transform, seekName, null, single: false, ref results, ref done); return results.ToArray(); } public static GameObject[] FindAllInHierarchyViaPartialName(GameObject start, string seekName) { List results = new List(); bool done = false; Traverse(start.transform, seekName, null, single: false, ref results, ref done, partial: true); return results.ToArray(); } public static GameObject FindWithComponentInHierarchy(GameObject start, string seekType) { List results = new List(); bool done = false; Traverse(start.transform, null, seekType, single: true, ref results, ref done); return (results.Count > 0) ? results.ElementAt(0) : null; } public static GameObject[] FindAllWithComponentInHierarchy(GameObject start, string seekType) { List results = new List(); bool done = false; Traverse(start.transform, null, seekType, single: false, ref results, ref done); return results.ToArray(); } public static void Traverse(Transform root, string seekName, string seekType, bool single, ref List results, ref bool done, bool partial = false) { try { if ((seekName == null || seekName == ((Object)((Component)root).gameObject).name || (partial && ((Object)((Component)root).gameObject).name.Contains(seekName))) && (seekType == null || (Object)(object)((Component)root).GetComponent(seekType) != (Object)null)) { LoggingPlugin.LogTrace("Matched '" + ((Object)((Component)root).gameObject).name + "'"); results.Add(((Component)root).gameObject); if (single) { done = true; return; } } foreach (Transform item in ExtensionMethods.Children(root)) { if (!done) { Traverse(item, seekName, seekType, single, ref results, ref done, partial); } } } catch { } } public static object LookUp(in Dictionary dictionary, string key) { foreach (KeyValuePair item in dictionary) { if (item.Key.ToUpper() == key.ToUpper()) { return item.Value; } } return null; } public static void PostOnMainPage(BaseUnityPlugin plugin) { string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s"); ModdingUtils.AddPluginToMenuList(plugin, text); } } public const string Name = "Beyond Link Via Chrome Plug-In"; public const string Guid = "org.lordashes.plugins.beyondlinkviachrome"; public const string Version = "3.1.1.0"; public const string Author = "Lord Ashes"; public DateTime lastUpdate = DateTime.UtcNow; private string location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); private string data = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/CustomData/"; private int refreshRate = 5000; private string[] statSource = new string[9]; private void Awake() { LoggingPlugin.LogDebug("Beyond Link Via Chrome Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " Active."); refreshRate = ((BaseUnityPlugin)this).Config.Bind("Settings", "Refreh Rate (ms)", 5000, (ConfigDescription)null).Value; statSource[0] = ((BaseUnityPlugin)this).Config.Bind("Settings", "HP Slot", "HP.Current,HP.Max", (ConfigDescription)null).Value; statSource[1] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 0", "HD.Used,level", (ConfigDescription)null).Value; statSource[2] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 1", "AC,AC", (ConfigDescription)null).Value; statSource[3] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 2", "Order,Move", (ConfigDescription)null).Value; statSource[4] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 3", "", (ConfigDescription)null).Value; statSource[5] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 4", "", (ConfigDescription)null).Value; statSource[6] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 5", "", (ConfigDescription)null).Value; statSource[7] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 6", "", (ConfigDescription)null).Value; statSource[8] = ((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Slot 7", "", (ConfigDescription)null).Value; Process[] processesByName = Process.GetProcessesByName("BeyondLinkServer"); if (processesByName.Length == 0) { LoggingPlugin.LogDebug("Beyond Link Via Chrome Plugin: Starting the BeyondLinkServer At " + location + "\\BeyondLinkServer.exe " + ((BaseUnityPlugin)this).Config.Bind("Settings", "Beyond Link Server Port", 9100, (ConfigDescription)null).Value); Process process = new Process { StartInfo = new ProcessStartInfo { FileName = location + "\\BeyondLinkServer.exe", Arguments = ((BaseUnityPlugin)this).Config.Bind("Settings", "Beyond Link Server Port", 9100, (ConfigDescription)null).Value.ToString(), CreateNoWindow = !((BaseUnityPlugin)this).Config.Bind("Settings", "Show Server Window", true, (ConfigDescription)null).Value, UseShellExecute = true, WorkingDirectory = location } }; process.Start(); } } private void Update() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) if (!Utility.isBoardLoaded() || !(DateTime.UtcNow.Subtract(lastUpdate).TotalMilliseconds > (double)refreshRate)) { return; } CreatureDataV4 val = default(CreatureDataV4); CreatureStat val2 = default(CreatureStat); foreach (CreatureBoardAsset item in (IEnumerable)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()) { for (int i = -1; i < statSource.Length - 1; i++) { if (!(statSource[i + 1] != "")) { continue; } string[] array = statSource[i + 1].Split(new char[1] { ',' }); LoggingPlugin.LogDebug("Beyond Link Via Chrome Plugin: Looking For " + data + Utility.GetCreatureName(item.Name) + "." + array[0] + " and " + data + Utility.GetCreatureName(item.Name) + "." + array[1]); if (!File.Exists(data + Utility.GetCreatureName(item.Name) + "." + array[0]) || !File.Exists(data + Utility.GetCreatureName(item.Name) + "." + array[1])) { continue; } LoggingPlugin.LogDebug("Beyond Link Via Chrome Plugin: Found. Checking For Change"); string s = File.ReadAllText(data + Utility.GetCreatureName(item.Name) + "." + array[0]); string s2 = File.ReadAllText(data + Utility.GetCreatureName(item.Name) + "." + array[1]); CreatureManager.TryGetCreatureData(item.CreatureId, ref val); bool flag = false; switch (i) { case -1: if (item.Hp.Value != float.Parse(s) || item.Hp.Max != float.Parse(s2)) { flag = true; } break; case 0: if (val.Stat0.Value != float.Parse(s) || val.Stat0.Max != float.Parse(s2)) { flag = true; } break; case 1: if (val.Stat1.Value != float.Parse(s) || val.Stat1.Max != float.Parse(s2)) { flag = true; } break; case 2: if (val.Stat2.Value != float.Parse(s) || val.Stat2.Max != float.Parse(s2)) { flag = true; } break; case 3: if (val.Stat3.Value != float.Parse(s) || val.Stat3.Max != float.Parse(s2)) { flag = true; } break; case 4: if (val.Stat4.Value != float.Parse(s) || val.Stat4.Max != float.Parse(s2)) { flag = true; } break; case 5: if (val.Stat5.Value != float.Parse(s) || val.Stat5.Max != float.Parse(s2)) { flag = true; } break; case 6: if (val.Stat6.Value != float.Parse(s) || val.Stat6.Max != float.Parse(s2)) { flag = true; } break; case 7: if (val.Stat7.Value != float.Parse(s) || val.Stat7.Max != float.Parse(s2)) { flag = true; } break; } if (flag) { LoggingPlugin.LogDebug("Beyond Link Via Chrome Plugin: Syncing '" + Utility.GetCreatureName(item.Name) + "." + array[0] + "/" + array[1] + " To Slot " + i); ((CreatureStat)(ref val2))..ctor(float.Parse(s), float.Parse(s2)); CreatureManager.SetCreatureStatByIndex(item.CreatureId, val2, i); CampaignSessionManager.SetCreatureStatNames(((BaseUnityPlugin)this).Config.Bind("Settings", "Stat Names", "HD,AC,Move", (ConfigDescription)null).Value.ToString().Split(new char[1] { ',' })); } } } lastUpdate = DateTime.UtcNow; } }