Decompiled source of Act1BossExhibitReplacer v1.0.1

Act1BossExhibitReplacer.dll

Decompiled a day 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 System.Security;
using System.Security.Permissions;
using AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.Base.Extensions;
using LBoL.Core;
using LBoL.Core.Stations;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Resource;
using UnityEngine;

[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: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("Act1BossExhibitReplacer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c95dbbe66067a037ca0840575409d8620cf93dd3")]
[assembly: AssemblyProduct("Act1BossExhibitReplacer")]
[assembly: AssemblyTitle("Act1BossExhibitReplacer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Act1BossExhibitReplacer
{
	[BepInPlugin("cramps-act1exhibitreplacer", "Act1BossExhibitReplacer", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		internal static TemplateSequenceTable sequenceTable = new TemplateSequenceTable(0);

		internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());

		internal static DirectorySource directorySource = new DirectorySource("cramps-act1exhibitreplacer", "");

		public static ConfigEntry<bool> replaceLeftExhibit;

		public static ConfigEntry<bool> replaceBottomExhibit;

		public static ConfigEntry<bool> replaceBossExhibit;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			replaceLeftExhibit = ((BaseUnityPlugin)this).Config.Bind<bool>("ReplaceExhibits", "ReplaceLeftExhibit", false, "Replace the left exhibit for act1 boss reward, with a random modded exhibit");
			replaceBottomExhibit = ((BaseUnityPlugin)this).Config.Bind<bool>("ReplaceExhibits", "ReplaceBottomExhibit", false, "Replace the bottom exhibit for act1 boss reward, with a random modded exhibit");
			replaceBossExhibit = ((BaseUnityPlugin)this).Config.Bind<bool>("ReplaceExhibits", "ReplaceBossExhibit", true, "Replace the boss exhibit for act1 boss reward, with a random modded exhibit");
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			EntityManager.RegisterSelf();
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class PInfo
	{
		public const string GUID = "cramps-act1exhibitreplacer";

		public const string Name = "Act1BossExhibitReplacer";

		public const string version = "1.0.1";

		public static readonly Harmony harmony = new Harmony("cramps-act1exhibitreplacer");
	}
	[HarmonyPatch]
	internal class Act1ExhibitReplacer
	{
		private static readonly string[] ownerToIgnore = new string[5] { "Reimu", "Marisa", "Sakuya", "Cirno", "Koishi" };

		[HarmonyPatch(typeof(BossStation), "GenerateBossRewards")]
		private static void Postfix(BossStation __instance)
		{
			if (((Station)__instance).Stage.Level != 1)
			{
				return;
			}
			List<Exhibit> list = new List<Exhibit>();
			foreach (Type item in ((Station)__instance).GameRun.ShiningExhibitPool)
			{
				Exhibit val = Library.CreateExhibit(item);
				if (!ownerToIgnore.Contains(val.OwnerId) && val.OwnerId != null)
				{
					list.Add(val);
				}
			}
			Exhibit[] bossRewards = __instance.BossRewards;
			if (BepinexPlugin.replaceBossExhibit.Value && CollectionsExtensions.NotEmpty<Exhibit>((IReadOnlyCollection<Exhibit>)list))
			{
				bossRewards[1] = CollectionsExtensions.Sample<Exhibit>((IEnumerable<Exhibit>)list, ((Station)__instance).GameRun.ExhibitRng);
				list.Remove(bossRewards[1]);
			}
			if (BepinexPlugin.replaceLeftExhibit.Value && CollectionsExtensions.NotEmpty<Exhibit>((IReadOnlyCollection<Exhibit>)list))
			{
				bossRewards[0] = CollectionsExtensions.Sample<Exhibit>((IEnumerable<Exhibit>)list, ((Station)__instance).GameRun.ExhibitRng);
				list.Remove(bossRewards[0]);
			}
			if (BepinexPlugin.replaceBottomExhibit.Value && CollectionsExtensions.NotEmpty<Exhibit>((IReadOnlyCollection<Exhibit>)list))
			{
				bossRewards[2] = CollectionsExtensions.Sample<Exhibit>((IEnumerable<Exhibit>)list, ((Station)__instance).GameRun.ExhibitRng);
				list.Remove(bossRewards[2]);
			}
			__instance.BossRewards = bossRewards;
		}
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}