using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using HarmonyLib;
using RocketLib;
using UnityEngine;
using UnityModManagerNet;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AutoEnterPassword")]
[assembly: AssemblyCompany("Gorzontrok")]
[assembly: AssemblyProduct("AutoEnterPassword")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: ComVisible(false)]
[assembly: Guid("b656b7f2-ef20-489c-8bec-7e0cfd81499f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoEnterPassword;
internal static class Main
{
public static ModEntry mod;
public static bool enabled;
public static Settings settings;
private static bool Load(ModEntry modEntry)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
mod = modEntry;
modEntry.OnGUI = ModUI.OnGUI;
modEntry.OnSaveGUI = OnSaveGUI;
modEntry.OnToggle = OnToggle;
settings = ModSettings.Load<Settings>(modEntry);
if (IEnumerableExtensions.IsNullOrEmpty<bool>((IEnumerable<bool>)settings.VanillaLoadOnStart))
{
settings.VanillaLoadOnStart = new bool[7];
}
try
{
Mod.Initialize();
Harmony val = new Harmony(modEntry.Info.Id);
Assembly executingAssembly = Assembly.GetExecutingAssembly();
val.PatchAll(executingAssembly);
}
catch (Exception ex)
{
Log("Failed Mod Initialization\n" + ex);
}
return true;
}
private static void OnSaveGUI(ModEntry modEntry)
{
settings.LoadOnStartRocketLib = (from kv in Mod.passwordsLoadOnStart
where kv.Value
select kv.Key).ToArray();
((ModSettings)settings).Save(modEntry);
}
private static bool OnToggle(ModEntry modEntry, bool value)
{
enabled = value;
return true;
}
public static void Log(object str)
{
mod.Logger.Log(str.ToString());
}
}
public class Settings : ModSettings
{
public bool[] VanillaLoadOnStart;
public string[] LoadOnStartRocketLib;
public override void Save(ModEntry modEntry)
{
ModSettings.Save<Settings>(this, modEntry);
}
}
[HarmonyPatch(typeof(UI), "Awake")]
public static class AfterLoadedMods_Patch
{
private static void Prefix()
{
if (Main.enabled)
{
Mod.StartLoadPasswords();
}
}
}
public static class Mod
{
public const int VANILLA_PASSWORD_COUNT = 7;
public static string[] vanillaPasswords;
public static Dictionary<string, bool> passwordsLoadOnStart = new Dictionary<string, bool>();
private static bool _hasInitialized = false;
public static bool hasLoadedOnStartup = false;
public static void Initialize()
{
if (!_hasInitialized)
{
vanillaPasswords = new string[7] { "IThinkPuttingMyTesticalsInSomeoneElseFaceWithoutTheirConsentIsOkay", "alaskanpipeline", "seagull", "mranderbro", "abrahamlincoln", "smokinggun", "iloveamerica" };
passwordsLoadOnStart = new Dictionary<string, bool>();
_hasInitialized = true;
}
}
public static void CallVanillaPassword(string password)
{
bool flag = false;
switch (password)
{
case "IThinkPuttingMyTesticalsInSomeoneElseFaceWithoutTheirConsentIsOkay":
TestVanDammeAnim.teaBagCheatEnabled = true;
flag = true;
break;
case "alaskanpipeline":
HeroUnlockController.UnlockAllBros();
PlayerProgress.Save(true);
flag = true;
break;
case "seagull":
HeroUnlockController.UnlockEverythingButBroheart();
flag = true;
break;
case "mranderbro":
Map.SetTryReduceLoadingTimes(true);
flag = true;
break;
case "abrahamlincoln":
GameModeController.CheatsEnabled = true;
flag = true;
break;
case "smokinggun":
LevelEditorGUI.hackedEditorOn = true;
flag = true;
break;
case "iloveamerica":
HeroUnlockController.UnlockAllBros();
WorldTerritory3D.unlockAllTerritories = true;
PlayerProgress.Save(true);
flag = true;
break;
}
if (flag)
{
Main.Log("'" + password + "' loaded.");
}
}
public static void StartLoadPasswords()
{
if (hasLoadedOnStartup)
{
return;
}
hasLoadedOnStartup = true;
Main.Log("--- Starting to load after startup. ---");
if (IEnumerableExtensions.IsNotNullOrEmpty<bool>((IEnumerable<bool>)Main.settings.VanillaLoadOnStart))
{
for (int i = 0; i < 7; i++)
{
if (Main.settings.VanillaLoadOnStart[i])
{
CallVanillaPassword(vanillaPasswords[i]);
}
}
}
if (IEnumerableExtensions.IsNullOrEmpty<string>((IEnumerable<string>)Main.settings.LoadOnStartRocketLib))
{
Main.Log("--- Ended loading after startup. ---");
return;
}
for (int i = 0; i < Main.settings.LoadOnStartRocketLib.Length; i++)
{
passwordsLoadOnStart.Add(Main.settings.LoadOnStartRocketLib[i], value: true);
}
if (IEnumerableExtensions.IsNullOrEmpty<GamePassword>((IEnumerable<GamePassword>)GamePassword.Passwords))
{
Main.Log("--- Ended loading after startup. ---");
return;
}
for (int i = 0; i < GamePassword.Passwords.Length; i++)
{
GamePassword val = GamePassword.Passwords[i];
if (passwordsLoadOnStart.ContainsKey(val.password) && passwordsLoadOnStart[val.password])
{
val.action?.Invoke();
Main.Log("'" + val.password + "' loaded.");
}
}
}
}
internal static class ModUI
{
public static void OnGUI(ModEntry modEntry)
{
GUILayout.Label("Game Passwords :", (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
for (int i = 0; i < 7; i++)
{
DrawVanillaPasswordUI(i);
}
GUILayout.EndHorizontal();
if (IEnumerableExtensions.IsNullOrEmpty<GamePassword>((IEnumerable<GamePassword>)GamePassword.Passwords))
{
return;
}
GUILayout.Label("RocketLib Passwords :", (GUILayoutOption[])(object)new GUILayoutOption[0]);
for (int j = 0; j < GamePassword.Passwords.Length; j++)
{
if (j == 0)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
}
DrawRocketLibPasswordUI(GamePassword.Passwords[j]);
if (j % 5 == 0 || j == GamePassword.Passwords.Length)
{
GUILayout.EndHorizontal();
}
}
}
public static void DrawVanillaPasswordUI(int i)
{
if (i < 7)
{
string text = Mod.vanillaPasswords[i];
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[0]))
{
Mod.CallVanillaPassword(text);
}
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
Main.settings.VanillaLoadOnStart[i] = GUILayout.Toggle(Main.settings.VanillaLoadOnStart[i], "Load On Start", (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
}
public static void DrawRocketLibPasswordUI(GamePassword gamePassword)
{
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayout.Button(gamePassword.password, (GUILayoutOption[])(object)new GUILayoutOption[0]))
{
gamePassword.action();
}
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
if (!Mod.passwordsLoadOnStart.ContainsKey(gamePassword.password))
{
Mod.passwordsLoadOnStart.Add(gamePassword.password, value: false);
}
Mod.passwordsLoadOnStart[gamePassword.password] = GUILayout.Toggle(Mod.passwordsLoadOnStart[gamePassword.password], "Load On Start", (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
}