Decompiled source of ButlerSettings v1.0.1

ButlerSettings.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ButlerSettings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Simple config for the Butler's stats")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+b535514c17e8248ad0ebad6ae915b9294c41cc2c")]
[assembly: AssemblyProduct("ButlerSettings")]
[assembly: AssemblyTitle("ButlerSettings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 ButlerSettings
{
	[BepInPlugin("dopadream.lethalcompany.ButlerSettings", "Butler Settings", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch]
		private class ButlerSettingsPatches
		{
			[HarmonyPatch(typeof(ButlerEnemyAI), "Start")]
			[HarmonyPostfix]
			private static void ButlerStartPostFix(ButlerEnemyAI __instance)
			{
				((EnemyAI)__instance).enemyHP = configHealthMultiplayer.Value;
				if (StartOfRound.Instance.connectedPlayersAmount == 0)
				{
					((EnemyAI)__instance).enemyHP = configHealthSingleplayer.Value;
				}
			}

			[HarmonyPatch(typeof(QuickMenuManager), "Start")]
			[HarmonyPostfix]
			private static void QuickMenuManagerPostStart(QuickMenuManager __instance)
			{
				allEnemiesList.Clear();
				List<SpawnableEnemyWithRarity>[] array = new List<SpawnableEnemyWithRarity>[1] { __instance.testAllEnemiesLevel.Enemies };
				for (int i = 0; i < array.Length; i++)
				{
					foreach (SpawnableEnemyWithRarity item in array[i])
					{
						if (allEnemiesList.ContainsKey(((Object)item.enemyType).name))
						{
							if ((Object)(object)allEnemiesList[((Object)item.enemyType).name] == (Object)(object)item.enemyType)
							{
								Logger.LogWarning((object)("allEnemiesList: Tried to cache reference to \"" + ((Object)item.enemyType).name + "\" more than once"));
							}
							else
							{
								Logger.LogWarning((object)("allEnemiesList: Tried to cache two different enemies by same name (" + ((Object)item.enemyType).name + ")"));
							}
						}
						else if (item.enemyType.enemyName == "Butler")
						{
							item.enemyType.MaxCount = configMaxCount.Value;
							item.enemyType.PowerLevel = configPowerLevel.Value;
							Logger.LogDebug((object)"Butler spawn settings overriden!");
							return;
						}
					}
				}
			}

			[HarmonyPatch(typeof(ButlerEnemyAI), "OnCollideWithPlayer")]
			[HarmonyPrefix]
			private static void ButlerAttackPrefix(ButlerEnemyAI __instance, Collider other)
			{
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				if (((EnemyAI)__instance).isEnemyDead)
				{
					return;
				}
				if (((EnemyAI)__instance).currentBehaviourStateIndex != 2)
				{
					if (Time.realtimeSinceStartup - __instance.timeSinceStealthStab < 10f)
					{
						return;
					}
					__instance.timeSinceStealthStab = Time.realtimeSinceStartup;
					if (Random.Range(0, 100) < 95)
					{
						return;
					}
				}
				if (__instance.timeSinceHittingPlayer < 0.25f)
				{
					return;
				}
				PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				__instance.timeSinceHittingPlayer = 0f;
				if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					if (((EnemyAI)__instance).currentBehaviourStateIndex != 2)
					{
						__instance.berserkModeTimer = 3f;
					}
					val.DamagePlayer(configDamage.Value, true, true, (CauseOfDeath)14, 0, false, default(Vector3));
					__instance.StabPlayerServerRpc((int)val.playerClientId, ((EnemyAI)__instance).currentBehaviourStateIndex != 2);
					((EnemyAI)__instance).SetEnemyStunned(true, configAttackCooldown.Value, val);
				}
			}
		}

		private const string PLUGIN_GUID = "dopadream.lethalcompany.ButlerSettings";

		private const string PLUGIN_NAME = "Butler Settings";

		private const string PLUGIN_VERSION = "1.0.1";

		private const string LETHAL_CONFIG = "ainavt.lc.lethalconfig";

		internal static ManualLogSource Logger;

		internal static Dictionary<string, EnemyType> allEnemiesList = new Dictionary<string, EnemyType>();

		internal static ConfigEntry<int> configMaxCount;

		internal static ConfigEntry<int> configPowerLevel;

		internal static ConfigEntry<int> configDamage;

		internal static ConfigEntry<int> configHealthMultiplayer;

		internal static ConfigEntry<int> configHealthSingleplayer;

		internal static ConfigEntry<float> configAttackCooldown;

		internal void initLethalConfig()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(configMaxCount, false));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(configPowerLevel, false));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(configDamage, false));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(configHealthMultiplayer, false));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(configHealthSingleplayer, false));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(configAttackCooldown, true));
			LethalConfigManager.SkipAutoGen();
		}

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			configMaxCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max Spawn Count", 7, new ConfigDescription("Defines the max spawn count of Butlers.", (AcceptableValueBase)null, Array.Empty<object>()));
			configPowerLevel = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Power Level", 2, new ConfigDescription("Defines the power level of Butlers.", (AcceptableValueBase)null, Array.Empty<object>()));
			configDamage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Attack Damage", 10, new ConfigDescription("Defines how much damage the Butlers deal per hit.", (AcceptableValueBase)null, Array.Empty<object>()));
			configHealthMultiplayer = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Multiplayer Health", 8, new ConfigDescription("Defines the health of Butlers when playing multiplayer.", (AcceptableValueBase)null, Array.Empty<object>()));
			configHealthSingleplayer = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Singleplayer Health", 2, new ConfigDescription("Defines the health of Butlers when playing singleplayer.", (AcceptableValueBase)null, Array.Empty<object>()));
			configAttackCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Attack Cooldown", 0f, new ConfigDescription("Adds an attack cooldown after stabbing the player. Not vanilla behavior.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				initLethalConfig();
			}
			new Harmony("dopadream.lethalcompany.ButlerSettings").PatchAll();
			Logger.LogInfo((object)"Butler Settings v1.0.1 loaded");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ButlerSettings";

		public const string PLUGIN_NAME = "ButlerSettings";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}