Decompiled source of RossButler v1.0.1

plugins/RossButler/XuXiaolan.RossButler.dll

Decompiled 5 months 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.Logging;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using On;
using RossButler.Patches;
using UnityEngine;
using XuXiaolan.RossButler.NetcodePatcher;

[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("XuXiaolan.RossButler")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("RossButler")]
[assembly: AssemblyTitle("XuXiaolan.RossButler")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 RossButler
{
	[BepInPlugin("XuXiaolan.RossButler", "RossButler", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			InitializeNetworkBehaviours();
			string path = "rossbutlerassets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("RossObj");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("RossTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("RossTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			EnemyType val4 = ModAssets.LoadAsset<EnemyType>("RossFartsObj");
			TerminalNode val5 = ModAssets.LoadAsset<TerminalNode>("RossFartsTN");
			TerminalKeyword val6 = ModAssets.LoadAsset<TerminalKeyword>("RossFartsTK");
			NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab);
			Item val7 = ModAssets.LoadAsset<Item>("RossKnifeObj");
			Utilities.FixMixerGroups(val7.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val7.spawnPrefab);
			Items.RegisterItem(val7);
			Enemies.RegisterEnemy(val4, 0, (LevelTypes)(-1), val5, val6);
			Enemies.RegisterEnemy(val, 0, (LevelTypes)(-1), val2, val3);
			RossPatches.Init();
			Logger.LogInfo((object)"Plugin XuXiaolan.RossButler is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			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);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "XuXiaolan.RossButler";

		public const string PLUGIN_NAME = "RossButler";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace RossButler.Patches
{
	public static class RossPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__StartOfRound_Start;
		}

		public static bool butlerFound;

		public static int butlerRarity;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__StartOfRound_Start;
			if (obj == null)
			{
				hook_Start val = StartOfRound_Start;
				<>O.<0>__StartOfRound_Start = val;
				obj = (object)val;
			}
			StartOfRound.Start += (hook_Start)obj;
		}

		private static void StartOfRound_Start(orig_Start orig, StartOfRound self)
		{
			orig.Invoke(self);
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if ((Object)(object)val != (Object)null)
				{
					foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
					{
						if (enemy.enemyType.enemyName == "Butler")
						{
							butlerFound = true;
							butlerRarity = enemy.rarity;
							enemy.rarity = 0;
						}
					}
					if (butlerFound)
					{
						foreach (SpawnableEnemyWithRarity enemy2 in val.Enemies)
						{
							if (enemy2.enemyType.enemyName == "YourPalButler")
							{
								enemy2.rarity = butlerRarity;
								Plugin.Logger.LogInfo((object)("Found a butler, replacing with the following values: " + butlerRarity));
							}
						}
					}
				}
				butlerFound = false;
				butlerRarity = 0;
			}
		}
	}
}
namespace XuXiaolan.RossButler.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}