using 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using Landfall.TABS.Workshop;
using QuickScene;
using QuickSceneFunctions;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("QuickScene")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("QuickScene")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace QuickSceneFunctions
{
public class QuickSceneUI : MonoBehaviour
{
private Vector2 scrollPos;
private bool showMenu = true;
public Texture2D windowTexture;
public Texture2D buttonTexture;
private GUIStyle windowStyle;
private GUIStyle buttonStyle;
private void OnGUI()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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)
EnsureStyles();
if (!showMenu)
{
if (GUI.Button(new Rect((float)Screen.width - 40f, 10f, 30f, 30f), "<"))
{
showMenu = true;
}
return;
}
float num = 250f;
float num2 = 500f;
GUILayout.BeginArea(new Rect((float)Screen.width - num - 10f, 10f, num, num2), windowStyle);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Quick Scenes", Array.Empty<GUILayoutOption>());
if (GUILayout.Button("X", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
{
showMenu = false;
}
GUILayout.EndHorizontal();
GUILayout.Space(10f);
GUILayout.Label("Loaded: " + Loader.SceneNames.Count, Array.Empty<GUILayoutOption>());
scrollPos = GUILayout.BeginScrollView(scrollPos, Array.Empty<GUILayoutOption>());
foreach (Loader.SceneShortcut sceneName in Loader.SceneNames)
{
if (GUILayout.Button(sceneName.DisplayName, buttonStyle, Array.Empty<GUILayoutOption>()))
{
Loader.LoadSceneOrMap(sceneName.SceneName);
}
}
GUILayout.EndScrollView();
GUILayout.Space(10f);
if (GUILayout.Button("Reload", buttonStyle, Array.Empty<GUILayoutOption>()))
{
Loader.ReloadScenes();
}
if (GUILayout.Button("Dump MapAssets", buttonStyle, Array.Empty<GUILayoutOption>()))
{
foreach (MapAsset item in ContentDatabase.Instance().GetAllMapAssetsOrdered())
{
Debug.Log((object)("[MapAsset] " + item.MapName + " | " + item.Entity.Name));
}
}
GUILayout.EndArea();
}
private void EnsureStyles()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
if (windowStyle == null)
{
windowStyle = new GUIStyle(GUI.skin.box);
if ((Object)(object)windowTexture != (Object)null)
{
windowStyle.normal.background = windowTexture;
}
}
if (buttonStyle == null)
{
buttonStyle = new GUIStyle(GUI.skin.button);
if ((Object)(object)buttonTexture != (Object)null)
{
buttonStyle.normal.background = buttonTexture;
}
}
}
}
}
namespace QuickScene
{
[BepInPlugin("GeeztJeez.QuickScene", "QuickScene", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
public class SceneShortcut
{
public string SceneName;
public string DisplayName;
}
public static Loader Instance;
public static string QuickSceneFolder;
public static string SceneFilePath;
public AssetBundle assetBundle;
public GameObject quickSceneUI;
public static string ConfigFilePath;
public static bool InstantLoadEnabled;
public static string InstantLoadScene;
public static bool DebugEnabled;
public static List<SceneShortcut> SceneNames = new List<SceneShortcut>();
public void Awake()
{
try
{
Instance = this;
QuickSceneFolder = Path.Combine(Application.dataPath, "../QuickScene");
SceneFilePath = Path.Combine(QuickSceneFolder, "shortcutScene.txt");
ConfigFilePath = Path.Combine(QuickSceneFolder, "config.txt");
CreateConfig();
LoadConfig();
ReloadScenes();
ApplyHarmony();
((MonoBehaviour)this).StartCoroutine(Call());
}
catch (Exception ex)
{
LogError("[QuickScene] Fatal error, mod loading failed: " + ex);
LogWarning("Please contact Geezt Jeez or try reloading the game for proper installation...");
}
}
public IEnumerator Call()
{
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ServiceLocator.GetService<GameModeService>() != (Object)null));
yield return (object)new WaitUntil((Func<bool>)(() => ContentDatabase.Instance() != null));
Log("[QuickScene] Loading...!");
assetBundle = LoadBundle("quicksceneassetbundle");
quickSceneUI = new GameObject("QuickSceneUI");
Object.DontDestroyOnLoad((Object)(object)quickSceneUI);
QuickSceneUI obj = quickSceneUI.AddComponent<QuickSceneUI>();
obj.windowTexture = assetBundle.LoadAsset<Texture2D>("QuickSceneWindowTexture");
obj.buttonTexture = assetBundle.LoadAsset<Texture2D>("QuickSceneButtonTexture");
SceneManager.sceneLoaded += SceneLoaded;
ServiceLocator.GetService<CustomContentLoaderModIO>().QuickRefresh((WorkshopContentType)5, (Action)null);
Log("[QuickScene] Successfully loaded!");
if (InstantLoadEnabled && !string.IsNullOrEmpty(InstantLoadScene))
{
Log("[QuickScene] Instant load enabled.");
LoadSceneOrMap(InstantLoadScene);
}
else
{
Log("[QuickScene] Instant load disabled.");
}
}
public static void CreateConfig()
{
if (!Directory.Exists(QuickSceneFolder))
{
Directory.CreateDirectory(QuickSceneFolder);
}
if (!File.Exists(SceneFilePath))
{
File.WriteAllText(SceneFilePath, "00_Simulation_Day_VC=Simulation\r\nUnitCreator_GamepadUI=Unit Creator\r\nEditor Scene=Map Editor");
}
if (!File.Exists(ConfigFilePath))
{
File.WriteAllText(ConfigFilePath, "InstantLoadEnabled=false\r\nInstantLoadScene=00_Simulation_Day_VC\r\nDebugEnabled=false");
}
}
public static void ReloadScenes()
{
try
{
SceneNames.Clear();
string[] array = File.ReadAllLines(SceneFilePath);
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (!string.IsNullOrWhiteSpace(text))
{
string[] array2 = text.Split(new char[1] { '=' }, 2);
string sceneName;
string displayName;
if (array2.Length == 2)
{
sceneName = array2[0].Trim();
displayName = array2[1].Trim();
}
else
{
sceneName = text;
displayName = text;
}
SceneNames.Add(new SceneShortcut
{
SceneName = sceneName,
DisplayName = displayName
});
}
}
Log($"[QuickScene] Loaded {SceneNames.Count} scene shortcuts.");
foreach (SceneShortcut sceneName2 in SceneNames)
{
Log($"[QuickScene] {sceneName2.SceneName} => {sceneName2.DisplayName}");
}
}
catch (Exception arg)
{
LogError($"[QuickScene] Failed loading scene list.\n{arg}");
}
}
public static bool SceneExists(string sceneName)
{
try
{
return Application.CanStreamedLevelBeLoaded(sceneName);
}
catch
{
return false;
}
}
public void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
try
{
Log($"[QuickScene] Loading scene: {((Scene)(ref scene)).name}");
}
catch (Exception arg)
{
LogError($"[QuickScene] SceneLoaded failed: {arg}");
}
}
public void ApplyHarmony()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
try
{
new Harmony("QuickScene").PatchAll(Assembly.GetExecutingAssembly());
Log("[QuickScene] Harmony patched successfully!");
}
catch (Exception ex)
{
LogError("[QuickScene] Harmony patch failed: " + ex);
LogWarning("Please contact Geezt Jeez or try reloading the game for proper installation...");
}
}
public AssetBundle LoadBundle(string assetBundleName)
{
Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assetBundleName);
if (manifestResourceStream == null)
{
return null;
}
if (!manifestResourceStream.CanRead)
{
return null;
}
return AssetBundle.LoadFromStream(manifestResourceStream);
}
public void OnDestroy()
{
SceneManager.sceneLoaded -= SceneLoaded;
}
public static void LoadConfig()
{
InstantLoadEnabled = false;
DebugEnabled = false;
InstantLoadScene = "";
try
{
string[] array = File.ReadAllLines(ConfigFilePath);
foreach (string text in array)
{
if (string.IsNullOrWhiteSpace(text))
{
continue;
}
string[] array2 = text.Split(new char[1] { '=' }, 2);
if (array2.Length == 2)
{
string text2 = array2[0].Trim();
string text3 = array2[1].Trim();
switch (text2)
{
case "DebugEnabled":
bool.TryParse(text3, out DebugEnabled);
break;
case "InstantLoadScene":
InstantLoadScene = text3;
break;
case "InstantLoadEnabled":
bool.TryParse(text3, out InstantLoadEnabled);
break;
}
}
}
Log($"[QuickScene] InstantLoadEnabled={InstantLoadEnabled}");
Log($"[QuickScene] DebugEnabled={DebugEnabled}");
Log("[QuickScene] InstantLoadScene=" + InstantLoadScene);
}
catch (Exception arg)
{
LogError($"[QuickScene] Failed loading config:\n{arg}");
}
}
public static void LoadSceneOrMap(string sceneName)
{
Log("[QuickScene] Selected: " + sceneName);
try
{
MapAsset val = null;
try
{
val = ContentDatabase.Instance().GetAllMapAssetsOrdered().FirstOrDefault((Func<MapAsset, bool>)((MapAsset m) => (Object)(object)m != (Object)null && m.MapName == sceneName));
}
catch (Exception ex)
{
LogWarning("[QuickScene] Failed to search MapAssets");
Debug.LogException(ex);
}
if ((Object)(object)val != (Object)null)
{
GameModeService service = ServiceLocator.GetService<GameModeService>();
if ((Object)(object)service != (Object)null)
{
service.SetGameMode<SandboxGameMode>();
}
CampaignPlayerDataHolder.StartedPlayingSandbox();
Log("[QuickScene] Loading sandbox map: " + val.MapName);
TABSSceneManager.LoadMap(val, true);
}
else
{
Log("[QuickScene] Loading normal scene: " + sceneName);
TABSSceneManager.LoadScene(sceneName, false);
}
}
catch (Exception ex2)
{
LogError("[QuickScene] Failed to load:");
Debug.LogException(ex2);
}
}
public static void Log(string message)
{
if (DebugEnabled)
{
Debug.Log((object)("[QuickScene] " + message));
}
}
public static void LogWarning(string message)
{
if (DebugEnabled)
{
Debug.LogWarning((object)("[QuickScene] " + message));
}
}
public static void LogError(string message)
{
Debug.LogError((object)("[QuickScene] " + message));
}
}
public class SceneShortcut
{
public string SceneName;
public string DisplayName;
}
}