Decompiled source of Gordion Sect0 v2.1.4

Sector0Flow.dll

Decompiled 2 months ago
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 DunGen.Graph;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sector0Flow")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("The lost remnants of an forgotton sector of Gordion.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("Sector0Flow")]
[assembly: AssemblyTitle("Sector0Flow")]
[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 Sector0Flow
{
	public static class ModInfo
	{
		public const string modGUID = "Sector0Flow";

		public const string modName = "Sector0Flow";

		public const string modVersion = "1.0.0";
	}
	[BepInPlugin("Sector0Flow", "Sector0Flow", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SectorDunGen : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Sector0Flow");

		public static SectorDunGen Instance;

		public ManualLogSource mls;

		public static AssetBundle Sector0Assets;

		private ConfigEntry<int> configSectorRarity;

		private ConfigEntry<string> configMoons;

		private ConfigEntry<int> configLengthOverride;

		private void Awake()
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Expected O, but got Unknown
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Expected O, but got Unknown
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			mls = Logger.CreateLogSource("Sector0Flow");
			Sector0Assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sector0flow"));
			if ((Object)(object)Sector0Assets == (Object)null)
			{
				mls.LogError((object)"Failed to load Sector0Flow assets.");
				return;
			}
			DungeonFlow val = Sector0Assets.LoadAsset<DungeonFlow>("Assets/LethalCompany/Mods/RosiesMoons/Interior/SectorFlow.asset");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load Sector0Flow.");
				return;
			}
			configSectorRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SectorRarity", 300, new ConfigDescription("How rare it is for Sector0Flow to be chosen. Higher values increases the chance of spawning the dungeon. Vanillas' main dungeons use a value of 300. Google Weighted Random if you don't know how it works, as that's how Lethal Company rarities function.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SectorMoonsList", "Sector@450", new ConfigDescription("The moon(s) that Sector0Flow can spawn on, in the form of a comma separated list of selectable level names and optionally a weight value by using an '@' and weight value after it (e.g. \"Titan@300,Dine,Rend@10,Sector@450\")\nThe name matching is lenient and should pick it up if you use the terminal name or internal mod name. If no rarity is specified, the SectorRarity parameter is used.\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\n", (AcceptableValueBase)null, Array.Empty<object>()));
			configLengthOverride = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SectorLengthOverride", -1, new ConfigDescription(string.Format("If not -1, overrides Sector0Flow length to whatever you'd like. Adjusts how long/large the dungeon generates.\nBe *EXTREMELY* careful not to set this too high (anything too big on a moon with a high dungeon size multipier can cause catastrophic problems, like crashing your computer or worse)\nFor reference, the default value for the current version [{0}] is {1}. If it's too big, make this lower e.g. 6, if it's too small use something like 10 (or higher, but don't go too crazy with it).", "1.0.0", val.Length.Min), (AcceptableValueBase)null, Array.Empty<object>()));
			if (configLengthOverride.Value != -1)
			{
				mls.LogInfo((object)$"Sector0Flow length override has been set to {configLengthOverride.Value}. Be careful with this value.");
				val.Length.Min = configLengthOverride.Value;
				val.Length.Max = configLengthOverride.Value;
			}
			ExtendedDungeonFlow val2 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val2.contentSourceName = "Sector0Flow";
			val2.dungeonFlow = val;
			val2.dungeonDefaultRarity = 0;
			int value = configSectorRarity.Value;
			switch (configMoons.Value.ToLower())
			{
			case "all":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", value));
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", value));
				mls.LogInfo((object)"Registered Sector0Flow for all moons.");
				break;
			case "vanilla":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", value));
				mls.LogInfo((object)"Registered Sector0Flow for all vanilla moons.");
				break;
			case "modded":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", value));
				mls.LogInfo((object)"Registered Sector0Flow for all modded moons.");
				break;
			case "paid":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), value));
				mls.LogInfo((object)"Registered Sector0Flow for all paid moons.");
				break;
			case "free":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), value));
				mls.LogInfo((object)"Registered Sector0Flow for all free moons.");
				break;
			default:
			{
				mls.LogInfo((object)"Registering Sector0Flow for predefined moon list.");
				string[] array = configMoons.Value.Split(',', StringSplitOptions.RemoveEmptyEntries);
				List<StringWithRarity> list = new List<StringWithRarity>();
				for (int k = 0; k < array.Length; k++)
				{
					string[] array2 = array[k].Split('@', StringSplitOptions.RemoveEmptyEntries);
					int num = array2.Length;
					int result;
					if (num > 2)
					{
						mls.LogError((object)("Invalid setup for moon rarity config: " + array[k] + ". Skipping."));
					}
					else if (num == 1)
					{
						mls.LogInfo((object)$"Registering Sector0Flow for moon {array[k]} at default rarity {value}");
						list.Add(new StringWithRarity(array[k], value));
					}
					else if (!int.TryParse(array2[1], out result))
					{
						mls.LogError((object)("Failed to parse rarity value for moon " + array2[0] + ": " + array2[1] + ". Skipping."));
					}
					else
					{
						mls.LogInfo((object)$"Registering Sector0Flow for moon {array[k]} at default rarity {value}");
						list.Add(new StringWithRarity(array2[0], result));
					}
				}
				val2.manualPlanetNameReferenceList = list;
				break;
			}
			}
			val2.dungeonSizeMin = 1f;
			val2.dungeonSizeMax = 1.75f;
			val2.dungeonSizeLerpPercentage = 0f;
			PatchedContent.RegisterExtendedDungeonFlow(val2);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Sector0Flow is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Sector0Flow";

		public const string PLUGIN_NAME = "Sector0Flow";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}