Decompiled source of Agnaris Mod v1.1.1

PeakMod.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
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 Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PeakMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Rentner Mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PeakMod")]
[assembly: AssemblyTitle("PeakMod")]
[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.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 PeakMod
{
	[BepInPlugin("com.redstone.rentenr", "Rentner Mod", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <ModLoop>d__19 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

			private string <sceneName>5__1;

			private bool <title>5__2;

			private Exception <e>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ModLoop>d__19(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<sceneName>5__1 = null;
				<e>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					FileLog("[SYSTEM] ModLoop Started.");
					break;
				case 1:
					<>1__state = -1;
					try
					{
						Scene activeScene = SceneManager.GetActiveScene();
						<sceneName>5__1 = ((Scene)(ref activeScene)).name;
						<title>5__2 = <>4__this.IsTitleScreen(<sceneName>5__1);
						if (!<title>5__2)
						{
							<>4__this.ManageSpawning(<sceneName>5__1);
							<>4__this.NukeWorldMaterials();
						}
						<sceneName>5__1 = null;
					}
					catch (Exception ex)
					{
						<e>5__3 = ex;
						FileLog("LOOP ERROR: " + <e>5__3.Message);
					}
					break;
				}
				<>2__current = (object)new WaitForSecondsRealtime(2f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <YeetPlayer>d__27 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject player;

			public Vector3 dir;

			public Plugin <>4__this;

			private List<MonoBehaviour> <suppressedScripts>5__1;

			private Rigidbody <playerRb>5__2;

			private bool <wasKinematic>5__3;

			private MonoBehaviour[] <behaviours>5__4;

			private float <elapsed>5__5;

			private Component[] <allComps>5__6;

			private Component[] <>s__7;

			private int <>s__8;

			private Component <c>5__9;

			private MonoBehaviour[] <>s__10;

			private int <>s__11;

			private MonoBehaviour <b>5__12;

			private string <name>5__13;

			private float <dt>5__14;

			private List<MonoBehaviour>.Enumerator <>s__15;

			private MonoBehaviour <b>5__16;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <YeetPlayer>d__27(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<suppressedScripts>5__1 = null;
				<playerRb>5__2 = null;
				<behaviours>5__4 = null;
				<allComps>5__6 = null;
				<>s__7 = null;
				<c>5__9 = null;
				<>s__10 = null;
				<b>5__12 = null;
				<name>5__13 = null;
				<>s__15 = default(List<MonoBehaviour>.Enumerator);
				<b>5__16 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0304: Unknown result type (might be due to invalid IL or missing references)
				//IL_0309: Unknown result type (might be due to invalid IL or missing references)
				//IL_0348: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0358: Unknown result type (might be due to invalid IL or missing references)
				//IL_0363: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					if (!_hasDumpedComponents)
					{
						_hasDumpedComponents = true;
						FileLog("### PLAYER DEBUG DUMP ###");
						FileLog("Target Name: " + ((Object)player).name);
						<allComps>5__6 = player.GetComponentsInChildren<Component>(true);
						<>s__7 = <allComps>5__6;
						for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++)
						{
							<c>5__9 = <>s__7[<>s__8];
							if ((Object)(object)<c>5__9 != (Object)null)
							{
								FileLog("COMP: " + ((object)<c>5__9).GetType().Name);
							}
							<c>5__9 = null;
						}
						<>s__7 = null;
						FileLog("###########################");
						<allComps>5__6 = null;
					}
					<suppressedScripts>5__1 = new List<MonoBehaviour>();
					<playerRb>5__2 = player.GetComponent<Rigidbody>();
					<wasKinematic>5__3 = false;
					if ((Object)(object)<playerRb>5__2 != (Object)null)
					{
						<wasKinematic>5__3 = <playerRb>5__2.isKinematic;
						<playerRb>5__2.isKinematic = true;
					}
					<behaviours>5__4 = player.GetComponentsInChildren<MonoBehaviour>(true);
					<>s__10 = <behaviours>5__4;
					for (<>s__11 = 0; <>s__11 < <>s__10.Length; <>s__11++)
					{
						<b>5__12 = <>s__10[<>s__11];
						if (!((Object)(object)<b>5__12 == (Object)null))
						{
							<name>5__13 = ((object)<b>5__12).GetType().Name.ToLower();
							if ((<name>5__13 == "maincameramovement" || ((<name>5__13.Contains("controller") || <name>5__13.Contains("movement") || <name>5__13.Contains("motor")) && !<name>5__13.Contains("render") && !<name>5__13.Contains("audio"))) && ((Behaviour)<b>5__12).enabled)
							{
								((Behaviour)<b>5__12).enabled = false;
								<suppressedScripts>5__1.Add(<b>5__12);
								FileLog("[YEET] Suppressed: " + ((object)<b>5__12).GetType().Name);
							}
							<name>5__13 = null;
							<b>5__12 = null;
						}
					}
					<>s__10 = null;
					<elapsed>5__5 = 0f;
					FileLog("[YEET] LAUNCHING (Physics Disabled)");
					Transform transform = player.transform;
					transform.position += Vector3.up * YEET_LIFT;
					break;
				}
				case 1:
					<>1__state = -1;
					break;
				}
				if (<elapsed>5__5 < YEET_DURATION && !((Object)(object)player == (Object)null))
				{
					<dt>5__14 = Time.deltaTime;
					Transform transform2 = player.transform;
					transform2.position += dir * YEET_POWER * <dt>5__14;
					Physics.SyncTransforms();
					<elapsed>5__5 += <dt>5__14;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>s__15 = <suppressedScripts>5__1.GetEnumerator();
				try
				{
					while (<>s__15.MoveNext())
					{
						<b>5__16 = <>s__15.Current;
						if ((Object)(object)<b>5__16 != (Object)null)
						{
							((Behaviour)<b>5__16).enabled = true;
						}
						<b>5__16 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__15).Dispose();
				}
				<>s__15 = default(List<MonoBehaviour>.Enumerator);
				if ((Object)(object)<playerRb>5__2 != (Object)null)
				{
					<playerRb>5__2.isKinematic = <wasKinematic>5__3;
				}
				FileLog("[YEET] System Restored.");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string modGUID = "com.redstone.rentenr";

		private const string modName = "Rentner Mod";

		private const string modVersion = "1.2.2";

		public static float MONSTER_SPEED = 4f;

		public static float MONSTER_CLIMB = 16f;

		public static int MAX_MONSTERS = 5;

		public static float SPAWN_DISTANCE = 100f;

		public static float YEET_POWER = 1000f;

		public static float YEET_DURATION = 2.5f;

		public static float YEET_LIFT = 2f;

		public static int DAMAGE_TYPE = 8;

		public static float DAMAGE_AMOUNT = 0.05f;

		public static Plugin Instance;

		public static Texture2D CustomSkin;

		private static string LogFilePath;

		public static List<GameObject> SpawnedMonsters = new List<GameObject>();

		private static bool _hasDumpedComponents = false;

		private void Awake()
		{
			Instance = this;
			LogFilePath = Path.Combine(Paths.PluginPath, "RentnerMod_Debug.log");
			try
			{
				File.WriteAllText(LogFilePath, string.Empty);
			}
			catch
			{
			}
			FileLog("Rentner Mod V22 (Fully Configurable) RESTART REQUIRED loading...");
			FileLog($"CONFIG :: Speed: {MONSTER_SPEED} | Dmg: {DAMAGE_AMOUNT} (Type {DAMAGE_TYPE}) | Yeet: {YEET_POWER}");
			string text = Path.Combine(Paths.PluginPath, "23.png");
			if (File.Exists(text))
			{
				CustomSkin = LoadPNG(text);
				FileLog($"[INIT] Texture 23.png loaded. {((Texture)CustomSkin).width}x{((Texture)CustomSkin).height}");
			}
			else
			{
				FileLog("ERROR: 23.png not found!");
			}
			((MonoBehaviour)this).StartCoroutine(ModLoop());
		}

		public static void FileLog(string msg)
		{
			try
			{
				using StreamWriter streamWriter = File.AppendText(LogFilePath);
				streamWriter.WriteLine($"[{DateTime.Now:HH:mm:ss}] {msg}");
			}
			catch
			{
			}
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)290))
			{
				DumpDebugInfoInput();
			}
		}

		private void DumpDebugInfoInput()
		{
			FileLog("### DEEP SCAN ###");
		}

		[IteratorStateMachine(typeof(<ModLoop>d__19))]
		private IEnumerator ModLoop()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ModLoop>d__19(0)
			{
				<>4__this = this
			};
		}

		private bool IsTitleScreen(string sceneName)
		{
			return sceneName.ToLower().Contains("menu") || sceneName.ToLower().Contains("title");
		}

		private void NukeWorldMaterials()
		{
			if ((Object)(object)CustomSkin == (Object)null)
			{
				return;
			}
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string text = ((Object)val).name.ToLower();
					string text2 = (Object.op_Implicit((Object)(object)val.shader) ? ((Object)val.shader).name.ToLower() : "");
					bool flag = false;
					if (text.Contains("font") || text.Contains("text") || text.Contains("sdf") || text.Contains("tmpro") || text.Contains("ui") || text.Contains("button") || text.Contains("panel") || text.Contains("cursor") || text.Contains("sprite") || text.Contains("particle") || text.Contains("skybox") || text2.Contains("ui") || text2.Contains("text") || text2.Contains("gui") || text2.Contains("particle"))
					{
						flag = true;
					}
					if (!flag)
					{
						SafeApplyTexture(val);
					}
				}
			}
		}

		private void SafeApplyTexture(Material mat)
		{
			if (!((Object)(object)mat == (Object)null))
			{
				if (mat.HasProperty("_MainTex"))
				{
					mat.SetTexture("_MainTex", (Texture)(object)CustomSkin);
				}
				if (mat.HasProperty("_BaseMap"))
				{
					mat.SetTexture("_BaseMap", (Texture)(object)CustomSkin);
				}
			}
		}

		private GameObject FindPlayerAggressively()
		{
			GameObject val = GameObject.FindGameObjectWithTag("Player");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			val = GameObject.Find("Player") ?? GameObject.Find("FPSController");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			CharacterController val2 = Object.FindObjectOfType<CharacterController>();
			if ((Object)(object)val2 != (Object)null)
			{
				return ((Component)val2).gameObject;
			}
			if ((Object)(object)Camera.main != (Object)null)
			{
				return ((Component)((Component)Camera.main).transform.root).gameObject;
			}
			return null;
		}

		private void ManageSpawning(string currentScene)
		{
			if (Time.timeSinceLevelLoad < 10f)
			{
				return;
			}
			SpawnedMonsters.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
			if (SpawnedMonsters.Count < MAX_MONSTERS)
			{
				GameObject val = FindPlayerAggressively();
				if (!((Object)(object)val == (Object)null))
				{
					SpawnMonster(val);
				}
			}
		}

		[IteratorStateMachine(typeof(<YeetPlayer>d__27))]
		public IEnumerator YeetPlayer(GameObject player, Vector3 dir)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <YeetPlayer>d__27(0)
			{
				<>4__this = this,
				player = player,
				dir = dir
			};
		}

		private void SpawnMonster(GameObject playerObj)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = playerObj.transform.position + Random.onUnitSphere * SPAWN_DISTANCE;
			val.y = playerObj.transform.position.y + 2f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 50f, Vector3.down, ref val2, 100f))
			{
				val = ((RaycastHit)(ref val2)).point + Vector3.up * 1.5f;
			}
			GameObject val3 = new GameObject("StalkerRentner");
			val3.transform.position = val;
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
			val4.transform.SetParent(val3.transform);
			val4.transform.localPosition = Vector3.zero;
			val4.transform.localScale = new Vector3(1f, 2f, 1f);
			Object.Destroy((Object)(object)val4.GetComponent<Collider>());
			Shader val5 = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val5 == (Object)null)
			{
				val5 = Shader.Find("Standard");
			}
			if ((Object)(object)val5 == (Object)null)
			{
				val5 = Shader.Find("Diffuse");
			}
			Material val6 = new Material(val5);
			val6.color = Color.white;
			if ((Object)(object)CustomSkin != (Object)null)
			{
				val6.mainTexture = (Texture)(object)CustomSkin;
				if (val6.HasProperty("_BaseMap"))
				{
					val6.SetTexture("_BaseMap", (Texture)(object)CustomSkin);
				}
				if (val6.HasProperty("_MainTex"))
				{
					val6.SetTexture("_MainTex", (Texture)(object)CustomSkin);
				}
				if (val6.HasProperty("_BaseColorMap"))
				{
					val6.SetTexture("_BaseColorMap", (Texture)(object)CustomSkin);
				}
			}
			else
			{
				val6.color = Color.magenta;
			}
			val4.GetComponent<Renderer>().material = val6;
			val3.AddComponent<CapsuleCollider>().height = 2f;
			StalkerAI stalkerAI = val3.AddComponent<StalkerAI>();
			stalkerAI.target = playerObj.transform;
			SpawnedMonsters.Add(val3);
		}

		public static Texture2D LoadPNG(string filePath)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				if (File.Exists(filePath))
				{
					byte[] array = File.ReadAllBytes(filePath);
					Texture2D val = new Texture2D(2, 2);
					ImageConversion.LoadImage(val, array);
					return val;
				}
			}
			catch
			{
			}
			return null;
		}
	}
	public class StalkerAI : MonoBehaviour
	{
		public Transform target;

		private Rigidbody rb;

		private float nextAttackTime = 0f;

		private Vector3 lastPos;

		private float stuckTimer = 0f;

		private float stuckThreshold = 0.5f;

		private static MonoBehaviour _afflictionsComp;

		private static MethodInfo _addStatusMethod;

		private static bool _reflectionFailed;

		private void Start()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			rb = ((Component)this).gameObject.AddComponent<Rigidbody>();
			rb.constraints = (RigidbodyConstraints)112;
			rb.mass = 60f;
			rb.drag = 1f;
			rb.useGravity = true;
			rb.interpolation = (RigidbodyInterpolation)1;
			lastPos = ((Component)this).transform.position;
			((MonoBehaviour)this).InvokeRepeating("CheckStuck", 1f, 1f);
		}

		private void CheckStuck()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null)
			{
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, target.position) > 5f && Vector3.Distance(((Component)this).transform.position, lastPos) < stuckThreshold)
			{
				stuckTimer += 1f;
				if (stuckTimer >= 3f)
				{
					((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, target.position, 0.2f) + Vector3.up * 2f;
					stuckTimer = 0f;
				}
			}
			else
			{
				stuckTimer = 0f;
			}
			lastPos = ((Component)this).transform.position;
		}

		private void FixedUpdate()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: 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_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null)
			{
				GameObject val = GameObject.FindGameObjectWithTag("Player") ?? GameObject.Find("Player") ?? GameObject.Find("FPSController");
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				target = val.transform;
			}
			float num = Vector3.Distance(((Component)this).transform.position, target.position);
			if (num > 60f)
			{
				Vector3 val2 = target.position - target.forward * 20f;
				val2.y = target.position.y + 1f;
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(val2 + Vector3.up * 10f, Vector3.down, ref val3, 20f))
				{
					val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 1.5f;
				}
				((Component)this).transform.position = val2;
			}
			Vector3 val4 = target.position - ((Component)this).transform.position;
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			bool flag = Physics.Raycast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)this).transform.forward, 1.5f);
			bool flag2 = target.position.y - ((Component)this).transform.position.y > 1.5f;
			if (flag && flag2)
			{
				rb.velocity = new Vector3(0f, Plugin.MONSTER_CLIMB, 0f);
			}
			else
			{
				if (flag && !flag2 && !Physics.Raycast(((Component)this).transform.position + Vector3.up * 2.2f, ((Component)this).transform.forward, 2f) && IsGrounded())
				{
					rb.AddForce(Vector3.up * 10f, (ForceMode)1);
				}
				Vector3 velocity = normalized * Plugin.MONSTER_SPEED;
				velocity.y = rb.velocity.y;
				rb.velocity = velocity;
			}
			Vector3 position = target.position;
			position.y = ((Component)this).transform.position.y;
			((Component)this).transform.LookAt(position);
			if (num < 3f && Time.time > nextAttackTime)
			{
				DealDamage(((Component)target).gameObject);
				ApplyAfflictionDamage(((Component)target).gameObject);
				nextAttackTime = Time.time + 1.5f;
			}
		}

		private bool IsGrounded()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return Physics.Raycast(((Component)this).transform.position + Vector3.up * 0.5f, Vector3.down, 1.2f);
		}

		private void DealDamage(GameObject player)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Plugin.FileLog("[COMBAT] YEET START!");
			Vector3 val = player.transform.position - ((Component)this).transform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = normalized + Vector3.up * 2f;
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(Plugin.Instance.YeetPlayer(player, normalized2));
			}
		}

		private void ApplyAfflictionDamage(GameObject player)
		{
			if (_reflectionFailed)
			{
				return;
			}
			try
			{
				if ((Object)(object)_afflictionsComp == (Object)null)
				{
					MonoBehaviour[] componentsInChildren = player.GetComponentsInChildren<MonoBehaviour>(true);
					MonoBehaviour[] array = componentsInChildren;
					foreach (MonoBehaviour val in array)
					{
						if (((object)val).GetType().Name == "CharacterAfflictions")
						{
							_afflictionsComp = val;
							Plugin.FileLog("[COMBAT] Found CharacterAfflictions!");
							break;
						}
					}
					if ((Object)(object)_afflictionsComp == (Object)null)
					{
						MonoBehaviour[] array2 = Object.FindObjectsOfType<MonoBehaviour>();
						MonoBehaviour[] array3 = array2;
						foreach (MonoBehaviour val2 in array3)
						{
							if (((object)val2).GetType().Name == "CharacterAfflictions")
							{
								_afflictionsComp = val2;
								Plugin.FileLog("[COMBAT] Found CharacterAfflictions (Global)!");
								break;
							}
						}
					}
				}
				if ((Object)(object)_afflictionsComp != (Object)null && _addStatusMethod == null)
				{
					MethodInfo[] methods = ((object)_afflictionsComp).GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public);
					MethodInfo[] array4 = methods;
					foreach (MethodInfo methodInfo in array4)
					{
						if (methodInfo.Name == "AddStatus")
						{
							ParameterInfo[] parameters = methodInfo.GetParameters();
							if (parameters.Length == 4)
							{
								_addStatusMethod = methodInfo;
								Plugin.FileLog("[REFLECTION] Selected 4-arg overload (MATCH FOUND).");
								break;
							}
						}
					}
					if (_addStatusMethod == null)
					{
						Plugin.FileLog("[COMBAT] CRITICAL: 4-Arg AddStatus method not found!");
						_reflectionFailed = true;
						return;
					}
				}
				if ((Object)(object)_afflictionsComp != (Object)null && _addStatusMethod != null)
				{
					_addStatusMethod.Invoke(_afflictionsComp, new object[4]
					{
						Plugin.DAMAGE_TYPE,
						Plugin.DAMAGE_AMOUNT,
						false,
						false
					});
					Plugin.FileLog($"[COMBAT] Applied {Plugin.DAMAGE_AMOUNT} (Type {Plugin.DAMAGE_TYPE})");
				}
			}
			catch (Exception ex)
			{
				Plugin.FileLog("[COMBAT] Reflection Error: " + ex.Message);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}