Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of OverworkedUI v1.0.0
OverworkedUI.dll
Decompiled 3 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using OverworkedTerminalConfig; using Rebalance80.Overworked; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OverworkedUI")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("OverworkedUI is a bundle of custom UI's for Lethal Company aiming to bring more customization to your save files.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OverworkedUI")] [assembly: AssemblyTitle("OverworkedUI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class OwButton : Selectable, IPointerClickHandler, IEventSystemHandler { public UnityEvent<bool> onClick = new UnityEvent<bool>(); public void OnPointerClick(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 bool flag = (int)eventData.button == 0; if ((int)eventData.button == 0 || (int)eventData.button == 1) { onClick.Invoke(flag); } } } public class OwHostHandler : MonoBehaviour { public GameObject Title; public GameObject LobbyName; public GameObject Confirm; public GameObject Back; public GameObject Saves; public GameObject Config; public GameObject SavesHolder; public GameObject ConfigHolder; public GameObject Public; public GameObject Private; public GameObject OwUi; public GameObject SelectSaveButtonPrefab; public GameObject ConfigHolderPrefab; public GameObject ConfigTextPrefab; public GameObject ConfigButtonPrefab; public int creditsAmount = 60; private int saveCount = 0; private Dictionary<string, ConfigCategory> TerminalConfig = new Dictionary<string, ConfigCategory>(); public int selectedSaveFileIndex { get; private set; } = -1; public bool isNewSave { get; private set; } = false; public bool isModded { get; private set; } = true; public bool isPublic { get; private set; } = true; public void _Start() { SetLobbyName("My lobby"); InitializeNewSave(); InitializeTerminal(); InitializeVisibility(); HighlightSaveButton(null); } public void SetOwUiRoast(string roast) { ((TMP_Text)OwUi.GetComponent<TextMeshProUGUI>()).text = roast; } private void InitializeVisibility() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown Image pubImg = Public.GetComponent<Image>(); Image privImg = Private.GetComponent<Image>(); ((UnityEvent)Public.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) isPublic = true; ((Graphic)pubImg).color = Color32.op_Implicit(new Color32((byte)253, (byte)148, (byte)69, byte.MaxValue)); ((Graphic)privImg).color = Color32.op_Implicit(new Color32((byte)118, (byte)47, (byte)47, byte.MaxValue)); }); ((UnityEvent)Private.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) isPublic = false; ((Graphic)privImg).color = Color32.op_Implicit(new Color32((byte)253, (byte)148, (byte)69, byte.MaxValue)); ((Graphic)pubImg).color = Color32.op_Implicit(new Color32((byte)118, (byte)47, (byte)47, byte.MaxValue)); }); } private void InitializeNewSave() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown GameObject NewSaveButton = ((Component)SavesHolder.transform.Find("OW_CreateSave")).gameObject; Button componentInChildren = NewSaveButton.GetComponentInChildren<Button>(); Hide(); HideTerminalConfig(); TMP_InputField textBox = LobbyName.GetComponent<TMP_InputField>(); ((UnityEvent)componentInChildren.onClick).AddListener((UnityAction)delegate { ShowTerminalConfig(); HighlightSaveButton(((Component)NewSaveButton.transform.Find("Button")).gameObject); selectedSaveFileIndex = saveCount + 1; isNewSave = true; ((UnityEventBase)textBox.onSubmit).RemoveAllListeners(); }); } public void CreateSaveFile(int index, string filepath, string filename, Action deleteCallback, Action<string> renameCallback) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown GameObject saveButton = Object.Instantiate<GameObject>(SelectSaveButtonPrefab, Vector3.zero, Quaternion.identity); saveButton.transform.SetParent(SavesHolder.transform, false); GameObject selectButton = ((Component)saveButton.transform.Find("Button")).gameObject; GameObject gameObject = ((Component)saveButton.transform.Find("Delete")).gameObject; ((TMP_Text)selectButton.GetComponentInChildren<TextMeshProUGUI>()).text = filename; TMP_InputField textBox = LobbyName.GetComponent<TMP_InputField>(); ((UnityEvent)selectButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { HighlightSaveButton(selectButton); SetLobbyName(filename); HideTerminalConfig(); selectedSaveFileIndex = index; isNewSave = false; ((UnityEventBase)textBox.onSubmit).RemoveAllListeners(); ((UnityEvent<string>)(object)textBox.onSubmit).AddListener((UnityAction<string>)delegate(string text) { filename = text; ((TMP_Text)selectButton.GetComponentInChildren<TextMeshProUGUI>()).text = text; renameCallback?.Invoke(text); }); }); ((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { Object.Destroy((Object)(object)saveButton); deleteCallback?.Invoke(); }); saveCount++; } public void ClearSaves() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown HighlightSaveButton(null); selectedSaveFileIndex = -1; saveCount = 0; foreach (Transform item in SavesHolder.transform) { Transform val = item; if (((Object)val).name != "OW_CreateSave") { Object.Destroy((Object)(object)((Component)val).gameObject); } } } public void HighlightSaveButton(GameObject? target) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in SavesHolder.transform) { Transform val = item; if (((Object)val).name != "OW_CreateSave") { ((Graphic)((Component)val.Find("Button")).GetComponent<Image>()).color = Color32.op_Implicit(new Color32((byte)118, (byte)47, (byte)76, (byte)100)); } else { ((Graphic)((Component)val.Find("Button")).GetComponent<Image>()).color = Color32.op_Implicit(new Color32((byte)118, (byte)47, (byte)47, (byte)100)); } } if ((Object)(object)target != (Object)null) { ((Graphic)target.GetComponentInChildren<Image>()).color = Color32.op_Implicit(new Color32((byte)238, (byte)115, (byte)86, (byte)100)); ((Graphic)Confirm.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(new Color32((byte)252, (byte)180, (byte)103, byte.MaxValue)); } else { ((Graphic)Confirm.GetComponentInChildren<TextMeshProUGUI>()).color = Color32.op_Implicit(new Color32((byte)222, (byte)49, (byte)5, byte.MaxValue)); } } private void SetLobbyName(string name) { LobbyName.GetComponent<TMP_InputField>().text = name; } public string GetLobbyName() { return LobbyName.GetComponent<TMP_InputField>().text; } public void Show() { ((Component)((Component)this).gameObject.transform.parent).gameObject.SetActive(true); } public void Hide() { ((Component)((Component)this).gameObject.transform.parent).gameObject.SetActive(false); } public void BindContext(Action CloseRequest, Action ConfirmRequest) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown ((UnityEvent)Back.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { CloseRequest(); }); ((UnityEvent)Confirm.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { ConfirmRequest(); }); } public void ShowTerminalConfig() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Saves.GetComponent<RectTransform>().sizeDelta = new Vector2(813.2242f, 670.676f); Saves.GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3(-491.1299f, -56.33801f)); Config.SetActive(true); } public void HideTerminalConfig() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Saves.GetComponent<RectTransform>().sizeDelta = new Vector2(1772.9f, 670.676f); Saves.GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3(-11.323f, -56.33801f)); Config.SetActive(false); } public void BuildCategory(ConfigCategory newCategory, GameObject categoryUI) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown foreach (Transform item in categoryUI.transform) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } foreach (ConfigElement element in newCategory.Elements) { element.GetUiElement(this, newCategory).transform.SetParent(categoryUI.transform, false); } } public void AddTerminalCategory(string name, ConfigCategory newCategory) { GameObject val = Object.Instantiate<GameObject>(ConfigHolderPrefab); val.transform.SetParent(ConfigHolder.transform, false); BuildCategory(newCategory, val); TerminalConfig[name] = newCategory; } public ConfigCategory? GetTerminalCategory(string name) { return TerminalConfig[name]; } public void UpdateCredits() { TextMeshProUGUI component = ((Component)Config.transform.Find("Panel/Credits")).GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = $"▪{creditsAmount}"; } private void InitializeTerminal() { ConfigCategory configCategory = new ConfigCategory(); configCategory.AddElement(new SpacingConfigElement()).AddElement(new SpacingConfigElement()).AddElement(new TextConfigElement(("id", "hint0"), ("text", ">Terminal"))) .AddElement(new TextConfigElement(("id", "hint1"), ("text", "Left-click to interact with a node."))) .AddElement(new TextConfigElement(("id", "hint2"), ("text", "Right-click to cancel the interaction."))) .AddElement(new SpacingConfigElement()); AddTerminalCategory("Hint", configCategory); } } namespace Rebalance80 { [BepInPlugin("dev.timmywastor.overworkedUI", "OverworkedUI", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string modGUID = "dev.timmywastor.overworkedUI"; public const string modName = "OverworkedUI"; public const string modVersion = "1.0.0"; public static Harmony harmony = new Harmony("dev.timmywastor.overworkedUI"); public static ManualLogSource logger = Logger.CreateLogSource("dev.timmywastor.overworkedUI"); public static string pluginFolder; private void Awake() { string location = ((BaseUnityPlugin)this).Info.Location; pluginFolder = Path.GetDirectoryName(location); OverworkedCore.Initialize(); } } public static class PluginInfo { public const string PLUGIN_GUID = "OverworkedUI"; public const string PLUGIN_NAME = "OverworkedUI"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Rebalance80.Overworked { internal class OverworkedCore { private const string bundleName = "ow_assets"; private const string nameProperty = "OW_Name"; private const string betterSaveProperty = "Alias_BetterSaves"; private const string lcSaveFile = "LCSaveFile"; private static readonly string[] defaultMoons = new string[6] { "41 Experimentation", "220 Assurance", "56 Vow", "21 Offense", "61 March", "20 Adamance" }; private static readonly Vector3 purchasePosition = new Vector3(1.2093f, 0.0084f, -6.7502f); public static void Initialize() { Plugin.logger.LogInfo((object)"Overworked core: initializing..."); Patch(); Plugin.logger.LogInfo((object)"Overworked core: patches applied..."); Plugin.logger.LogInfo((object)"Overworked core: loaded."); } private static void Patch() { Plugin.harmony.PatchAll(typeof(MenuManagerPatches)); Plugin.harmony.PatchAll(typeof(GameNetworkManagerPatches)); Plugin.harmony.PatchAll(typeof(StartOfRoundPatch)); Plugin.harmony.PatchAll(typeof(TerminalPatch)); } public static AssetBundle LoadBundle() { AssetBundle val = AssetBundle.LoadFromFile(Plugin.pluginFolder + "/Assets/ow_assets"); if ((Object)(object)val == (Object)null) { Plugin.logger.LogError((object)"The bundle could not be loaded because it does not exist."); } return val; } public static void RebuildRefs(Component target, Dictionary<string, (GameObject root, string path)> lookUp) { Type type = ((object)target).GetType(); foreach (KeyValuePair<string, (GameObject, string)> item3 in lookUp) { string key = item3.Key; GameObject item = item3.Value.Item1; string item2 = item3.Value.Item2; FieldInfo field = type.GetField(key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { Debug.LogWarning((object)("Field '" + key + "' not found on " + type.Name)); continue; } Transform val = item.transform.Find(item2); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Path '" + item2 + "' not found under '" + ((Object)item).name + "'")); } else { field.SetValue(target, ((Component)val).gameObject); } } } private static bool StartHosting(string lobbyName, bool isPublic, int saveFileIndex) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (!string.IsNullOrEmpty(lobbyName) && saveFileIndex > 0) { GameNetworkManager instance = GameNetworkManager.Instance; instance.currentSaveFileName = string.Format("{0}{1}", "LCSaveFile", saveFileIndex); instance.saveFileNum = saveFileIndex; instance.lobbyHostSettings = new HostSettings(lobbyName, isPublic, ""); Plugin.logger.LogInfo((object)"Host started"); instance.StartHost(); return true; } return false; } private static void LoadSavesFor(OwHostHandler handler) { handler.ClearSaves(); string[] array = (from f in ES3.GetFiles() where ES3.FileExists(f) && Regex.IsMatch(f, "^LCSaveFile\\d+$") select f).OrderBy(delegate(string f) { string s = new string(f.Where(char.IsDigit).ToArray()); int result; return int.TryParse(s, out result) ? result : int.MaxValue; }).ToArray(); int num = 1; string[] array2 = array; foreach (string text in array2) { string newFileName = string.Format("{0}{1}", "LCSaveFile", num); if (text != newFileName) { ES3.RenameFile(text, newFileName); } string text2 = ES3.Load<string>("OW_Name", newFileName, ""); string text3 = ES3.Load<string>("Alias_BetterSaves", newFileName, ""); string filename = ((!string.IsNullOrEmpty(text2)) ? text2 : ((!string.IsNullOrEmpty(text3)) ? text3 : "Unnamed save file")); handler.CreateSaveFile(num, newFileName, filename, delegate { DeleteSave(newFileName); LoadSavesFor(handler); }, delegate(string name) { RenameSave(newFileName, name); }); num++; } } private static void DeleteSave(string file) { if (ES3.FileExists(file) && Regex.IsMatch(file, "^LCSaveFile\\d+$")) { ES3.DeleteFile(file); } } public static void RenameSave(string path, string name) { ES3.Save<string>("OW_Name", name, path); } private static void CreateShopCategoryFor(OwHostHandler currentHandler) { ConfigCategory configCategory = new ConfigCategory(); configCategory.AddElement(new TextConfigElement(("id", "title"), ("text", ">Shop"))); Action<ConfigElementActor, bool> callback = delegate(ConfigElementActor a, bool i) { string arg = a.TargetElement.Get<string>("id"); int num = a.TargetElement.Get<int>("price"); int num2 = a.TargetElement.Get<int>("bought"); if (i) { if (currentHandler.creditsAmount - num >= 0) { currentHandler.creditsAmount -= num; a.TargetElement.Set("bought", num2 + 1); } } else if (num2 > 0) { currentHandler.creditsAmount += num; a.TargetElement.Set("bought", num2 - 1); } num2 = a.TargetElement.Get<int>("bought"); a.TargetElement.Set("text", $"* x{num2} // {arg} // Price: ■{num}"); currentHandler.UpdateCredits(); a.Blink(); a.Rebuild(); }; Item[] array = Resources.FindObjectsOfTypeAll<Item>(); Item[] array2 = array; foreach (Item val in array2) { if (val.creditsWorth > 5 && val.creditsWorth <= currentHandler.creditsAmount && val.minValue == 0) { configCategory.AddElement(new ButtonConfigElement(callback, ("id", val.itemName), ("text", $"* x0 // {val.itemName} // Price: ■{val.creditsWorth}"), ("price", val.creditsWorth), ("bought", 0))); } } configCategory.AddElement(new SpacingConfigElement()); currentHandler.AddTerminalCategory("Shop", configCategory); } private static void CreateMoonCategoryFor(OwHostHandler currentHandler) { ConfigCategory configCategory = new ConfigCategory(); configCategory.AddElement(new TextConfigElement(("id", "title"), ("text", ">Default Moon"))); Action<ConfigElementActor, bool> callback = delegate(ConfigElementActor a, bool i) { a.SetHighlighted(); a.Rebuild(); }; for (int j = 0; j < defaultMoons.Length; j++) { string text = defaultMoons[j]; ButtonConfigElement buttonConfigElement = new ButtonConfigElement(callback, ("id", text), ("text", "* " + text)); if (j == 0) { buttonConfigElement.Set("highlighted", true); } configCategory.AddElement(buttonConfigElement); } configCategory.AddElement(new SpacingConfigElement()); currentHandler.AddTerminalCategory("DefaultMoon", configCategory); } private static void BuildConfigFromHandler(OwHostHandler handler) { OverworkedSaveConfig.SaveFileName = handler.GetLobbyName(); OverworkedSaveConfig.StartCredits = handler.creditsAmount; OverworkedSaveConfig.IsNewSave = handler.isNewSave; ConfigCategory terminalCategory = handler.GetTerminalCategory("DefaultMoon"); ConfigElement highlightedElement = terminalCategory.GetHighlightedElement(); OverworkedSaveConfig.DefaultPlanet = highlightedElement.Get<string>("id"); ConfigCategory terminalCategory2 = handler.GetTerminalCategory("Shop"); OverworkedSaveConfig.InitialPurchases.Clear(); foreach (ConfigElement element in terminalCategory2.Elements) { int num = element.Get<int>("bought"); string key = element.Get<string>("id"); if (num > 0) { OverworkedSaveConfig.InitialPurchases[key] = num; } } } private static void BuildPreConfigFromHandler(OwHostHandler handler) { OverworkedSaveConfig.IsPublic = handler.isPublic; } private static void HandleUiFor(OwHostHandler handler) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown Button component = GameObject.Find("Canvas/MenuContainer/MainButtons/HostButton").GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { handler.Show(); LoadSavesFor(handler); }); handler.BindContext(delegate { handler.HideTerminalConfig(); handler.HighlightSaveButton(null); handler.Hide(); }, delegate { BuildPreConfigFromHandler(handler); if (StartHosting(handler.GetLobbyName(), handler.isPublic, handler.selectedSaveFileIndex)) { handler.Hide(); BuildConfigFromHandler(handler); } }); } private static void SetRoastFor(OwHostHandler handler) { TextMeshProUGUI component = ((Component)References.currentMenuManager.versionNumberText).GetComponent<TextMeshProUGUI>(); if (!((Object)(object)component == (Object)null)) { string text = ((TMP_Text)component).text; int num = int.Parse(text.Split('v')[1]); if (num < 60) { handler.SetOwUiRoast("Baby mode"); } else { handler.SetOwUiRoast("Goated version"); } } } public static void LoadHostModule() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown AssetBundle val = LoadBundle(); Object val2 = val.LoadAsset<Object>("assets/overworked/ui/ow_host.prefab"); GameObject selectSaveButtonPrefab = (GameObject)val.LoadAsset<Object>("assets/overworked/ui/ow_save.prefab"); GameObject configHolderPrefab = (GameObject)val.LoadAsset<Object>("assets/overworked/ui/ow_holder.prefab"); GameObject configTextPrefab = (GameObject)val.LoadAsset<Object>("assets/overworked/ui/ow_text.prefab"); GameObject configButtonPrefab = (GameObject)val.LoadAsset<Object>("assets/overworked/ui/ow_button.prefab"); GameObject val3 = (GameObject)(object)((val2 is GameObject) ? val2 : null); if (val3 != null) { GameObject val4 = Object.Instantiate<GameObject>(val3); OwHostHandler owHostHandler = ((val4 != null) ? ((Component)val4.transform.Find("OW_Host")).gameObject.AddComponent<OwHostHandler>() : null); owHostHandler.SelectSaveButtonPrefab = selectSaveButtonPrefab; owHostHandler.ConfigHolderPrefab = configHolderPrefab; owHostHandler.ConfigTextPrefab = configTextPrefab; owHostHandler.ConfigButtonPrefab = configButtonPrefab; RebuildRefs((Component)(object)owHostHandler, new Dictionary<string, (GameObject, string)> { { "Title", (val4, "OW_Host/Foreground/Title") }, { "LobbyName", (val4, "OW_Host/Foreground/LobbyName") }, { "Confirm", (val4, "OW_Host/Foreground/Confirm") }, { "Back", (val4, "OW_Host/Foreground/Back") }, { "Saves", (val4, "OW_Host/Foreground/Saves") }, { "Config", (val4, "OW_Host/Foreground/SaveConfig") }, { "SavesHolder", (val4, "OW_Host/Foreground/Saves/Viewport/Content") }, { "ConfigHolder", (val4, "OW_Host/Foreground/SaveConfig/Viewport/Content") }, { "Public", (val4, "OW_Host/Foreground/Public") }, { "Private", (val4, "OW_Host/Foreground/Private") }, { "OwUi", (val4, "OW_Host/Foreground/OwUI_Elem") } }); owHostHandler._Start(); CreateShopCategoryFor(owHostHandler); CreateMoonCategoryFor(owHostHandler); HandleUiFor(owHostHandler); SetRoastFor(owHostHandler); } val.Unload(false); } public static void TrySetDefaultPlanet(StartOfRound s, string p) { for (int i = 0; i < s.levels.Length; i++) { SelectableLevel val = s.levels[i]; if (val.PlanetName == p) { s.defaultPlanet = i; break; } } } public static void InstantiatePurchases(StartOfRound s, Dictionary<string, int> d) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) foreach (Item items in s.allItemsList.itemsList) { if (d.ContainsKey(items.itemName)) { for (int i = 0; i < d[items.itemName]; i++) { GrabbableObject component = Object.Instantiate<GameObject>(items.spawnPrefab, Vector3.zero, Quaternion.identity, s.elevatorTransform).GetComponent<GrabbableObject>(); ((Component)component).gameObject.transform.localPosition = purchasePosition; component.fallTime = 0f; component.scrapPersistedThroughRounds = true; component.isInElevator = true; component.isInShipRoom = true; ((NetworkBehaviour)component).NetworkObject.Spawn(false); } } } } public static void AttemptUpdateCredits(Terminal t, int c) { t.groupCredits = c; t.startingCreditsAmount = c; } } internal class OverworkedSaveConfig { public static string SaveFileName = "Unnamed"; public static int StartCredits = -1; public static string DefaultPlanet = "56 Vow"; public static Dictionary<string, int> InitialPurchases = new Dictionary<string, int>(); public static bool IsPublic = true; public static bool IsNewSave = false; } internal class References { public static MenuManager currentMenuManager; } [HarmonyPatch(typeof(MenuManager))] internal class MenuManagerPatches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_PostFix(MenuManager __instance) { if (!__instance.isInitScene) { References.currentMenuManager = __instance; OverworkedCore.LoadHostModule(); } } [HarmonyPatch("ClickHostButton")] [HarmonyPostfix] private static void ClickHostButton_PostFix(MenuManager __instance) { __instance.HostSettingsScreen.SetActive(false); } } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatches { [HarmonyPatch("SaveGame")] [HarmonyPostfix] private static void SaveGame_PostFix(GameNetworkManager __instance) { if (OverworkedSaveConfig.IsNewSave) { OverworkedCore.RenameSave(__instance.currentSaveFileName, OverworkedSaveConfig.SaveFileName); } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void Start_PreFix(StartOfRound __instance) { if (OverworkedSaveConfig.IsNewSave) { OverworkedCore.TrySetDefaultPlanet(__instance, OverworkedSaveConfig.DefaultPlanet); } } [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyPrefix] private static void LoadShipGrabbableItems_PreFix(StartOfRound __instance) { if (OverworkedSaveConfig.IsNewSave) { OverworkedCore.InstantiatePurchases(__instance, OverworkedSaveConfig.InitialPurchases); } } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Awake_PostFix(Terminal __instance) { if (OverworkedSaveConfig.IsNewSave) { OverworkedCore.AttemptUpdateCredits(__instance, OverworkedSaveConfig.StartCredits); } } } } namespace OverworkedTerminalConfig { public abstract class ConfigElement { private Dictionary<string, object> Data; public ConfigElement(params (string key, object value)[] fields) { Data = fields.ToDictionary(((string key, object value) f) => f.key, ((string key, object value) f) => f.value); } public bool TryGet<T>(string key, out T result) { if (Data.TryGetValue(key, out var value) && value is T val) { result = val; return true; } result = default(T); return false; } public void Set(string key, object value) { Data[key] = value; } public T Get<T>(string key) { if (Data.TryGetValue(key, out var value) && value is T result) { return result; } return default(T); } public virtual GameObject GetUiElement(OwHostHandler handler, ConfigCategory category) { return null; } } public class TextConfigElement : ConfigElement { public TextConfigElement(params (string key, object value)[] fields) : base(fields) { } public override GameObject GetUiElement(OwHostHandler handler, ConfigCategory category) { GameObject val = Object.Instantiate<GameObject>(handler.ConfigTextPrefab); if (TryGet<string>("text", out var result)) { ((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = result; } return val; } } public class SpacingConfigElement : ConfigElement { public override GameObject GetUiElement(OwHostHandler handler, ConfigCategory category) { GameObject val = Object.Instantiate<GameObject>(handler.ConfigTextPrefab); ((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = ""; return val; } } public class ButtonConfigElement : ConfigElement { [CompilerGenerated] private sealed class <Blink>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Image img; public ButtonConfigElement <>4__this; private int <i>5__1; private byte <alpha>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Blink>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <i>5__1 = 10; break; case 1: <>1__state = -1; <i>5__1--; break; } if (<i>5__1 >= 0) { <alpha>5__2 = (byte)(<i>5__1 * 10); ((Graphic)img).color = Color32.op_Implicit(new Color32((byte)48, (byte)148, (byte)55, <alpha>5__2)); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Action<ConfigElementActor, bool> CallbackMethod; public ButtonConfigElement(Action<ConfigElementActor, bool> callback, params (string key, object value)[] fields) : base(fields) { CallbackMethod = callback; } public override GameObject GetUiElement(OwHostHandler handler, ConfigCategory category) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) GameObject UIObject = Object.Instantiate<GameObject>(handler.ConfigButtonPrefab); TextMeshProUGUI componentInChildren = UIObject.GetComponentInChildren<TextMeshProUGUI>(); Image component = UIObject.GetComponent<Image>(); if (TryGet<string>("text", out var result)) { ((TMP_Text)componentInChildren).text = result; } if (TryGet<bool>("highlighted", out var result2) && result2) { ((Graphic)UIObject.GetComponent<Image>()).color = Color32.op_Implicit(new Color32((byte)48, (byte)148, (byte)55, (byte)100)); ((Graphic)componentInChildren).color = Color32.op_Implicit(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue)); } if (TryGet<bool>("doBlink", out var result3) && result3) { ((MonoBehaviour)component).StartCoroutine(Blink(component)); Set("doBlink", false); } UIObject.AddComponent<OwButton>(); OwButton component2 = UIObject.GetComponent<OwButton>(); component2.onClick.AddListener((UnityAction<bool>)delegate(bool isLeftClick) { CallbackMethod(new ConfigElementActor(UIObject, this, category, handler), isLeftClick); }); return UIObject; } [IteratorStateMachine(typeof(<Blink>d__3))] private IEnumerator Blink(Image img) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Blink>d__3(0) { <>4__this = this, img = img }; } } public class ConfigElementActor { private GameObject TargetObject = null; private ConfigCategory TargetCategory; private OwHostHandler Handler; public ConfigElement TargetElement { get; private set; } = null; public ConfigElementActor(GameObject o, ConfigElement e, ConfigCategory c, OwHostHandler h) { TargetObject = o; TargetElement = e; TargetCategory = c; Handler = h; } public void Blink() { TargetElement.Set("doBlink", true); } public void SetHighlighted() { foreach (ConfigElement element in TargetCategory.Elements) { element.Set("highlighted", false); } TargetElement.Set("highlighted", true); } public void Rebuild() { Handler.BuildCategory(TargetCategory, ((Component)TargetObject.transform.parent).gameObject); } } public class ConfigCategory { public List<ConfigElement> Elements { get; private set; } = new List<ConfigElement>(); public ConfigCategory AddElement(ConfigElement element) { Elements.Add(element); return this; } public ConfigElement? GetElementFromId(string id) { foreach (ConfigElement element in Elements) { if (element.TryGet<string>("id", out var result) && result == id) { return element; } } return null; } public ConfigElement? GetHighlightedElement() { foreach (ConfigElement element in Elements) { if (element.TryGet<bool>("highlighted", out var result) && result) { return element; } } return null; } } }