using System;
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 BepInEx;
using BepInEx.IL2CPP;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.ModManager")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.ModManager")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.ModManager")]
[assembly: AssemblyTitle("Antro.ModManager")]
[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 Antro.ModManager
{
[BepInPlugin("Antro.ModManager", "Antro Mod Manager", "1.0.0")]
public class ModManagerPlugin : BasePlugin
{
public override void Load()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
ClassInjector.RegisterTypeInIl2Cpp<ModManagerController>();
GameObject val = new GameObject("Antro_ModManager_UI");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<ModManagerController>();
((BasePlugin)this).Log.LogInfo((object)"Antro Mod Manager 1.7.0 Loaded.");
}
}
public class ModManagerController : MonoBehaviour
{
private bool _isMenuOpen = false;
private Rect _windowRect = new Rect(20f, 20f, 300f, 450f);
private Vector2 _scrollPos;
private string _savePath;
private List<ModGroup> _modGroups = new List<ModGroup>();
private Dictionary<string, bool> _settings = new Dictionary<string, bool>();
private readonly string[] _menuVars = new string[6] { "_isMenuOpen", "isMenuOpen", "menuOpen", "showMenu", "ShowMenu", "isVisible" };
private Type _monoType;
private GUIStyle richStyle => new GUIStyle(GUI.skin.label)
{
richText = true,
fontSize = 13,
alignment = (TextAnchor)3
};
public ModManagerController(IntPtr ptr)
: base(ptr)
{
}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
private void Start()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
_savePath = Path.Combine(Paths.ConfigPath, "AntroModManager.txt");
GameObject val = new GameObject();
MonoBehaviour val2 = (MonoBehaviour)(object)val.AddComponent<ModManagerController>();
_monoType = ((Object)val2).GetIl2CppType().BaseType;
Object.Destroy((Object)(object)val);
LoadSettings();
ScanMods();
}
private void Update()
{
if (Input.GetKeyDown((KeyCode)277))
{
_isMenuOpen = !_isMenuOpen;
Cursor.lockState = (CursorLockMode)((!_isMenuOpen) ? 1 : 0);
Cursor.visible = _isMenuOpen;
if (_isMenuOpen)
{
ScanMods();
}
}
foreach (ModGroup modGroup in _modGroups)
{
if (!modGroup.IsAllowed)
{
foreach (MonoBehaviour instance in modGroup.Instances)
{
if ((Object)(object)instance == (Object)null)
{
continue;
}
if (instance.useGUILayout)
{
instance.useGUILayout = false;
}
if (modGroup.MenuField != null)
{
try
{
modGroup.MenuField.SetValue(instance, false);
}
catch
{
}
}
}
continue;
}
foreach (MonoBehaviour instance2 in modGroup.Instances)
{
if ((Object)(object)instance2 != (Object)null && !instance2.useGUILayout)
{
instance2.useGUILayout = true;
}
}
}
}
private void ScanMods()
{
_modGroups.Clear();
if (_monoType == (Type)null)
{
return;
}
Dictionary<string, ModGroup> dictionary = new Dictionary<string, ModGroup>();
Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(_monoType);
foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
{
MonoBehaviour val2 = ((Il2CppObjectBase)item).TryCast<MonoBehaviour>();
if ((Object)(object)val2 == (Object)null)
{
continue;
}
Type il2CppType = ((Object)val2).GetIl2CppType();
string text = il2CppType.Namespace ?? "";
string name = ((MemberInfo)il2CppType).Name;
bool flag = text.Contains("Antro");
if (!flag && name.StartsWith("Antro"))
{
flag = true;
}
if (name.Contains("ModManager"))
{
flag = false;
}
if (!flag)
{
continue;
}
string text2 = name.Replace("Antro", "").Replace("Controller", "").Replace("Plugin", "")
.Trim(new char[1] { '.' });
if (string.IsNullOrEmpty(text2))
{
text2 = name;
}
if (!dictionary.ContainsKey(text2))
{
FieldInfo menuField = null;
Type type = ((object)val2).GetType();
string[] menuVars = _menuVars;
foreach (string name2 in menuVars)
{
FieldInfo field = type.GetField(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null && field.FieldType == typeof(bool))
{
menuField = field;
break;
}
}
bool isAllowed = true;
if (_settings.ContainsKey(text2))
{
isAllowed = _settings[text2];
}
else
{
_settings[text2] = true;
}
dictionary[text2] = new ModGroup
{
DisplayName = text2,
Instances = new List<MonoBehaviour>(),
MenuField = menuField,
IsAllowed = isAllowed
};
}
dictionary[text2].Instances.Add(val2);
}
_modGroups = dictionary.Values.ToList();
_modGroups.Sort((ModGroup a, ModGroup b) => a.DisplayName.CompareTo(b.DisplayName));
}
private void OnGUI()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if (_isMenuOpen)
{
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.95f);
GUI.contentColor = Color.white;
_windowRect = GUI.Window(444123, _windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "Antro Mods");
}
}
private void DrawWindow(int id)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
float num = 10f;
float num2 = 25f;
if (GUI.Button(new Rect(num, num2, 80f, 20f), "Refresh"))
{
ScanMods();
}
if (GUI.Button(new Rect(num + 90f, num2, 80f, 20f), "Save"))
{
SaveSettings();
}
float num3 = 35f;
float num4 = (float)_modGroups.Count * num3;
float num5 = ((Rect)(ref _windowRect)).width - 25f;
Rect val = default(Rect);
((Rect)(ref val))..ctor(0f, 0f, num5, num4);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(num, num2 + 30f, ((Rect)(ref _windowRect)).width - num, ((Rect)(ref _windowRect)).height - 65f);
_scrollPos = GUI.BeginScrollView(val2, _scrollPos, val, false, true);
float num6 = 0f;
foreach (ModGroup modGroup in _modGroups)
{
GUI.Box(new Rect(0f, num6, num5, num3 - 2f), "");
bool isAllowed = modGroup.IsAllowed;
Color backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = (isAllowed ? new Color(0f, 0.8f, 0f) : new Color(0.8f, 0f, 0f));
string text = (isAllowed ? "ON" : "OFF");
if (GUI.Button(new Rect(5f, num6 + 2f, 50f, num3 - 6f), text))
{
modGroup.IsAllowed = !isAllowed;
_settings[modGroup.DisplayName] = modGroup.IsAllowed;
SaveSettings();
}
GUI.backgroundColor = backgroundColor;
float num7 = num6 + num3 / 2f - 10f;
GUI.Label(new Rect(65f, num7, 200f, 20f), "<b>" + modGroup.DisplayName + "</b>", richStyle);
num6 += num3;
}
GUI.EndScrollView();
GUI.DragWindow();
}
private void SaveSettings()
{
try
{
List<string> list = new List<string>();
foreach (KeyValuePair<string, bool> setting in _settings)
{
list.Add($"{setting.Key}={setting.Value}");
}
File.WriteAllLines(_savePath, list);
}
catch
{
}
}
private void LoadSettings()
{
_settings.Clear();
if (!File.Exists(_savePath))
{
return;
}
try
{
string[] array = File.ReadAllLines(_savePath);
string[] array2 = array;
foreach (string text in array2)
{
if (!string.IsNullOrWhiteSpace(text))
{
string[] array3 = text.Split(new char[1] { '=' });
if (array3.Length == 2)
{
_settings[array3[0].Trim()] = bool.Parse(array3[1].Trim());
}
}
}
}
catch
{
}
}
}
public class ModGroup
{
public string DisplayName;
public List<MonoBehaviour> Instances;
public FieldInfo MenuField;
public bool IsAllowed;
}
}