Decompiled source of RobloxMode v1.0.0

RobloxMode.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace CrossFlow.RobloxMode;

internal class AvatarAssets
{
	internal class Part
	{
		public string Name;

		public Mesh Mesh;

		public string MaterialName;

		public Texture2D Texture;

		public Color MtlColor = Color.white;

		public Vector3 OriginalCenter;

		public Vector3 Size;

		public Vector3 MaxXCapCenter;

		public bool TexColored;

		public Color Tint
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)Texture != (Object)null) || !TexColored)
				{
					return MtlColor;
				}
				return Color.white;
			}
		}
	}

	private class GroupBuilder
	{
		public string Material;

		public readonly List<Vector3> Vertices = new List<Vector3>();

		public readonly List<Vector3> Normals = new List<Vector3>();

		public readonly List<Vector2> Uvs = new List<Vector2>();

		public readonly List<int> Triangles = new List<int>();

		private readonly Dictionary<string, int> _index = new Dictionary<string, int>();

		public void AddFace(string[] t, List<Vector3> positions, List<Vector2> uvs, List<Vector3> normals)
		{
			int num = t.Length - 1;
			int[] array = new int[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = GetIndex(t[i + 1], positions, uvs, normals);
			}
			for (int j = 1; j < num - 1; j++)
			{
				Triangles.Add(array[0]);
				Triangles.Add(array[j + 1]);
				Triangles.Add(array[j]);
			}
		}

		private int GetIndex(string token, List<Vector3> positions, List<Vector2> uvs, List<Vector3> normals)
		{
			//IL_007b: 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_008f: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (_index.TryGetValue(token, out var value))
			{
				return value;
			}
			string[] array = token.Split('/');
			int index = Resolve(array[0], positions.Count);
			int num = ((array.Length > 1 && array[1].Length > 0) ? Resolve(array[1], uvs.Count) : (-1));
			int num2 = ((array.Length > 2 && array[2].Length > 0) ? Resolve(array[2], normals.Count) : (-1));
			Vertices.Add(positions[index]);
			Uvs.Add((num >= 0) ? uvs[num] : Vector2.zero);
			Normals.Add((num2 >= 0) ? normals[num2] : Vector3.zero);
			int num3 = Vertices.Count - 1;
			_index[token] = num3;
			return num3;
		}

		private static int Resolve(string s, int count)
		{
			int num = int.Parse(s, CultureInfo.InvariantCulture);
			if (num <= 0)
			{
				return count + num;
			}
			return num - 1;
		}

		public Part Build(string name)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0043: 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_005e: 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_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_006f: 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_0071: 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_009a: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00be: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//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_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vertices[0];
			Vector3 val2 = Vertices[0];
			foreach (Vector3 vertex in Vertices)
			{
				val = Vector3.Min(val, vertex);
				val2 = Vector3.Max(val2, vertex);
			}
			Vector3 val3 = (val + val2) * 0.5f;
			Vector3 val4 = val2 - val;
			Vector3[] array = (Vector3[])(object)new Vector3[Vertices.Count];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Vertices[i] - val3;
			}
			float num = val2.x - val3.x - val4.x * 0.03f;
			Vector3 val5 = Vector3.zero;
			int num2 = 0;
			Vector3[] array2 = array;
			foreach (Vector3 val6 in array2)
			{
				if (val6.x >= num)
				{
					val5 += val6;
					num2++;
				}
			}
			Vector3 maxXCapCenter = (Vector3)((num2 > 0) ? (val5 / (float)num2) : new Vector3(val4.x * 0.5f, 0f, 0f));
			Mesh val7 = new Mesh
			{
				name = "Roblox_" + name
			};
			if (array.Length > 65000)
			{
				val7.indexFormat = (IndexFormat)1;
			}
			val7.vertices = array;
			val7.uv = Uvs.ToArray();
			val7.triangles = Triangles.ToArray();
			bool flag = false;
			foreach (Vector3 normal in Normals)
			{
				if (normal != Vector3.zero)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				val7.normals = Normals.ToArray();
			}
			else
			{
				val7.RecalculateNormals();
			}
			val7.RecalculateBounds();
			return new Part
			{
				Name = name,
				Mesh = val7,
				MaterialName = Material,
				OriginalCenter = val3,
				Size = val4,
				MaxXCapCenter = maxXCapCenter
			};
		}
	}

	private readonly Dictionary<Texture2D, bool> _texColored = new Dictionary<Texture2D, bool>();

	public readonly Dictionary<string, Part> Parts = new Dictionary<string, Part>();

	public readonly List<string> PartOrder = new List<string>();

	private readonly Dictionary<string, string> _materialTexture = new Dictionary<string, string>();

	private readonly Dictionary<string, Color> _materialColor = new Dictionary<string, Color>();

	private readonly Dictionary<string, Texture2D> _textureCache = new Dictionary<string, Texture2D>();

	public Part First
	{
		get
		{
			if (PartOrder.Count <= 0)
			{
				return null;
			}
			return Parts[PartOrder[0]];
		}
	}

	public void GetCombinedBounds(out Vector3 center, out Vector3 size)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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_0097: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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_00bb: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		if (PartOrder.Count == 0)
		{
			center = Vector3.zero;
			size = Vector3.zero;
			return;
		}
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(float.MaxValue, float.MaxValue, float.MaxValue);
		Vector3 val2 = default(Vector3);
		((Vector3)(ref val2))..ctor(float.MinValue, float.MinValue, float.MinValue);
		foreach (string item in PartOrder)
		{
			Part part = Parts[item];
			val = Vector3.Min(val, part.OriginalCenter - part.Size * 0.5f);
			val2 = Vector3.Max(val2, part.OriginalCenter + part.Size * 0.5f);
		}
		center = (val + val2) * 0.5f;
		size = val2 - val;
	}

	public GameObject BuildModel(string name, Transform parent, int layer, Material sourceMat, bool useMtlColor)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		GetCombinedBounds(out var center, out var _);
		GameObject val = new GameObject(name);
		val.layer = layer;
		val.transform.SetParent(parent, false);
		foreach (string item in PartOrder)
		{
			Part part = Parts[item];
			Material mat = ViewAnim.MakeMaterial(sourceMat, part.Texture, useMtlColor ? part.Tint : Color.white, "Roblox_" + item);
			ViewAnim.MakeMeshObject(item, val.transform, layer, part.Mesh, mat).transform.localPosition = part.OriginalCenter - center;
		}
		return val;
	}

	public static AvatarAssets Load(string objPath)
	{
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: 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)
		AvatarAssets avatarAssets = new AvatarAssets();
		if (!File.Exists(objPath))
		{
			Plugin.Log.LogError((object)("OBJ 없음: " + objPath));
			return avatarAssets;
		}
		string directoryName = Path.GetDirectoryName(objPath);
		avatarAssets.Parse(objPath, directoryName);
		foreach (string item in avatarAssets.PartOrder)
		{
			Part part = avatarAssets.Parts[item];
			Plugin.Log.LogInfo((object)string.Format("OBJ part '{0}:{1}': verts={2}, size={3}, center={4}, mtl={5}, color={6}, tex={7}, maxXCap={8}", Path.GetFileName(objPath), part.Name, part.Mesh.vertexCount, part.Size, part.OriginalCenter, part.MaterialName, part.MtlColor, ((Object)(object)part.Texture != (Object)null) ? ((Object)part.Texture).name : "none", part.MaxXCapCenter));
		}
		return avatarAssets;
	}

	public static AvatarAssets LoadFirstObjInFolder(string folder)
	{
		if (!Directory.Exists(folder))
		{
			return null;
		}
		string[] files = Directory.GetFiles(folder, "*.obj");
		if (files.Length == 0)
		{
			return null;
		}
		Array.Sort(files, (IComparer<string>?)StringComparer.OrdinalIgnoreCase);
		return Load(files[0]);
	}

	private void Parse(string objPath, string dir)
	{
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		List<Vector2> list3 = new List<Vector2>();
		string text = null;
		string material = null;
		Dictionary<string, GroupBuilder> dictionary = new Dictionary<string, GroupBuilder>();
		List<string> list4 = new List<string>();
		foreach (string item in File.ReadLines(objPath))
		{
			string text2 = item.Trim();
			if (text2.Length == 0 || text2[0] == '#')
			{
				continue;
			}
			string[] array = text2.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
			string text3 = array[0];
			if (text3 == null)
			{
				continue;
			}
			switch (text3.Length)
			{
			case 6:
				switch (text3[0])
				{
				case 'm':
					if (text3 == "mtllib")
					{
						LoadMtl(Path.Combine(dir, text2.Substring(7).Trim()));
					}
					break;
				case 'u':
					if (text3 == "usemtl")
					{
						material = ((array.Length > 1) ? array[1] : null);
						if (text != null)
						{
							dictionary[text].Material = material;
						}
					}
					break;
				}
				break;
			case 1:
				switch (text3[0])
				{
				case 'v':
					list.Add(new Vector3(F(array[1]), F(array[2]), 0f - F(array[3])));
					break;
				case 'g':
				case 'o':
					text = ((array.Length > 1) ? array[1] : "default");
					if (!dictionary.ContainsKey(text))
					{
						dictionary[text] = new GroupBuilder();
						list4.Add(text);
					}
					break;
				case 'f':
					if (text == null)
					{
						text = "default";
						dictionary[text] = new GroupBuilder
						{
							Material = material
						};
						list4.Add(text);
					}
					dictionary[text].AddFace(array, list, list3, list2);
					break;
				}
				break;
			case 2:
				switch (text3[1])
				{
				case 'n':
					if (text3 == "vn")
					{
						list2.Add(new Vector3(F(array[1]), F(array[2]), 0f - F(array[3])));
					}
					break;
				case 't':
					if (text3 == "vt")
					{
						list3.Add(new Vector2(F(array[1]), F(array[2])));
					}
					break;
				}
				break;
			}
		}
		foreach (string item2 in list4)
		{
			GroupBuilder groupBuilder = dictionary[item2];
			if (groupBuilder.Vertices.Count == 0)
			{
				continue;
			}
			Part part = groupBuilder.Build(item2);
			if (groupBuilder.Material != null)
			{
				if (_materialTexture.TryGetValue(groupBuilder.Material, out var value))
				{
					part.Texture = LoadTexture(Path.Combine(dir, value));
					if ((Object)(object)part.Texture != (Object)null && _texColored.TryGetValue(part.Texture, out var value2))
					{
						part.TexColored = value2;
					}
				}
				if (_materialColor.TryGetValue(groupBuilder.Material, out var value3))
				{
					part.MtlColor = value3;
				}
			}
			Parts[item2] = part;
			PartOrder.Add(item2);
		}
	}

	private void LoadMtl(string mtlPath)
	{
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		if (!File.Exists(mtlPath))
		{
			Plugin.Log.LogWarning((object)("MTL 없음: " + mtlPath));
			return;
		}
		string text = null;
		foreach (string item in File.ReadLines(mtlPath))
		{
			string text2 = item.Trim();
			if (text2.StartsWith("newmtl "))
			{
				text = text2.Substring(7).Trim();
			}
			else if (text2.StartsWith("map_Kd ") && text != null)
			{
				_materialTexture[text] = text2.Substring(7).Trim();
			}
			else if (text2.StartsWith("Kd ") && text != null)
			{
				string[] array = text2.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length >= 4)
				{
					_materialColor[text] = new Color(Mathf.LinearToGammaSpace(F(array[1])), Mathf.LinearToGammaSpace(F(array[2])), Mathf.LinearToGammaSpace(F(array[3])), 1f);
				}
			}
		}
	}

	private Texture2D LoadTexture(string path)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		if (_textureCache.TryGetValue(path, out var value))
		{
			return value;
		}
		Texture2D val = null;
		if (File.Exists(path))
		{
			val = new Texture2D(2, 2, (TextureFormat)4, true);
			if (ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
			{
				((Object)val).name = Path.GetFileName(path);
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				_texColored[val] = MeasureColored(val, out var meanSat);
				Plugin.Log.LogInfo((object)string.Format("텍스처 {0}: {1}x{2}, 평균 채도={3:F3} → {4}", ((Object)val).name, ((Texture)val).width, ((Texture)val).height, meanSat, _texColored[val] ? "색 있는 텍스처 (MTL 색 무시)" : "회색 텍스처 (MTL 색 곱함)"));
			}
			else
			{
				Plugin.Log.LogWarning((object)("텍스처 디코딩 실패: " + path));
				val = null;
			}
		}
		else
		{
			Plugin.Log.LogWarning((object)("텍스처 없음: " + path));
		}
		_textureCache[path] = val;
		return val;
	}

	private static bool MeasureColored(Texture2D tex, out float meanSat)
	{
		//IL_003e: 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_0045: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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)
		meanSat = 0f;
		try
		{
			Color32[] pixels = tex.GetPixels32();
			if (pixels.Length == 0)
			{
				return false;
			}
			int num = Mathf.Max(1, pixels.Length / 65536);
			double num2 = 0.0;
			int num3 = 0;
			for (int i = 0; i < pixels.Length; i += num)
			{
				Color32 val = pixels[i];
				int num4 = Math.Max(val.r, Math.Max(val.g, val.b));
				int num5 = Math.Min(val.r, Math.Min(val.g, val.b));
				num2 += (double)(num4 - num5) / 255.0;
				num3++;
			}
			meanSat = (float)(num2 / (double)num3);
			return meanSat > 0.05f;
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("텍스처 채도 측정 실패 (" + ((Object)tex).name + "): " + ex.Message));
			return false;
		}
	}

	private static float F(string s)
	{
		return float.Parse(s, NumberStyles.Float, CultureInfo.InvariantCulture);
	}
}
internal class BlockMeshBuilder
{
	private readonly List<Vector3> _verts = new List<Vector3>();

	private readonly List<Vector3> _normals = new List<Vector3>();

	private readonly List<Vector2> _uvs = new List<Vector2>();

	private readonly List<List<int>> _subTris = new List<List<int>>();

	public BlockMeshBuilder(int subMeshCount)
	{
		for (int i = 0; i < subMeshCount; i++)
		{
			_subTris.Add(new List<int>());
		}
	}

	public void AddBox(Vector3 center, Vector3 size, int subMesh = 0)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_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_0079: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		Vector3 h = size * 0.5f;
		AddFace(center, h, Vector3.right, Vector3.up, Vector3.forward, subMesh);
		AddFace(center, h, Vector3.left, Vector3.up, Vector3.back, subMesh);
		AddFace(center, h, Vector3.up, Vector3.forward, Vector3.right, subMesh);
		AddFace(center, h, Vector3.down, Vector3.back, Vector3.right, subMesh);
		AddFace(center, h, Vector3.forward, Vector3.up, Vector3.left, subMesh);
		AddFace(center, h, Vector3.back, Vector3.up, Vector3.right, subMesh);
	}

	private void AddFace(Vector3 c, Vector3 h, Vector3 n, Vector3 up, Vector3 right, int sub)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_0063: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = c + Vector3.Scale(n, h);
		Vector3 val2 = Vector3.Scale(up, h);
		Vector3 val3 = Vector3.Scale(right, h);
		int count = _verts.Count;
		_verts.Add(val - val3 - val2);
		_verts.Add(val - val3 + val2);
		_verts.Add(val + val3 + val2);
		_verts.Add(val + val3 - val2);
		for (int i = 0; i < 4; i++)
		{
			_normals.Add(n);
		}
		_uvs.Add(new Vector2(0f, 0f));
		_uvs.Add(new Vector2(0f, 1f));
		_uvs.Add(new Vector2(1f, 1f));
		_uvs.Add(new Vector2(1f, 0f));
		List<int> list = _subTris[sub];
		list.Add(count);
		list.Add(count + 1);
		list.Add(count + 2);
		list.Add(count);
		list.Add(count + 2);
		list.Add(count + 3);
	}

	public void AddCylinder(Vector3 center, float radius, float height, int segments, int subMesh = 0)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_0076: 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_0087: 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_0094: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: 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_00d4: 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_015b: 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_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: 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_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		List<int> list = _subTris[subMesh];
		float num = height * 0.5f;
		int count = _verts.Count;
		Vector3 val = default(Vector3);
		for (int i = 0; i <= segments; i++)
		{
			float num2 = (float)i / (float)segments * (float)Math.PI * 2f;
			((Vector3)(ref val))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2));
			_verts.Add(center + val * radius + Vector3.down * num);
			_verts.Add(center + val * radius + Vector3.up * num);
			_normals.Add(val);
			_normals.Add(val);
			_uvs.Add(new Vector2((float)i / (float)segments, 0f));
			_uvs.Add(new Vector2((float)i / (float)segments, 1f));
		}
		for (int j = 0; j < segments; j++)
		{
			int num3 = count + j * 2;
			int num4 = num3 + 2;
			list.Add(num3);
			list.Add(num3 + 1);
			list.Add(num4);
			list.Add(num4);
			list.Add(num3 + 1);
			list.Add(num4 + 1);
		}
		AddCap(center + Vector3.up * num, radius, segments, Vector3.up, list);
		AddCap(center + Vector3.down * num, radius, segments, Vector3.down, list);
	}

	private void AddCap(Vector3 c, float radius, int segments, Vector3 n, List<int> t)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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_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)
		//IL_008b: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
		int count = _verts.Count;
		_verts.Add(c);
		_normals.Add(n);
		_uvs.Add(new Vector2(0.5f, 0.5f));
		for (int i = 0; i <= segments; i++)
		{
			float num = (float)i / (float)segments * (float)Math.PI * 2f;
			_verts.Add(c + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * radius);
			_normals.Add(n);
			_uvs.Add(new Vector2(0.5f + Mathf.Cos(num) * 0.5f, 0.5f + Mathf.Sin(num) * 0.5f));
		}
		for (int j = 0; j < segments; j++)
		{
			int num2 = count + 1 + j;
			if (n.y > 0f)
			{
				t.Add(count);
				t.Add(num2 + 1);
				t.Add(num2);
			}
			else
			{
				t.Add(count);
				t.Add(num2);
				t.Add(num2 + 1);
			}
		}
	}

	public Mesh Build(string name)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		Mesh val = new Mesh
		{
			name = name
		};
		val.SetVertices(_verts);
		val.SetNormals(_normals);
		val.SetUVs(0, _uvs);
		val.subMeshCount = _subTris.Count;
		for (int i = 0; i < _subTris.Count; i++)
		{
			val.SetTriangles(_subTris[i], i);
		}
		val.RecalculateBounds();
		return val;
	}
}
internal static class BloxyCola
{
	internal const string ModelFolder = "Piercer/Marksman/Coin";

	private static readonly HashSet<string> LoggedCoins = new HashSet<string>();

	private static Material _src;

	private static bool _objChecked;

	private static AvatarAssets _obj;

	private static Material[] _objMats;

	private static Mesh _blockMesh;

	private static Material[] _blockMats;

	public static void Prepare(GameObject coinPrefab, Material fallbackSource)
	{
		if ((Object)(object)_src != (Object)null)
		{
			return;
		}
		if ((Object)(object)coinPrefab != (Object)null)
		{
			Renderer[] componentsInChildren = coinPrefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material sharedMaterial = val.sharedMaterial;
				if ((val is MeshRenderer || val is SkinnedMeshRenderer) && (Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null && ((Object)sharedMaterial.shader).name.StartsWith("ULTRAKILL/Master"))
				{
					_src = sharedMaterial;
					break;
				}
			}
		}
		if ((Object)(object)_src == (Object)null)
		{
			_src = fallbackSource;
		}
		Plugin.Log.LogInfo((object)("블록시 콜라 머티리얼 원본: " + (((Object)(object)_src != (Object)null) ? (((Object)_src).name + "/" + ((Object)_src.shader).name) : "null")));
	}

	private static AvatarAssets GetObj()
	{
		if (!_objChecked)
		{
			_objChecked = true;
			_obj = Plugin.Instance.GetWeaponAssets("Piercer/Marksman/Coin");
			if (_obj != null && _obj.Parts.Count == 0)
			{
				_obj = null;
			}
			Plugin.Log.LogInfo((object)("블록시 콜라 모델: " + ((_obj != null) ? ("Weapons/Piercer/Marksman/Coin OBJ (" + _obj.Parts.Count + " parts)") : "없음 → 블록 캔")));
		}
		return _obj;
	}

	private static GameObject BuildVisual(string name, Transform parent, int layer)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
		//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_0113: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.layer = layer;
		val.transform.SetParent(parent, false);
		AvatarAssets obj = GetObj();
		if (obj != null)
		{
			obj.GetCombinedBounds(out var center, out var size);
			float num = Mathf.Max(0.01f, size.y);
			if (_objMats == null)
			{
				_objMats = (Material[])(object)new Material[obj.PartOrder.Count];
				for (int i = 0; i < obj.PartOrder.Count; i++)
				{
					AvatarAssets.Part part = obj.Parts[obj.PartOrder[i]];
					_objMats[i] = ViewAnim.MakeMaterial(_src, part.Texture, part.Tint, "BloxyCola_" + part.Name);
				}
			}
			for (int j = 0; j < obj.PartOrder.Count; j++)
			{
				AvatarAssets.Part part2 = obj.Parts[obj.PartOrder[j]];
				GameObject obj2 = ViewAnim.MakeMeshObject(part2.Name, val.transform, layer, part2.Mesh, _objMats[j]);
				obj2.transform.localPosition = (part2.OriginalCenter - center) / num;
				obj2.transform.localScale = Vector3.one / num;
			}
			return val;
		}
		if ((Object)(object)_blockMesh == (Object)null)
		{
			_blockMesh = BuildBlockMesh();
		}
		if (_blockMats == null)
		{
			Plugin instance = Plugin.Instance;
			Texture2D whiteTexture = Texture2D.whiteTexture;
			_blockMats = (Material[])(object)new Material[3]
			{
				ViewAnim.MakeMaterial(_src, whiteTexture, instance.MColaColor.Value, "BloxyColaBody"),
				ViewAnim.MakeMaterial(_src, whiteTexture, instance.MColaLabelColor.Value, "BloxyColaLabel"),
				ViewAnim.MakeMaterial(_src, whiteTexture, new Color(0.75f, 0.75f, 0.78f, 1f), "BloxyColaCap")
			};
		}
		val.AddComponent<MeshFilter>().sharedMesh = _blockMesh;
		MeshRenderer obj3 = val.AddComponent<MeshRenderer>();
		((Renderer)obj3).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj3).receiveShadows = false;
		((Renderer)obj3).sharedMaterials = _blockMats;
		return val;
	}

	public static void Attach(GameObject coinObj, Material fallbackSource)
	{
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)coinObj == (Object)null)
		{
			return;
		}
		Plugin instance = Plugin.Instance;
		int num = -1;
		string text = "";
		Renderer[] componentsInChildren = coinObj.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren)
		{
			if (val is MeshRenderer || val is SkinnedMeshRenderer)
			{
				Material sharedMaterial = val.sharedMaterial;
				if (num < 0)
				{
					num = ((Component)val).gameObject.layer;
					text = string.Format("{0} layer={1} mat={2}", ((Object)((Component)val).gameObject).name, ((Component)val).gameObject.layer, ((Object)(object)sharedMaterial != (Object)null) ? (((Object)sharedMaterial).name + "/" + (((Object)(object)sharedMaterial.shader != (Object)null) ? ((Object)sharedMaterial.shader).name : "null")) : "null");
				}
				val.forceRenderingOff = true;
			}
		}
		if (num < 0)
		{
			num = coinObj.layer;
		}
		if (LoggedCoins.Add(((Object)coinObj).name))
		{
			Plugin.Log.LogInfo((object)$"블록시 콜라 부착: coin='{((Object)coinObj).name}' layer={coinObj.layer} 표시레이어={num} model=[{text}] lossyScale={coinObj.transform.lossyScale}");
		}
		Prepare(null, fallbackSource);
		GameObject obj = BuildVisual("BloxyCola", coinObj.transform, num);
		ViewAnim.SetWorldScale(obj.transform, instance.MColaHeight.Value);
		obj.AddComponent<ColaSpin>().Init(coinObj.GetComponent<Rigidbody>());
	}

	public static GameObject CreateHeld(Transform parent, int layer, Material fallbackSource)
	{
		Prepare(null, fallbackSource);
		return BuildVisual("HeldBloxyCola", parent, layer);
	}

	private static Mesh BuildBlockMesh()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		BlockMeshBuilder blockMeshBuilder = new BlockMeshBuilder(3);
		blockMeshBuilder.AddCylinder(Vector3.zero, 0.3f, 0.84f, 16);
		blockMeshBuilder.AddCylinder(Vector3.zero, 0.305f, 0.34f, 16, 1);
		blockMeshBuilder.AddCylinder(new Vector3(0f, 0.46f, 0f), 0.27f, 0.08f, 16, 2);
		blockMeshBuilder.AddCylinder(new Vector3(0f, -0.46f, 0f), 0.27f, 0.08f, 16, 2);
		return blockMeshBuilder.Build("BloxyColaMesh");
	}
}
internal class ColaSpin : MonoBehaviour
{
	private Rigidbody _rb;

	private float _speed;

	private Vector3 _axis;

	public void Init(Rigidbody rb)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		_rb = rb;
		_speed = Plugin.Instance.MColaSpinSpeed.Value;
		Vector3 val = new Vector3(1f, Random.Range(-0.25f, 0.25f), Random.Range(-0.15f, 0.15f));
		_axis = ((Vector3)(ref val)).normalized;
		((Component)this).transform.localRotation = Quaternion.AngleAxis(Random.Range(0f, 360f), _axis);
	}

	private void Update()
	{
		//IL_006a: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_rb != (Object)null && !_rb.isKinematic)
		{
			Vector3 velocity = _rb.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude < 4f)
			{
				_speed = Mathf.MoveTowards(_speed, 0f, Time.deltaTime * 2000f);
			}
		}
		if (_speed > 0f)
		{
			((Component)this).transform.Rotate(_axis, _speed * Time.deltaTime, (Space)1);
		}
	}
}
internal static class Chainsaw
{
	private static Mesh _mesh;

	private static float _meshBlade;

	public static GameObject Create(Transform parent, int layer, Material source, bool centered = false)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_00e7: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Expected O, but got Unknown
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		Plugin instance = Plugin.Instance;
		GameObject val = new GameObject(centered ? "ThrownChainsawVisual" : "HeldChainsaw");
		val.layer = layer;
		if ((Object)(object)parent != (Object)null)
		{
			val.transform.SetParent(parent, false);
		}
		AvatarAssets weaponAssets = instance.GetWeaponAssets("ShotGun/Sawed-On");
		if (weaponAssets != null && weaponAssets.Parts.Count > 0)
		{
			GameObject val2 = weaponAssets.BuildModel("ChainsawModel", val.transform, layer, source, useMtlColor: true);
			if (centered)
			{
				val2.transform.localPosition = Vector3.zero;
			}
			else
			{
				float value = instance.SOObjScale.Value;
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(instance.SOObjGripX.Value, instance.SOObjGripY.Value, instance.SOObjGripZ.Value);
				val2.transform.localScale = Vector3.one * value;
				val2.transform.localPosition = -val3 * value;
				Plugin.Log.LogInfo((object)$"전기톱 모델: Sawed-On.obj ({weaponAssets.Parts.Count} parts), scale={value}, grip={val3}");
			}
			return val;
		}
		if (!centered)
		{
			Plugin.Log.LogInfo((object)"전기톱 모델: Sawed-On.obj 없음 → 블록 전기톱");
		}
		float num = Mathf.Max(0.3f, instance.SOSawBlade.Value);
		if ((Object)(object)_mesh == (Object)null || !Mathf.Approximately(_meshBlade, num))
		{
			_mesh = BuildMesh(num);
			_meshBlade = num;
		}
		Texture2D whiteTexture = Texture2D.whiteTexture;
		Material[] sharedMaterials = (Material[])(object)new Material[3]
		{
			ViewAnim.MakeMaterial(source, whiteTexture, instance.SOBodyColor.Value, "RobloxChainsawBody"),
			ViewAnim.MakeMaterial(source, whiteTexture, new Color(0.12f, 0.12f, 0.13f, 1f), "RobloxChainsawDark"),
			ViewAnim.MakeMaterial(source, whiteTexture, instance.SOBarColor.Value, "RobloxChainsawBar")
		};
		GameObject val4 = new GameObject("ChainsawBlock");
		val4.layer = layer;
		val4.transform.SetParent(val.transform, false);
		if (centered)
		{
			val4.transform.localPosition = new Vector3(0f, 0f, (0f - (0.95f + num)) * 0.5f);
		}
		val4.AddComponent<MeshFilter>().sharedMesh = _mesh;
		MeshRenderer obj = val4.AddComponent<MeshRenderer>();
		((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj).receiveShadows = false;
		((Renderer)obj).sharedMaterials = sharedMaterials;
		return val;
	}

	private static Mesh BuildMesh(float blade)
	{
		//IL_0017: 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_0046: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: 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_01de: Unknown result type (might be due to invalid IL or missing references)
		BlockMeshBuilder blockMeshBuilder = new BlockMeshBuilder(3);
		blockMeshBuilder.AddBox(new Vector3(0f, 0f, 0f), new Vector3(0.22f, 0.22f, 0.5f), 1);
		blockMeshBuilder.AddBox(new Vector3(0f, 0.05f, 0.55f), new Vector3(0.6f, 0.65f, 0.75f));
		blockMeshBuilder.AddBox(new Vector3(0f, 0.55f, 0.5f), new Vector3(0.14f, 0.12f, 0.6f), 1);
		blockMeshBuilder.AddBox(new Vector3(0f, 0.45f, 0.24f), new Vector3(0.14f, 0.22f, 0.1f), 1);
		blockMeshBuilder.AddBox(new Vector3(0f, 0.45f, 0.76f), new Vector3(0.14f, 0.22f, 0.1f), 1);
		blockMeshBuilder.AddBox(new Vector3(0f, 0.15f, 0.95f), new Vector3(0.5f, 0.45f, 0.06f), 1);
		float num = 0.95f;
		blockMeshBuilder.AddBox(new Vector3(0f, -0.05f, num + blade * 0.5f), new Vector3(0.08f, 0.34f, blade), 2);
		blockMeshBuilder.AddBox(new Vector3(0f, -0.05f, num + blade + 0.06f), new Vector3(0.08f, 0.24f, 0.12f), 2);
		for (float num2 = num + 0.08f; num2 < num + blade; num2 += 0.16f)
		{
			blockMeshBuilder.AddBox(new Vector3(0f, 0.14f, num2), new Vector3(0.11f, 0.06f, 0.09f), 1);
			blockMeshBuilder.AddBox(new Vector3(0f, -0.24f, num2), new Vector3(0.11f, 0.06f, 0.09f), 1);
		}
		return blockMeshBuilder.Build("RobloxChainsawMesh");
	}
}
internal class GunHud
{
	private static Font _font;

	private static bool _fontLogged;

	private readonly GameObject _obj;

	private readonly TextMesh _text;

	private readonly TextMesh _shadow;

	private readonly string _logName;

	private string _last;

	private bool _logged;

	private GunHud(GameObject obj, TextMesh text, TextMesh shadow, string logName)
	{
		_obj = obj;
		_text = text;
		_shadow = shadow;
		_logName = logName;
	}

	public static GunHud Create(Transform parent, int layer, string logName)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0058: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		Font font = GetFont();
		if ((Object)(object)font == (Object)null)
		{
			return null;
		}
		GameObject val = new GameObject("GunHud");
		val.layer = layer;
		val.transform.SetParent(parent, false);
		TextMesh val2 = MakeText("Shadow", val.transform, layer, font);
		val2.color = new Color(0f, 0f, 0f, 0.85f);
		((Component)val2).transform.localPosition = new Vector3(0.025f, -0.025f, 0.01f);
		TextMesh val3 = MakeText("Text", val.transform, layer, font);
		val3.color = Color.white;
		return new GunHud(val, val3, val2, logName);
	}

	private static Font GetFont()
	{
		if ((Object)(object)_font != (Object)null)
		{
			return _font;
		}
		string[] array = new string[2] { "LegacyRuntime.ttf", "Arial.ttf" };
		foreach (string text in array)
		{
			try
			{
				_font = Resources.GetBuiltinResource<Font>(text);
			}
			catch (Exception)
			{
				_font = null;
			}
			if ((Object)(object)_font != (Object)null)
			{
				break;
			}
		}
		if ((Object)(object)_font == (Object)null)
		{
			_font = Font.CreateDynamicFontFromOSFont("Arial", 32);
		}
		if (!_fontLogged)
		{
			_fontLogged = true;
			Plugin.Log.LogInfo((object)("무기 HUD 폰트: " + (((Object)(object)_font != (Object)null) ? ((Object)_font).name : "null") + ", material=" + (((Object)(object)_font != (Object)null && (Object)(object)_font.material != (Object)null) ? ((Object)_font.material.shader).name : "null")));
		}
		return _font;
	}

	private static TextMesh MakeText(string name, Transform parent, int layer, Font font)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.layer = layer;
		val.transform.SetParent(parent, false);
		TextMesh obj = val.AddComponent<TextMesh>();
		obj.font = font;
		obj.fontSize = 48;
		obj.characterSize = 0.1f;
		obj.anchor = (TextAnchor)7;
		obj.alignment = (TextAlignment)1;
		obj.richText = true;
		MeshRenderer component = val.GetComponent<MeshRenderer>();
		((Renderer)component).sharedMaterial = font.material;
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component).receiveShadows = false;
		return obj;
	}

	public void SetVisible(bool on)
	{
		if ((Object)(object)_obj != (Object)null && _obj.activeSelf != on)
		{
			_obj.SetActive(on);
		}
	}

	public void Update(Transform cam, Vector3 worldPos, float lineHeight, string title, Color titleColor, string state)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_obj == (Object)null) && _obj.activeSelf)
		{
			Transform transform = _obj.transform;
			transform.position = worldPos;
			transform.rotation = cam.rotation;
			ViewAnim.SetWorldScale(transform, lineHeight / 0.48f);
			string text = title + "|" + state;
			if (text != _last)
			{
				_last = text;
				string text2 = ColorUtility.ToHtmlStringRGB(titleColor);
				_text.text = "<color=#" + text2 + ">" + title + "</color>\n" + state;
				_shadow.text = title + "\n" + state;
			}
			if (!_logged)
			{
				_logged = true;
				MeshRenderer component = ((Component)_text).GetComponent<MeshRenderer>();
				ManualLogSource log = Plugin.Log;
				object[] obj = new object[4]
				{
					_logName,
					cam.InverseTransformPoint(transform.position),
					null,
					null
				};
				Bounds bounds = ((Renderer)component).bounds;
				obj[2] = ((Bounds)(ref bounds)).size;
				obj[3] = _obj.layer;
				log.LogInfo((object)string.Format("{0} HUD: pos(cam)={1}, bounds={2}, layer={3}", obj));
			}
		}
	}
}
[Serializable]
internal class ModSaveData
{
	public int Version = 1;

	public int EnterCount;

	public int Currency;

	public List<string> UnlockedWeapons = new List<string>();

	private static string Dir => Path.Combine(Paths.ConfigPath, "RobloxMode");

	private static string FilePath => Path.Combine(Dir, "save.json");

	public static ModSaveData Load()
	{
		try
		{
			if (File.Exists(FilePath))
			{
				ModSaveData modSaveData = JsonConvert.DeserializeObject<ModSaveData>(File.ReadAllText(FilePath));
				if (modSaveData != null)
				{
					if (modSaveData.UnlockedWeapons == null)
					{
						modSaveData.UnlockedWeapons = new List<string>();
					}
					return modSaveData;
				}
			}
		}
		catch (Exception arg)
		{
			Plugin.Log.LogError((object)$"save.json 로드 실패, 새로 생성: {arg}");
		}
		ModSaveData modSaveData2 = new ModSaveData();
		modSaveData2.Save();
		return modSaveData2;
	}

	public void Save()
	{
		try
		{
			Directory.CreateDirectory(Dir);
			string text = FilePath + ".tmp";
			File.WriteAllText(text, JsonConvert.SerializeObject((object)this, (Formatting)1));
			if (File.Exists(FilePath))
			{
				File.Delete(FilePath);
			}
			File.Move(text, FilePath);
		}
		catch (Exception arg)
		{
			Plugin.Log.LogError((object)$"save.json 저장 실패: {arg}");
		}
	}

	public bool IsUnlocked(string weaponId)
	{
		return UnlockedWeapons.Contains(weaponId);
	}

	public void Unlock(string weaponId)
	{
		if (!UnlockedWeapons.Contains(weaponId))
		{
			UnlockedWeapons.Add(weaponId);
			Save();
		}
	}
}
internal static class ModeManager
{
	private const string MainMenuScene = "Main Menu";

	public static bool IsActive
	{
		get
		{
			if (Plugin.Loaded)
			{
				return GameProgressSaver.currentSlot == Plugin.Instance.ReservedSlot.Value;
			}
			return false;
		}
	}

	public static bool IsInMainMenu => SceneHelper.CurrentScene == "Main Menu";

	public static void Toggle()
	{
		if (IsActive)
		{
			Exit();
		}
		else
		{
			Enter();
		}
	}

	public static void Enter()
	{
		Plugin instance = Plugin.Instance;
		int currentSlot = GameProgressSaver.currentSlot;
		int value = instance.ReservedSlot.Value;
		if (currentSlot != value)
		{
			if (currentSlot >= 0 && currentSlot <= 4)
			{
				instance.ReturnSlot.Value = currentSlot;
				((BaseUnityPlugin)instance).Config.Save();
			}
			Plugin.Log.LogInfo((object)$"Enter Roblox Mode: slot {currentSlot} -> {value}");
			instance.SaveData.EnterCount++;
			instance.SaveData.Save();
			GameProgressSaver.SetSlot(value);
			SceneHelper.LoadScene("Main Menu", false);
		}
	}

	public static void Exit()
	{
		int num = Plugin.Instance.ReturnSlot.Value;
		if (num < 0 || num > 4)
		{
			num = 0;
		}
		Plugin.Log.LogInfo((object)$"Exit Roblox Mode: slot {GameProgressSaver.currentSlot} -> {num}");
		GameProgressSaver.SetSlot(num);
		SceneHelper.LoadScene("Main Menu", false);
	}
}
internal static class PunchPatchUtil
{
	internal static RobloxArm Arm(Punch p)
	{
		if (!ModeManager.IsActive || (Object)(object)p == (Object)null)
		{
			return null;
		}
		return ((Component)p).GetComponent<RobloxArm>();
	}
}
[HarmonyPatch(typeof(Punch), "PunchStart")]
internal static class PunchStartPatch
{
	private static void Postfix(Punch __instance)
	{
		RobloxArm robloxArm = PunchPatchUtil.Arm(__instance);
		if ((Object)(object)robloxArm != (Object)null)
		{
			robloxArm.OnPunchStart();
		}
	}
}
[HarmonyPatch(typeof(Punch), "ActiveStart")]
internal static class PunchActiveStartPatch
{
	private static void Postfix(Punch __instance)
	{
		RobloxArm robloxArm = PunchPatchUtil.Arm(__instance);
		if ((Object)(object)robloxArm != (Object)null)
		{
			robloxArm.OnActiveStart();
		}
	}
}
[HarmonyPatch(typeof(Punch), "ActiveEnd")]
internal static class PunchActiveEndPatch
{
	private static void Postfix(Punch __instance)
	{
		RobloxArm robloxArm = PunchPatchUtil.Arm(__instance);
		if ((Object)(object)robloxArm != (Object)null)
		{
			robloxArm.OnActiveEnd();
		}
	}
}
[HarmonyPatch(typeof(Punch), "PunchEnd")]
internal static class PunchEndPatch
{
	private static void Postfix(Punch __instance)
	{
		RobloxArm robloxArm = PunchPatchUtil.Arm(__instance);
		if ((Object)(object)robloxArm != (Object)null)
		{
			robloxArm.OnActiveEnd();
		}
	}
}
[HarmonyPatch(typeof(Punch), "Parry")]
internal static class PunchParryPatch
{
	private static void Postfix(Punch __instance)
	{
		RobloxArm robloxArm = PunchPatchUtil.Arm(__instance);
		if ((Object)(object)robloxArm != (Object)null)
		{
			robloxArm.OnParry();
		}
	}
}
[BepInPlugin("com.crossflow.robloxmode", "RobloxMode", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string PluginGuid = "com.crossflow.robloxmode";

	public const string PluginName = "RobloxMode";

	public const string PluginVersion = "1.0.0";

	private const Key DefaultToggleKey = (Key)102;

	private const float ScanInterval = 0.5f;

	private const string RevolverFolder = "Piercer";

	private static readonly string[] RevolverVariantNames = new string[3] { "Normal", "Marksman", "Sharpshooter" };

	private const string ShotgunFolder = "ShotGun";

	private static readonly string[] ShotgunVariantNames = new string[3] { "Core Eject", "Pump Charge", "Sawed-On" };

	internal static Plugin Instance;

	internal static bool Loaded;

	internal static ManualLogSource Log;

	internal ConfigEntry<int> ReservedSlot;

	internal ConfigEntry<int> ReturnSlot;

	internal ConfigEntry<Key> ToggleKey;

	internal ConfigEntry<string> AvatarObj;

	internal ConfigEntry<float> BobAmount;

	internal ConfigEntry<float> BobFrequency;

	internal ConfigEntry<float> SwayAmount;

	internal ConfigEntry<float> SwayMaxOffset;

	internal ConfigEntry<float> SwaySmooth;

	internal ConfigEntry<bool> LArmEnabled;

	internal ConfigEntry<string> LArmPart;

	internal ConfigEntry<float> LArmWorldPerStud;

	internal ConfigEntry<float> LArmIdleX;

	internal ConfigEntry<float> LArmIdleY;

	internal ConfigEntry<float> LArmIdleZ;

	internal ConfigEntry<float> LArmIdlePitch;

	internal ConfigEntry<float> LArmIdleYaw;

	internal ConfigEntry<float> LArmIdleRoll;

	internal ConfigEntry<float> LArmIdleTwist;

	internal ConfigEntry<float> LArmPunchX;

	internal ConfigEntry<float> LArmPunchY;

	internal ConfigEntry<float> LArmPunchZ;

	internal ConfigEntry<float> LArmPunchPitch;

	internal ConfigEntry<float> LArmPunchYaw;

	internal ConfigEntry<float> LArmPunchRoll;

	internal ConfigEntry<float> LArmPunchTwist;

	internal ConfigEntry<float> LArmWindupFallback;

	internal ConfigEntry<float> LArmMaxHold;

	internal ConfigEntry<float> LArmReturnDuration;

	internal ConfigEntry<float> LArmBreathAmount;

	internal ConfigEntry<float> LArmBreathSpeed;

	internal ConfigEntry<bool> PEnabled;

	internal ConfigEntry<float> PWorldPerStud;

	internal ConfigEntry<float> PPosX;

	internal ConfigEntry<float> PPosY;

	internal ConfigEntry<float> PPosZ;

	internal ConfigEntry<float> PRotX;

	internal ConfigEntry<float> PRotY;

	internal ConfigEntry<float> PRotZ;

	internal ConfigEntry<bool> PArmEnabled;

	internal ConfigEntry<string> PArmPart;

	internal ConfigEntry<float> PArmHandX;

	internal ConfigEntry<float> PArmHandY;

	internal ConfigEntry<float> PArmHandZ;

	internal ConfigEntry<float> PArmPitch;

	internal ConfigEntry<float> PArmYaw;

	internal ConfigEntry<float> PArmRoll;

	internal ConfigEntry<float> PArmGripDepth;

	internal ConfigEntry<float> PDrawDuration;

	internal ConfigEntry<float> PFireInterval;

	internal ConfigEntry<RobloxRevolver.RightClickMode> PRightClickMode;

	internal ConfigEntry<float> PChargeTime;

	internal ConfigEntry<float> PSuperCooldown;

	internal ConfigEntry<float> PSuperDamageMultiplier;

	internal ConfigEntry<float> PSuperRecoilScale;

	internal ConfigEntry<float> PChargeShake;

	internal ConfigEntry<int> PBurstCount;

	internal ConfigEntry<float> PBurstInterval;

	internal ConfigEntry<float> PBurstCooldown;

	internal ConfigEntry<float> PDamageMultiplier;

	internal ConfigEntry<float> PPitch;

	internal ConfigEntry<float> PShake;

	internal ConfigEntry<float> PRecoilBack;

	internal ConfigEntry<float> PRecoilAngle;

	internal ConfigEntry<float> PRecoilRecovery;

	internal ConfigEntry<bool> PShareModel;

	internal ConfigEntry<bool> PHud;

	internal ConfigEntry<float> PHudX;

	internal ConfigEntry<float> PHudY;

	internal ConfigEntry<float> PHudZ;

	internal ConfigEntry<float> PHudSize;

	internal ConfigEntry<float> MColaHeight;

	internal ConfigEntry<Color> MColaColor;

	internal ConfigEntry<Color> MColaLabelColor;

	internal ConfigEntry<float> MColaSpinSpeed;

	internal ConfigEntry<bool> MHeldCola;

	internal ConfigEntry<float> MHeldHeight;

	internal ConfigEntry<float> MHeldX;

	internal ConfigEntry<float> MHeldY;

	internal ConfigEntry<float> MHeldZ;

	internal ConfigEntry<float> MHeldRotX;

	internal ConfigEntry<float> MHeldRotY;

	internal ConfigEntry<float> MHeldRotZ;

	internal ConfigEntry<int> SMaxBounces;

	internal ConfigEntry<float> SStepTime;

	internal ConfigEntry<float> SCooldown;

	internal ConfigEntry<bool> STwirl;

	internal ConfigEntry<float> STwirlSpeed;

	internal ConfigEntry<float> STwirlDirection;

	internal ConfigEntry<float> STwirlPivotX;

	internal ConfigEntry<float> STwirlPivotY;

	private const int CurrentConfigVersion = 13;

	internal ConfigEntry<int> ConfigVersion;

	internal ConfigEntry<bool> REnabled;

	internal ConfigEntry<bool> RUsePlaceholder;

	internal ConfigEntry<float> RWorldPerStud;

	internal ConfigEntry<float> RPosX;

	internal ConfigEntry<float> RPosY;

	internal ConfigEntry<float> RPosZ;

	internal ConfigEntry<float> RRotX;

	internal ConfigEntry<float> RRotY;

	internal ConfigEntry<float> RRotZ;

	internal ConfigEntry<float> RGripX;

	internal ConfigEntry<float> RGripY;

	internal ConfigEntry<float> RGripZ;

	internal ConfigEntry<float> RMuzzleX;

	internal ConfigEntry<float> RMuzzleY;

	internal ConfigEntry<float> RMuzzleZ;

	internal ConfigEntry<float> ROneHandTilt;

	internal ConfigEntry<float> RLeftHandX;

	internal ConfigEntry<float> RLeftHandY;

	internal ConfigEntry<float> RLeftHandZ;

	internal ConfigEntry<float> RLeftArmPitch;

	internal ConfigEntry<float> RLeftArmYaw;

	internal ConfigEntry<float> RLeftArmRoll;

	internal ConfigEntry<Color> RBodyColor;

	internal ConfigEntry<Color> RAccentColor;

	internal ConfigEntry<float> RFireRate;

	internal ConfigEntry<float> RSpread;

	internal ConfigEntry<float> RDamageMultiplier;

	internal ConfigEntry<int> RMagazineSize;

	internal ConfigEntry<float> RReloadTime;

	internal ConfigEntry<float> RPitch;

	internal ConfigEntry<float> RShake;

	internal ConfigEntry<float> RRecoilBack;

	internal ConfigEntry<float> RRecoilAngle;

	internal ConfigEntry<float> RRecoilRecovery;

	internal ConfigEntry<float> RDrawDuration;

	internal ConfigEntry<float> RGrenadeCooldown;

	internal ConfigEntry<float> RGrenadeSpeed;

	internal ConfigEntry<float> RGrenadeArc;

	internal ConfigEntry<bool> RShareModel;

	internal ConfigEntry<string> RUnderbarrelPart;

	internal ConfigEntry<float> RUnderOffsetY;

	internal ConfigEntry<bool> RHud;

	internal ConfigEntry<float> RHudY;

	internal ConfigEntry<float> RHudForward;

	internal ConfigEntry<float> RHudSize;

	internal ConfigEntry<float> RMagX;

	internal ConfigEntry<float> RMagY;

	internal ConfigEntry<float> RMagZ;

	internal ConfigEntry<float> PCWorldPerStud;

	internal ConfigEntry<float> PCPosX;

	internal ConfigEntry<float> PCPosY;

	internal ConfigEntry<float> PCPosZ;

	internal ConfigEntry<float> PCRightArmPitch;

	internal ConfigEntry<float> PCRightArmYaw;

	internal ConfigEntry<float> PCLeftArmPitch;

	internal ConfigEntry<float> PCLeftArmYaw;

	internal ConfigEntry<float> PCRotY;

	internal ConfigEntry<float> PCGripX;

	internal ConfigEntry<float> PCGripY;

	internal ConfigEntry<float> PCGripZ;

	internal ConfigEntry<float> PCMuzzleX;

	internal ConfigEntry<float> PCMuzzleY;

	internal ConfigEntry<float> PCMuzzleZ;

	internal ConfigEntry<float> PCLeftHandX;

	internal ConfigEntry<float> PCLeftHandY;

	internal ConfigEntry<float> PCLeftHandZ;

	internal ConfigEntry<float> PCCooldown;

	internal ConfigEntry<float> PCGripDepth;

	internal ConfigEntry<float> PCOverpumpRange;

	internal ConfigEntry<float> PCForeEndZMin;

	internal ConfigEntry<float> PCForeEndZMax;

	internal ConfigEntry<float> PCForeEndYMin;

	internal ConfigEntry<float> PCForeEndYMax;

	internal ConfigEntry<int> PCPellets;

	internal ConfigEntry<float> PCSpread;

	internal ConfigEntry<float> PCPumpDelay;

	internal ConfigEntry<float> PCPumpSlide;

	internal ConfigEntry<Color> PCTubeColor;

	internal ConfigEntry<Color> PCGripColor;

	internal ConfigEntry<float> SOTick;

	internal ConfigEntry<float> SODamagePerTick;

	internal ConfigEntry<float> SORadius;

	internal ConfigEntry<float> SOReach;

	internal ConfigEntry<float> SOGrindHandX;

	internal ConfigEntry<float> SOGrindHandY;

	internal ConfigEntry<float> SOGrindHandZ;

	internal ConfigEntry<float> SOGrindPitch;

	internal ConfigEntry<float> SOGrindYaw;

	internal ConfigEntry<float> SOGrindHeldRotX;

	internal ConfigEntry<float> SOSawBlade;

	internal ConfigEntry<float> SOSawScale;

	internal ConfigEntry<Color> SOBodyColor;

	internal ConfigEntry<Color> SOBarColor;

	internal ConfigEntry<float> SOHeldX;

	internal ConfigEntry<float> SOHeldY;

	internal ConfigEntry<float> SOHeldZ;

	internal ConfigEntry<float> SOHeldRotX;

	internal ConfigEntry<float> SOHeldRotY;

	internal ConfigEntry<float> SOHeldRotZ;

	internal ConfigEntry<float> SOObjScale;

	internal ConfigEntry<float> SOThrowSpeed;

	internal ConfigEntry<float> SOThrowRange;

	internal ConfigEntry<float> SOThrowRadius;

	internal ConfigEntry<float> SOThrowDamagePerTick;

	internal ConfigEntry<float> SOGrindTime;

	internal ConfigEntry<float> SOThrowCooldown;

	internal ConfigEntry<float> SOThrownWorldPerStud;

	internal ConfigEntry<float> SOThrownSpin;

	internal ConfigEntry<float> SOPunchRange;

	internal ConfigEntry<float> SOPunchDamageMultiplier;

	internal ConfigEntry<float> SOObjGripX;

	internal ConfigEntry<float> SOObjGripY;

	internal ConfigEntry<float> SOObjGripZ;

	internal ConfigEntry<float> SOIdlePitch;

	internal ConfigEntry<float> SOIdleYaw;

	internal ModSaveData SaveData;

	private Harmony _harmony;

	private AvatarAssets _avatar;

	private bool _avatarLoadAttempted;

	private readonly Dictionary<string, AvatarAssets> _weaponAssets = new Dictionary<string, AvatarAssets>();

	private float _nextScan;

	private GUIStyle _labelStyle;

	private bool _toggleKeyWasDown;

	internal static string PluginDir => Path.GetDirectoryName(typeof(Plugin).Assembly.Location);

	private void Awake()
	{
		//IL_0a78: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab1: Unknown result type (might be due to invalid IL or missing references)
		//IL_1079: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_1886: Unknown result type (might be due to invalid IL or missing references)
		//IL_18bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ab4: Unknown result type (might be due to invalid IL or missing references)
		//IL_1aed: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e5c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e63: Invalid comparison between Unknown and I4
		//IL_1e82: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ff7: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f1e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f28: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		ReservedSlot = ((BaseUnityPlugin)this).Config.Bind<int>("Save", "ReservedSlotIndex", 98, "Roblox 모드 전용 세이브 슬롯 인덱스. 실제 폴더는 Saves/Slot{인덱스+1} (기본 98 -> Slot99). 기존 슬롯(0~4)과 겹치면 안 됨.");
		ReturnSlot = ((BaseUnityPlugin)this).Config.Bind<int>("Save", "ReturnSlotIndex", 0, "Roblox 모드 종료 시 돌아갈 일반 슬롯 인덱스 (0~4). 모드 진입 시 자동 기록됨.");
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Input", "ToggleKey", (Key)102, "메인 메뉴에서 Roblox 모드 진입/종료 키. F8은 게임 콘솔 키라 사용 불가.");
		AvatarObj = ((BaseUnityPlugin)this).Config.Bind<string>("Avatar", "ObjFile", "blue0k37.obj", "plugins/CrossFlow-RobloxMode/Avatar 폴더 안의 Roblox OBJ 파일 이름");
		BobAmount = ((BaseUnityPlugin)this).Config.Bind<float>("ViewModel", "BobAmount", 0.025f, "걸을 때 흔들림 크기 (월드 단위)");
		BobFrequency = ((BaseUnityPlugin)this).Config.Bind<float>("ViewModel", "BobFrequency", 9f, "걸을 때 흔들림 속도");
		SwayAmount = ((BaseUnityPlugin)this).Config.Bind<float>("ViewModel", "SwayAmount", 1f, "시점 돌릴 때 팔/총 관성 흔들림 배율 (0 = 끔)");
		SwayMaxOffset = ((BaseUnityPlugin)this).Config.Bind<float>("ViewModel", "SwayMaxOffset", 0.04f, "관성 흔들림 최대 이동량 (월드 단위)");
		SwaySmooth = ((BaseUnityPlugin)this).Config.Bind<float>("ViewModel", "SwaySmooth", 10f, "관성 흔들림 따라오는 속도 (클수록 빠름)");
		LArmEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("LeftArm", "Enabled", true, "Roblox 모드에서 V1 왼팔을 Roblox 팔로 교체 (자체 애니메이션)");
		LArmPart = ((BaseUnityPlugin)this).Config.Bind<string>("LeftArm", "PartName", "Rig4", "OBJ 그룹 이름 (R6: Rig4 = 왼팔)");
		LArmWorldPerStud = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "WorldPerStud", 0.3f, "1 stud 당 화면 크기");
		LArmIdleX = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdleHandX", -0.34f, "대기 시 손 위치 X (카메라 기준, 오른쪽 +)");
		LArmIdleY = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdleHandY", -0.32f, "대기 시 손 위치 Y (위 +)");
		LArmIdleZ = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdleHandZ", 0.85f, "대기 시 손 위치 Z (앞 +)");
		LArmIdlePitch = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdlePitch", -130f, "대기 시 팔 기울기 (-90 수평, -180 수직)");
		LArmIdleYaw = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdleYaw", 15f, "대기 시 팔 좌우 각도");
		LArmIdleRoll = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdleRoll", 0f, "대기 시 팔 옆 기울기");
		LArmIdleTwist = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "IdleTwist", 0f, "대기 시 팔 길이축 비틀기 (도)");
		LArmPunchX = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchHandX", -0.12f, "펀치 최대 손 위치 X");
		LArmPunchY = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchHandY", -0.16f, "펀치 최대 손 위치 Y");
		LArmPunchZ = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchHandZ", 1.35f, "펀치 최대 손 위치 Z");
		LArmPunchPitch = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchPitch", -95f, "펀치 시 팔 기울기");
		LArmPunchYaw = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchYaw", 5f, "펀치 시 팔 좌우 각도");
		LArmPunchRoll = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchRoll", 0f, "펀치 시 팔 옆 기울기");
		LArmPunchTwist = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "PunchTwist", 90f, "펀치 시 팔 길이축 비틀기 (도). 90 = 코르크스크루 펀치");
		LArmWindupFallback = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "WindupFallback", 0.08f, "키 입력→최대로 뻗기 시간(초). 원작 타격 시점(ActiveStart)을 실측하면 그 값을 대신 사용 (첫 펀치에만 쓰임)");
		LArmMaxHold = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "MaxHold", 0.25f, "최대로 뻗은 채 유지하는 최대 시간(초). 보통은 원작 타격 끝(ActiveEnd)에 맞춰 복귀");
		LArmReturnDuration = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "ReturnDuration", 0.2f, "펀치 후 제자리로 돌아오는 시간(초)");
		LArmBreathAmount = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "BreathAmount", 0.008f, "대기 숨쉬기 동작 크기 (0 = 끔)");
		LArmBreathSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("LeftArm", "BreathSpeed", 1.6f, "대기 숨쉬기 동작 속도");
		PEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Pistol", "Enabled", true, "Roblox 모드에서 리볼버를 Roblox 권총으로 교체. Weapons/Piercer/{Normal|Marksman|Sharpshooter}[ Alt] 폴더에 OBJ가 있는 변형만 교체");
		PWorldPerStud = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "WorldPerStud", 0.3f, "1 stud 당 화면 크기");
		PPosX = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "PosX", 0.28f, "총 중심 X (카메라 기준, 오른쪽 +)");
		PPosY = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "PosY", -0.27f, "총 중심 Y (위 +)");
		PPosZ = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "PosZ", 0.62f, "총 중심 Z (앞 +)");
		PRotX = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "RotX", 0f, "총 모델 회전 X");
		PRotY = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "RotY", -90f, "총 모델 회전 Y (기본 -90: 모델 +X 총구 -> 화면 앞)");
		PRotZ = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "RotZ", 0f, "총 모델 회전 Z");
		PArmEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Pistol", "ArmEnabled", true, "총 쥔 Roblox 오른팔 표시");
		PArmPart = ((BaseUnityPlugin)this).Config.Bind<string>("Pistol", "ArmPartName", "Rig3", "오른팔 OBJ 그룹 이름");
		PArmHandX = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmHandX", 0f, "손 끝 위치 보정 X (stud, 손잡이 기준)");
		PArmHandY = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmHandY", 0f, "손 끝 위치 보정 Y (stud)");
		PArmHandZ = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmHandZ", 0f, "손 끝 위치 보정 Z (stud)");
		PArmPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmPitch", -90f, "오른팔 기울기 (-90 = 앞으로 수평, Roblox 도구 드는 자세)");
		PArmYaw = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmYaw", -6f, "오른팔 좌우 각도 (- = 안쪽)");
		PArmRoll = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmRoll", 0f, "오른팔 비틀기");
		PArmGripDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ArmGripDepth", 0.35f, "손잡이가 팔 끝에서 안쪽으로 들어간 깊이 (stud). 클수록 총이 팔 쪽으로 깊이 박힘");
		PDrawDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "DrawDuration", 0.3f, "꺼내기 애니메이션 길이(초)");
		PFireInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "FireInterval", 0.15f, "좌클릭 단발 간격(초)");
		PRightClickMode = ((BaseUnityPlugin)this).Config.Bind<RobloxRevolver.RightClickMode>("Pistol", "RightClickMode", RobloxRevolver.RightClickMode.Charge, "우클릭 능력. Charge = 누르고 있다가 완충 후 떼면 관통 강화탄 / Burst = 점사");
		PChargeTime = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ChargeTime", 0.8f, "차지샷 완충 시간(초)");
		PSuperCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "SuperCooldown", 2.5f, "차지샷 발사 후 재충전 대기(초). 대기 중엔 총이 어두워짐");
		PSuperDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "SuperDamageMultiplier", 1f, "강화탄 데미지 추가 배율 (DamageMultiplier 와 곱해짐)");
		PSuperRecoilScale = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "SuperRecoilScale", 2.2f, "강화탄 반동 배율");
		PChargeShake = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ChargeShake", 0.004f, "충전 중 총 떨림 크기 (월드 단위)");
		PBurstCount = ((BaseUnityPlugin)this).Config.Bind<int>("Pistol", "BurstCount", 3, "우클릭 점사 발수 (RightClickMode=Burst 일 때)");
		PBurstInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "BurstInterval", 0.08f, "점사 발 간격(초)");
		PBurstCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "BurstCooldown", 0.6f, "점사 후 대기(초)");
		PDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "DamageMultiplier", 1f, "리볼버 빔 데미지 배율");
		PPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "SoundPitch", 1.3f, "발사음 피치 (리볼버 소리 재사용)");
		PShake = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "ScreenShake", 0.15f, "발사 시 화면 흔들림");
		PRecoilBack = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "RecoilBack", 0.06f, "반동 뒤로 밀림 (월드 단위)");
		PRecoilAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "RecoilAngle", 14f, "반동 총구 들림 (도)");
		PRecoilRecovery = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "RecoilRecovery", 6f, "반동 회복 속도");
		PShareModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Pistol", "ShareModel", true, "마크스맨/샤프슈터 등 변형 폴더에 OBJ 가 없으면 Piercer/Normal 모델을 그대로 사용 (색 변경 없음)");
		PHud = ((BaseUnityPlugin)this).Config.Bind<bool>("Pistol", "Hud", true, "권총 모델 위에 현재 변형과 우클릭 능력 상태 표시");
		PHudX = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "HudX", 0.3f, "HUD 위치 X (stud, 총 모델 뒤끝 기준, + = 총구 쪽)");
		PHudY = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "HudY", 0.35f, "HUD 위치 Y (stud, 총 모델 윗면 기준, + = 위)");
		PHudZ = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "HudZ", 0f, "HUD 위치 Z (stud, 총 모델 옆 방향)");
		PHudSize = ((BaseUnityPlugin)this).Config.Bind<float>("Pistol", "HudSize", 0.014f, "HUD 글자 한 줄 높이 (월드 단위)");
		MColaHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "ColaHeight", 0.45f, "블록시 콜라 캔 높이 (월드 단위)");
		MColaColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Marksman", "ColaColor", new Color(0.85f, 0.08f, 0.1f, 1f), "콜라 캔 몸통 색");
		MColaLabelColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Marksman", "ColaLabelColor", new Color(0.95f, 0.95f, 0.95f, 1f), "콜라 캔 라벨 띠 색");
		MColaSpinSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "ColaSpinSpeed", 900f, "던진 콜라 캔 회전 속도 (도/초, 0 = 회전 안 함)");
		MHeldCola = ((BaseUnityPlugin)this).Config.Bind<bool>("Marksman", "HeldCola", true, "마크스맨을 들고 있으면 왼손에 콜라 캔을 듦 (던질 수 있는 콜라가 있을 때)");
		MHeldHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldHeight", 1.6f, "손에 든 캔 높이 (stud)");
		MHeldX = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldX", 0f, "손에 든 캔 위치 X (stud, 팔 끝 기준, 팔 로컬)");
		MHeldY = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldY", 0.1f, "손에 든 캔 위치 Y (stud, + = 팔 안쪽)");
		MHeldZ = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldZ", 0f, "손에 든 캔 위치 Z (stud)");
		MHeldRotX = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldRotX", 90f, "손에 든 캔 회전 X (90 = 팔과 수직으로 쥠)");
		MHeldRotY = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldRotY", 0f, "손에 든 캔 회전 Y");
		MHeldRotZ = ((BaseUnityPlugin)this).Config.Bind<float>("Marksman", "HeldRotZ", 0f, "손에 든 캔 회전 Z");
		SMaxBounces = ((BaseUnityPlugin)this).Config.Bind<int>("Sharpshooter", "MaxBounces", 3, "최대 튕김 횟수 (원작 샤프슈터 최대 3)");
		SStepTime = ((BaseUnityPlugin)this).Config.Bind<float>("Sharpshooter", "StepTime", 0.35f, "우클릭을 누르고 있을 때 튕김 횟수 +1 되는 시간(초). 1회 → 2회 → 3회");
		SCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Sharpshooter", "Cooldown", 1.5f, "반사 레이저 발사 후 재사용 대기(초)");
		STwirl = ((BaseUnityPlugin)this).Config.Bind<bool>("Sharpshooter", "Twirl", true, "충전 중 원작처럼 권총 돌리기 (발사 후 한 바퀴 마저 돌고 멈춤)");
		STwirlSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Sharpshooter", "TwirlSpeed", 1f, "돌리기 속도 배율 (원작식: 1200 x (단계/3 + 0.5) 도/초)");
		STwirlDirection = ((BaseUnityPlugin)this).Config.Bind<float>("Sharpshooter", "TwirlDirection", 1f, "돌리는 방향. 1 = 총구가 아래로 먼저, -1 = 위로 먼저");
		STwirlPivotX = ((BaseUnityPlugin)this).Config.Bind<float>("Sharpshooter", "TwirlPivotX", 0f, "회전 중심 보정 X (stud, 기본 = 방아쇠울 근처, + = 총구 쪽)");
		STwirlPivotY = ((BaseUnityPlugin)this).Config.Bind<float>("Sharpshooter", "TwirlPivotY", 0f, "회전 중심 보정 Y (stud)");
		REnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Rifle", "Enabled", true, "Roblox 모드에서 샷건을 Roblox 돌격소총으로 교체 (Weapons/ShotGun/{변형} 에 OBJ 있는 변형)");
		RUsePlaceholder = ((BaseUnityPlugin)this).Config.Bind<bool>("Rifle", "UsePlaceholderModel", false, "Weapons/ShotGun/{Core Eject|Pump Charge|Sawed-On} 에 OBJ 가 없을 때도 블록 임시 소총으로 교체");
		RWorldPerStud = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "WorldPerStud", 0.36f, "1 stud 당 화면 크기");
		RPosX = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "PosX", 0.24f, "총 중심 X (카메라 기준, 오른쪽 +)");
		RPosY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "PosY", -0.3f, "총 중심 Y (위 +)");
		RPosZ = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "PosZ", 0.85f, "총 중심 Z (앞 +)");
		RRotX = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "RotX", 0f, "OBJ 모델 회전 X");
		RRotY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "RotY", 180f, "OBJ 모델 회전 Y (Core Eject.obj: 총구가 Unity -Z → 180)");
		RRotZ = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "RotZ", 0f, "OBJ 모델 회전 Z");
		RGripX = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "GripX", 0f, "OBJ 모델 손잡이 위치 X (stud, 모델 중심 기준, 회전 전)");
		RGripY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "GripY", -0.25f, "OBJ 모델 손잡이 위치 Y");
		RGripZ = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "GripZ", 0.82f, "OBJ 모델 손잡이 위치 Z");
		RMuzzleX = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "MuzzleX", 0f, "OBJ 모델 총구 위치 X (stud, 모델 중심 기준, 회전 전)");
		RMuzzleY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "MuzzleY", 0.28f, "OBJ 모델 총구 위치 Y");
		RMuzzleZ = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "MuzzleZ", -1.7f, "OBJ 모델 총구 위치 Z");
		ROneHandTilt = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "OneHandTilt", 8f, "보조 손으로 펀치하는 동안 소총이 한 손으로 들려 기우는 각도(도)");
		RLeftHandX = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "LeftHandX", 0f, "왼손 위치 X (stud, 모델 중심 기준, 회전 전) — 총열 아래 유탄발사기");
		RLeftHandY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "LeftHandY", -0.08f, "왼손 위치 Y");
		RLeftHandZ = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "LeftHandZ", -0.4f, "왼손 위치 Z");
		RLeftArmPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "LeftArmPitch", -100f, "왼팔 기울기 (-90 수평)");
		RLeftArmYaw = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "LeftArmYaw", 30f, "왼팔 좌우 각도 (+ = 손이 오른쪽으로)");
		RLeftArmRoll = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "LeftArmRoll", 0f, "왼팔 비틀기");
		RBodyColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Rifle", "PlaceholderBodyColor", new Color(0.35f, 0.37f, 0.4f, 1f), "임시 모델 몸통 색");
		RAccentColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Rifle", "PlaceholderAccentColor", new Color(0.1f, 0.1f, 0.12f, 1f), "임시 모델 총열/탄창 색");
		RFireRate = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "FireRate", 10f, "초당 발사 수");
		RSpread = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "Spread", 1.2f, "탄 퍼짐 (도)");
		RDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "DamageMultiplier", 0.3f, "발당 데미지 = 리볼버 빔 데미지 x 이 값");
		RMagazineSize = ((BaseUnityPlugin)this).Config.Bind<int>("Rifle", "MagazineSize", 30, "탄창 크기 (0 = 무한)");
		RReloadTime = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "ReloadTime", 1.2f, "자동 재장전 시간(초)");
		RPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "SoundPitch", 1.7f, "발사음 피치 (리볼버 소리 재사용)");
		RShake = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "ScreenShake", 0.05f, "발사 시 화면 흔들림");
		RRecoilBack = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "RecoilBack", 0.03f, "반동 뒤로 밀림 (월드 단위)");
		RRecoilAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "RecoilAngle", 5f, "반동 총구 들림 (도)");
		RRecoilRecovery = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "RecoilRecovery", 8f, "반동 회복 속도");
		RDrawDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "DrawDuration", 0.35f, "꺼내기 애니메이션 길이(초)");
		RGrenadeCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "GrenadeCooldown", 3f, "유탄 재사용 대기(초)");
		RGrenadeSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "GrenadeSpeed", 45f, "유탄 발사 속도");
		RGrenadeArc = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "GrenadeArc", 0.12f, "유탄 위쪽 각도 보정 (0 = 직선)");
		RShareModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Rifle", "ShareModel", true, "Pump Charge / Sawed-On 폴더에 OBJ 가 없으면 Core Eject 모델을 그대로 사용 (총열 아래 부착물만 변형별로 교체)");
		RUnderbarrelPart = ((BaseUnityPlugin)this).Config.Bind<string>("Rifle", "UnderbarrelPart", "Union1", "OBJ 에서 총열 아래 유탄발사기 파트 이름 (Pump/Sawed-On 에서 숨기고 부착물로 교체)");
		RUnderOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "UnderbarrelOffsetY", 0f, "펌프 산탄총/칼 부착물 높이 보정 (stud)");
		RHud = ((BaseUnityPlugin)this).Config.Bind<bool>("Rifle", "Hud", true, "소총 모델 위에 현재 변형과 부착물 상태 표시 (화면에는 탄약만)");
		RHudY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "HudY", 0.9f, "HUD 높이 (stud, 손잡이 기준 위)");
		RHudForward = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "HudForward", 0.3f, "HUD 앞뒤 위치 (stud, 손잡이 기준 총구 방향 +)");
		RHudSize = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "HudSize", 0.014f, "HUD 글자 한 줄 높이 (월드 단위)");
		RMagX = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "MagX", 0f, "재장전 때 왼손이 잡는 탄창 아래 끝 X (stud, 모델 중심 기준, 회전 전)");
		RMagY = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "MagY", -0.52f, "탄창 아래 끝 Y");
		RMagZ = ((BaseUnityPlugin)this).Config.Bind<float>("Rifle", "MagZ", 0.12f, "탄창 아래 끝 Z");
		PCWorldPerStud = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "WorldPerStud", 0.145f, "Pump Charge.obj 산탄총 1 stud 당 화면 크기 (모델 길이 8.3 stud, 0.145 = 돌격소총과 같은 길이 1.2)");
		PCPosX = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "PosX", 0.22f, "산탄총 중심 X (카메라 기준, 오른쪽 +)");
		PCPosY = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "PosY", -0.22f, "산탄총 중심 Y (위 +)");
		PCPosZ = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "PosZ", 0.8f, "산탄총 중심 Z (앞 +)");
		PCRightArmPitch = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "RightArmPitch", -150f, "오른팔 기울기 (-90 수평, -120 = 아래에서 받침. 수평이면 팔이 가는 총을 가림)");
		PCRightArmYaw = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "RightArmYaw", 15f, "오른팔 좌우 각도");
		PCLeftArmPitch = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "LeftArmPitch", -150f, "왼팔 기울기");
		PCLeftArmYaw = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "LeftArmYaw", -30f, "왼팔 좌우 각도");
		PCRotY = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "RotY", 180f, "Pump Charge.obj 회전 Y (총구 Unity -Z → 180)");
		PCGripX = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "GripX", 0f, "Pump Charge.obj 오른손(손목) 위치 X (stud, 모델 중심 기준, 회전 전)");
		PCGripY = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "GripY", -0.25f, "오른손 위치 Y (낮을수록 총이 손 위로 올라감)");
		PCGripZ = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "GripZ", 1.5f, "오른손 위치 Z");
		PCMuzzleX = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "MuzzleX", 0f, "총구 위치 X");
		PCMuzzleY = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "MuzzleY", 0.5f, "총구 위치 Y");
		PCMuzzleZ = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "MuzzleZ", -4.11f, "총구 위치 Z");
		PCLeftHandX = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "LeftHandX", 0f, "왼손(펌프 손잡이) 위치 X");
		PCLeftHandY = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "LeftHandY", -0.1f, "왼손 위치 Y");
		PCLeftHandZ = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "LeftHandZ", -1.8f, "왼손 위치 Z");
		PCCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "Cooldown", 0.8f, "산탄 재사용 대기(초)");
		PCGripDepth = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "GripDepth", 0.15f, "손잡이/앞 손잡이가 손 끝에서 안쪽으로 들어간 깊이 (stud)");
		PCOverpumpRange = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "OverpumpRange", 150f, "과펌프(충전 3) 탄 사거리 — 맞은 곳(적/벽)에서 폭발, 안 맞으면 사거리 끝");
		PCForeEndZMin = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "ForeEndZMin", -2.8f, "펌프 때 움직이는 앞 손잡이 범위 Z 최소 (stud, 모델 중심 기준)");
		PCForeEndZMax = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "ForeEndZMax", -0.8f, "앞 손잡이 범위 Z 최대");
		PCForeEndYMin = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "ForeEndYMin", 0.05f, "앞 손잡이 범위 Y 최소");
		PCForeEndYMax = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "ForeEndYMax", 0.47f, "앞 손잡이 범위 Y 최대");
		PCPellets = ((BaseUnityPlugin)this).Config.Bind<int>("PumpCharge", "Pellets", 12, "산탄 발 수 (원작 샷건 탄 프리팹 사용)");
		PCSpread = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "SpreadMultiplier", 1f, "퍼짐 배율 (원작 Shotgun.spread x 이 값)");
		PCPumpDelay = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "PumpDelay", 0.15f, "발사 후 펌프 동작 시작까지(초)");
		PCPumpSlide = ((BaseUnityPlugin)this).Config.Bind<float>("PumpCharge", "PumpSlide", 0.6f, "펌프 때 앞 손잡이가 뒤로 당겨지는 거리 (stud)");
		PCTubeColor = ((BaseUnityPlugin)this).Config.Bind<Color>("PumpCharge", "TubeColor", new Color(0.22f, 0.22f, 0.24f, 1f), "총열 아래 산탄총 총열 색");
		PCGripColor = ((BaseUnityPlugin)this).Config.Bind<Color>("PumpCharge", "GripColor", new Color(0.42f, 0.26f, 0.13f, 1f), "펌프 손잡이 색");
		SOTick = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "DamageTick", 0.1f, "전기톱 데미지 간격(초)");
		SODamagePerTick = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "DamagePerTick", 0.3f, "전기톱 한 번 데미지 배율 (원작 기본 펀치 = 1)");
		SORadius = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "Radius", 1.5f, "전기톱 판정 반경");
		SOReach = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "Reach", 1.6f, "전기톱 판정 중심 (카메라 앞 거리)");
		SOGrindHandX = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindHandX", -0.14f, "우클릭(갈기) 때 왼손 위치 X (카메라 기준)");
		SOGrindHandY = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindHandY", -0.32f, "갈기 왼손 위치 Y");
		SOGrindHandZ = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindHandZ", 0.95f, "갈기 왼손 위치 Z");
		SOGrindPitch = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindPitch", -100f, "갈기 왼팔 기울기");
		SOGrindYaw = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindYaw", 10f, "갈기 왼팔 좌우 각도");
		SOGrindHeldRotX = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindHeldRotX", 70f, "갈기 때 전기톱 회전 X (평소 HeldRotX 에서 이 값으로, 클수록 날이 앞으로)");
		SOSawBlade = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "BladeLength", 1.6f, "전기톱 날 길이 (stud)");
		SOSawScale = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "Scale", 1f, "전기톱 크기 배율");
		SOBodyColor = ((BaseUnityPlugin)this).Config.Bind<Color>("SawedOn", "BodyColor", new Color(0.95f, 0.55f, 0.1f, 1f), "전기톱 몸체 색");
		SOBarColor = ((BaseUnityPlugin)this).Config.Bind<Color>("SawedOn", "BarColor", new Color(0.7f, 0.72f, 0.75f, 1f), "전기톱 날 색");
		SOHeldX = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "HeldX", 0f, "전기톱 위치 X (stud, 팔 끝 기준, 팔 로컬)");
		SOHeldY = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "HeldY", 0.2f, "전기톱 위치 Y (stud, + = 팔 안쪽)");
		SOHeldZ = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "HeldZ", 0f, "전기톱 위치 Z (stud)");
		SOHeldRotX = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "HeldRotX", 45f, "전기톱 회전 X (90 = 날이 손 끝 방향, 45 = 날이 위로 45도)");
		SOHeldRotY = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "HeldRotY", 0f, "전기톱 회전 Y");
		SOHeldRotZ = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "HeldRotZ", 0f, "전기톱 회전 Z");
		SOObjScale = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ObjScale", 1.1f, "Sawed-On.obj 손에 든 전기톱 크기 (stud 배율, 모델 길이 4.9 stud)");
		SOThrowSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrowSpeed", 55f, "던진 전기톱 속도 (돌아올 땐 x1.3)");
		SOThrowRange = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrowRange", 30f, "던진 전기톱 최대 거리");
		SOThrowRadius = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrowRadius", 1.6f, "던진 전기톱 판정 반경");
		SOThrowDamagePerTick = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrowDamagePerTick", 0.4f, "던진 전기톱 한 번 데미지 배율 (DamageTick 간격)");
		SOGrindTime = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "GrindTime", 0.6f, "적에 닿으면 그 자리에서 갈아내는 시간(초)");
		SOThrowCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrowCooldown", 1.5f, "전기톱이 돌아와 잡힌 뒤 재사용 대기(초)");
		SOThrownWorldPerStud = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrownWorldPerStud", 0.45f, "던진 전기톱 1 stud 당 월드 크기");
		SOThrownSpin = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ThrownSpin", 1440f, "던진 전기톱 회전 속도 (도/초)");
		SOPunchRange = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "PunchRange", 6f, "돌아오는 전기톱을 피드배커로 칠 수 있는 거리");
		SOPunchDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "PunchDamageMultiplier", 1.5f, "피드배커로 쳐서 다시 날린 전기톱 데미지 배율");
		SOObjGripX = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ObjGripX", 0f, "Sawed-On.obj 손잡이(뒤) 위치 X (stud, 모델 중심 기준)");
		SOObjGripY = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ObjGripY", -0.18f, "Sawed-On.obj 손잡이 위치 Y");
		SOObjGripZ = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "ObjGripZ", -2.35f, "Sawed-On.obj 손잡이 위치 Z (날 방향 = +Z)");
		SOIdlePitch = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "IdlePitch", -120f, "전기톱 들고 있을 때 왼팔 기울기 (-90 수평)");
		SOIdleYaw = ((BaseUnityPlugin)this).Config.Bind<float>("SawedOn", "IdleYaw", 20f, "전기톱 들고 있을 때 왼팔 좌우 각도");
		ConfigVersion = ((BaseUnityPlugin)this).Config.Bind<int>("Internal", "ConfigVersion", 0, "내부용. 수정하지 말 것");
		MigrateConfig();
		if ((int)ToggleKey.Value == 101 || (int)ToggleKey.Value == 0)
		{
			Log.LogWarning((object)$"ToggleKey={ToggleKey.Value} 는 사용 불가 (F8 = 게임 콘솔). {(object)(Key)102}로 변경.");
			ToggleKey.Value = (Key)102;
			((BaseUnityPlugin)this).Config.Save();
		}
		if (ReservedSlot.Value >= 0 && ReservedSlot.Value <= 4)
		{
			Log.LogWarning((object)$"ReservedSlotIndex={ReservedSlot.Value} 는 기본 슬롯 범위(0~4)와 겹침. 98로 강제 변경.");
			ReservedSlot.Value = 98;
			((BaseUnityPlugin)this).Config.Save();
		}
		SaveData = ModSaveData.Load();
		_harmony = new Harmony("com.crossflow.robloxmode");
		try
		{
			_harmony.PatchAll(typeof(Plugin).Assembly);
			int num = 0;
			foreach (MethodBase patchedMethod in _harmony.GetPatchedMethods())
			{
				_ = patchedMethod;
				num++;
			}
			Log.LogInfo((object)$"Harmony 패치 적용: {num}개 메서드");
		}
		catch (Exception arg)
		{
			Log.LogError((object)$"Harmony 패치 실패 (