Decompiled source of SleepsDungeon v1.1.4

plugins/SleepsSchool/SleepsSchoolDungeon.dll

Decompiled 3 months ago
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.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using LethalLevelLoaderTest.GamePatch;
using LethalLib.Modules;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalLevelLoaderTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalLevelLoaderTest")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("04276201-78da-488a-9fcb-6414e5eadc05")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalLevelLoaderTest
{
	public static class Assets
	{
		public static AssetBundle MainAssetBundle = null;

		public static ExtendedDungeonFlow dungeon;

		public static Item[] items;

		public static List<ExtendedDungeonMapLoad.CustomMoonEntry> customMoonEntryList;

		public static void LoadAssetBundle()
		{
			string location = Assembly.GetExecutingAssembly().Location;
			string directoryName = Path.GetDirectoryName(location);
			string[] files = Directory.GetFiles(directoryName, "*.lb", SearchOption.AllDirectories);
			foreach (string file in files)
			{
				LoadBundle(file);
			}
		}

		public static void LoadBundle(string file)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			Plugin.logger.LogInfo((object)file);
			FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read);
			AssetBundle val = AssetBundle.LoadFromStream((Stream)fileStream);
			if ((Object)(object)val != (Object)null)
			{
				Plugin.logger.LogInfo((object)"Loaded bundle");
				Plugin.logger.LogInfo((object)"Trying to find an extended dungeon flow");
				string[] allAssetNames = val.GetAllAssetNames();
				string[] array = allAssetNames;
				foreach (string text in array)
				{
					Plugin.logger.LogInfo((object)("Found asset " + text));
				}
				DungeonFlow[] source = val.LoadAllAssets<DungeonFlow>();
				DungeonFlow val2 = source.FirstOrDefault();
				Item[] array2 = val.LoadAllAssets<Item>();
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.logger.LogError((object)"Could not find a dungeon flow in the bundle");
				}
				MainAssetBundle = val;
				dungeon = new ExtendedDungeonFlow();
				dungeon.dungeonFlow = val2;
				items = array2;
				Item[] array3 = items;
				foreach (Item val3 in array3)
				{
					Plugin.logger.LogInfo((object)("Adding " + val3.itemName));
					Items.RegisterScrap(val3, 0, (LevelTypes)1);
					NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
				}
			}
		}
	}
	public class ExtendedDungeonMapLoad
	{
		public abstract class CustomMoonEntry
		{
			public virtual void Add(ExtendedDungeonFlow flow)
			{
				Plugin.logger.LogInfo((object)("Added " + ToString()));
			}

			public virtual void Remove(ExtendedDungeonFlow flow)
			{
				Plugin.logger.LogInfo((object)("Removed " + ToString()));
			}

			public abstract void SetRarity(int rarity);
		}

		public class ManualContentSourceNameReference : CustomMoonEntry
		{
			public StringWithRarity value;

			public ManualContentSourceNameReference(string title, int rarity)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				value = new StringWithRarity(title, rarity);
			}

			public override void Add(ExtendedDungeonFlow flow)
			{
				base.Add(flow);
				flow.manualContentSourceNameReferenceList.Add(value);
			}

			public override void Remove(ExtendedDungeonFlow flow)
			{
				if (flow.manualContentSourceNameReferenceList.Remove(value))
				{
					base.Remove(flow);
				}
				else
				{
					Plugin.logger.LogInfo((object)("Tried to remove " + ToString() + " but it's already gone"));
				}
			}

			public override void SetRarity(int rarity)
			{
				value.Rarity = rarity;
			}

			public override string ToString()
			{
				return $"ManualContentSourceNameReference: ({value.Name}, {value.Rarity})";
			}
		}

		public class DynamicLevelTags : CustomMoonEntry
		{
			public StringWithRarity value;

			public DynamicLevelTags(string title, int rarity)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				value = new StringWithRarity(title, rarity);
			}

			public override void Add(ExtendedDungeonFlow flow)
			{
				base.Add(flow);
				flow.dynamicLevelTagsList.Add(value);
			}

			public override void Remove(ExtendedDungeonFlow flow)
			{
				if (flow.dynamicLevelTagsList.Remove(value))
				{
					base.Remove(flow);
				}
				else
				{
					Plugin.logger.LogInfo((object)("Tried to remove " + ToString() + " but it's already gone"));
				}
			}

			public override void SetRarity(int rarity)
			{
				value.Rarity = rarity;
			}

			public override string ToString()
			{
				return $"DynamicLevelTags: ({value.Name}, {value.Rarity})";
			}
		}

		public class ManualPlanetNameReference : CustomMoonEntry
		{
			public StringWithRarity value;

			public ManualPlanetNameReference(string title, int rarity)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				value = new StringWithRarity(title, rarity);
			}

			public override void Add(ExtendedDungeonFlow flow)
			{
				base.Add(flow);
				flow.manualPlanetNameReferenceList.Add(value);
			}

			public override void Remove(ExtendedDungeonFlow flow)
			{
				if (flow.manualPlanetNameReferenceList.Remove(value))
				{
					base.Remove(flow);
				}
				else
				{
					Plugin.logger.LogInfo((object)("Tried to remove " + ToString() + " but it's already gone"));
				}
			}

			public override void SetRarity(int rarity)
			{
				value.Rarity = rarity;
			}

			public override string ToString()
			{
				return $"ManualPlanetNameReference: ({value.Name}, {value.Rarity})";
			}
		}

		public class DynamicRoutePrices : CustomMoonEntry
		{
			public Vector2WithRarity value;

			public DynamicRoutePrices(Vector2 price, int rarity)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				value = new Vector2WithRarity(price, rarity);
			}

			public override void Add(ExtendedDungeonFlow flow)
			{
				base.Add(flow);
				flow.dynamicRoutePricesList.Add(value);
			}

			public override void Remove(ExtendedDungeonFlow flow)
			{
				if (flow.dynamicRoutePricesList.Remove(value))
				{
					base.Remove(flow);
				}
				else
				{
					Plugin.logger.LogInfo((object)("Tried to remove " + ToString() + " but it's already gone"));
				}
			}

			public override void SetRarity(int rarity)
			{
				value.Rarity = rarity;
			}

			public override string ToString()
			{
				return $"DynamicRoutePrices: ([{value.Min}, {value.Max}], {value.Rarity})";
			}
		}

		public static List<CustomMoonEntry> GetCustomMoons(string value, int rarity)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			List<CustomMoonEntry> list = new List<CustomMoonEntry>();
			string text = value.ToLowerInvariant();
			switch (text)
			{
			case "all":
				list.Add(new DynamicLevelTags("Vanilla", rarity));
				list.Add(new DynamicLevelTags("Custom", rarity));
				Plugin.logger.LogInfo((object)"Loading SDM for all moons");
				break;
			case "vanilla":
				list.Add(new DynamicLevelTags("Vanilla", rarity));
				Plugin.logger.LogInfo((object)"Loading SDM for all vanilla moons");
				break;
			case "modded":
				list.Add(new DynamicLevelTags("Custom", rarity));
				Plugin.logger.LogInfo((object)"Loading SDM for all modded moons");
				break;
			case "paid":
				list.Add(new DynamicRoutePrices(new Vector2(1f, 9999f), rarity));
				Plugin.logger.LogInfo((object)"Loading SDM for all paid moons");
				break;
			case "free":
				list.Add(new DynamicRoutePrices(new Vector2(0f, 9999f), rarity));
				Plugin.logger.LogInfo((object)"Loading SDM for all free moons");
				break;
			default:
			{
				Plugin.logger.LogInfo((object)"Loading SDM with predefined moon list");
				string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				string[] array2 = array;
				foreach (string text2 in array2)
				{
					string[] array3 = text2.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries);
					int num = array3.Length;
					if (num > 2)
					{
						Plugin.logger.LogError((object)("Invalid setup for moon rarity config: " + text2 + ". Skipping"));
						continue;
					}
					if (num == 1)
					{
						Plugin.logger.LogInfo((object)$"Loading SDM for moon {text2} at default rarity of {rarity}");
						list.Add(new ManualPlanetNameReference(text2, rarity));
						continue;
					}
					string text3 = array3[0];
					string text4 = array3[1];
					if (int.TryParse(text4, out var result))
					{
						Plugin.logger.LogInfo((object)$"Loading SDM for moon {text3} at rarity of {result}");
						list.Add(new ManualPlanetNameReference(text3, result));
						continue;
					}
					Plugin.logger.LogError((object)("Failed to parse rarity value for moon " + text3 + " rarity " + text4 + ". Skipping"));
				}
				break;
			}
			}
			return list;
		}

		public static void ClearLastCustomMoonEntryList()
		{
			Plugin.logger.LogInfo((object)"Clearing previous custom dungeon load");
			ExtendedDungeonFlow dungeon = Assets.dungeon;
			List<CustomMoonEntry> customMoonEntryList = Assets.customMoonEntryList;
			if (customMoonEntryList != null)
			{
				foreach (CustomMoonEntry item in customMoonEntryList)
				{
					item.Remove(dungeon);
				}
			}
			Assets.customMoonEntryList = null;
		}

		public static void AddToExtendedDungeonFlow(List<CustomMoonEntry> list)
		{
			ExtendedDungeonFlow dungeon = Assets.dungeon;
			foreach (CustomMoonEntry item in list)
			{
				item.Add(dungeon);
			}
			Assets.customMoonEntryList = list;
		}
	}
	[BepInPlugin("MusicalSleep.SleepsSchoolDungeon", "Sleeps School Dungeon", "1.0.0")]
	[BepInDependency("imabatby.lethallevelloader", "1.0.3")]
	[BepInDependency("evaisa.lethallib", "0.13.2")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "MusicalSleep.SleepsSchoolDungeon";

		private const string modName = "Sleeps School Dungeon";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("MusicalSleep.SleepsSchoolDungeon");

		internal static ManualLogSource logger;

		public static Plugin Instance { get; private set; }

		public static PluginConfig MyConfig { get; internal set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("MusicalSleep.SleepsSchoolDungeon");
			logger.LogInfo((object)"Plugin Sleeps School Dungeon has been added!");
			MyConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			harmony.PatchAll(typeof(InitPatch));
			harmony.PatchAll(typeof(PluginConfig));
			SetupForNetcodePatcher();
			Assets.LoadAssetBundle();
			if (Object.op_Implicit((Object)(object)Assets.dungeon))
			{
				AssetBundleLoader.RegisterExtendedDungeonFlow(Assets.dungeon);
			}
		}

		private void SetupForNetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[Serializable]
	public class PluginConfig : SyncedInstance<PluginConfig>
	{
		public class ConfigEntryBundle<T>
		{
			public ConfigEntry<T> config;

			public ConfigDefinition definition;

			public T defaultValue;

			public ConfigDescription description;

			public ConfigDefinition[] oldDefinitions;

			public ConfigEntryBundle(string section, string key, T dvalue, string desc, AcceptableValueBase valuebase = null, params ConfigDefinition[] oldDef)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				definition = new ConfigDefinition(section, key);
				defaultValue = dvalue;
				description = new ConfigDescription(desc, valuebase, Array.Empty<object>());
				oldDefinitions = oldDef;
			}

			public T Bind(ConfigFile cfg)
			{
				config = cfg.Bind<T>(definition, defaultValue, description);
				return config.Value;
			}
		}

		public const string modPrefix = "LLLTest";

		public static readonly string requestMessage = "LLLTest_OnRequestConfigSync";

		public static readonly string receiveMessage = "LLLTest_OnReceieveConfigSync";

		public const string dungeonWeightPrefix = "Dungeon Weight";

		public static ConfigEntryBundle<string> customMaps = new ConfigEntryBundle<string>("Dungeon Weight", "Custom Moons", "all", "The moon(s) that SDM 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,CUSTOM_MOON_NAME@9999\")\nUsing this config WILL override the default weights used above.\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 default weight below 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", null);

		public static ConfigEntryBundle<int> customMapDefaultWeight = new ConfigEntryBundle<int>("Dungeon Weight", "Custom Moons Weight", 450, "The default weight of the dungeon appearing for custom moons. A higher weight means a higher chance.\n300 = 50% chance, 99999 = 99.99% chance", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 99999));

		public string customMapsValue;

		public int customMapDefaultWeightValue;

		public PluginConfig(ConfigFile cfg)
		{
			InitInstance(this);
			customMapsValue = customMaps.Bind(cfg);
			customMapDefaultWeightValue = customMapDefaultWeight.Bind(cfg);
		}

		public static void RequestSync()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<PluginConfig>.IsClient)
			{
				return;
			}
			FastBufferWriter stream = default(FastBufferWriter);
			((FastBufferWriter)(ref stream))..ctor(SyncedInstance<PluginConfig>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<PluginConfig>.SendMessage(stream, requestMessage, 0uL);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref stream)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<PluginConfig>.IsHost)
			{
				return;
			}
			SyncedInstance<PluginConfig>.logger.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<PluginConfig>.SerializeToBytes(SyncedInstance<PluginConfig>.Instance);
			int num = array.Length;
			FastBufferWriter stream = default(FastBufferWriter);
			((FastBufferWriter)(ref stream))..ctor(num + SyncedInstance<PluginConfig>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref stream)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref stream)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<PluginConfig>.SendMessage(stream, receiveMessage, clientId);
			}
			catch (Exception arg)
			{
				SyncedInstance<PluginConfig>.logger.LogError((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref stream)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<PluginConfig>.IntSize))
			{
				SyncedInstance<PluginConfig>.logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				SyncedInstance<PluginConfig>.logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<PluginConfig>.SyncInstance(data);
			SyncedInstance<PluginConfig>.logger.LogInfo((object)"Successfully synced config with host.");
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void InitializeLocalPlayer()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			if (SyncedInstance<PluginConfig>.IsHost)
			{
				SyncedInstance<PluginConfig>.MessageManager.RegisterNamedMessageHandler(requestMessage, new HandleNamedMessageDelegate(OnRequestSync));
				SyncedInstance<PluginConfig>.Synced = true;
			}
			else
			{
				SyncedInstance<PluginConfig>.Synced = false;
				SyncedInstance<PluginConfig>.MessageManager.RegisterNamedMessageHandler(receiveMessage, new HandleNamedMessageDelegate(OnReceiveSync));
				RequestSync();
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		[HarmonyPostfix]
		public static void PlayerLeave()
		{
			SyncedInstance<PluginConfig>.RevertSync();
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		internal static ManualLogSource logger => Plugin.logger;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}

		public static void SendMessage(FastBufferWriter stream, string title, ulong clientId = 0uL)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ((FastBufferWriter)(ref stream)).Capacity > 1300;
			NetworkDelivery val = (NetworkDelivery)(flag ? 4 : 2);
			if (flag)
			{
				logger.LogInfo((object)"Stream is past capacity. Sending fragmented message");
			}
			MessageManager.SendNamedMessage(title, clientId, stream, val);
			Plugin.logger.LogInfo((object)$"Send message to client {clientId} with title {title} and flag {val}");
		}
	}
	public class MyOwnCoroutine : MonoBehaviour
	{
		private static MyOwnCoroutine _Instance;

		public static MyOwnCoroutine Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)_Instance == (Object)null)
				{
					GameObject val = new GameObject("My Own Coroutine");
					_Instance = val.AddComponent<MyOwnCoroutine>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				return _Instance;
			}
		}

		public static Coroutine AddCoroutine(IEnumerator c)
		{
			return ((MonoBehaviour)Instance).StartCoroutine(c);
		}
	}
}
namespace LethalLevelLoaderTest.GamePatch
{
	public class InitPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPrefix]
		public static void StartOfRound_Start(ref StartOfRound __instance)
		{
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		public static void RoundManagerStartPatch(ref RoundManager __instance)
		{
			MyOwnCoroutine.AddCoroutine(UpdateNetworkConfig(__instance));
		}

		private static IEnumerator UpdateNetworkConfig(RoundManager roundManager)
		{
			while (!SyncedInstance<PluginConfig>.Synced)
			{
				yield return null;
			}
			List<ExtendedDungeonMapLoad.CustomMoonEntry> list = ExtendedDungeonMapLoad.GetCustomMoons(SyncedInstance<PluginConfig>.Instance.customMapsValue, SyncedInstance<PluginConfig>.Instance.customMapDefaultWeightValue);
			ExtendedDungeonMapLoad.ClearLastCustomMoonEntryList();
			Plugin.logger.LogInfo((object)"Loading with custom moon list");
			ExtendedDungeonMapLoad.AddToExtendedDungeonFlow(list);
			Plugin.logger.LogInfo((object)"Set networked config values");
		}
	}
}