Decompiled source of BerserkerEnemies v1.2.9

BerserkerEnemies/BerserkerEnemies.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BerserkerEnemies;
using HarmonyLib;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Animations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BerserkerEnemies")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BerserkerEnemies")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ebbf84f-d225-4b22-b9af-ebd8768167b2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class ModPatch
{
	public static bool enableBerserker = true;

	public static int startingLevel = 9;

	public static int minHealth = 400;

	public static int maxHealth = 5000;

	public static int berserkerHealth = 2000;

	public static bool enableHealthScaling = true;

	public static int healthScalingFactor = 20;

	public static bool berserkerUnkillable = false;

	public static bool canBeStunned = true;

	public static bool enableAnimal = true;

	public static bool enableApexPredator = true;

	public static bool enableBowtie = true;

	public static bool enableChef = true;

	public static bool enableClown = true;

	public static bool enableHeadman = true;

	public static bool enableHidden = true;

	public static bool enableHuntsman = true;

	public static bool enableMentalist = true;

	public static bool enableReaper = true;

	public static bool enableRobe = true;

	public static bool enableRugrat = true;

	public static bool enableShadowChild = true;

	public static bool enableSpewer = true;

	public static bool enableTrudge = true;

	public static bool enableUpscream = true;

	public static bool containModded = true;

	public static bool enableGusher = true;

	public static bool enableRoaster = true;

	public static bool enableDroid = true;

	public static bool enableDestroyer = true;

	public static bool enableSoldier = true;

	public static bool enableFreddyFazbear = true;

	public static float berserkerSpawnChance = 10f;

	public static float berserkerSpawnChancePerLevel = 5f;

	public static int maBerserkersAllowed = 1;

	private static BerserkerManager berserkerScript;

	public static EnemyParent _berserkerChosen;

	public static bool showDebugLogs = false;

	public static bool _masterUnkillable = false;

	public static bool _masterCanBeStunned = true;

	public static AssetBundle _assetBundle = null;

	public static (float, float) _orbValue = (0f, 0f);

	private static (float, float) currentBerserkerValuable = (0f, 0f);

	private static float minimumOrbValue = 8000f;

	private static float minOrbValueSubtract = 1000f;

	private static float maximumOrbValue = 50000f;

	private static float maxOrbValueSubtract = 10000f;

	[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
	[HarmonyPostfix]
	public static void GenerateDonePostfix(LevelGenerator __instance)
	{
		if (!SemiFunc.RunIsLevel())
		{
			return;
		}
		_berserkerChosen = null;
		berserkerScript = ((Component)LevelGenerator.Instance).gameObject.AddComponent<BerserkerManager>();
		PhotonView component = ((Component)LevelGenerator.Instance).GetComponent<PhotonView>();
		if (!enableBerserker || RunManager.instance.levelsCompleted + 1 < startingLevel || !SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		List<string> enemyTypes = GetEnemyTypes();
		if (enableHealthScaling)
		{
			berserkerHealth = CalculateHealthScaling(berserkerHealth);
		}
		currentBerserkerValuable = CalculateOrbValue(berserkerHealth);
		float num = Mathf.Clamp(berserkerSpawnChance + (float)(RunManager.instance.levelsCompleted + 1 - startingLevel) * berserkerSpawnChancePerLevel, 0f, 100f);
		if (showDebugLogs)
		{
			Log.Info($"Current level: {RunManager.instance.levelsCompleted + 1} - Base chance: {berserkerSpawnChance}% - Level chance: {num}%");
		}
		int num2 = 0;
		List<EnemyParent> enemiesSpawned = EnemyDirector.instance.enemiesSpawned;
		foreach (EnemyParent item in enemiesSpawned)
		{
			if (num2 >= maBerserkersAllowed)
			{
				continue;
			}
			float num3 = Random.Range(0, 100);
			if (showDebugLogs)
			{
				Log.Info($"Enemy: {item.enemyName} - Chance {num3}% of {num}% - Berserker? {num3 <= num && enemyTypes.Contains(item.enemyName)} - Is in list? {enemyTypes.Contains(item.enemyName)}");
			}
			if (!(num3 <= num) || !enemyTypes.Contains(item.enemyName))
			{
				continue;
			}
			Log.Info("Berserker Spawned!");
			_berserkerChosen = item;
			if ((Object)(object)((Component)_berserkerChosen).GetComponent<BerserkerController>() == (Object)null)
			{
				((Component)_berserkerChosen).gameObject.AddComponent<BerserkerController>();
			}
			((Component)_berserkerChosen).GetComponent<BerserkerController>().isBerserkerFlag = true;
			num2++;
			if (SemiFunc.IsMultiplayer())
			{
				if ((Object)(object)component != (Object)null)
				{
					component.RPC("StartBerserker", (RpcTarget)0, new object[2]
					{
						berserkerHealth,
						((Component)item).transform.GetSiblingIndex()
					});
					component.RPC("GetCanBeStunnedFromMaster", (RpcTarget)1, new object[1] { canBeStunned });
					component.RPC("GetUnkillableVariableFromMaster", (RpcTarget)1, new object[1] { berserkerUnkillable });
					component.RPC("GetOrbValuableFromMaster", (RpcTarget)1, new object[2] { currentBerserkerValuable.Item1, currentBerserkerValuable.Item2 });
				}
				if (showDebugLogs)
				{
					if (SemiFunc.IsMasterClient())
					{
						Log.Info($"Berserker: {item.enemyName} - Health: {berserkerHealth} - Unkillable? {berserkerUnkillable} - Can be stunned? {canBeStunned} - Orb value range: {currentBerserkerValuable.Item2} - {currentBerserkerValuable.Item1}");
					}
					else
					{
						Log.Info($"Berserker: {item.enemyName} - Health: {berserkerHealth} - Unkillable? {_masterUnkillable} - Can be stunned? {_masterCanBeStunned} - Orb value range: {_orbValue.Item2} - {_orbValue.Item1}");
					}
				}
			}
			else
			{
				berserkerScript.StartBerserker(berserkerHealth, ((Component)item).transform.GetSiblingIndex());
				if (showDebugLogs)
				{
					Log.Info($"Berserker: {item.enemyName} - Health: {berserkerHealth} - Unkillable? {berserkerUnkillable} - Can be stunned? {canBeStunned} - Orb value range: {currentBerserkerValuable.Item2} - {currentBerserkerValuable.Item1}");
				}
			}
			if (!containModded || !(_berserkerChosen.enemyName == "Soldier"))
			{
				continue;
			}
			List<EnemyParent> list = EnemyDirector.instance.enemiesSpawned.Where((EnemyParent ghost) => ghost.enemyName == "Soldier Ghost").ToList();
			foreach (EnemyParent item2 in list)
			{
				EnemyParent val = (_berserkerChosen = item2);
				((Component)_berserkerChosen).GetComponent<BerserkerController>().isBerserkerFlag = true;
				if (SemiFunc.IsMultiplayer())
				{
					if ((Object)(object)component != (Object)null)
					{
						component.RPC("StartBerserker", (RpcTarget)0, new object[2]
						{
							berserkerHealth,
							((Component)val).transform.GetSiblingIndex()
						});
						component.RPC("GetCanBeStunnedFromMaster", (RpcTarget)1, new object[1] { canBeStunned });
						component.RPC("GetUnkillableVariableFromMaster", (RpcTarget)1, new object[1] { berserkerUnkillable });
						component.RPC("GetOrbValuableFromMaster", (RpcTarget)1, new object[2] { currentBerserkerValuable.Item1, currentBerserkerValuable.Item2 });
					}
				}
				else
				{
					berserkerScript.StartBerserker(berserkerHealth, ((Component)val).transform.GetSiblingIndex());
				}
			}
		}
		if ((Object)(object)_berserkerChosen == (Object)null)
		{
			Log.Info("Berserker not spawned!");
		}
	}

	[HarmonyPatch(typeof(HurtCollider), "EnemyHurtRigidbody")]
	[HarmonyPrefix]
	public static bool EnemyHurtRigidbody(HurtCollider __instance, ref EnemyRigidbody _enemyRigidbody, PhysGrabObject _physGrabObject)
	{
		if ((Object)(object)_enemyRigidbody != (Object)null && enableBerserker)
		{
			bool masterUnkillable = berserkerUnkillable;
			if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
			{
				masterUnkillable = _masterUnkillable;
			}
			BerserkerController componentInMainParent = ModPatch.GetComponentInMainParent<BerserkerController>(((Component)_enemyRigidbody).transform);
			if ((Object)(object)componentInMainParent != (Object)null)
			{
				if (componentInMainParent.isBerserkerFlag && masterUnkillable)
				{
					return false;
				}
				return true;
			}
		}
		return true;
	}

	[HarmonyPatch(typeof(EnemyParent), "SpawnRPC")]
	[HarmonyPostfix]
	private static void SpawnRPCPostfix(EnemyParent __instance)
	{
		if ((Object)(object)((Component)__instance).gameObject.GetComponent<BerserkerController>() == (Object)null)
		{
			((Component)__instance).gameObject.AddComponent<BerserkerController>();
			if (showDebugLogs)
			{
				Log.Info("BerserkerController added to enemy " + __instance.enemyName + "!");
			}
		}
	}

	[HarmonyPatch(typeof(EnemyParent), "Despawn")]
	[HarmonyPrefix]
	public static bool DespawnPrefix(EnemyParent __instance)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Expected O, but got Unknown
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		if (enableBerserker && Object.op_Implicit((Object)(object)((Component)LevelGenerator.Instance).gameObject.GetComponent<BerserkerManager>()))
		{
			BerserkerController component = ((Component)__instance).GetComponent<BerserkerController>();
			if ((Object)(object)component != (Object)null)
			{
				if (component.isBerserkerFlag)
				{
					if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
					{
						return false;
					}
					FieldInfo fieldInfo = AccessTools.Field(typeof(EnemyParent), "Enemy");
					Enemy val = (Enemy)fieldInfo.GetValue(__instance);
					if ((Object)(object)val != (Object)null)
					{
						FieldInfo fieldInfo2 = AccessTools.Field(typeof(EnemyDirector), "despawnedTimeMultiplier");
						val.CurrentState = (EnemyState)11;
						__instance.DespawnedTimer = Random.Range(__instance.DespawnedTimeMin, __instance.DespawnedTimeMax) * (float)fieldInfo2.GetValue(EnemyDirector.instance);
						__instance.DespawnedTimer = Mathf.Max(__instance.DespawnedTimer, 1f);
						FieldInfo fieldInfo3 = AccessTools.Field(typeof(Enemy), "HasRigidbody");
						if ((bool)fieldInfo3.GetValue(val))
						{
							FieldInfo fieldInfo4 = AccessTools.Field(typeof(Enemy), "Rigidbody");
							EnemyRigidbody val2 = (EnemyRigidbody)fieldInfo4.GetValue(val);
							FieldInfo fieldInfo5 = AccessTools.Field(typeof(EnemyRigidbody), "grabbed");
							FieldInfo fieldInfo6 = AccessTools.Field(typeof(EnemyRigidbody), "grabStrengthTimer");
							fieldInfo5.SetValue(val2, false);
							fieldInfo6.SetValue(val2, 0f);
							val2.GrabRelease();
						}
						if (GameManager.Multiplayer())
						{
							((Component)__instance).GetComponent<PhotonView>().RPC("DespawnRPC", (RpcTarget)0, Array.Empty<object>());
						}
						else
						{
							MethodInfo method = typeof(EnemyParent).GetMethod("DespawnRPC", BindingFlags.Instance | BindingFlags.NonPublic);
							if (method != null)
							{
								method.Invoke(__instance, new object[0]);
							}
						}
						FieldInfo fieldInfo7 = AccessTools.Field(typeof(Enemy), "HasHealth");
						EnemyHealth component2 = ((Component)val).GetComponent<EnemyHealth>();
						FieldInfo fieldInfo8 = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");
						if (!(bool)fieldInfo7.GetValue(val) || (int)fieldInfo8.GetValue(component2) > 0)
						{
							return false;
						}
						GameObject val3 = _assetBundle.LoadAsset<GameObject>("Enemy Valuable - Berserker");
						Transform val4 = val.CustomValuableSpawnTransform;
						if (!Object.op_Implicit((Object)(object)val4))
						{
							val4 = val.CenterTransform;
						}
						val3 = (SemiFunc.IsMultiplayer() ? NetworkPrefabs.SpawnNetworkPrefab("Enemy Valuable - Berserker", val4.position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(val3, val4.position, Quaternion.identity));
						(float, float) orbValue = currentBerserkerValuable;
						if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
						{
							orbValue = _orbValue;
						}
						ScriptableObject obj = _assetBundle.LoadAsset<ScriptableObject>("Value - Berserker");
						Value val5 = (Value)(object)((obj is Value) ? obj : null);
						(val5.valueMax, val5.valueMin) = orbValue;
						if (!canBeStunned)
						{
							val5.valueMax += 2000f;
							val5.valueMin += 2000f;
							if (showDebugLogs)
							{
								Log.Info("Added bonus orb value for non-stunnable Berserker!");
							}
						}
						val3.GetComponent<ValuableObject>().valuePreset = val5;
						__instance.DespawnedTimer *= 3f;
						return false;
					}
					Log.Warn("CurrentEnemy is null! Dropping default valuable!");
					return true;
				}
				if (showDebugLogs)
				{
					Log.Info("Enemy " + __instance.enemyName + " is not Berserker!");
				}
				return true;
			}
			Log.Warn("BerserkerController not found in enemy " + __instance.enemyName + "!");
		}
		return true;
	}

	public static int CalculateHealthScaling(int _berserkerHealth)
	{
		return _berserkerHealth + (RunManager.instance.levelsCompleted + 1 - startingLevel) * (SemiFunc.PlayerGetAll().Count * healthScalingFactor);
	}

	public static (float, float) CalculateOrbValue(int _berserkerHealth)
	{
		int num = maxHealth;
		if (enableHealthScaling)
		{
			num += (RunManager.instance.levelsCompleted + 1 - startingLevel) * (SemiFunc.PlayerGetAll().Count * healthScalingFactor);
		}
		float num2 = Mathf.InverseLerp((float)minHealth, (float)num, (float)_berserkerHealth);
		float num3 = Mathf.Lerp(maxOrbValueSubtract, maximumOrbValue, num2);
		float item = num3 - Mathf.Lerp(minOrbValueSubtract, minimumOrbValue, num2);
		return (num3, item);
	}

	public static T GetComponentInChildrenRecursive<T>(Transform obj) where T : Component
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in obj)
		{
			Transform val = item;
			T component = ((Component)val).GetComponent<T>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = GetComponentInChildrenRecursive<T>(val);
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
		}
		return default(T);
	}

	public static T GetComponentInMainParent<T>(Transform obj) where T : Component
	{
		Transform parent = obj.parent;
		T result = default(T);
		while ((Object)(object)parent != (Object)null)
		{
			T component = ((Component)parent).GetComponent<T>();
			if ((Object)(object)component != (Object)null)
			{
				result = component;
			}
			parent = parent.parent;
		}
		return result;
	}

	public static List<string> GetEnemyTypes()
	{
		List<string> list = new List<string>();
		if (enableAnimal)
		{
			list.Add("Animal");
		}
		if (enableApexPredator)
		{
			list.Add("Apex Predator");
		}
		if (enableBowtie)
		{
			list.Add("Bowtie");
		}
		if (enableChef)
		{
			list.Add("Chef");
		}
		if (enableClown)
		{
			list.Add("Clown");
		}
		if (enableHeadman)
		{
			list.Add("Headman");
		}
		if (enableHuntsman)
		{
			list.Add("Huntsman");
		}
		if (enableMentalist)
		{
			list.Add("Mentalist");
		}
		if (enableReaper)
		{
			list.Add("Reaper");
		}
		if (enableRobe)
		{
			list.Add("Robe");
		}
		if (enableRugrat)
		{
			list.Add("Rugrat");
		}
		if (enableShadowChild)
		{
			list.Add("Shadow Child");
		}
		if (enableSpewer)
		{
			list.Add("Spewer");
		}
		if (enableTrudge)
		{
			list.Add("Trudge");
		}
		if (enableUpscream)
		{
			list.Add("Upscream");
		}
		if (containModded)
		{
			if (enableGusher)
			{
				list.Add("Gusher");
			}
			if (enableRoaster)
			{
				list.Add("Roaster");
			}
			if (enableDroid)
			{
				list.Add("Lost droid");
			}
			if (enableDestroyer)
			{
				list.Add("Lost Destroyer");
			}
			if (enableSoldier)
			{
				list.Add("Soldier");
			}
			if (enableFreddyFazbear)
			{
				list.Add("Freddy Fazbear");
			}
		}
		return list;
	}

	public static Texture2D LoadEmbeddedTexture(string resourceName)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		using (Stream stream = executingAssembly.GetManifestResourceStream(resourceName))
		{
			if (stream == null)
			{
				Log.Warn("Resource " + resourceName + " not found!");
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (ImageConversion.LoadImage(val, array))
			{
				((Texture)val).filterMode = (FilterMode)2;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				return val;
			}
		}
		return null;
	}
}
internal class BerserkerManager : MonoBehaviourPun
{
	public static BerserkerManager instance;

	public EnemyParent berserkerChosen;

	private static Transform berserkerChosenTransform;

	private static ParticleSystem berserkerParticlesObjPS;

	private void Awake()
	{
		instance = this;
	}

	private void Update()
	{
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Invalid comparison between Unknown and I4
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Invalid comparison between Unknown and I4
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		if (!ModPatch.enableBerserker || EnemyDirector.instance.enemiesSpawned.Count <= 0)
		{
			return;
		}
		for (int i = 0; i < EnemyDirector.instance.enemiesSpawned.Count; i++)
		{
			Enemy val = null;
			try
			{
				val = GetBerserkerEnemyScript(((Component)EnemyDirector.instance.enemiesSpawned[i]).transform);
			}
			catch
			{
				continue;
			}
			if ((Object)(object)val != (Object)null)
			{
				EnemyParent componentInMainParent = ModPatch.GetComponentInMainParent<EnemyParent>(((Component)val).transform);
				if ((Object)(object)componentInMainParent != (Object)null)
				{
					try
					{
						if (componentInMainParent.enemyName == "Freddy Fazbear")
						{
							val = GetBerserkerEnemyScript(((Component)componentInMainParent).transform);
							if ((Object)(object)val != (Object)null && ((Component)((Component)val).transform.parent).gameObject.activeInHierarchy)
							{
								GameObject gameObject = ((Component)((Component)val).transform.parent.GetChild(2).GetChild(3).GetChild(0)
									.GetChild(3)).gameObject;
								if ((Object)(object)gameObject != (Object)null && (Object)(object)berserkerParticlesObjPS != (Object)null)
								{
									if (gameObject.transform.localPosition.z > 0f)
									{
										if (berserkerParticlesObjPS.isPlaying)
										{
											berserkerParticlesObjPS.Stop();
										}
									}
									else if (berserkerParticlesObjPS.isStopped)
									{
										berserkerParticlesObjPS.Play();
									}
								}
							}
						}
					}
					catch (Exception arg)
					{
						Log.Warn($"Error while processing Freddy Fazbear: {arg}");
					}
					try
					{
						if (!(componentInMainParent.enemyName == "Spewer"))
						{
							continue;
						}
						val = GetBerserkerEnemyScript(((Component)componentInMainParent).transform);
						if (!((Object)(object)val != (Object)null) || !((Component)((Component)val).transform.parent).gameObject.activeInHierarchy)
						{
							continue;
						}
						EnemySlowMouth component = ((Component)val).GetComponent<EnemySlowMouth>();
						if (!((Object)(object)berserkerParticlesObjPS != (Object)null))
						{
							continue;
						}
						if ((int)component.currentState == 9 || (int)component.currentState == 10)
						{
							if (berserkerParticlesObjPS.isPlaying)
							{
								berserkerParticlesObjPS.Stop();
							}
						}
						else if (berserkerParticlesObjPS.isStopped)
						{
							berserkerParticlesObjPS.Play();
						}
					}
					catch (Exception arg2)
					{
						Log.Warn($"Error while processing Spewer: {arg2}");
					}
				}
				else if (ModPatch.showDebugLogs)
				{
					Log.Warn("EnemyParent script is null!");
				}
			}
			else if (ModPatch.showDebugLogs)
			{
				Log.Warn("Enemy script is null!");
			}
		}
	}

	[PunRPC]
	public void GetCanBeStunnedFromMaster(bool _canBeStunned)
	{
		ModPatch._masterCanBeStunned = _canBeStunned;
	}

	[PunRPC]
	public void GetUnkillableVariableFromMaster(bool _umasterUnkillable)
	{
		ModPatch._masterUnkillable = _umasterUnkillable;
	}

	[PunRPC]
	public void GetOrbValuableFromMaster(float _valueMax, float _valueMin)
	{
		ModPatch._orbValue = (_valueMax, _valueMin);
	}

	[PunRPC]
	public void StartBerserker(int berserkerHealth, int enemyIndex)
	{
		List<EnemyParent> enemiesSpawned = EnemyDirector.instance.enemiesSpawned;
		berserkerChosen = enemiesSpawned[enemyIndex];
		if ((Object)(object)berserkerChosen != (Object)null)
		{
			berserkerChosenTransform = ((Component)berserkerChosen).transform;
			Log.Info("Setting Berserker properties...");
			SetBerserkerValues(berserkerChosenTransform, berserkerHealth);
			SetBerserkerGrabForce(berserkerChosenTransform);
			if (((Component)berserkerChosenTransform).GetComponent<EnemyParent>().enemyName != "Hidden")
			{
				SetBerserkerGlow(berserkerChosenTransform);
				SetBerserkerSmoke(berserkerChosenTransform);
			}
			else if (((Component)berserkerChosenTransform).GetComponent<EnemyParent>().enemyName == "Hidden")
			{
				SetUpHidden(berserkerChosenTransform);
			}
			Log.Info("Berserker configured!");
		}
		else if (ModPatch.showDebugLogs)
		{
			Log.Warn("Berserker Chosen is null!");
		}
	}

	private static void SetBerserkerValues(Transform enemy, int _masterHealth)
	{
		int num = ModPatch.berserkerHealth;
		if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
		{
			num = _masterHealth;
		}
		EnemyHealth berserkerHealthScript = GetBerserkerHealthScript(enemy);
		if ((Object)(object)berserkerHealthScript != (Object)null)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");
			fieldInfo.SetValue(berserkerHealthScript, num);
			berserkerHealthScript.health = num;
			berserkerHealthScript.impactHurt = false;
			berserkerHealthScript.objectHurt = false;
			berserkerHealthScript.objectHurtStun = false;
		}
		bool flag = ModPatch.canBeStunned;
		if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
		{
			flag = ModPatch._masterCanBeStunned;
		}
		Enemy berserkerEnemyScript = GetBerserkerEnemyScript(enemy);
		if ((Object)(object)berserkerEnemyScript != (Object)null && !flag)
		{
			FieldInfo fieldInfo2 = AccessTools.Field(typeof(Enemy), "HasStateStunned");
			fieldInfo2.SetValue(berserkerEnemyScript, false);
			if (ModPatch.showDebugLogs)
			{
				Log.Info("Disabled stun...");
			}
		}
		EnemyRigidbody berserkerRigidbodyScript = GetBerserkerRigidbodyScript(enemy);
		if ((Object)(object)berserkerRigidbodyScript != (Object)null && !flag)
		{
			berserkerRigidbodyScript.grabStun = false;
			berserkerRigidbodyScript.stunFromFall = false;
			if (ModPatch.showDebugLogs)
			{
				Log.Info("Disabled stun from grab and fall...");
			}
		}
	}

	private static void SetBerserkerGlow(Transform enemy)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		foreach (Transform item in enemy)
		{
			Transform val = item;
			Renderer component = ((Component)val).GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				Material material = component.material;
				if ((Object)(object)material != (Object)null && (((Object)material.shader).name == "Hurtable/Hurtable" || ((Object)material.shader).name == "Hurtable/Hurtable Alpha Clip" || ((Object)material.shader).name == "Patcher/Hurtable/Hurtable" || ((Object)material.shader).name == "Patcher/Hurtable/Hurtable Alpha Clip" || ((Object)material.shader).name == "Ortong/Hurtable" || ((Object)material.shader).name == "Orton/Hurtable/Hurtable Freddy"))
				{
					material.SetFloat("_FresnelAmount", 1f);
					material.SetFloat("_FresnelScale", 1f);
					material.SetFloat("_FresnelPower", 5f);
					material.SetFloat("_FresnelBias", 0f);
					material.SetColor("_FresnelColor", Color.red);
					material.SetFloat("_FresnelEmission", 1f);
				}
			}
			SetBerserkerGlow(val);
		}
	}

	private static void SetBerserkerGrabForce(Transform enemy)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		GrabForce val = ScriptableObject.CreateInstance<GrabForce>();
		val.amount = 1E+10f;
		((Object)val).name = "Grab Force - Berserker";
		foreach (Transform item in enemy)
		{
			Transform berserkerGrabForce = item;
			EnemyRigidbody component = ((Component)enemy).gameObject.GetComponent<EnemyRigidbody>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.grabForceNeeded != (Object)(object)val)
			{
				component.grabForceNeeded = val;
			}
			SetBerserkerGrabForce(berserkerGrabForce);
		}
	}

	private static Transform GetBerserkerParticleParent(Transform enemy)
	{
		Transform result = null;
		Animator componentInChildrenRecursive = ModPatch.GetComponentInChildrenRecursive<Animator>(enemy);
		if ((Object)(object)componentInChildrenRecursive != (Object)null)
		{
			result = ((Component)componentInChildrenRecursive).transform;
		}
		return result;
	}

	private static void SetBerserkerSmoke(Transform enemy)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		Transform berserkerParticleParent = GetBerserkerParticleParent(enemy);
		GameObject val = ModPatch._assetBundle.LoadAsset<GameObject>("BerserkerAura");
		GameObject val2 = Object.Instantiate<GameObject>(val);
		berserkerParticlesObjPS = val2.GetComponent<ParticleSystem>();
		if ((Object)(object)berserkerParticleParent != (Object)null)
		{
			val2.transform.SetParent(berserkerParticleParent, false);
		}
		Vector3 val3 = Vector3.zero;
		if (((Component)enemy).GetComponent<EnemyParent>().enemyName == "Robe" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Reaper" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Clown" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Hunter" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Soldier" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Soldier Ghost" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Lost droid" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Lost Destroyer")
		{
			val3 += new Vector3(0f, 1f, 0f);
		}
		else if (((Component)enemy).GetComponent<EnemyParent>().enemyName == "Trudge" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Gusher" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Roaster" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Freddy Fazbear" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Shadow Child")
		{
			val3 += new Vector3(0f, 1.5f, 0f);
		}
		val2.transform.localPosition = val3;
		val2.transform.localRotation = Quaternion.identity;
	}

	private static Enemy GetBerserkerEnemyScript(Transform enemy)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in enemy)
		{
			Transform val = item;
			if (((Object)val).name == "Controller")
			{
				Enemy component = ((Component)val).GetComponent<Enemy>();
				if ((Object)(object)component != (Object)null)
				{
					return component;
				}
			}
			Enemy berserkerEnemyScript = GetBerserkerEnemyScript(val);
			if ((Object)(object)berserkerEnemyScript != (Object)null)
			{
				return berserkerEnemyScript;
			}
		}
		return null;
	}

	private static EnemyRigidbody GetBerserkerRigidbodyScript(Transform enemy)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in enemy)
		{
			Transform val = item;
			if (((Object)val).name == "Rigidbody")
			{
				EnemyRigidbody component = ((Component)val).GetComponent<EnemyRigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					return component;
				}
			}
			EnemyRigidbody berserkerRigidbodyScript = GetBerserkerRigidbodyScript(val);
			if ((Object)(object)berserkerRigidbodyScript != (Object)null)
			{
				return berserkerRigidbodyScript;
			}
		}
		return null;
	}

	private static EnemyHealth GetBerserkerHealthScript(Transform enemy)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in enemy)
		{
			Transform val = item;
			if (((Object)val).name == "Controller")
			{
				EnemyHealth component = ((Component)val).GetComponent<EnemyHealth>();
				if ((Object)(object)component != (Object)null)
				{
					return component;
				}
			}
			EnemyHealth berserkerHealthScript = GetBerserkerHealthScript(val);
			if ((Object)(object)berserkerHealthScript != (Object)null)
			{
				return berserkerHealthScript;
			}
		}
		return null;
	}

	private static void SetUpHidden(Transform enemy)
	{
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = ModPatch._assetBundle.LoadAsset<GameObject>("Berserker Hidden Breath");
		GameObject val2 = ModPatch._assetBundle.LoadAsset<GameObject>("Berserker Hidden Breath Constant");
		GameObject val3 = ModPatch._assetBundle.LoadAsset<GameObject>("Berserker Hidden Breath Fast");
		GameObject val4 = ModPatch._assetBundle.LoadAsset<GameObject>("Berserker Hidden Foot Shape Left");
		GameObject val5 = ModPatch._assetBundle.LoadAsset<GameObject>("Berserker Hidden Foot Shape Right");
		((Component)enemy.GetChild(0).GetChild(0)).gameObject.SetActive(false);
		((Component)enemy.GetChild(0).GetChild(1)).gameObject.SetActive(false);
		((Component)enemy.GetChild(0).GetChild(2)).gameObject.SetActive(false);
		((Component)enemy.GetChild(0).GetChild(3)).gameObject.SetActive(false);
		((Component)enemy.GetChild(0).GetChild(4)).gameObject.SetActive(false);
		GameObject val6 = Object.Instantiate<GameObject>(val, enemy.GetChild(0).GetChild(0).position, enemy.GetChild(0).GetChild(0).rotation, enemy.GetChild(0));
		val6.transform.SetSiblingIndex(0);
		ParentConstraint component = val6.GetComponent<ParentConstraint>();
		ConstraintSource val7 = default(ConstraintSource);
		((ConstraintSource)(ref val7)).sourceTransform = enemy.GetChild(1).GetChild(1).GetChild(6)
			.GetChild(0);
		((ConstraintSource)(ref val7)).weight = 1f;
		component.SetSource(0, val7);
		val6.GetComponent<ParentConstraint>().translationAtRest = new Vector3(0f, 1.826f, -2.702927f);
		GameObject val8 = Object.Instantiate<GameObject>(val3, enemy.GetChild(0).GetChild(1).position, enemy.GetChild(0).GetChild(1).rotation, enemy.GetChild(0));
		val8.transform.SetSiblingIndex(1);
		ParentConstraint component2 = val8.GetComponent<ParentConstraint>();
		val7 = default(ConstraintSource);
		((ConstraintSource)(ref val7)).sourceTransform = enemy.GetChild(1).GetChild(1).GetChild(6)
			.GetChild(0);
		((ConstraintSource)(ref val7)).weight = 1f;
		component2.SetSource(0, val7);
		val8.GetComponent<ParentConstraint>().translationAtRest = new Vector3(0f, 1.826f, -2.702927f);
		GameObject val9 = Object.Instantiate<GameObject>(val2, enemy.GetChild(0).GetChild(2).position, enemy.GetChild(0).GetChild(2).rotation, enemy.GetChild(0));
		val9.transform.SetSiblingIndex(2);
		ParentConstraint component3 = val9.GetComponent<ParentConstraint>();
		val7 = default(ConstraintSource);
		((ConstraintSource)(ref val7)).sourceTransform = enemy.GetChild(1).GetChild(1).GetChild(6)
			.GetChild(0);
		((ConstraintSource)(ref val7)).weight = 1f;
		component3.SetSource(0, val7);
		val9.GetComponent<ParentConstraint>().translationAtRest = new Vector3(0f, 1.826f, -2.702927f);
		GameObject val10 = Object.Instantiate<GameObject>(val5, enemy.GetChild(0).GetChild(3).position, enemy.GetChild(0).GetChild(3).rotation, enemy.GetChild(0));
		val10.transform.SetSiblingIndex(3);
		GameObject val11 = Object.Instantiate<GameObject>(val4, enemy.GetChild(0).GetChild(4).position, enemy.GetChild(0).GetChild(4).rotation, enemy.GetChild(0));
		val11.transform.SetSiblingIndex(4);
		EnemyHiddenAnim component4 = ((Component)enemy.GetChild(1).GetChild(1).GetChild(6)).GetComponent<EnemyHiddenAnim>();
		component4.particleBreath = val6.GetComponent<ParticleSystem>();
		component4.particleBreathFast = val8.GetComponent<ParticleSystem>();
		component4.particleBreathConstant = val9.GetComponent<ParticleSystem>();
		component4.particleFootstepShapeLeft = val11.GetComponent<ParticleSystem>();
		component4.particleFootstepShapeRight = val10.GetComponent<ParticleSystem>();
	}
}
public class BerserkerController : MonoBehaviourPun
{
	public bool isBerserkerFlag = false;
}
namespace BerserkerEnemies;

[BepInPlugin("FNKTLabs.BerserkerEnemies", "Berserker Enemies", "1.2.9")]
public class ModBase : BaseUnityPlugin
{
	private const string modGUID = "FNKTLabs.BerserkerEnemies";

	public const string modName = "Berserker Enemies";

	private const string modVersion = "1.2.9";

	private Harmony _harmony = new Harmony("FNKTLabs.BerserkerEnemies");

	public static ConfigEntry<bool> config_EnableBerserker;

	public static ConfigEntry<int> config_StartingLevel;

	public static ConfigEntry<int> config_MaxBerserkers;

	public static ConfigEntry<int> config_BerserkerHealth;

	public static ConfigEntry<bool> config_EnableHealthScaling;

	public static ConfigEntry<int> config_HealthScalingFactor;

	public static ConfigEntry<bool> config_BerserkerUnkillable;

	public static ConfigEntry<bool> config_CanBeStunned;

	public static ConfigEntry<float> config_berserkerSpawnChance;

	public static ConfigEntry<float> config_berserkerSpawnChancePerLevel;

	public static ConfigEntry<bool> config_enableAnimal;

	public static ConfigEntry<bool> config_enableApexPredator;

	public static ConfigEntry<bool> config_enableChef;

	public static ConfigEntry<bool> config_enableClown;

	public static ConfigEntry<bool> config_enableBowtie;

	public static ConfigEntry<bool> config_enableMentalist;

	public static ConfigEntry<bool> config_enableHeadman;

	public static ConfigEntry<bool> config_enableHuntsman;

	public static ConfigEntry<bool> config_enableReaper;

	public static ConfigEntry<bool> config_enableRobe;

	public static ConfigEntry<bool> config_enableRugrat;

	public static ConfigEntry<bool> config_enableShadowChild;

	public static ConfigEntry<bool> config_enableSpewer;

	public static ConfigEntry<bool> config_enableTrudge;

	public static ConfigEntry<bool> config_enableUpscream;

	public static ConfigEntry<bool> config_enableDestroyer;

	public static ConfigEntry<bool> config_enableDroid;

	public static ConfigEntry<bool> config_enableGusher;

	public static ConfigEntry<bool> config_enableRoaster;

	public static ConfigEntry<bool> config_enableSoldier;

	public static ConfigEntry<bool> config_enableFreddyFazbear;

	public static ConfigEntry<bool> config_showDebugLogs;

	public void Awake()
	{
		Log.Init(((BaseUnityPlugin)this).Logger);
		Log.Info("BerserkerEnemies loaded!");
		_harmony.PatchAll(typeof(ModBase));
		_harmony.PatchAll(typeof(ModPatch));
		ConfigFile();
		SetUpBundle();
	}

	public void SetUpBundle()
	{
		string directoryName = Path.GetDirectoryName(typeof(ModBase).Assembly.Location);
		string text = Path.Combine(directoryName, "berserker_enemies");
		Log.Info("Trying to load bundle: " + text);
		if (!File.Exists(text))
		{
			Log.Error("AssetBundle not found: " + text);
			return;
		}
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val == (Object)null)
		{
			Log.Error("Failed to load AssetBundle from: " + text);
			return;
		}
		ModPatch._assetBundle = val;
		GameObject val2 = val.LoadAsset<GameObject>("Enemy Valuable - Berserker");
		NetworkPrefabs.RegisterNetworkPrefab(((Object)val2).name, val2);
		Log.Info("AssetBundle loaded successfully!");
	}

	public void ConfigFile()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Expected O, but got Unknown
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Expected O, but got Unknown
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Expected O, but got Unknown
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Expected O, but got Unknown
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Expected O, but got Unknown
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Expected O, but got Unknown
		config_EnableBerserker = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Toggle Berserker enemy", (AcceptableValueBase)null, Array.Empty<object>()));
		ModPatch.enableBerserker = config_EnableBerserker.Value;
		config_showDebugLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Debug", false, new ConfigDescription("Toggle debug log visibility", (AcceptableValueBase)null, Array.Empty<object>()));
		ModPatch.showDebugLogs = config_showDebugLogs.Value;
		config_MaxBerserkers = ((BaseUnityPlugin)this).Config.Bind<int>("Berserker", "Max Berserkers Allowed", 1, new ConfigDescription("Define the number of Berserkers that can spawn", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
		ModPatch.maBerserkersAllowed = config_MaxBerserkers.Value;
		config_StartingLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Berserker", "Starting Level", 9, new ConfigDescription("Min level for the Berserker to spawn", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		ModPatch.startingLevel = config_StartingLevel.Value;
		config_BerserkerUnkillable = ((BaseUnityPlugin)this).Config.Bind<bool>("Berserker", "Unkillable", false, new ConfigDescription("Toggle whether the Berserker is unkillable", (AcceptableValueBase)null, Array.Empty<object>()));
		ModPatch.berserkerUnkillable = config_BerserkerUnkillable.Value;
		config_CanBeStunned = ((BaseUnityPlugin)this).Config.Bind<bool>("Berserker", "Can Be Stunned", true, new ConfigDescription("Toggle whether the Berserker can be stunned", (AcceptableValueBase)null, Array.Empty<object>()));
		ModPatch.canBeStunned = config_CanBeStunned.Value;
		config_BerserkerHealth = ((BaseUnityPlugin)this).Config.Bind<int>("Health", "Health", 2000, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(ModPatch.minHealth, ModPatch.maxHealth), Array.Empty<object>()));
		ModPatch.berserkerHealth = config_BerserkerHealth.Value;
		config_EnableHealthScaling = ((BaseUnityPlugin)this).Config.Bind<bool>("Health", "Enable Scaling", false, new ConfigDescription("Enable Berserker health scaling", (AcceptableValueBase)null, Array.Empty<object>()));
		ModPatch.enableHealthScaling = config_EnableHealthScaling.Value;
		config_HealthScalingFactor = ((BaseUnityPlugin)this).Config.Bind<int>("Health", "Scaling Value", 10, new ConfigDescription("Health scaling (level × players)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>()));
		ModPatch.healthScalingFactor = config_HealthScalingFactor.Value;
		config_berserkerSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chance", "Percentage", 10f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		ModPatch.berserkerSpawnChance = config_berserkerSpawnChance.Value;
		config_berserkerSpawnChancePerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chance", "Increase Per Level", 5f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
		ModPatch.berserkerSpawnChancePerLevel = config_berserkerSpawnChancePerLevel.Value;
		config_enableAnimal = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Animal", true, (ConfigDescription)null);
		ModPatch.enableAnimal = config_enableAnimal.Value;
		config_enableApexPredator = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Apex Predator", true, (ConfigDescription)null);
		ModPatch.enableApexPredator = config_enableApexPredator.Value;
		config_enableBowtie = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Bowtie", true, (ConfigDescription)null);
		ModPatch.enableBowtie = config_enableBowtie.Value;
		config_enableChef = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Chef", true, (ConfigDescription)null);
		ModPatch.enableChef = config_enableChef.Value;
		config_enableClown = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Clown", true, (ConfigDescription)null);
		ModPatch.enableClown = config_enableClown.Value;
		config_enableHeadman = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Headman", true, (ConfigDescription)null);
		ModPatch.enableHeadman = config_enableHeadman.Value;
		config_enableHuntsman = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Huntsman", true, (ConfigDescription)null);
		ModPatch.enableHuntsman = config_enableHuntsman.Value;
		config_enableMentalist = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Mentalist", true, (ConfigDescription)null);
		ModPatch.enableMentalist = config_enableMentalist.Value;
		config_enableReaper = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Reaper", true, (ConfigDescription)null);
		ModPatch.enableReaper = config_enableReaper.Value;
		config_enableRobe = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Robe", true, (ConfigDescription)null);
		ModPatch.enableRobe = config_enableRobe.Value;
		config_enableRugrat = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Rugrat", true, (ConfigDescription)null);
		ModPatch.enableRugrat = config_enableRugrat.Value;
		config_enableShadowChild = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Shadow Child", true, (ConfigDescription)null);
		ModPatch.enableShadowChild = config_enableShadowChild.Value;
		config_enableSpewer = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Spewer", true, (ConfigDescription)null);
		ModPatch.enableSpewer = config_enableSpewer.Value;
		config_enableTrudge = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Trudge", true, (ConfigDescription)null);
		ModPatch.enableTrudge = config_enableTrudge.Value;
		config_enableUpscream = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Upscream", true, (ConfigDescription)null);
		ModPatch.enableUpscream = config_enableUpscream.Value;
		List<string> list = ListPluginFiles();
		if (list.Contains("WesleysEnemies.dll"))
		{
			ModPatch.containModded = true;
			config_enableDestroyer = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Destroyer", true, (ConfigDescription)null);
			ModPatch.enableDestroyer = config_enableDestroyer.Value;
			config_enableDroid = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Droid", true, (ConfigDescription)null);
			ModPatch.enableDroid = config_enableDroid.Value;
			config_enableGusher = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Gusher", true, (ConfigDescription)null);
			ModPatch.enableGusher = config_enableGusher.Value;
			config_enableRoaster = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Roaster", true, (ConfigDescription)null);
			ModPatch.enableRoaster = config_enableRoaster.Value;
			config_enableSoldier = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "The Soldier", true, (ConfigDescription)null);
			ModPatch.enableSoldier = config_enableSoldier.Value;
		}
		if (list.Contains("FreddyEnemy.dll"))
		{
			ModPatch.containModded = true;
			config_enableFreddyFazbear = ((BaseUnityPlugin)this).Config.Bind<bool>("Freddy Enemy", "Freddy Fazbear", true, (ConfigDescription)null);
			ModPatch.enableFreddyFazbear = config_enableFreddyFazbear.Value;
		}
	}

	public static List<string> ListPluginFiles()
	{
		if (config_showDebugLogs.Value)
		{
			Log.Info("Checking for modded enemies...");
		}
		List<string> list = new List<string>();
		string pluginPath = Paths.PluginPath;
		if (!Directory.Exists(pluginPath))
		{
			Log.Error("Folder " + pluginPath + " not found!");
			return null;
		}
		string[] files = Directory.GetFiles(pluginPath, "*.dll", SearchOption.AllDirectories);
		string[] array = files;
		foreach (string path in array)
		{
			if (ModPatch.showDebugLogs)
			{
				Log.Info(("Mod found: " + Path.GetFileName(path)).Replace(".dll", ""));
			}
			list.Add(Path.GetFileName(path));
		}
		return list;
	}
}
public static class Log
{
	public static ManualLogSource Source;

	public static void Init(ManualLogSource logger)
	{
		Source = logger;
	}

	public static void Info(object msg)
	{
		ManualLogSource source = Source;
		if (source != null)
		{
			source.LogInfo(msg);
		}
	}

	public static void Warn(object msg)
	{
		ManualLogSource source = Source;
		if (source != null)
		{
			source.LogWarning(msg);
		}
	}

	public static void Error(object msg)
	{
		ManualLogSource source = Source;
		if (source != null)
		{
			source.LogError(msg);
		}
	}
}