using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MycoModList.Patches;
using Pigeon.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("MycoModList")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MycoModList")]
[assembly: AssemblyTitle("MycoModList")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MycoModList
{
[BepInPlugin("MycoModList", "MycoModList", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Logger;
private Harmony _harmony = new Harmony("MycoModList");
private ConfigEntry<int> _intEntry;
private ConfigEntry<bool> _boolEntry;
private ConfigEntry<string> _stringEntry;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
_harmony.PatchAll(typeof(StartMenuPatch));
Logger.LogInfo((object)"MycoModList loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MycoModList";
public const string PLUGIN_NAME = "MycoModList";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace MycoModList.Patches
{
[HarmonyPatch(typeof(StartMenu))]
public class StartMenuPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__5_0;
internal void <Update_Postfix>b__5_0()
{
StartMenu.Instance.OpenSettingsWindow();
PlayerOptions.Instance.SetSection(_sectionButtonIndex);
}
}
private static GameObject _startScreenButtonObj;
private static GameObject _settingsTabObj;
private static GameObject _settingsSectionObj;
private static int _sectionButtonIndex;
private static bool _initialized;
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void Update_Postfix(StartMenu __instance)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Expected O, but got Unknown
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Expected O, but got Unknown
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
if (_initialized || !((Component)((Window)__instance).WindowSystem).gameObject.activeSelf)
{
return;
}
_initialized = true;
GameObject val = GameObject.Find("Menu/StartScreen/Credits");
_startScreenButtonObj = Object.Instantiate<GameObject>(val);
_startScreenButtonObj.transform.SetParent(((Component)((Window)__instance).WindowSystem).transform);
((Object)_startScreenButtonObj).name = "Mods Button";
_startScreenButtonObj.transform.localScale = Vector3.one;
_startScreenButtonObj.transform.localPosition = new Vector3(val.transform.localPosition.x, val.transform.localPosition.y + 50f, val.transform.localPosition.z);
_startScreenButtonObj.transform.localRotation = Quaternion.identity;
((TMP_Text)_startScreenButtonObj.GetComponentInChildren<TextMeshProUGUI>()).text = "MODS";
DefaultButton component = _startScreenButtonObj.GetComponent<DefaultButton>();
((Button)component).OnClickUp = new UnityEvent();
UnityEvent onClickUp = ((Button)component).OnClickUp;
object obj = <>c.<>9__5_0;
if (obj == null)
{
UnityAction val2 = delegate
{
StartMenu.Instance.OpenSettingsWindow();
PlayerOptions.Instance.SetSection(_sectionButtonIndex);
};
<>c.<>9__5_0 = val2;
obj = (object)val2;
}
onClickUp.AddListener((UnityAction)obj);
GameObject val3 = GameObject.Find("Menu/StartScreen/Settings/Graphics");
if ((Object)(object)val3 == (Object)null)
{
return;
}
PlayerOptions options = ((Component)val3.transform.parent).GetComponent<PlayerOptions>();
_settingsSectionObj = ((Component)((Component)((Component)options).transform).GetComponentInChildren<OptionsContainer>()).gameObject;
_settingsTabObj = Object.Instantiate<GameObject>(val3, val3.transform.parent);
_settingsSectionObj = Object.Instantiate<GameObject>(((Component)((Component)__instance.settingsWindow).GetComponentInChildren<OptionsContainer>()).gameObject, val3.transform.parent);
((Object)_settingsTabObj).name = "Mods";
((Object)_settingsSectionObj).name = "Mods section";
RectTransform component2 = _settingsTabObj.GetComponent<RectTransform>();
component2.anchoredPosition += new Vector2(0f, -96f);
_settingsSectionObj.transform.localPosition = Vector2.op_Implicit(new Vector2(174.05f, -76f));
TextMeshProUGUI componentInChildren = ((Component)_settingsTabObj.transform).GetComponentInChildren<TextMeshProUGUI>();
if ((Object)(object)componentInChildren != (Object)null)
{
((TMP_Text)componentInChildren).text = "MODS";
}
RectTransform[] sections = options.sections;
RectTransform[] array = (RectTransform[])(object)new RectTransform[sections.Length + 1];
Array.Copy(sections, array, sections.Length);
array[sections.Length] = _settingsSectionObj.GetComponent<RectTransform>();
options.sections = array;
DefaultButton[] sectionButtons = options.sectionButtons;
DefaultButton[] array2 = (DefaultButton[])(object)new DefaultButton[sectionButtons.Length + 1];
Array.Copy(sectionButtons, array2, sectionButtons.Length);
array2[sectionButtons.Length] = _settingsTabObj.GetComponent<DefaultButton>();
options.sectionButtons = array2;
float[] sectionPositions = options.sectionPositions;
float[] array3 = new float[sectionPositions.Length + 1];
_sectionButtonIndex = array3.Length - 1;
Array.Copy(sectionPositions, array3, sectionPositions.Length);
array3[sectionPositions.Length] = options.sectionXPos;
options.sectionPositions = array3;
DefaultButton component3 = _settingsTabObj.GetComponent<DefaultButton>();
((UnityEventBase)((Button)component3).OnClickUp).RemoveAllListeners();
((Button)component3).OnClickUp.AddListener((UnityAction)delegate
{
options.SetSection(_sectionButtonIndex);
});
foreach (Transform item in _settingsSectionObj.transform.GetChild(0))
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
CreateModList(ModManager.Mods);
}
[HarmonyPrefix]
[HarmonyPatch("OnDestroy")]
private static void OnDestroy_Prefix()
{
Object.Destroy((Object)(object)_startScreenButtonObj);
Object.Destroy((Object)(object)_settingsTabObj);
Object.Destroy((Object)(object)_settingsSectionObj);
_sectionButtonIndex = 0;
_initialized = false;
}
private static Dictionary<string, List<string>> ParseModConfig(string configPath)
{
Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
string key = "";
foreach (string item in File.ReadLines(configPath))
{
if (item.StartsWith("#") || string.IsNullOrWhiteSpace(item))
{
continue;
}
if (item.StartsWith("[") && item.EndsWith("]"))
{
key = item.Trim();
if (!dictionary.ContainsKey(key))
{
dictionary[key] = new List<string>();
}
}
else if (item.Contains("="))
{
if (!dictionary.ContainsKey(key))
{
dictionary[key] = new List<string>();
}
dictionary[key].Add(item.Trim());
}
}
return dictionary;
}
private static void CreateModList(IReadOnlyList<ModInfo> mods)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Expected O, but got Unknown
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Expected O, but got Unknown
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Expected O, but got Unknown
//IL_0712: Unknown result type (might be due to invalid IL or missing references)
//IL_0717: Unknown result type (might be due to invalid IL or missing references)
//IL_072f: Unknown result type (might be due to invalid IL or missing references)
//IL_074b: Unknown result type (might be due to invalid IL or missing references)
//IL_0755: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0419: Unknown result type (might be due to invalid IL or missing references)
//IL_0429: Unknown result type (might be due to invalid IL or missing references)
//IL_0433: Unknown result type (might be due to invalid IL or missing references)
//IL_0460: Unknown result type (might be due to invalid IL or missing references)
//IL_046a: Unknown result type (might be due to invalid IL or missing references)
//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: Expected O, but got Unknown
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
//IL_04fb: Expected O, but got Unknown
//IL_0540: Unknown result type (might be due to invalid IL or missing references)
//IL_054f: Unknown result type (might be due to invalid IL or missing references)
//IL_0556: Expected O, but got Unknown
//IL_0582: Unknown result type (might be due to invalid IL or missing references)
//IL_0589: Expected O, but got Unknown
//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
//IL_05bc: Expected O, but got Unknown
//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0628: Unknown result type (might be due to invalid IL or missing references)
//IL_0686: Unknown result type (might be due to invalid IL or missing references)
//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
Transform child = _settingsSectionObj.transform.GetChild(0);
RectTransform component = ((Component)child).GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 1f);
component.anchorMax = new Vector2(0.5f, 1f);
component.pivot = new Vector2(0.5f, 1f);
component.anchoredPosition = Vector2.zero;
VerticalLayoutGroup component2 = ((Component)child).GetComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)component2).spacing = 20f;
((LayoutGroup)component2).padding = new RectOffset(0, 0, (int)((HorizontalOrVerticalLayoutGroup)component2).spacing, 0);
foreach (ModInfo mod in mods)
{
ModInfo current = mod;
GameObject val = new GameObject(((ModInfo)(ref current)).Name, new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(TextMeshProUGUI)
});
val.transform.SetParent(child, false);
TextMeshProUGUI component3 = val.GetComponent<TextMeshProUGUI>();
((TMP_Text)component3).text = "<b>" + ((ModInfo)(ref current)).Name + "</b>";
((TMP_Text)component3).fontSize = 28f;
((Graphic)component3).color = Color.yellow;
((TMP_Text)component3).alignment = (TextAlignmentOptions)514;
val.GetComponent<RectTransform>().sizeDelta = new Vector2(600f, -1f);
LayoutElement obj = val.AddComponent<LayoutElement>();
obj.preferredWidth = 600f;
obj.minHeight = 40f;
val.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
GameObject modContent = new GameObject(((ModInfo)(ref current)).Name + " content", new Type[3]
{
typeof(RectTransform),
typeof(VerticalLayoutGroup),
typeof(ContentSizeFitter)
});
modContent.transform.SetParent(child, false);
RectTransform component4 = modContent.GetComponent<RectTransform>();
component4.sizeDelta = new Vector2(500f, -1f);
component4.anchorMin = new Vector2(0.5f, 1f);
component4.anchorMax = new Vector2(0.5f, 1f);
component4.pivot = new Vector2(0.5f, 1f);
component4.anchoredPosition = Vector2.zero;
VerticalLayoutGroup component5 = modContent.GetComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)component5).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)component5).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)component5).spacing = 10f;
modContent.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
modContent.SetActive(false);
GameObject val2 = new GameObject("Background", new Type[1] { typeof(Rect) });
val2.transform.SetParent(val.transform, false);
val2.transform.localPosition = Vector3.zero;
val2.transform.localScale = Vector3.one;
val2.transform.localRotation = Quaternion.identity;
val2.GetComponent<RectTransform>().sizeDelta = new Vector2(500f, 55f);
((Graphic)val2.GetComponent<Rect>()).color = new Color(0.9451f, 0.9451f, 0.9451f, 0f);
DefaultButton obj2 = val2.AddComponent<DefaultButton>();
obj2.mainGraphic = (Graphic)(object)val2.GetComponent<Rect>();
obj2.secondaryGraphic = (Graphic)(object)component3;
obj2.SetHoverColor(new Color(0.9451f, 0.9451f, 0.9451f, 0.5f));
((Button)obj2).OnClickUp = new UnityEvent();
((Button)obj2).OnClickUp.AddListener((UnityAction)delegate
{
modContent.SetActive(!modContent.activeSelf);
});
string text = Path.Combine(Paths.ConfigPath, ((ModInfo)(ref current)).Name + ".cfg");
if (File.Exists(text))
{
foreach (KeyValuePair<string, List<string>> item in ParseModConfig(text))
{
GameObject val3 = new GameObject("Section: " + item.Key, new Type[1] { typeof(TextMeshProUGUI) });
val3.transform.SetParent(modContent.transform, false);
val3.GetComponent<RectTransform>().sizeDelta = new Vector2(600f, -1f);
TextMeshProUGUI component6 = val3.GetComponent<TextMeshProUGUI>();
((TMP_Text)component6).text = "<i>" + item.Key + "</i>";
((TMP_Text)component6).fontSize = 22f;
((Graphic)component6).color = Color.cyan;
LayoutElement obj3 = val3.AddComponent<LayoutElement>();
obj3.preferredWidth = 600f;
obj3.preferredHeight = -1f;
obj3.minHeight = 30f;
val3.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
foreach (string item2 in item.Value)
{
GameObject val4 = new GameObject("Entry");
val4.transform.SetParent(modContent.transform, false);
GameObject val5 = new GameObject("Entry Left", new Type[1] { typeof(TextMeshProUGUI) });
val5.transform.SetParent(val4.transform, false);
TextMeshProUGUI component7 = val5.GetComponent<TextMeshProUGUI>();
((TMP_Text)component7).text = item2.Substring(0, item2.LastIndexOf('=') - 1);
((TMP_Text)component7).fontSize = 18f;
((Graphic)component7).color = Color.white;
GameObject val6 = new GameObject("Entry Right");
val6.transform.SetParent(val4.transform, false);
GameObject val7 = new GameObject("Value", new Type[1] { typeof(RectTransform) });
val7.transform.SetParent(val6.transform, false);
GameObject val8 = new GameObject("Text Area", new Type[1] { typeof(RectTransform) });
val8.transform.SetParent(val7.transform, false);
GameObject val9 = new GameObject("Text", new Type[1] { typeof(TextMeshProUGUI) });
val9.transform.SetParent(val8.transform, false);
TextMeshProUGUI component8 = val9.GetComponent<TextMeshProUGUI>();
((TMP_Text)component8).text = item2.Substring(item2.LastIndexOf('=') + 2);
((TMP_Text)component8).fontSize = 18f;
((Graphic)component8).color = Color.white;
LayoutElement obj4 = val4.AddComponent<LayoutElement>();
obj4.preferredWidth = 400f;
obj4.minHeight = 36f;
ContentSizeFitter obj5 = val4.AddComponent<ContentSizeFitter>();
obj5.verticalFit = (FitMode)2;
obj5.horizontalFit = (FitMode)2;
val6.transform.localPosition = new Vector3((float)((TMP_Text)component7).text.Length + 100f, 0f, 0f);
val5.transform.localPosition = new Vector3(0f - ((float)((TMP_Text)component7).text.Length + 100f), 0f, 0f);
}
}
}
else
{
GameObject val10 = new GameObject("NoConfig", new Type[1] { typeof(TextMeshProUGUI) });
val10.transform.SetParent(modContent.transform, false);
TextMeshProUGUI component9 = val10.GetComponent<TextMeshProUGUI>();
((TMP_Text)component9).text = "(No config found)";
((TMP_Text)component9).fontSize = 20f;
((Graphic)component9).color = Color.gray;
LayoutElement obj6 = val10.AddComponent<LayoutElement>();
obj6.preferredWidth = 600f;
obj6.preferredHeight = -1f;
obj6.minHeight = 30f;
val10.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
}
}
}
}
public class CoroutineRunner : MonoBehaviour
{
private static CoroutineRunner _instance;
public static CoroutineRunner Instance
{
get
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
GameObject val = new GameObject("CoroutineRunner");
Object.DontDestroyOnLoad((Object)val);
_instance = val.AddComponent<CoroutineRunner>();
}
return _instance;
}
}
}
}