Decompiled source of RandomBosses v1.0.0

BepInEx/plugins/RandomBosses/RandomBosses.dll

Decompiled 9 months 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 Atomicrops.Global;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RandomBosses;
using SharedLib;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: BuildDateTime("2024-02-19T14:17:46")]
[assembly: AssemblyCompany("RandomBosses")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9e5aa4c2025358bb98e77afb304d2a4e519622cf")]
[assembly: AssemblyProduct("RandomBosses")]
[assembly: AssemblyTitle("RandomBosses")]
[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 Template
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "RandomBosses";

		public const string PLUGIN_NAME = "RandomBosses";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace RandomBosses
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class BuildDateTimeAttribute : Attribute
	{
		public DateTime Built { get; }

		public BuildDateTimeAttribute(string date)
		{
			Built = DateTime.Parse(date);
		}
	}
	[HarmonyPatch(typeof(BossesManager), "GetBossDefForSeason", new Type[] { typeof(Season) })]
	internal class BossesManager_GetBossDefForSeason_Patch
	{
		private static List<BossDef> pool;

		private static bool Prefix()
		{
			return false;
		}

		private static void Postfix(ref BossDef __result, BossesManager __instance, Season season)
		{
			if (pool == null)
			{
				List<BossDef> spring = SingletonScriptableObject<ConfigGame>.I.Bosses.Spring;
				List<BossDef> summer = SingletonScriptableObject<ConfigGame>.I.Bosses.Summer;
				List<BossDef> fall = SingletonScriptableObject<ConfigGame>.I.Bosses.Fall;
				List<BossDef> winter = SingletonScriptableObject<ConfigGame>.I.Bosses.Winter;
				pool = spring.Union(summer).Union(fall).Union(winter)
					.ToList();
			}
			if (pool.Count == 0)
			{
				Debug.LogError((object)"No bosses found");
				__result = null;
				return;
			}
			Debug.Log((object)"Bosses in pool:");
			foreach (BossDef item in pool)
			{
				Debug.Log((object)$"--{item}");
			}
			int index = new Random().Next(pool.Count);
			Debug.Log((object)$"Random boss picked: {pool[index]}");
			__result = pool[index];
			pool.RemoveAt(index);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "fhghaha.plugin.RandomBosses";

		public const string PLUGIN_NAME = "RandomBosses";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("fhghaha.plugin.RandomBosses", "RandomBosses", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private void Awake()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogMessage((object)"---------------Plugin fhghaha.plugin.RandomBosses is loaded!---------------");
			((BaseUnityPlugin)this).Logger.LogMessage((object)$"---------------{GetBuildDateTime()}---------------");
			Harmony val = new Harmony("fhghaha.plugin.RandomBosses");
			val.PatchAll();
		}

		private static DateTime? GetBuildDateTime()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			return (Attribute.GetCustomAttribute(executingAssembly, typeof(BuildDateTimeAttribute)) is BuildDateTimeAttribute buildDateTimeAttribute) ? new DateTime?(buildDateTimeAttribute.Built) : null;
		}
	}
}