Decompiled source of TemerskieModLethal v1.0.0

TemerskieModLethal.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TemerskieModLethal")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TemerskieModLethal")]
[assembly: AssemblyTitle("TemerskieModLethal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 TemerskieModLethal
{
	internal static class GLTFLoader
	{
		public static GameObject LoadZmoraPrefab()
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_01bf: 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)
			string path = Path.Combine(TemerskieMod._pluginDir, "zmora");
			string path2 = Path.Combine(path, "scene.gltf");
			string path3 = Path.Combine(path, "scene.bin");
			string text = File.ReadAllText(path2);
			byte[] bin = File.ReadAllBytes(path3);
			JObject val = JObject.Parse(text);
			List<JToken> accessors = ParseAccessors(val);
			List<JToken> bufferViews = ParseBufferViews(val);
			string texturesDir = Path.Combine(path, "textures");
			List<Material> materials = BuildMaterials(val, texturesDir);
			List<GameObject> list = new List<GameObject>();
			JToken obj = val["meshes"];
			JArray val2 = (JArray)(object)((obj is JArray) ? obj : null);
			if (val2 != null)
			{
				for (int i = 0; i < ((JContainer)val2).Count; i++)
				{
					JToken val3 = val2[i];
					JToken obj2 = val3[(object)"primitives"];
					JArray val4 = (JArray)(object)((obj2 is JArray) ? obj2 : null);
					if (val4 == null)
					{
						continue;
					}
					for (int j = 0; j < ((JContainer)val4).Count; j++)
					{
						JToken prim = val4[j];
						GameObject val5 = BuildMeshGO($"ZmoraMesh{i}_{j}", bin, bufferViews, accessors, prim, materials);
						if ((Object)(object)val5 != (Object)null)
						{
							list.Add(val5);
						}
					}
				}
			}
			if (list.Count == 0)
			{
				throw new Exception("No meshes built from GLTF");
			}
			GameObject val6 = new GameObject("ZmoraPrefab");
			foreach (GameObject item in list)
			{
				item.transform.SetParent(val6.transform, false);
			}
			val6.transform.localScale = Vector3.one * 0.01f;
			return val6;
		}

		private static List<JToken> ParseAccessors(JObject root)
		{
			List<JToken> list = new List<JToken>();
			JToken obj = root["accessors"];
			JArray val = (JArray)(object)((obj is JArray) ? obj : null);
			if (val != null)
			{
				foreach (JToken item in val)
				{
					list.Add(item);
				}
			}
			return list;
		}

		private static List<JToken> ParseBufferViews(JObject root)
		{
			List<JToken> list = new List<JToken>();
			JToken obj = root["bufferViews"];
			JArray val = (JArray)(object)((obj is JArray) ? obj : null);
			if (val != null)
			{
				foreach (JToken item in val)
				{
					list.Add(item);
				}
			}
			return list;
		}

		private static List<Material> BuildMaterials(JObject root, string texturesDir)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			Shader val = Shader.Find("HDRP/Lit");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Standard");
			}
			List<Material> list = new List<Material>();
			JToken obj = root["materials"];
			JArray val2 = (JArray)(object)((obj is JArray) ? obj : null);
			if (val2 == null)
			{
				return list;
			}
			JToken obj2 = root["textures"];
			JArray textures = (JArray)(object)((obj2 is JArray) ? obj2 : null);
			JToken obj3 = root["images"];
			JArray images = (JArray)(object)((obj3 is JArray) ? obj3 : null);
			foreach (JToken item in val2)
			{
				Material val3 = new Material(val);
				JToken val4 = item[(object)"pbrMetallicRoughness"];
				if (val4 != null)
				{
					JToken val5 = val4[(object)"baseColorTexture"];
					if (val5 != null)
					{
						int texIdx = (int)(val5[(object)"index"] ?? JToken.op_Implicit(-1));
						Texture2D val6 = LoadTextureFromIndex(textures, images, texturesDir, texIdx);
						if ((Object)(object)val6 != (Object)null)
						{
							val3.SetTexture("_BaseColorMap", (Texture)(object)val6);
							if (((Object)val).name == "Standard")
							{
								val3.SetTexture("_MainTex", (Texture)(object)val6);
							}
						}
					}
				}
				JToken val7 = item[(object)"normalTexture"];
				if (val7 != null)
				{
					int texIdx2 = (int)(val7[(object)"index"] ?? JToken.op_Implicit(-1));
					Texture2D val8 = LoadTextureFromIndex(textures, images, texturesDir, texIdx2);
					if ((Object)(object)val8 != (Object)null)
					{
						val3.SetTexture("_NormalMap", (Texture)(object)val8);
						if (((Object)val).name == "Standard")
						{
							val3.SetTexture("_BumpMap", (Texture)(object)val8);
						}
					}
				}
				list.Add(val3);
			}
			return list;
		}

		private static Texture2D? LoadTextureFromIndex(JArray? textures, JArray? images, string texturesDir, int texIdx)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			if (textures == null || images == null)
			{
				return null;
			}
			if (texIdx < 0 || texIdx >= ((JContainer)textures).Count)
			{
				return null;
			}
			JToken val = textures[texIdx];
			int num = (int)(val[(object)"source"] ?? JToken.op_Implicit(-1));
			if (num < 0 || num >= ((JContainer)images).Count)
			{
				return null;
			}
			string text = (string)images[num][(object)"uri"];
			if (string.IsNullOrEmpty(text))
			{
				return null;
			}
			string text2 = Path.Combine(texturesDir, text.Replace('/', Path.DirectorySeparatorChar));
			if (!File.Exists(text2))
			{
				return null;
			}
			try
			{
				byte[] array = File.ReadAllBytes(text2);
				Texture2D val2 = new Texture2D(2, 2);
				ImageConversion.LoadImage(val2, array);
				((Texture)val2).wrapMode = (TextureWrapMode)0;
				return val2;
			}
			catch (Exception arg)
			{
				ManualLogSource? log = TemerskieMod._log;
				if (log != null)
				{
					log.LogWarning((object)$"Failed to load texture {text2}: {arg}");
				}
				return null;
			}
		}

		private static GameObject? BuildMeshGO(string name, byte[] bin, List<JToken> bufferViews, List<JToken> accessors, JToken prim, List<Material> materials)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			JToken obj = prim[(object)"attributes"];
			JObject val = (JObject)(object)((obj is JObject) ? obj : null);
			if (val == null)
			{
				return null;
			}
			List<Vector3> list = ReadVec3(bin, bufferViews, accessors, GetAccessorIndex(val, "POSITION"));
			List<Vector3> list2 = ReadVec3(bin, bufferViews, accessors, GetAccessorIndex(val, "NORMAL"));
			List<Vector2> list3 = ReadVec2(bin, bufferViews, accessors, GetAccessorIndex(val, "TEXCOORD_0"));
			List<int> list4 = ReadIndices(bin, bufferViews, accessors, prim[(object)"indices"]);
			if (list == null || list4 == null)
			{
				return null;
			}
			Mesh val2 = new Mesh();
			((Object)val2).name = name;
			val2.SetVertices(list);
			if (list2 != null)
			{
				val2.SetNormals(list2);
			}
			else
			{
				val2.RecalculateNormals();
			}
			if (list3 != null)
			{
				val2.SetUVs(0, list3);
			}
			val2.subMeshCount = 1;
			val2.SetTriangles(list4, 0);
			val2.RecalculateBounds();
			GameObject val3 = new GameObject(name);
			val3.AddComponent<MeshFilter>().sharedMesh = val2;
			MeshRenderer val4 = val3.AddComponent<MeshRenderer>();
			int num = ((prim[(object)"material"] != null) ? ((int)(prim[(object)"material"] ?? JToken.op_Implicit(-1))) : (-1));
			if (num >= 0 && num < materials.Count)
			{
				((Renderer)val4).sharedMaterial = materials[num];
			}
			else if (materials.Count > 0)
			{
				((Renderer)val4).sharedMaterial = materials[0];
			}
			return val3;
		}

		private static int GetAccessorIndex(JObject attrs, string key)
		{
			JToken val = attrs[key];
			return (val != null) ? ((int)val) : (-1);
		}

		private static int GetAccessorInt(JToken acc, string field, int defaultVal = 0)
		{
			JToken val = acc[(object)field];
			return (val != null) ? ((int)val) : defaultVal;
		}

		private static List<Vector3>? ReadVec3(byte[] bin, List<JToken> bufferViews, List<JToken> accessors, int accIdx)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if (accIdx < 0 || accIdx >= accessors.Count)
			{
				return null;
			}
			JToken acc = accessors[accIdx];
			int accessorInt = GetAccessorInt(acc, "bufferView");
			int accessorInt2 = GetAccessorInt(acc, "byteOffset");
			int accessorInt3 = GetAccessorInt(acc, "count");
			if (accessorInt < 0 || accessorInt >= bufferViews.Count)
			{
				return null;
			}
			JToken val = bufferViews[accessorInt];
			int accessorInt4 = GetAccessorInt(val, "byteOffset");
			JToken val2 = val[(object)"byteStride"];
			int num = ((val2 != null) ? ((int)(val2 ?? JToken.op_Implicit(12))) : 12);
			int num2 = accessorInt4 + accessorInt2;
			if (num2 + accessorInt3 * num > bin.Length)
			{
				return null;
			}
			List<Vector3> list = new List<Vector3>(accessorInt3);
			for (int i = 0; i < accessorInt3; i++)
			{
				int num3 = num2 + i * num;
				float num4 = BitConverter.ToSingle(bin, num3);
				float num5 = BitConverter.ToSingle(bin, num3 + 4);
				float num6 = BitConverter.ToSingle(bin, num3 + 8);
				list.Add(new Vector3(num4, num5, 0f - num6));
			}
			return list;
		}

		private static List<Vector2>? ReadVec2(byte[] bin, List<JToken> bufferViews, List<JToken> accessors, int accIdx)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (accIdx < 0 || accIdx >= accessors.Count)
			{
				return null;
			}
			JToken acc = accessors[accIdx];
			int accessorInt = GetAccessorInt(acc, "bufferView");
			int accessorInt2 = GetAccessorInt(acc, "byteOffset");
			int accessorInt3 = GetAccessorInt(acc, "count");
			if (accessorInt < 0 || accessorInt >= bufferViews.Count)
			{
				return null;
			}
			JToken val = bufferViews[accessorInt];
			int accessorInt4 = GetAccessorInt(val, "byteOffset");
			JToken val2 = val[(object)"byteStride"];
			int num = ((val2 != null) ? ((int)val2) : 8);
			int num2 = accessorInt4 + accessorInt2;
			if (num2 + accessorInt3 * num > bin.Length)
			{
				return null;
			}
			List<Vector2> list = new List<Vector2>(accessorInt3);
			for (int i = 0; i < accessorInt3; i++)
			{
				int num3 = num2 + i * num;
				float num4 = BitConverter.ToSingle(bin, num3);
				float num5 = BitConverter.ToSingle(bin, num3 + 4);
				list.Add(new Vector2(num4, num5));
			}
			return list;
		}

		private static List<int>? ReadIndices(byte[] bin, List<JToken> bufferViews, List<JToken> accessors, JToken? indicesToken)
		{
			if (indicesToken == null)
			{
				return null;
			}
			int num = (int)indicesToken;
			if (num < 0 || num >= accessors.Count)
			{
				return null;
			}
			JToken acc = accessors[num];
			int accessorInt = GetAccessorInt(acc, "bufferView");
			int accessorInt2 = GetAccessorInt(acc, "byteOffset");
			int accessorInt3 = GetAccessorInt(acc, "count");
			int accessorInt4 = GetAccessorInt(acc, "componentType", 5125);
			if (accessorInt < 0 || accessorInt >= bufferViews.Count)
			{
				return null;
			}
			JToken acc2 = bufferViews[accessorInt];
			int accessorInt5 = GetAccessorInt(acc2, "byteOffset");
			if (1 == 0)
			{
			}
			int num2 = accessorInt4 switch
			{
				5121 => 1, 
				5123 => 2, 
				5125 => 4, 
				_ => 4, 
			};
			if (1 == 0)
			{
			}
			int num3 = num2;
			int num4 = accessorInt5 + accessorInt2;
			if (num4 + accessorInt3 * num3 > bin.Length)
			{
				return null;
			}
			List<int> list = new List<int>(accessorInt3);
			for (int i = 0; i < accessorInt3; i++)
			{
				int num5 = num4 + i * num3;
				if (1 == 0)
				{
				}
				num2 = accessorInt4 switch
				{
					5121 => bin[num5], 
					5123 => BitConverter.ToUInt16(bin, num5), 
					5125 => (int)BitConverter.ToUInt32(bin, num5), 
					_ => BitConverter.ToInt32(bin, num5), 
				};
				if (1 == 0)
				{
				}
				int item = num2;
				list.Add(item);
			}
			return list;
		}
	}
	[BepInPlugin("TemerskieModLethal", "Temerskie Mod Lethal", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TemerskieMod : BaseUnityPlugin
	{
		public const string PluginGuid = "TemerskieModLethal";

		public const string PluginName = "Temerskie Mod Lethal";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource? _log;

		internal static string? _pluginDir;

		internal static GameObject? ZmoraPrefab;

		internal static EnemyType? ZmoraEnemyType;

		internal static bool ForceBialaMewa;

		private void Awake()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			_log = ((BaseUnityPlugin)this).Logger;
			_pluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Loading {0} v{1} [BUILD-{2:yyyyMMdd-HHmmss}]...", "Temerskie Mod Lethal", "1.0.0", DateTime.Now));
			try
			{
				Harmony val = new Harmony("TemerskieModLethal");
				val.PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Harmony init failed: {arg}");
			}
			GameObject val2 = new GameObject("ZmoraDirectionUI");
			val2.AddComponent<ZmoraDirectionUI>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"TemerskieModLethal loaded!");
		}

		internal static void BuildZmoraAssets()
		{
			try
			{
				GameObject val = GLTFLoader.LoadZmoraPrefab();
				((Object)val).name = "ZmoraEnemy";
				if ((Object)(object)val.GetComponent<NetworkObject>() == (Object)null)
				{
					val.AddComponent<NetworkObject>();
				}
				if ((Object)(object)val.GetComponent<Animator>() == (Object)null)
				{
					val.AddComponent<Animator>();
				}
				if ((Object)(object)val.GetComponent<AudioSource>() == (Object)null)
				{
					val.AddComponent<AudioSource>();
				}
				if ((Object)(object)val.GetComponent<ZmoraAI>() == (Object)null)
				{
					val.AddComponent<ZmoraAI>();
				}
				ApplyDarkThemeToModel(val);
				AddSmokeParticles(val);
				EnemyType val2 = ScriptableObject.CreateInstance<EnemyType>();
				val2.enemyName = "Zmora";
				val2.enemyPrefab = val;
				val2.canDie = true;
				val2.canBeDestroyed = true;
				val2.canBeStunned = true;
				val2.destroyOnDeath = true;
				val2.isOutsideEnemy = false;
				Object.DontDestroyOnLoad((Object)(object)val);
				NetworkPrefabs.RegisterNetworkPrefab(val);
				ZmoraPrefab = val;
				ZmoraEnemyType = val2;
				ManualLogSource? log = _log;
				if (log != null)
				{
					log.LogInfo((object)"Zmora assets built successfully");
				}
			}
			catch (Exception arg)
			{
				ManualLogSource? log2 = _log;
				if (log2 != null)
				{
					log2.LogError((object)$"Failed to build Zmora assets: {arg}");
				}
			}
		}

		private static void ApplyDarkThemeToModel(GameObject model)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0087: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = model.GetComponentsInChildren<MeshRenderer>(true);
			MeshRenderer[] array = componentsInChildren;
			Color val4 = default(Color);
			foreach (MeshRenderer val in array)
			{
				Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Material val2 = sharedMaterials[j];
					if (!((Object)(object)val2 == (Object)null))
					{
						Material val3 = new Material(val2);
						((Object)val3).name = ((Object)val2).name + "_DarkTheme";
						((Color)(ref val4))..ctor(0.05f, 0.03f, 0.08f, 1f);
						val3.SetColor("_BaseColor", val4);
						if (val3.HasProperty("_Color"))
						{
							val3.SetColor("_Color", val4);
						}
						if (val3.HasProperty("_EmissiveColor"))
						{
							val3.SetColor("_EmissiveColor", new Color(0.02f, 0.01f, 0.03f, 1f));
						}
						if (val3.HasProperty("_BaseColorMap"))
						{
							val3.SetTexture("_BaseColorMap", val3.GetTexture("_BaseColorMap"));
						}
						val3.SetFloat("_SurfaceType", 0f);
						val3.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
						val3.renderQueue = 2000;
						if (val3.HasProperty("_Metallic"))
						{
							val3.SetFloat("_Metallic", 0.2f);
						}
						if (val3.HasProperty("_Smoothness"))
						{
							val3.SetFloat("_Smoothness", 0.5f);
						}
						sharedMaterials[j] = val3;
					}
				}
				((Renderer)val).sharedMaterials = sharedMaterials;
			}
		}

		private static void AddSmokeParticles(GameObject root)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: 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)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ZmoraSmokeParticles");
			val.transform.SetParent(root.transform, false);
			val.transform.localPosition = new Vector3(0f, 0.9f, 0f);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 2f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 0.8f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.2f, 0.8f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.15f, 0.4f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.15f, 0.1f, 0.2f, 0.4f), new Color(0.05f, 0.02f, 0.1f, 0.15f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(15f);
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.35f;
			((ShapeModule)(ref shape)).position = Vector3.zero;
			((ShapeModule)(ref shape)).alignToDirection = false;
			((ShapeModule)(ref shape)).randomDirectionAmount = 1f;
			((ShapeModule)(ref shape)).sphericalDirectionAmount = 1f;
			VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.1f, 0.5f);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			AnimationCurve val3 = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.2f),
				new Keyframe(0.5f, 1f),
				new Keyframe(1f, 0f)
			});
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val3);
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val4 = new Gradient();
			val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(0.15f, 0.1f, 0.2f), 0f),
				new GradientColorKey(new Color(0.1f, 0.05f, 0.15f), 0.5f),
				new GradientColorKey(new Color(0.05f, 0.02f, 0.1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0.4f, 0f),
				new GradientAlphaKey(0.3f, 0.3f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4);
			NoiseModule noise = val2.noise;
			((NoiseModule)(ref noise)).enabled = true;
			((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.3f);
			((NoiseModule)(ref noise)).frequency = 0.5f;
			((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.2f);
		}

		internal static (Mesh mesh, Material mat, GameObject prefab) BuildAssets()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(_pluginDir, "Scene_-_Root_baseColor.png");
			if (!File.Exists(text))
			{
				throw new Exception("Texture not found: " + text);
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
			ImageConversion.LoadImage(val, array);
			((Texture)val).wrapMode = (TextureWrapMode)0;
			Mesh val2 = LoadMesh();
			Shader val3 = Shader.Find("HDRP/Lit") ?? throw new Exception("HDRP/Lit shader not found!");
			Material val4 = new Material(val3);
			val4.SetTexture("_BaseColorMap", (Texture)(object)val);
			val4.SetColor("_BaseColor", Color.white);
			val4.enableInstancing = true;
			Sprite icon = LoadIcon();
			GameObject val5 = BuildPrefab(val2, val4, icon);
			Object.DontDestroyOnLoad((Object)(object)val5);
			NetworkPrefabs.RegisterNetworkPrefab(val5);
			return (mesh: val2, mat: val4, prefab: val5);
		}

		internal static Sprite? LoadIcon()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			string path = Path.Combine(_pluginDir, "temerczyk.png");
			if (!File.Exists(path))
			{
				ManualLogSource? log = _log;
				if (log != null)
				{
					log.LogInfo((object)"temerczyk.png not found, no icon set");
				}
				return null;
			}
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}

		internal static (AudioClip? grab, AudioClip? drop, AudioClip? pocket, AudioClip? throwSfx, AudioClip[] clinks) LoadFlaskAudio()
		{
			Item val = ((IEnumerable<Item>)Resources.FindObjectsOfTypeAll<Item>()).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemName.IndexOf("flask", StringComparison.OrdinalIgnoreCase) >= 0));
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource? log = _log;
				if (log != null)
				{
					log.LogWarning((object)"Flask item not found, no audio");
				}
				return (grab: null, drop: null, pocket: null, throwSfx: null, clinks: Array.Empty<AudioClip>());
			}
			ManualLogSource? log2 = _log;
			if (log2 != null)
			{
				log2.LogInfo((object)"Found flask item, copying audio clips");
			}
			return (grab: val.grabSFX, drop: val.dropSFX, pocket: val.pocketSFX, throwSfx: val.throwSFX, clinks: val.clinkAudios);
		}

		private static Mesh LoadMesh()
		{
			string path = Path.Combine(_pluginDir, "temerczyk.obj");
			if (File.Exists(path))
			{
				ManualLogSource? log = _log;
				if (log != null)
				{
					log.LogInfo((object)"Loading temerczyk.obj...");
				}
				try
				{
					return ObjLoader.Load(path);
				}
				catch (Exception arg)
				{
					ManualLogSource? log2 = _log;
					if (log2 != null)
					{
						log2.LogWarning((object)$"OBJ load failed: {arg}, falling back to procedural mesh");
					}
				}
			}
			else
			{
				ManualLogSource? log3 = _log;
				if (log3 != null)
				{
					log3.LogInfo((object)"temerczyk.obj not found, using procedural mesh");
				}
			}
			return BuildProceduralMesh();
		}

		private static Mesh BuildProceduralMesh()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			Mesh val = new Mesh();
			((Object)val).name = "TemerskieProcedural";
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector3> normals = new List<Vector3>();
			List<int> list3 = new List<int>();
			AddCylinder(list, list2, normals, list3, 0f, 0.4125f, 0.081f, 12);
			AddCone(list, list2, normals, list3, 0.4125f, 0.55f, 0.081f, 12);
			AddCylinder(list, list2, normals, list3, 13f / 32f, 93f / 160f, 0.056f, 12);
			AddCylinder(list, list2, normals, list3, 91f / 160f, 19f / 32f, 0.069f, 12);
			AddCylinder(list, list2, normals, list3, 0.5875f, 0.6f, 0.0625f, 12);
			val.SetVertices(list);
			val.SetUVs(0, list2);
			val.SetNormals(normals);
			val.subMeshCount = 1;
			val.SetTriangles(list3, 0);
			val.RecalculateBounds();
			val.Optimize();
			return val;
		}

		private static void AddCylinder(List<Vector3> verts, List<Vector2> uvs, List<Vector3> normals, List<int> tris, float yBot, float yTop, float radius, int segs)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00ef: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			int count = verts.Count;
			verts.Add(new Vector3(0f, yTop, 0f));
			uvs.Add(new Vector2(0.5f, 0.95f));
			normals.Add(Vector3.up);
			verts.Add(new Vector3(0f, yBot, 0f));
			uvs.Add(new Vector2(0.5f, 0.05f));
			normals.Add(Vector3.down);
			for (int i = 0; i < segs; i++)
			{
				float num = (float)i / (float)segs * MathF.PI * 2f;
				float num2 = Mathf.Cos(num) * radius;
				float num3 = Mathf.Sin(num) * radius;
				verts.Add(new Vector3(num2, yTop, num3));
				uvs.Add(new Vector2((float)i / (float)segs, 1f));
				Vector3 val = new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num));
				normals.Add(((Vector3)(ref val)).normalized);
				verts.Add(new Vector3(num2, yBot, num3));
				uvs.Add(new Vector2((float)i / (float)segs, 0f));
				val = new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num));
				normals.Add(((Vector3)(ref val)).normalized);
			}
			for (int j = 0; j < segs; j++)
			{
				int num4 = (j + 1) % segs;
				int item = count + 2 + j * 2;
				int item2 = count + 2 + num4 * 2;
				tris.Add(count);
				tris.Add(item2);
				tris.Add(item);
				item = count + 2 + j * 2 + 1;
				item2 = count + 2 + num4 * 2 + 1;
				tris.Add(count + 1);
				tris.Add(item);
				tris.Add(item2);
				int num5 = count + 2 + j * 2;
				int item3 = num5 + 1;
				int num6 = count + 2 + num4 * 2;
				int item4 = num6 + 1;
				tris.Add(num5);
				tris.Add(num6);
				tris.Add(item3);
				tris.Add(num6);
				tris.Add(item4);
				tris.Add(item3);
			}
		}

		private static void AddCone(List<Vector3> verts, List<Vector2> uvs, List<Vector3> normals, List<int> tris, float yBot, float yTop, float radius, int segs)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			int count = verts.Count;
			verts.Add(new Vector3(0f, yBot, 0f));
			uvs.Add(new Vector2(0.5f, 0.05f));
			normals.Add(Vector3.down);
			verts.Add(new Vector3(0f, yTop, 0f));
			uvs.Add(new Vector2(0.5f, 0.95f));
			normals.Add(Vector3.up);
			for (int i = 0; i < segs; i++)
			{
				float num = (float)i / (float)segs * MathF.PI * 2f;
				verts.Add(new Vector3(Mathf.Cos(num) * radius, yBot, Mathf.Sin(num) * radius));
				uvs.Add(new Vector2((float)i / (float)segs, 0f));
				Vector3 val = new Vector3(Mathf.Cos(num), 0.5f, Mathf.Sin(num));
				normals.Add(((Vector3)(ref val)).normalized);
			}
			for (int j = 0; j < segs; j++)
			{
				int num2 = (j + 1) % segs;
				int item = count + 2 + j;
				int item2 = count + 2 + num2;
				tris.Add(count);
				tris.Add(item);
				tris.Add(item2);
				tris.Add(item);
				tris.Add(count + 1);
				tris.Add(item2);
			}
		}

		private static GameObject BuildPrefab(Mesh mesh, Material mat, Sprite? icon)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			GameObject val = new GameObject("TemerskieScrap");
			val.tag = "PhysicsProp";
			val.layer = LayerMask.NameToLayer("Props");
			val.transform.localScale = Vector3.one * 0.0025f;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
			Bounds bounds = mesh.bounds;
			val.AddComponent<BoxCollider>();
			TemerskieProp temerskieProp = val.AddComponent<TemerskieProp>();
			((GrabbableObject)temerskieProp).grabbable = true;
			((GrabbableObject)temerskieProp).grabbableToEnemies = true;
			((GrabbableObject)temerskieProp).floorYRot = -1;
			((GrabbableObject)temerskieProp).rotateObject = true;
			Item val2 = ScriptableObject.CreateInstance<Item>();
			val2.itemName = "Temerskie";
			val2.weight = 1.18f;
			val2.isScrap = true;
			val2.itemSpawnsOnGround = true;
			val2.canBeGrabbedBeforeGameStart = true;
			val2.twoHanded = false;
			val2.twoHandedAnimation = false;
			val2.isConductiveMetal = true;
			val2.isDefensiveWeapon = true;
			val2.holdButtonUse = false;
			val2.syncUseFunction = true;
			val2.toolTips = new string[1] { "Wypij za Temerie : [LMB]" };
			val2.minValue = 60;
			val2.maxValue = 160;
			val2.spawnPrefab = val;
			val2.restingRotation = new Vector3(0f, -90f, 0f);
			val2.rotationOffset = new Vector3(0f, 0f, 0f);
			val2.positionOffset = new Vector3(0f, 0.15f, 0.2f);
			val2.meshVariants = (Mesh[])(object)new Mesh[1] { mesh };
			val2.materialVariants = (Material[])(object)new Material[1] { mat };
			(AudioClip? grab, AudioClip? drop, AudioClip? pocket, AudioClip? throwSfx, AudioClip[] clinks) tuple = LoadFlaskAudio();
			AudioClip item = tuple.grab;
			AudioClip item2 = tuple.drop;
			AudioClip item3 = tuple.pocket;
			AudioClip item4 = tuple.throwSfx;
			AudioClip[] item5 = tuple.clinks;
			val2.grabSFX = item;
			val2.dropSFX = item2;
			val2.pocketSFX = item3;
			val2.throwSFX = item4;
			val2.clinkAudios = item5;
			val2.spawnPositionTypes = new List<ItemGroup>();
			val2.itemIcon = icon;
			((GrabbableObject)temerskieProp).itemProperties = val2;
			val.AddComponent<AudioSource>().spatialBlend = 1f;
			val.GetComponent<AudioSource>().pitch = 0.8f;
			val.AddComponent<NetworkObject>().SynchronizeTransform = true;
			GameObject val3 = new GameObject("ScanNode");
			val3.transform.SetParent(val.transform, false);
			val3.layer = LayerMask.NameToLayer("ScanNode");
			((Collider)val3.AddComponent<BoxCollider>()).isTrigger = true;
			ScanNodeProperties val4 = val3.AddComponent<ScanNodeProperties>();
			val4.maxRange = 13;
			val4.minRange = 1;
			val4.requiresLineOfSight = true;
			val4.headerText = "Temerskie";
			val4.subText = "Value: ";
			val4.scrapValue = 0;
			val4.creatureScanID = -1;
			val4.nodeType = 2;
			return val;
		}
	}
	internal static class ObjLoader
	{
		public static Mesh Load(string path)
		{
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Expected O, but got Unknown
			//IL_0150: 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_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			string[] array = File.ReadAllLines(path);
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector3> list3 = new List<Vector3>();
			List<Vector3> list4 = new List<Vector3>();
			List<Vector2> list5 = new List<Vector2>();
			List<Vector3> list6 = new List<Vector3>();
			List<int> list7 = new List<int>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string text2 = text.Trim();
				if (text2.Length == 0 || text2.StartsWith("#") || text2.StartsWith("o ") || text2.StartsWith("s ") || text2.StartsWith("g ") || text2.StartsWith("usemtl ") || text2.StartsWith("mtllib "))
				{
					continue;
				}
				string[] array3 = text2.Split(' ', StringSplitOptions.RemoveEmptyEntries);
				if (array3.Length == 0)
				{
					continue;
				}
				if (array3[0] == "v" && array3.Length >= 4)
				{
					if (float.TryParse(array3[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array3[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array3[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
					{
						list.Add(new Vector3(result, result2, result3));
					}
				}
				else if (array3[0] == "vt" && array3.Length >= 3)
				{
					if (float.TryParse(array3[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4) && float.TryParse(array3[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result5))
					{
						list2.Add(new Vector2(result4, result5));
					}
				}
				else if (array3[0] == "vn" && array3.Length >= 4)
				{
					if (float.TryParse(array3[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result6) && float.TryParse(array3[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result7) && float.TryParse(array3[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result8))
					{
						list3.Add(new Vector3(result6, result7, result8));
					}
				}
				else
				{
					if (!(array3[0] == "f"))
					{
						continue;
					}
					List<int> list8 = new List<int>();
					List<int> list9 = new List<int>();
					List<int> list10 = new List<int>();
					for (int j = 1; j < array3.Length; j++)
					{
						string[] array4 = array3[j].Split('/');
						if (array4.Length != 0 && int.TryParse(array4[0], out var result9))
						{
							list8.Add((result9 < 0) ? (list.Count + result9) : (result9 - 1));
						}
						if (array4.Length > 1 && array4[1].Length > 0 && int.TryParse(array4[1], out var result10))
						{
							list9.Add((result10 < 0) ? (list2.Count + result10) : (result10 - 1));
						}
						if (array4.Length > 2 && array4[2].Length > 0 && int.TryParse(array4[2], out var result11))
						{
							list10.Add((result11 < 0) ? (list3.Count + result11) : (result11 - 1));
						}
					}
					if (list8.Count >= 3)
					{
						for (int k = 1; k < list8.Count - 1; k++)
						{
							int count = list4.Count;
							list4.Add(list[list8[0]]);
							list5.Add((list9.Count > 0) ? list2[list9[0]] : Vector2.zero);
							list6.Add((list10.Count > 0) ? list3[list10[0]] : Vector3.up);
							int count2 = list4.Count;
							list4.Add(list[list8[k]]);
							list5.Add((list9.Count > k) ? list2[list9[k]] : Vector2.zero);
							list6.Add((list10.Count > k) ? list3[list10[k]] : Vector3.up);
							int count3 = list4.Count;
							list4.Add(list[list8[k + 1]]);
							list5.Add((list9.Count > k + 1) ? list2[list9[k + 1]] : Vector2.zero);
							list6.Add((list10.Count > k + 1) ? list3[list10[k + 1]] : Vector3.up);
							list7.Add(count);
							list7.Add(count2);
							list7.Add(count3);
						}
					}
				}
			}
			if (list7.Count == 0)
			{
				throw new Exception("No triangles generated from OBJ");
			}
			Mesh val = new Mesh();
			((Object)val).name = "TemerskieOBJ";
			val.SetVertices(list4);
			val.SetUVs(0, list5);
			val.SetNormals(list6);
			val.subMeshCount = 1;
			val.SetTriangles(list7, 0);
			val.RecalculateBounds();
			return val;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatches
	{
		private static GameObject? _prefab;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AfterStartOfRoundAwake(StartOfRound __instance)
		{
			ManualLogSource? log = TemerskieMod._log;
			if (log != null)
			{
				log.LogInfo((object)"BuildAssets starting...");
			}
			try
			{
				(Mesh mesh, Material mat, GameObject prefab) tuple = TemerskieMod.BuildAssets();
				Mesh item = tuple.mesh;
				Material item2 = tuple.mat;
				GameObject item3 = tuple.prefab;
				_prefab = item3;
				RegisterScrap(__instance, item, item2);
				TemerskieMod.BuildZmoraAssets();
				ManualLogSource? log2 = TemerskieMod._log;
				if (log2 != null)
				{
					log2.LogInfo((object)"BuildAssets + Zmora + registration done");
				}
			}
			catch (Exception arg)
			{
				ManualLogSource? log3 = TemerskieMod._log;
				if (log3 != null)
				{
					log3.LogError((object)$"BuildAssets failed: {arg}");
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void AfterStartOfRoundStart(StartOfRound __instance)
		{
			bool valueOrDefault = __instance.allItemsList?.itemsList?.Any((Item i) => i.itemName == "Temerskie") == true;
			ManualLogSource? log = TemerskieMod._log;
			if (log != null)
			{
				log.LogInfo((object)$"SOR.Start: Temerskie registered = {valueOrDefault}");
			}
		}

		private static void RegisterScrap(StartOfRound sor, Mesh mesh, Material mat)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			if ((Object)(object)_prefab == (Object)null)
			{
				ManualLogSource? log = TemerskieMod._log;
				if (log != null)
				{
					log.LogError((object)"_prefab null in RegisterScrap");
				}
				return;
			}
			if ((Object)(object)sor.allItemsList == (Object)null)
			{
				ManualLogSource? log2 = TemerskieMod._log;
				if (log2 != null)
				{
					log2.LogError((object)"allItemsList null");
				}
				return;
			}
			Item val = ScriptableObject.CreateInstance<Item>();
			((Object)val).name = "TemerskieItem";
			val.itemName = "Temerskie";
			val.weight = 1.18f;
			val.isScrap = true;
			val.itemSpawnsOnGround = true;
			val.canBeGrabbedBeforeGameStart = true;
			val.twoHanded = false;
			val.twoHandedAnimation = false;
			val.isConductiveMetal = false;
			val.isDefensiveWeapon = true;
			val.holdButtonUse = false;
			val.syncUseFunction = true;
			val.toolTips = new string[1] { "Wypij za Temerie : [LMB]" };
			val.minValue = 60;
			val.maxValue = 80;
			val.spawnPrefab = _prefab;
			val.verticalOffset = 0f;
			val.restingRotation = new Vector3(0f, -90f, 0f);
			val.rotationOffset = new Vector3(0f, 0f, 0f);
			val.positionOffset = new Vector3(0f, 0.15f, 0.2f);
			val.meshVariants = (Mesh[])(object)new Mesh[1] { mesh };
			val.materialVariants = (Material[])(object)new Material[1] { mat };
			(AudioClip? grab, AudioClip? drop, AudioClip? pocket, AudioClip? throwSfx, AudioClip[] clinks) tuple = TemerskieMod.LoadFlaskAudio();
			AudioClip item = tuple.grab;
			AudioClip item2 = tuple.drop;
			AudioClip item3 = tuple.pocket;
			AudioClip item4 = tuple.throwSfx;
			AudioClip[] item5 = tuple.clinks;
			val.grabSFX = item;
			val.dropSFX = item2;
			val.pocketSFX = item3;
			val.throwSFX = item4;
			val.clinkAudios = item5;
			val.itemIcon = TemerskieMod.LoadIcon();
			sor.allItemsList.itemsList.Add(val);
			SelectableLevel[] array = Resources.FindObjectsOfTypeAll<SelectableLevel>();
			SelectableLevel[] array2 = array;
			foreach (SelectableLevel val2 in array2)
			{
				if (val2.spawnableScrap != null)
				{
					val2.spawnableScrap.Add(new SpawnableItemWithRarity(val, 100));
				}
			}
			ManualLogSource? log3 = TemerskieMod._log;
			if (log3 != null)
			{
				log3.LogInfo((object)$"Temerskie scrap item registered, added to {array.Length} levels");
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal static class HUDManagerPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("AddTextToChatOnServer")]
		private static bool BeforeAddTextToChat(HUDManager __instance, string chatMessage, int playerId)
		{
			try
			{
				PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
				if ((Object)(object)val == (Object)null || playerId != (int)val.playerClientId)
				{
					return true;
				}
				string text = chatMessage.Trim();
				ManualLogSource? log = TemerskieMod._log;
				if (log != null)
				{
					log.LogInfo((object)("Chat from local player: \"" + text + "\""));
				}
				switch (text)
				{
				case "/debug":
				{
					AllItemsList val2 = StartOfRound.Instance?.allItemsList;
					int num = val2?.itemsList?.Count ?? (-1);
					bool valueOrDefault = val2?.itemsList?.Any((Item i) => i.itemName == "Temerskie") == true;
					__instance.AddTextToChatOnServer($"[Temerskie] Debug: itemsList.Count={num} found={valueOrDefault}", playerId);
					return false;
				}
				case "/test":
				{
					TemerskieMod.ForceBialaMewa = !TemerskieMod.ForceBialaMewa;
					string text2 = (TemerskieMod.ForceBialaMewa ? "[Temerskie] Biała Mewa forced ON (100% chance)" : "[Temerskie] Biała Mewa forced OFF");
					ManualLogSource? log2 = TemerskieMod._log;
					if (log2 != null)
					{
						log2.LogInfo((object)text2);
					}
					HUDManager.Instance.AddTextToChatOnServer(text2, (int)val.playerClientId);
					return false;
				}
				case "/zmora":
					SpawnZmora(val);
					return false;
				default:
					if (text.StartsWith("/tp") || text.StartsWith("/temerskie"))
					{
						TeleportToNearestTemerskie(val);
						return false;
					}
					break;
				}
			}
			catch (Exception arg)
			{
				ManualLogSource? log3 = TemerskieMod._log;
				if (log3 != null)
				{
					log3.LogError((object)$"Chat handler error: {arg}");
				}
			}
			return true;
		}

		private static void TeleportToNearestTemerskie(PlayerControllerB player)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			PhysicsProp[] array = Object.FindObjectsOfType<PhysicsProp>();
			PhysicsProp val = null;
			float num = float.MaxValue;
			Vector3 position = ((Component)player).transform.position;
			PhysicsProp[] array2 = array;
			foreach (PhysicsProp val2 in array2)
			{
				if (!(((GrabbableObject)val2).itemProperties?.itemName != "Temerskie") && ((NetworkBehaviour)val2).IsSpawned && !((GrabbableObject)val2).isHeld)
				{
					float num2 = Vector3.Distance(position, ((Component)val2).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				HUDManager.Instance.AddTextToChatOnServer("[Temerskie] No Temerskie scrap found on the map.", (int)player.playerClientId);
				return;
			}
			Vector3 val3 = FindSafePosition(((Component)val).transform.position, position);
			player.TeleportPlayer(val3, false, 0f, false, true);
			HUDManager.Instance.AddTextToChatOnServer($"[Temerskie] Teleported to ({val3.x:F1}, {val3.y:F1}, {val3.z:F1})", (int)player.playerClientId);
			GiveProFlashlight(player);
		}

		private static Vector3 FindSafePosition(Vector3 scrapPos, Vector3 playerPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = scrapPos - playerPos;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.up * 1f;
			Vector3[] obj = new Vector3[10]
			{
				normalized,
				default(Vector3),
				default(Vector3),
				default(Vector3),
				default(Vector3),
				default(Vector3),
				default(Vector3),
				default(Vector3),
				default(Vector3),
				default(Vector3)
			};
			val = normalized + Vector3.forward;
			obj[1] = ((Vector3)(ref val)).normalized;
			val = normalized - Vector3.forward;
			obj[2] = ((Vector3)(ref val)).normalized;
			val = normalized + Vector3.right;
			obj[3] = ((Vector3)(ref val)).normalized;
			val = normalized - Vector3.right;
			obj[4] = ((Vector3)(ref val)).normalized;
			obj[5] = Vector3.forward;
			obj[6] = Vector3.back;
			obj[7] = Vector3.right;
			obj[8] = Vector3.left;
			val = normalized + Vector3.forward - Vector3.right;
			obj[9] = ((Vector3)(ref val)).normalized;
			Vector3[] array = (Vector3[])(object)obj;
			int mask = LayerMask.GetMask(new string[5] { "Default", "Terrain", "Room", "InteractableObject", "Colliders" });
			float[] array2 = new float[4] { 1.5f, 2f, 2.5f, 3f };
			foreach (float num in array2)
			{
				Vector3[] array3 = array;
				foreach (Vector3 val3 in array3)
				{
					Vector3 val4 = scrapPos + val3 * num + val2;
					if (!Physics.CheckSphere(val4, 0.5f, mask))
					{
						return val4;
					}
				}
			}
			return scrapPos + normalized * 3f + Vector3.up * 2f;
		}

		private static void SpawnZmora(PlayerControllerB player)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer || (Object)(object)TemerskieMod.ZmoraEnemyType == (Object)null)
			{
				return;
			}
			float num = Random.Range(10f, 20f);
			float num2 = Random.Range(0f, 360f);
			Vector3 val = Quaternion.Euler(0f, num2, 0f) * Vector3.forward;
			Vector3 val2 = ((Component)player).transform.position + val * num;
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(val2.x, val2.y + 5f, val2.z);
			NavMeshHit val4 = default(NavMeshHit);
			if (!NavMesh.SamplePosition(val3, ref val4, 20f, -1))
			{
				ManualLogSource? log = TemerskieMod._log;
				if (log != null)
				{
					log.LogWarning((object)"Zmora spawn aborted: no valid NavMesh near player");
				}
				HUDManager.Instance.AddTextToChatOnServer("[Temerskie] No valid spawn point for Zmora.", (int)player.playerClientId);
				return;
			}
			ZmoraAI.PrepareSpawn(TemerskieMod.ZmoraEnemyType, ((NetworkBehaviour)player).NetworkObjectId);
			NetworkObjectReference val5 = RoundManager.Instance.SpawnEnemyGameObject(((NavMeshHit)(ref val4)).position, 0f, -1, TemerskieMod.ZmoraEnemyType);
			NetworkObject val6 = default(NetworkObject);
			if (((NetworkObjectReference)(ref val5)).TryGet(ref val6, (NetworkManager)null))
			{
				(((Component)val6).GetComponent<ZmoraAI>() ?? ((Component)val6).GetComponentInChildren<ZmoraAI>())?.ApplyPendingTarget();
			}
			ManualLogSource? log2 = TemerskieMod._log;
			if (log2 != null)
			{
				log2.LogInfo((object)$"Zmora spawned at {((NavMeshHit)(ref val4)).position}");
			}
			HUDManager.Instance.AddTextToChatOnServer("[Temerskie] Zmora summoned!", (int)player.playerClientId);
		}

		private static void GiveProFlashlight(PlayerControllerB player)
		{
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance?.allItemsList == (Object)null)
			{
				return;
			}
			Item val = null;
			foreach (Item items in instance.allItemsList.itemsList)
			{
				if (items.itemName.Equals("Flashlight", StringComparison.OrdinalIgnoreCase))
				{
					val = items;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				foreach (Item items2 in instance.allItemsList.itemsList)
				{
					if (items2.itemName.IndexOf("flashlight", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						val = items2;
						break;
					}
				}
			}
			if ((Object)(object)val?.spawnPrefab == (Object)null)
			{
				ManualLogSource? log = TemerskieMod._log;
				if (log != null)
				{
					log.LogWarning((object)"Pro-flashlight item not found in allItemsList");
				}
				return;
			}
			Vector3 position = ((Component)player).transform.position;
			Vector3 val2 = -((Component)player).transform.forward;
			Vector3 val3 = position + val2 * 1.2f + Vector3.up * 1.5f;
			RaycastHit val4 = default(RaycastHit);
			if (Physics.Raycast(val3, Vector3.down, ref val4, 3f, LayerMask.GetMask(new string[2] { "Default", "Terrain" })))
			{
				val3 = ((RaycastHit)(ref val4)).point + Vector3.up * 0.3f;
			}
			GameObject val5 = Object.Instantiate<GameObject>(val.spawnPrefab, val3, Quaternion.identity);
			val5.GetComponent<NetworkObject>().Spawn(false);
			ManualLogSource? log2 = TemerskieMod._log;
			if (log2 != null)
			{
				log2.LogInfo((object)"Spawned pro-flashlight near player");
			}
		}
	}
	public class TemerskieProp : PhysicsProp
	{
		private static readonly Dictionary<int, NetworkObject> _activeZmoras = new Dictionary<int, NetworkObject>();

		private bool _isDrinking;

		private Vector3 _origPosOff;

		private Vector3 _origRotOff;

		private AudioSource? _audio;

		private AudioClip? _gulpClip;

		public override void Start()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			((GrabbableObject)this).Start();
			_audio = ((Component)this).GetComponent<AudioSource>();
			if ((Object)(object)_audio == (Object)null)
			{
				_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
				_audio.spatialBlend = 1f;
			}
			Item itemProperties = ((GrabbableObject)this).itemProperties;
			if ((Object)(object)itemProperties != (Object)null)
			{
				itemProperties.holdButtonUse = false;
				itemProperties.syncUseFunction = true;
				itemProperties.toolTips = new string[1] { "Wypij za Temerie : [LMB]" };
				_gulpClip = itemProperties.dropSFX ?? itemProperties.grabSFX;
				_origPosOff = itemProperties.positionOffset;
				_origRotOff = itemProperties.rotationOffset;
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (!_isDrinking && ((GrabbableObject)this).isHeld && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance?.localPlayerController && Mouse.current.leftButton.wasPressedThisFrame)
			{
				StartDrinkingServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void StartDrinkingServerRpc()
		{
			StartDrinkingClientRpc();
		}

		[ClientRpc]
		private void StartDrinkingClientRpc()
		{
			((MonoBehaviour)this).StartCoroutine(DrinkAnimation());
		}

		private IEnumerator DrinkAnimation()
		{
			_isDrinking = true;
			Item ip = ((GrabbableObject)this).itemProperties;
			Vector3 startPos = ip.positionOffset;
			Vector3 startRot = ip.rotationOffset;
			Vector3 raisePos = startPos + new Vector3(0f, 0.15f, -0.2f);
			Vector3 raiseRot = startRot + new Vector3(60f, 0f, 0f);
			float dur = 0.3f;
			float elapsed = 0f;
			while (elapsed < dur)
			{
				elapsed += Time.deltaTime;
				float t = elapsed / dur;
				ip.positionOffset = Vector3.Lerp(startPos, raisePos, t);
				ip.rotationOffset = Vector3.Lerp(startRot, raiseRot, t);
				yield return null;
			}
			ip.positionOffset = raisePos;
			ip.rotationOffset = raiseRot;
			if ((Object)(object)_audio != (Object)null && (Object)(object)_gulpClip != (Object)null)
			{
				float saved = _audio.pitch;
				_audio.pitch = Random.Range(0.9f, 1f);
				_audio.PlayOneShot(_gulpClip);
				_audio.pitch = saved;
			}
			yield return (object)new WaitForSeconds(0.7f);
			if ((Object)(object)_audio != (Object)null && (Object)(object)_gulpClip != (Object)null)
			{
				float saved2 = _audio.pitch;
				_audio.pitch = Random.Range(1.1f, 1.2f);
				_audio.PlayOneShot(_gulpClip);
				_audio.pitch = saved2;
			}
			yield return (object)new WaitForSeconds(0.15f);
			elapsed = 0f;
			while (elapsed < dur)
			{
				elapsed += Time.deltaTime;
				float t2 = elapsed / dur;
				ip.positionOffset = Vector3.Lerp(raisePos, startPos, t2);
				ip.rotationOffset = Vector3.Lerp(raiseRot, startRot, t2);
				yield return null;
			}
			ip.positionOffset = startPos;
			ip.rotationOffset = startRot;
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				PlayerControllerB p = ((GrabbableObject)this).playerHeldBy;
				p.DestroyItemInSlotAndSync(p.currentItemSlot);
				p.movementSpeed *= 2f;
				GameObject baseReset = new GameObject("TemerskieSpeedReset");
				Object.DontDestroyOnLoad((Object)(object)baseReset);
				baseReset.AddComponent<TemerskieSpeedReset>().StartReset(p, 30f);
				float roll = (TemerskieMod.ForceBialaMewa ? 0f : Random.value);
				if (roll < 0.01f)
				{
					BialaMewaServerRpc(NetworkObjectReference.op_Implicit(((Component)p).GetComponent<NetworkObject>()));
				}
				else if (roll < 0.11f)
				{
					RandomEffectServerRpc(NetworkObjectReference.op_Implicit(((Component)p).GetComponent<NetworkObject>()));
				}
			}
			_isDrinking = false;
		}

		[ServerRpc(RequireOwnership = false)]
		private void BialaMewaServerRpc(NetworkObjectReference playerRef)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			BialaMewaClientRpc(playerRef);
			NetworkObject val = default(NetworkObject);
			if (NetworkManager.Singleton.IsServer && ((NetworkObjectReference)(ref playerRef)).TryGet(ref val, (NetworkManager)null))
			{
				PlayerControllerB component = ((Component)val).GetComponent<PlayerControllerB>();
				if (!((Object)(object)component == (Object)null))
				{
					SpawnZmora(component);
				}
			}
		}

		private void SpawnZmora(PlayerControllerB player)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			if (!((Object)(object)TemerskieMod.ZmoraEnemyType == (Object)null))
			{
				DespawnZmora((int)player.playerClientId);
				Vector3 val = ((Component)player).transform.forward * -4f + Vector3.up * 1.5f;
				Vector3 val2 = ((Component)player).transform.position + val;
				NavMeshHit val3 = default(NavMeshHit);
				if (NavMesh.SamplePosition(val2, ref val3, 20f, -1))
				{
					val2 = ((NavMeshHit)(ref val3)).position;
				}
				ZmoraAI.PrepareSpawn(TemerskieMod.ZmoraEnemyType, ((NetworkBehaviour)player).NetworkObjectId);
				NetworkObjectReference val4 = RoundManager.Instance.SpawnEnemyGameObject(val2, 0f, -1, TemerskieMod.ZmoraEnemyType);
				NetworkObject val5 = default(NetworkObject);
				if (((NetworkObjectReference)(ref val4)).TryGet(ref val5, (NetworkManager)null))
				{
					(((Component)val5).GetComponent<ZmoraAI>() ?? ((Component)val5).GetComponentInChildren<ZmoraAI>())?.ApplyPendingTarget();
					_activeZmoras[(int)player.playerClientId] = val5;
				}
			}
		}

		internal static void DespawnZmora(int playerClientId)
		{
			if (NetworkManager.Singleton.IsServer && _activeZmoras.TryGetValue(playerClientId, out NetworkObject value))
			{
				if ((Object)(object)value != (Object)null && value.IsSpawned)
				{
					value.Despawn(false);
				}
				_activeZmoras.Remove(playerClientId);
			}
		}

		[ClientRpc]
		private void BialaMewaClientRpc(NetworkObjectReference playerRef)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			NetworkObject val = default(NetworkObject);
			if (!((NetworkObjectReference)(ref playerRef)).TryGet(ref val, (NetworkManager)null))
			{
				return;
			}
			PlayerControllerB component = ((Component)val).GetComponent<PlayerControllerB>();
			if (!((Object)(object)component == (Object)null))
			{
				component.movementSpeed *= 1.25f;
				float carryWeight = component.carryWeight;
				component.carryWeight = carryWeight / 1.25f;
				GameObject val2 = new GameObject("TemerskieMewa");
				Object.DontDestroyOnLoad((Object)(object)val2);
				val2.AddComponent<TemerskieMewaEffect>().StartEffect(component, 20f, carryWeight);
				if ((Object)(object)component == (Object)(object)GameNetworkManager.Instance?.localPlayerController)
				{
					component.drunkness = 1f;
					component.drunknessSpeed = 0f;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RandomEffectServerRpc(NetworkObjectReference playerRef)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			RandomEffectClientRpc(playerRef);
		}

		[ClientRpc]
		private void RandomEffectClientRpc(NetworkObjectReference playerRef)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			NetworkObject val = default(NetworkObject);
			if (!((NetworkObjectReference)(ref playerRef)).TryGet(ref val, (NetworkManager)null))
			{
				return;
			}
			PlayerControllerB component = ((Component)val).GetComponent<PlayerControllerB>();
			if (!((Object)(object)component == (Object)null))
			{
				GameObject val2 = new GameObject("TemerskieBurp");
				Object.DontDestroyOnLoad((Object)(object)val2);
				val2.transform.position = ((Component)component).transform.position;
				AudioSource val3 = val2.AddComponent<AudioSource>();
				val3.spatialBlend = 1f;
				val3.maxDistance = 500f;
				val3.minDistance = 10f;
				val3.rolloffMode = (AudioRolloffMode)1;
				val3.volume = 1.5f;
				val3.pitch = Random.Range(0.3f, 0.6f);
				if ((Object)(object)_gulpClip != (Object)null)
				{
					val3.PlayOneShot(_gulpClip);
				}
				Object.Destroy((Object)(object)val2, 3f);
				if (((NetworkBehaviour)this).IsOwner)
				{
					GameObject val4 = new GameObject("TemerskieRandomKnockdown");
					Object.DontDestroyOnLoad((Object)(object)val4);
					val4.AddComponent<TemerskieRandomKnockdown>().StartEffect(component);
				}
			}
		}

		public override void OnDestroy()
		{
			((MonoBehaviour)this).StopAllCoroutines();
			((GrabbableObject)this).OnDestroy();
		}
	}
	internal class TemerskieSpeedReset : MonoBehaviour
	{
		private PlayerControllerB? _player;

		private float _timer;

		public void StartReset(PlayerControllerB player, float delay)
		{
			_player = player;
			_timer = delay;
		}

		private void Update()
		{
			if ((Object)(object)_player == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_timer -= Time.deltaTime;
			if (_timer <= 0f)
			{
				PlayerControllerB? player = _player;
				player.movementSpeed *= 0.5f;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	internal class TemerskieMewaEffect : MonoBehaviour
	{
		private PlayerControllerB? _player;

		private float _timer;

		private float _origCarryWeight;

		private float _speedBeforeKnockdown;

		private bool _hasFallen;

		public void StartEffect(PlayerControllerB player, float duration, float origCarryWeight)
		{
			_player = player;
			_timer = duration;
			_origCarryWeight = origCarryWeight;
		}

		private void Update()
		{
			if ((Object)(object)_player == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_timer -= Time.deltaTime;
			if (_timer <= 0f && !_hasFallen)
			{
				_hasFallen = true;
				PlayerControllerB? player = _player;
				player.movementSpeed /= 1.25f;
				_player.carryWeight = _origCarryWeight;
				if ((Object)(object)_player == (Object)(object)GameNetworkManager.Instance?.localPlayerController)
				{
					_player.drunkness = 0f;
					_player.drunknessSpeed = 1f;
				}
				_speedBeforeKnockdown = _player.movementSpeed;
				_player.movementSpeed = 0f;
				((MonoBehaviour)this).Invoke("RestoreMovement", 3f);
			}
		}

		private void RestoreMovement()
		{
			if ((Object)(object)_player != (Object)null)
			{
				if (NetworkManager.Singleton.IsServer)
				{
					TemerskieProp.DespawnZmora((int)_player.playerClientId);
				}
				_player.movementSpeed = _speedBeforeKnockdown;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	internal class TemerskieRandomKnockdown : MonoBehaviour
	{
		private PlayerControllerB? _player;

		private float _savedSpeed;

		private bool _started;

		public void StartEffect(PlayerControllerB player)
		{
			_player = player;
		}

		private void Update()
		{
			if ((Object)(object)_player == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if (!_started)
			{
				_started = true;
				_savedSpeed = _player.movementSpeed;
				_player.movementSpeed = 0f;
				((MonoBehaviour)this).Invoke("ApplySpeedBoost", 2f);
			}
		}

		private void ApplySpeedBoost()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if ((Object)(object)_player == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_player.movementSpeed = _savedSpeed * 2f;
			GameObject val = new GameObject("TemerskieRandomSpeed");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<TemerskieSpeedReset>().StartReset(_player, 5f);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	public class ZmoraAI : EnemyAI
	{
		private const int STATE_ROAM = 0;

		private const int STATE_HUNT = 1;

		private const int STATE_ATTACK = 2;

		public NetworkVariable<ulong> targetPlayerId = new NetworkVariable<ulong>(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private PlayerControllerB? _targetPlayer;

		private float _phaseTimer = 10f;

		private float _flickerTimer;

		private bool _isFlickering;

		private Vector3 _roamTarget;

		private bool _hasRoamTarget;

		private Vector3 _huntTarget;

		private bool _hasHuntTarget;

		private Vector3 _lastNoisePos;

		private float _noiseAge = float.MaxValue;

		private bool _hasAttacked;

		internal ulong pendingTargetPlayerId = ulong.MaxValue;

		private float _targetRefreshTimer = 0f;

		private float _huntTimer = 0f;

		private bool _hasSeenPlayer = false;

		private bool _isRetreating = false;

		private float _retreatTimer = 0f;

		private float _verticalVelocity = 0f;

		private float _gravity = -30f;

		private float _terminalVelocity = -50f;

		private float _groundCheckDistance = 0.3f;

		private int _groundLayerMask;

		private int _wallLayerMask;

		private int _obstacleDoorLayerMask;

		private bool _isGrounded;

		private Rigidbody? _rigidbody;

		private CapsuleCollider? _capsuleCollider;

		private int _currentInteriorIndex = -1;

		private float _interiorCheckTimer = 0f;

		private Vector3 _moveVelocity;

		private float _teleportCooldown = 0f;

		private const float TELEPORT_COOLDOWN = 3f;

		private const float TELEPORT_RANGE = 15f;

		private const float TELEPORT_MIN_DIST = 5f;

		private const float FLY_HEIGHT_THRESHOLD = 5f;

		private const float FLY_SPEED = 8f;

		private MeshRenderer[]? _myRenderers;

		private ParticleSystem? _smokeParticles;

		private bool _currentVisible;

		private bool _callbacksHooked;

		private bool _initialized;

		private float _aiTimer;

		private Vector3? _manualMoveTarget;

		private float _manualMoveSpeed;

		internal static void PrepareSpawn(EnemyType type, ulong targetPlayerId)
		{
			ZmoraSpawnContext.NextEnemyType = type;
			ZmoraSpawnContext.NextTargetId = targetPlayerId;
		}

		internal bool IsTargetingPlayer(ulong playerNetworkObjectId)
		{
			if (targetPlayerId.Value == playerNetworkObjectId)
			{
				return true;
			}
			return pendingTargetPlayerId == playerNetworkObjectId;
		}

		public override void Start()
		{
			if (!((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned)
			{
				if (base.meshRenderers == null || base.meshRenderers.Length == 0)
				{
					base.meshRenderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true);
				}
				if (base.skinnedMeshRenderers == null || base.skinnedMeshRenderers.Length == 0)
				{
					base.skinnedMeshRenderers = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true);
				}
				if ((Object)(object)base.creatureSFX == (Object)null)
				{
					base.creatureSFX = ((Component)this).GetComponent<AudioSource>();
				}
				if ((Object)(object)base.creatureAnimator == (Object)null)
				{
					base.creatureAnimator = ((Component)this).GetComponentInChildren<Animator>(true);
				}
				InitializeEnemy();
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			ManualLogSource? log = TemerskieMod._log;
			if (log != null)
			{
				object arg = ((NetworkBehaviour)this).IsServer;
				NetworkObject networkObject = ((NetworkBehaviour)this).NetworkObject;
				log.LogInfo((object)$"Zmora OnNetworkSpawn - IsServer: {arg}, IsSpawned: {((networkObject != null) ? new bool?(networkObject.IsSpawned) : ((bool?)null))}, IsOwner: {((NetworkBehaviour)this).IsOwner}");
			}
			ZmoraSpawnContext.Consume(this);
			InitializeEnemy();
			if (((NetworkBehaviour)this).IsServer)
			{
				ApplyPendingTarget();
			}
		}

		private IEnumerator ApplyPendingTargetDeferred()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned));
			yield return (object)new WaitForSeconds(0.1f);
			ApplyPendingTarget();
		}

		internal void ApplyPendingTarget()
		{
			if (!((NetworkBehaviour)this).IsServer || pendingTargetPlayerId == ulong.MaxValue)
			{
				return;
			}
			if ((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null || !((NetworkBehaviour)this).NetworkObject.IsSpawned)
			{
				ManualLogSource? log = TemerskieMod._log;
				if (log != null)
				{
					log.LogInfo((object)"Zmora: NetworkObject not spawned yet, deferring target assignment");
				}
				((MonoBehaviour)this).StartCoroutine(ApplyPendingTargetDeferred());
				return;
			}
			targetPlayerId.Value = pendingTargetPlayerId;
			pendingTargetPlayerId = ulong.MaxValue;
			ResolveTargetPlayer();
			ManualLogSource? log2 = TemerskieMod._log;
			if (log2 != null)
			{
				log2.LogInfo((object)$"Zmora target set to player id {targetPlayerId.Value}");
			}
		}

		internal void ConfigureAfterSpawn(EnemyType type)
		{
			base.enemyType = type;
			base.ventAnimationFinished = true;
			DisableBasePathfinding();
			SnapToNavMesh();
			ApplyPendingTarget();
			if ((Object)(object)RoundManager.Instance != (Object)null && !RoundManager.Instance.SpawnedEnemies.Contains((EnemyAI)(object)this))
			{
				RoundManager.Instance.SpawnedEnemies.Add((EnemyAI)(object)this);
			}
		}

		private void DisableBasePathfinding()
		{
			base.moveTowardsDestination = false;
			base.movingTowardsTargetPlayer = false;
			if ((Object)(object)base.agent != (Object)null)
			{
				((Behaviour)base.agent).enabled = false;
			}
		}

		private void InitializeEnemy()
		{
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource? log = TemerskieMod._log;
			if (log != null)
			{
				object arg = _initialized;
				NetworkObject networkObject = ((NetworkBehaviour)this).NetworkObject;
				NetworkObject networkObject2 = ((NetworkBehaviour)this).NetworkObject;
				log.LogInfo((object)$"Zmora InitializeEnemy - _initialized: {arg}, NetworkObject: {networkObject}, IsSpawned: {((networkObject2 != null) ? new bool?(networkObject2.IsSpawned) : ((bool?)null))}");
			}
			if (_initialized)
			{
				return;
			}
			_initialized = true;
			if ((Object)(object)base.enemyType == (Object)null)
			{
				base.enemyType = ZmoraSpawnContext.NextEnemyType ?? TemerskieMod.ZmoraEnemyType;
			}
			ManualLogSource? log2 = TemerskieMod._log;
			if (log2 != null)
			{
				log2.LogInfo((object)("Zmora enemyType: " + (base.enemyType?.enemyName ?? "null")));
			}
			base.ventAnimationFinished = true;
			base.timeSinceSpawn = base.exitVentAnimationTime + 1f;
			if ((Object)(object)base.agent == (Object)null)
			{
				base.agent = ((Component)this).GetComponent<NavMeshAgent>();
			}
			if ((Object)(object)base.agent != (Object)null)
			{
				base.agent.radius = 0.1f;
				base.agent.height = 0.2f;
				base.agent.autoRepath = false;
				base.agent.updatePosition = false;
				base.agent.updateRotation = false;
				base.agent.stoppingDistance = 0.5f;
			}
			_rigidbody = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)_rigidbody == (Object)null)
			{
				_rigidbody = ((Component)this).gameObject.AddComponent<Rigidbody>();
			}
			_rigidbody.useGravity = false;
			_rigidbody.isKinematic = false;
			_rigidbody.constraints = (RigidbodyConstraints)112;
			_rigidbody.mass = 100f;
			_rigidbody.collisionDetectionMode = (CollisionDetectionMode)2;
			_capsuleCollider = ((Component)this).GetComponent<CapsuleCollider>();
			if ((Object)(object)_capsuleCollider == (Object)null)
			{
				_capsuleCollider = ((Component)this).gameObject.AddComponent<CapsuleCollider>();
			}
			_capsuleCollider.radius = 0.4f;
			_capsuleCollider.height = 1.8f;
			_capsuleCollider.center = new Vector3(0f, 0.9f, 0f);
			_groundLayerMask = LayerMask.GetMask(new string[5] { "Default", "Terrain", "Room", "InteractableObject", "Colliders" });
			_wallLayerMask = LayerMask.GetMask(new string[4] { "Default", "Terrain", "Room", "Colliders" });
			_obstacleDoorLayerMask = LayerMask.GetMask(new string[4] { "InteractableObject", "Door", "Doors", "Obstacles" });
			DisableBasePathfinding();
			SnapToNavMesh();
			try
			{
				((EnemyAI)this).Start();
			}
			catch (Exception ex)
			{
				ManualLogSource? log3 = TemerskieMod._log;
				if (log3 != null)
				{
					log3.LogWarning((object)("Zmora base.Start partial fail: " + ex.Message));
				}
			}
			((Behaviour)this).enabled = true;
			DisableBasePathfinding();
			base.ventAnimationFinished = true;
			SnapToNavMesh();
			if (base.meshRenderers == null || base.meshRenderers.Length == 0)
			{
				base.meshRenderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true);
			}
			ManualLogSource? log4 = TemerskieMod._log;
			if (log4 != null)
			{
				MeshRenderer[] meshRenderers = base.meshRenderers;
				log4.LogInfo((object)$"Zmora meshRenderers found: {((meshRenderers != null) ? meshRenderers.Length : 0)}");
			}
			if ((Object)(object)base.creatureAnimator == (Object)null)
			{
				base.creatureAnimator = ((Component)this).GetComponentInChildren<Animator>(true);
			}
			if ((Object)(object)base.creatureSFX == (Object)null)
			{
				base.creatureSFX = ((Component)this).GetComponent<AudioSource>();
			}
			base.AIIntervalTime = 0.3f;
			base.enemyHP = 20;
			base.openDoorSpeedMultiplier = 1f;
			base.currentBehaviourStateIndex = 0;
			_phaseTimer = 10f;
			_flickerTimer = Random.Range(3f, 5f);
			_aiTimer = base.AIIntervalTime;
			_myRenderers = ((Component)this).GetComponentsInChildren<MeshRenderer>(true);
			_smokeParticles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
			SetVisible(visible: false);
			ResolveTargetPlayer();
			if (!_callbacksHooked)
			{
				NetworkVariable<ulong> obj = targetPlayerId;
				obj.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<ulong>)delegate
				{
					ResolveTargetPlayer();
				});
				_callbacksHooked = true;
			}
			ManualLogSource? log5 = TemerskieMod._log;
			if (log5 != null)
			{
				log5.LogInfo((object)$"Zmora InitializeEnemy complete - AIIntervalTime: {base.AIIntervalTime}, _aiTimer: {_aiTimer}, enabled: {((Behaviour)this).enabled}, activeInHierarchy: {((Component)this).gameObject.activeInHierarchy}");
			}
		}

		public override void Update()
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: 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_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource? log = TemerskieMod._log;
			if (log != null)
			{
				object[] obj = new object[4]
				{
					((NetworkBehaviour)this).IsServer,
					null,
					null,
					null
				};
				NetworkObject networkObject = ((NetworkBehaviour)this).NetworkObject;
				obj[1] = ((networkObject != null) ? new bool?(networkObject.IsSpawned) : ((bool?)null));
				obj[2] = ((Behaviour)this).enabled;
				obj[3] = ((Component)this).gameObject.activeInHierarchy;
				log.LogInfo((object)string.Format("Zmora Update - IsServer: {0}, IsSpawned: {1}, enabled: {2}, activeInHierarchy: {3}", obj));
			}
			if (!((NetworkBehaviour)this).IsServer)
			{
				UpdateVisibility();
				return;
			}
			DisableBasePathfinding();
			HandlePhysics();
			TickManualMovementPhysics();
			if (_aiTimer > 0f)
			{
				_aiTimer -= Time.deltaTime;
			}
			else
			{
				_aiTimer = base.AIIntervalTime + Random.Range(-0.015f, 0.015f);
				((EnemyAI)this).DoAIInterval();
			}
			_targetRefreshTimer += Time.deltaTime;
			if (_targetRefreshTimer > 5f)
			{
				_targetRefreshTimer = 0f;
				if (base.currentBehaviourStateIndex == 0 && _hasRoamTarget)
				{
					float num = Vector3.Distance(_roamTarget, ((Component)_targetPlayer).transform.position);
					if (num > 20f)
					{
						_hasRoamTarget = false;
						ManualLogSource? log2 = TemerskieMod._log;
						if (log2 != null)
						{
							log2.LogInfo((object)"Zmora: Player moved far, refreshing roam target");
						}
					}
				}
				else if (base.currentBehaviourStateIndex == 1 && _hasHuntTarget)
				{
					float num2 = Vector3.Distance(_huntTarget, ((Component)_targetPlayer).transform.position);
					if (num2 > 20f)
					{
						_hasHuntTarget = false;
						ManualLogSource? log3 = TemerskieMod._log;
						if (log3 != null)
						{
							log3.LogInfo((object)"Zmora: Player moved far, refreshing hunt target");
						}
					}
				}
			}
			if (base.isEnemyDead || (Object)(object)_targetPlayer == (Object)null)
			{
				return;
			}
			float num3 = ((base.currentBehaviourStateIndex == 2) ? 1.5f : 10f);
			float num4 = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position);
			if (num4 < num3)
			{
				Vector3 val = ((Component)this).transform.position - ((Component)_targetPlayer).transform.position;
				Vector3 val2 = ((Vector3)(ref val)).normalized;
				val2.y = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
				{
					val2 = Vector3.forward;
				}
				_moveVelocity += val2 * (num3 - num4) * 15f;
				_moveVelocity = Vector3.ClampMagnitude(_moveVelocity, 20f);
			}
			Vector3 val3 = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position;
			val3.y = 0f;
			if (((Vector3)(ref val3)).sqrMagnitude > 0.001f)
			{
				Quaternion val4 = Quaternion.LookRotation(val3);
				_rigidbody.MoveRotation(Quaternion.Slerp(_rigidbody.rotation, val4, 5f * Time.deltaTime));
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				SyncPositionToClients();
			}
		}

		private void SyncPositionToClients()
		{
		}

		private void HandlePhysics()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0127: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown r