Decompiled source of ExtraEndless v0.1.1

plugins/WK_Extra_Endless.dll

Decompiled 2 months ago
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using WK_Extra_Endless.Core;

[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("WK_Extra_Endless")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+727e94a82ade1f2ea71d0c2a41837bb821131287")]
[assembly: AssemblyProduct("WK_Extra_Endless")]
[assembly: AssemblyTitle("WK_Extra_Endless")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 WK_Extra_Endless
{
	[BepInPlugin("WK_Extra_Endless", "WK_Extra_Endless", "0.1.0")]
	public class ExtraEndless : BaseUnityPlugin
	{
		private bool _patched;

		private static Harmony _harmony;

		public static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if (_patched)
			{
				Logger.LogWarning((object)"Already Patched");
			}
			Logger = ((BaseUnityPlugin)this).Logger;
			if (Assets.Load())
			{
				_harmony = new Harmony("WK_Extra_Endless");
				_harmony.PatchAll(Assembly.GetExecutingAssembly());
				SceneManager.sceneLoaded += UI.OnSceneLoad;
				Logger.LogInfo((object)"Plugin WK_Extra_Endless is loaded!");
				_patched = true;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WK_Extra_Endless";

		public const string PLUGIN_NAME = "WK_Extra_Endless";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace WK_Extra_Endless.Core
{
	public class Assets
	{
		private static AssetBundle _assets;

		internal static GameObject ExtraEndlessObj;

		internal static List<ScriptableObject> ExtraEndlessScriptables = new List<ScriptableObject>();

		internal static bool Load()
		{
			_assets = AssetBundle.LoadFromFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Assets/extra_endless_assets");
			if (!Object.op_Implicit((Object)(object)_assets))
			{
				ExtraEndless.Logger.LogError((object)"Failed to load AssetBundle, aborting!");
				return false;
			}
			List<bool> source = new List<bool>(1) { LoadFile<GameObject>(_assets, "Assets/Neb.Assets/Extra Endless/Extra Endless.prefab", out ExtraEndlessObj) };
			ScriptableObject[] collection = _assets.LoadAllAssets<ScriptableObject>();
			ExtraEndlessScriptables.AddRange(collection);
			ExtraEndless.Logger.LogInfo((object)$"Loaded {ExtraEndlessScriptables.Count} ScriptableObjects from asset bundle.");
			if (source.Any((bool result) => !result) || ExtraEndlessScriptables == null)
			{
				ExtraEndless.Logger.LogWarning((object)"Failed to load one or more assets, aborting!");
				return false;
			}
			return true;
		}

		private static bool LoadFile<T>(AssetBundle assets, string path, out T loadedObject) where T : Object
		{
			loadedObject = assets.LoadAsset<T>(path);
			if (!Object.op_Implicit((Object)(object)loadedObject))
			{
				ExtraEndless.Logger.LogError((object)("Failed to load '" + path + "'"));
				return false;
			}
			return true;
		}
	}
	public class Gamemode
	{
		private static GameObject World_Root;

		private static GameObject Denizen_Death_Floor;

		internal static M_Gamemode GM_Endless_Service_Shaft;

		internal static M_Gamemode GM_Endless_Delta_Labs;

		internal static M_Gamemode GM_Endless_Lost_Pier;

		private static M_Region Region_Habitation_Breakroom;

		private static M_Region Region_Service_Shaft_Endless;

		private static M_Region Region_Delta_Labs_Endless;

		private static M_Region Region_Lost_Pier_Endless;

		private static M_Subregion Subregion_Habitation_Endless_Breakroom;

		private static M_Subregion Subregion_Service_Shaft_Endless_Entry;

		private static M_Subregion Subregion_Service_Shaft_Endless;

		private static M_Subregion Subregion_Service_Shaft_Endless_Exit;

		private static M_Subregion Subregion_Delta_Labs_Endless;

		private static M_Subregion Subregion_Lost_Pier_Endless_Entry;

		private static M_Subregion Subregion_Lost_Pier_Endless;

		private static M_Subregion Subregion_Lost_Pier_Endless_Exit;

		internal static void GenerateGameModes()
		{
			ExtraEndless.Logger.LogInfo((object)"Generating Gamemodes");
			InitializeGameObjects();
			InitializeGameModeAssets();
			ConfigureRegions();
			ExtraEndless.Logger.LogInfo((object)"Generated Gamemodes");
		}

		private static void InitializeGameObjects()
		{
			World_Root = FindGameObject("World_Root");
			Denizen_Death_Floor = FindGameObject("Denizen_Death_Floor");
		}

		private static GameObject FindGameObject(string name)
		{
			return ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((GameObject obj) => ((Object)obj).name == name));
		}

		private static void InitializeGameModeAssets()
		{
			Region_Habitation_Breakroom = FindScriptableAsset<M_Region>("Region_Habitation_Breakroom");
			Subregion_Habitation_Endless_Breakroom = FindScriptableAsset<M_Subregion>("Subregion_Habitation_Endless_Breakroom");
			GM_Endless_Service_Shaft = FindScriptableAsset<M_Gamemode>("GM_Endless_Service_Shaft");
			Region_Service_Shaft_Endless = FindScriptableAsset<M_Region>("Region_Service_Shaft_Endless");
			Subregion_Service_Shaft_Endless_Entry = FindScriptableAsset<M_Subregion>("Subregion_Service_Shaft_Endless_Entry");
			Subregion_Service_Shaft_Endless = FindScriptableAsset<M_Subregion>("Subregion_Service_Shaft_Endless");
			Subregion_Service_Shaft_Endless_Exit = FindScriptableAsset<M_Subregion>("Subregion_Service_Shaft_Endless_Exit");
			GM_Endless_Delta_Labs = FindScriptableAsset<M_Gamemode>("GM_Endless_Delta_Labs");
			Region_Delta_Labs_Endless = FindScriptableAsset<M_Region>("Region_Delta_Labs_Endless");
			Subregion_Delta_Labs_Endless = FindScriptableAsset<M_Subregion>("Subregion_Delta_Labs_Endless");
			GM_Endless_Lost_Pier = FindScriptableAsset<M_Gamemode>("GM_Endless_Lost_Pier");
			Region_Lost_Pier_Endless = FindScriptableAsset<M_Region>("Region_Lost_Pier_Endless");
			Subregion_Lost_Pier_Endless_Entry = FindScriptableAsset<M_Subregion>("Subregion_Lost_Pier_Endless_Entry");
			Subregion_Lost_Pier_Endless = FindScriptableAsset<M_Subregion>("Subregion_Lost_Pier_Endless");
			Subregion_Lost_Pier_Endless_Exit = FindScriptableAsset<M_Subregion>("Subregion_Lost_Pier_Endless_Exit");
		}

		private static T FindScriptableAsset<T>(string name) where T : class
		{
			return ((IEnumerable<ScriptableObject>)Assets.ExtraEndlessScriptables).FirstOrDefault((Func<ScriptableObject, bool>)((ScriptableObject obj) => ((Object)obj).name == name)) as T;
		}

		private static void ConfigureRegions()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Expected O, but got Unknown
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Expected O, but got Unknown
			Region_Habitation_Breakroom.subregionGroups = new List<SubregionGroup>(1)
			{
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Habitation_Endless_Breakroom }
				}
			};
			M_Level item = FindLevel("M3_Habitation_Endless_Breakroom_01");
			Subregion_Habitation_Endless_Breakroom.levels = new List<M_Level>(1) { item };
			M_Level item2 = FindLevel("M3_Habitation_Endless_Start");
			Region_Service_Shaft_Endless.startLevels = new List<M_Level>(1) { item2 };
			M_Level item3 = FindLevel("M3_Habitation_Endless_Shaft_Start");
			Subregion_Service_Shaft_Endless_Entry.levels = new List<M_Level>(1) { item3 };
			List<M_Level> levels = FindLevels("M3_Habitation_Shaft_0");
			Subregion_Service_Shaft_Endless.levels = levels;
			M_Level item4 = FindLevel("M3_Habitation_Endless_Shaft_End");
			Subregion_Service_Shaft_Endless_Exit.levels = new List<M_Level>(1) { item4 };
			GM_Endless_Service_Shaft.gamemodeObjects = new List<GameObject>(2) { World_Root, Denizen_Death_Floor };
			GM_Endless_Service_Shaft.roachBankID = "endless";
			GM_Endless_Service_Shaft.regions = new List<M_Region>(2) { Region_Service_Shaft_Endless, Region_Habitation_Breakroom };
			Region_Service_Shaft_Endless.subregionGroups = new List<SubregionGroup>(3)
			{
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Service_Shaft_Endless_Entry }
				},
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Service_Shaft_Endless }
				},
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Service_Shaft_Endless_Exit }
				}
			};
			M_Level item5 = FindLevel("M3_Habitation_Lab_Lobby");
			Region_Delta_Labs_Endless.startLevels = new List<M_Level>(1) { item5 };
			List<M_Level> levels2 = FindLevels("M3_Habitation_Lab_0");
			Subregion_Delta_Labs_Endless.levels = levels2;
			GM_Endless_Delta_Labs.gamemodeObjects = new List<GameObject>(2) { World_Root, Denizen_Death_Floor };
			GM_Endless_Delta_Labs.roachBankID = "endless";
			GM_Endless_Delta_Labs.regions = new List<M_Region>(2) { Region_Delta_Labs_Endless, Region_Habitation_Breakroom };
			Region_Delta_Labs_Endless.subregionGroups = new List<SubregionGroup>(1)
			{
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Delta_Labs_Endless }
				}
			};
			Region_Lost_Pier_Endless.startLevels = new List<M_Level>(1) { item2 };
			M_Level item6 = FindLevel("M3_Delta_Pier_Intro");
			Subregion_Lost_Pier_Endless_Entry.levels = new List<M_Level>(1) { item6 };
			List<M_Level> levels3 = FindLevels("M3_Delta_Pier_0");
			Subregion_Lost_Pier_Endless.levels = levels3;
			M_Level item7 = FindLevel("M3_Delta_Pier_Outro");
			Subregion_Lost_Pier_Endless_Exit.levels = new List<M_Level>(1) { item7 };
			GM_Endless_Lost_Pier.gamemodeObjects = new List<GameObject>(2) { World_Root, Denizen_Death_Floor };
			GM_Endless_Lost_Pier.roachBankID = "endless";
			GM_Endless_Lost_Pier.regions = new List<M_Region>(2) { Region_Lost_Pier_Endless, Region_Habitation_Breakroom };
			Region_Lost_Pier_Endless.subregionGroups = new List<SubregionGroup>(3)
			{
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Lost_Pier_Endless_Entry }
				},
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Lost_Pier_Endless }
				},
				new SubregionGroup
				{
					subregions = new List<M_Subregion>(1) { Subregion_Lost_Pier_Endless_Exit }
				}
			};
		}

		private static M_Level FindLevel(string nameContains)
		{
			GameObject? obj = CL_AssetManager.instance.assetDatabase.levelPrefabs.Find((GameObject x) => ((Object)x).name.Contains(nameContains));
			return (obj != null) ? obj.GetComponent<M_Level>() : null;
		}

		private static List<M_Level> FindLevels(string nameContains)
		{
			return (from x in CL_AssetManager.instance.assetDatabase.levelPrefabs.FindAll((GameObject x) => ((Object)x).name.Contains(nameContains))
				select x.GetComponent<M_Level>()).ToList();
		}
	}
	public class UI
	{
		private static GameObject Ui;

		internal static void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			if (!(((Scene)(ref scene)).name != "Main-Menu"))
			{
				Gamemode.GenerateGameModes();
				Ui = Object.Instantiate<GameObject>(Assets.ExtraEndlessObj, GameObject.Find("Content").transform);
			}
		}
	}
}