Decompiled source of CleansingPoolReturns v1.0.0

plugins/CleansingPoolReturns/CleansingPoolReturns.dll

Decompiled 17 hours ago
using System;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CleansingPoolReturns.ModCompatability;
using HG;
using Microsoft.CodeAnalysis;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("CleansingPoolReturns")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CleansingPoolReturns")]
[assembly: AssemblyTitle("CleansingPoolReturns")]
[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;
		}
	}
}
public static class BuildInfo
{
	public const string TargetPath = "I:\\_important\\_hobby\\c#\\ror2mods\\CleansingPoolReturns\\CleansingPoolReturns\\bin\\Release\\netstandard2.1\\CleansingPoolReturns.dll";
}
namespace CleansingPoolReturns
{
	[BepInPlugin("disro.CleansingPoolReturns", "CleansingPoolReturns", "1.0.0")]
	public class CleansingPoolReturns : BaseUnityPlugin
	{
		public const string PluginGUID = "disro.CleansingPoolReturns";

		public const string PluginAuthor = "disro";

		public const string PluginName = "CleansingPoolReturns";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<int> CleanseShrineChanceCoefficient { get; set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			CleanseShrineChanceCoefficient = ((BaseUnityPlugin)this).Config.Bind<int>("Options", "cleanseShrineChanceCoefficient", 1, "Spawn chance multiplier for cleanse shrine (3 * cleanseShrineCoefficient)");
			if (RiskOfOptions.Enabled)
			{
				RiskOfOptions.InitConfig(CleanseShrineChanceCoefficient);
			}
			SceneDirector.onGenerateInteractableCardSelection += SceneDirector_onGenerateInteractableCardSelection;
		}

		private void SceneDirector_onGenerateInteractableCardSelection(SceneDirector sceneDirector, DirectorCardCategorySelection directorCardCategorySelection)
		{
			int num = directorCardCategorySelection.FindCategoryIndexByName("Shrines");
			if (num == -1)
			{
				return;
			}
			ref Category reference = ref directorCardCategorySelection.categories[num];
			bool flag = false;
			DirectorCard[] cards = reference.cards;
			foreach (DirectorCard val in cards)
			{
				if ((Object)(object)val.spawnCard != (Object)null && ((Object)val.spawnCard).name == "iscShrineCleanse")
				{
					flag = true;
				}
			}
			if (!flag)
			{
				AddCleansingPoolToCategory(ref reference);
			}
		}

		private void AddCleansingPoolToCategory(ref Category category)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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)
			//IL_0080: Expected O, but got Unknown
			InteractableSpawnCard val = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/ShrineCleanse/iscShrineCleanse.asset").WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Couldn't find cleanse shrine asset", "I:\\_important\\_hobby\\c#\\ror2mods\\CleansingPoolReturns\\CleansingPoolReturns\\CleansingPoolReturns.cs", 73);
				return;
			}
			DirectorCard[] cards = category.cards;
			foreach (DirectorCard val2 in cards)
			{
				if (val2 != null)
				{
					val2.selectionWeight *= 10;
				}
			}
			DirectorCard val3 = new DirectorCard
			{
				spawnCard = (SpawnCard)(object)val,
				selectionWeight = 3 * CleanseShrineChanceCoefficient.Value
			};
			ArrayUtils.ArrayAppend<DirectorCard>(ref category.cards, ref val3);
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
}
namespace CleansingPoolReturns.ModCompatability
{
	internal class RiskOfOptions
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void InitConfig(ConfigEntry<int> cleanseShrineChanceCoefficient)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(cleanseShrineChanceCoefficient));
		}
	}
}