Decompiled source of EqualInteriors v1.0.0

BepInEx/plugins/EqualInteriors/EqualInteriors.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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("EqualInteriors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EqualInteriors")]
[assembly: AssemblyTitle("EqualInteriors")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 EqualInteriors
{
	[BepInPlugin("TheFixer.EqualInteriors", "EqualInteriors", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> AllowEverywhere;

		internal static ConfigEntry<string> Excluded;

		private void Awake()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			AllowEverywhere = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowAllInteriorsOnEveryMoon", false, "false: each moon only uses the interiors its mods allow for it (all at equal odds).\ntrue: every installed interior can appear on every moon. Some interiors are built for specific moons and may look or play oddly elsewhere.");
			Excluded = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ExcludedInteriors", "", "Comma-separated interior names that should never be picked, e.g. \"Mineshaft, Haunted Mansion\". The names are printed in the log on every landing.");
			new Harmony("TheFixer.EqualInteriors").PatchAll(typeof(Plugin).Assembly);
		}
	}
	[HarmonyPatch(typeof(DungeonManager), "GetValidExtendedDungeonFlows")]
	internal static class EqualWeightsPatch
	{
		private const int Weight = 100;

		[HarmonyPostfix]
		private static void Postfix(ExtendedLevel extendedLevel, bool debugResults, ref List<ExtendedDungeonFlowWithRarity> __result)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			if (Plugin.AllowEverywhere.Value)
			{
				foreach (ExtendedDungeonFlow flow in PatchedContent.ExtendedDungeonFlows)
				{
					if (!__result.Any((ExtendedDungeonFlowWithRarity r) => (Object)(object)r.extendedDungeonFlow == (Object)(object)flow))
					{
						__result.Add(new ExtendedDungeonFlowWithRarity(flow, 100));
					}
				}
			}
			HashSet<string> excluded = new HashSet<string>(from s in Plugin.Excluded.Value.Split(',')
				select s.Trim() into s
				where s.Length > 0
				select s, StringComparer.OrdinalIgnoreCase);
			List<ExtendedDungeonFlowWithRarity> list = __result.Where((ExtendedDungeonFlowWithRarity r) => !excluded.Contains(r.extendedDungeonFlow.DungeonName)).ToList();
			if (list.Count > 0)
			{
				__result = list;
			}
			foreach (ExtendedDungeonFlowWithRarity item in __result)
			{
				item.rarity = 100;
			}
			if (debugResults)
			{
				string arg = (((Object)(object)extendedLevel != (Object)null) ? extendedLevel.NumberlessPlanetName : "?");
				Plugin.Log.LogInfo((object)($"{arg}: {__result.Count} interiors at equal odds ({100f / (float)__result.Count:0.#}% each): " + string.Join(", ", __result.Select((ExtendedDungeonFlowWithRarity r) => r.extendedDungeonFlow.DungeonName))));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TheFixer.EqualInteriors";

		public const string PLUGIN_NAME = "EqualInteriors";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}