Decompiled source of AnkletOfBloodlust v1.0.0

AnkletOfBloodlust.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AnkletOfBloodlust")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3902aa590c889876faa63eea6ed975c9d40159aa")]
[assembly: AssemblyProduct("AnkletOfBloodlust")]
[assembly: AssemblyTitle("AnkletOfBloodlust")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AnkletOfBloodlust
{
	internal static class AnkletAssets
	{
		private const float RingRadius = 0.42f;

		private const float BandThickness = 0.1f;

		private const float TiltDegrees = 8f;

		private const int SpikeCount = 8;

		private const float DropWidth = 0.22f;

		private const float DropHeight = 0.33f;

		private static readonly Color BandColor = new Color(0.36f, 0.04f, 0.06f);

		private static readonly Color BoneColor = new Color(0.78f, 0.74f, 0.66f);

		private static readonly Color BloodColor = new Color(0.42f, 0f, 0.03f);

		private static readonly Color BloodGlow = new Color(0.6f, 0f, 0.04f);

		private static Shader hgStandard;

		private static Material material;

		private static GameObject prefabHolder;

		private const float BandU = 1f / 6f;

		private const float BoneU = 0.5f;

		private const float BloodU = 5f / 6f;

		public static Sprite LoadSprite(string resourceName)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			using Stream stream = typeof(AnkletAssets).Assembly.GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				Debug.LogError((object)("[AnkletOfBloodlust] Missing embedded resource " + resourceName));
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, array);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}

		private static void EnsureShared()
		{
			//IL_0012: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)material))
			{
				hgStandard = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader").WaitForCompletion();
				material = MakeAtlasMaterial();
				prefabHolder = new GameObject("AnkletOfBloodlustPrefabs");
				prefabHolder.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)prefabHolder);
			}
		}

		private static Mesh BuildAnkletMesh(Matrix4x4 body, float tiltDegrees, out Vector3 dropTop)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00d2: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			List<CombineInstance> list = new List<CombineInstance>();
			Matrix4x4 val = body * Matrix4x4.Rotate(Quaternion.Euler(tiltDegrees, 0f, 0f));
			AddPart(list, WithColor(Torus(0.42f, 0.1f, 48, 12), 1f / 6f), val);
			Mesh mesh = WithColor(Cone(0.055f, 0.18f, 10), 0.5f);
			for (int i = 0; i < 8; i++)
			{
				float num = (float)i * MathF.PI * 2f / 8f;
				Vector3 val2 = new Vector3(Mathf.Sin(num), -0.15f, Mathf.Cos(num));
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				Vector3 val3 = new Vector3(Mathf.Sin(num), 0f, Mathf.Cos(num)) * 0.48f;
				AddPart(list, mesh, val * Matrix4x4.TRS(val3, Quaternion.FromToRotation(Vector3.up, normalized), Vector3.one));
			}
			float num2 = tiltDegrees * (MathF.PI / 180f);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(0f, -0.52f * Mathf.Sin(num2), 0.52f * Mathf.Cos(num2));
			AddPart(list, WithColor(Torus(0.07f, 0.024f, 16, 8), 0.5f), body * Matrix4x4.TRS(val4 + new Vector3(0f, -0.09f, 0f), Quaternion.Euler(0f, 0f, 90f), Vector3.one));
			dropTop = val4 + new Vector3(0f, -0.13f, 0f);
			AddPart(list, WithColor(Teardrop(0.22f, 0.33f, 24, 20), 5f / 6f), body * Matrix4x4.Translate(dropTop));
			Mesh val5 = new Mesh
			{
				name = "AnkletOfBloodlustMesh"
			};
			val5.CombineMeshes(list.ToArray(), true, true);
			val5.RecalculateBounds();
			return val5;
		}

		public static GameObject CreateDisplayModel()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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)
			EnsureShared();
			Vector3 dropTop;
			Mesh sharedMesh = BuildAnkletMesh(Matrix4x4.identity, 0f, out dropTop);
			GameObject val = new GameObject("dispAnkletOfBloodlust");
			val.transform.SetParent(prefabHolder.transform, false);
			val.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			((Renderer)val2).sharedMaterial = material;
			val.AddComponent<ItemDisplay>().rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
			{
				new RendererInfo
				{
					renderer = (Renderer)(object)val2,
					defaultMaterial = material,
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false
				}
			};
			return val;
		}

		public static GameObject CreatePickupModel()
		{
			//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_001e: 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_0038: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			EnsureShared();
			Matrix4x4 body = Matrix4x4.Translate(new Vector3(0f, 0.2f, 0f));
			Vector3 dropTop;
			Mesh sharedMesh = BuildAnkletMesh(body, 8f, out dropTop);
			GameObject val = new GameObject("mdlAnkletOfBloodlust");
			val.transform.SetParent(prefabHolder.transform, false);
			val.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			Light obj = new GameObject("Glow").AddComponent<Light>();
			((Component)obj).transform.SetParent(val.transform, false);
			((Component)obj).transform.localPosition = ((Matrix4x4)(ref body)).MultiplyPoint3x4(dropTop + new Vector3(0f, -0.19800001f, 0f));
			obj.type = (LightType)2;
			obj.color = BloodGlow;
			obj.range = 0.9f;
			obj.intensity = 0.5f;
			Transform transform = new GameObject("FocusPoint").transform;
			transform.SetParent(val.transform, false);
			Transform transform2 = new GameObject("CameraPosition").transform;
			transform2.SetParent(val.transform, false);
			transform2.localPosition = new Vector3(0f, 0.4f, 2.4f);
			ModelPanelParameters obj2 = val.AddComponent<ModelPanelParameters>();
			obj2.focusPointTransform = transform;
			obj2.cameraPositionTransform = transform2;
			obj2.modelRotation = Quaternion.identity;
			obj2.minDistance = 1.2f;
			obj2.maxDistance = 4f;
			return val;
		}

		private static Texture2D Strip(Color band, Color bone, Color blood)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0018: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			Texture2D val = new Texture2D(3, 1, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			val.SetPixels((Color[])(object)new Color[3] { band, bone, blood });
			val.Apply();
			return val;
		}

		private static Material MakeAtlasMaterial()
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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)
			Texture2D val = Strip(BandColor, BoneColor, BloodColor);
			Texture2D val2 = Strip(Color.black, Color.black, BloodGlow);
			Material val3;
			if (Object.op_Implicit((Object)(object)hgStandard))
			{
				val3 = new Material(hgStandard);
				val3.SetTexture("_MainTex", (Texture)(object)val);
				val3.SetColor("_Color", Color.white);
				val3.SetFloat("_Smoothness", 0.75f);
				val3.SetFloat("_Cull", 0f);
				if (val3.HasProperty("_EmTex"))
				{
					val3.SetTexture("_EmTex", (Texture)(object)val2);
					val3.SetColor("_EmColor", Color.white);
					val3.SetFloat("_EmPower", 0.5f);
				}
				else
				{
					val3.SetColor("_EmColor", Color.black);
					val3.SetFloat("_EmPower", 0f);
				}
			}
			else
			{
				val3 = new Material(Shader.Find("Standard"));
				val3.mainTexture = (Texture)(object)val;
				val3.SetFloat("_Glossiness", 0.75f);
				val3.EnableKeyword("_EMISSION");
				val3.SetTexture("_EmissionMap", (Texture)(object)val2);
				val3.SetColor("_EmissionColor", Color.white * 0.5f);
			}
			return val3;
		}

		private static Mesh WithColor(Mesh mesh, float u)
		{
			//IL_0018: 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)
			Vector2[] array = (Vector2[])(object)new Vector2[mesh.vertexCount];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Vector2(u, 0.5f);
			}
			mesh.uv = array;
			return mesh;
		}

		private static void AddPart(List<CombineInstance> parts, Mesh mesh, Matrix4x4 transform)
		{
			//IL_0003: 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)
			CombineInstance item = default(CombineInstance);
			((CombineInstance)(ref item)).mesh = mesh;
			((CombineInstance)(ref item)).transform = transform;
			parts.Add(item);
		}

		private static Mesh Torus(float radius, float thickness, int segments, int sides)
		{
			//IL_0036: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < segments; i++)
			{
				float num = (float)i * MathF.PI * 2f / (float)segments;
				Vector3 val = new Vector3(Mathf.Sin(num), 0f, Mathf.Cos(num)) * radius;
				for (int j = 0; j < sides; j++)
				{
					float num2 = (float)j * MathF.PI * 2f / (float)sides;
					((Vector3)(ref val2))..ctor(Mathf.Sin(num), 0f, Mathf.Cos(num));
					list.Add(val + (val2 * Mathf.Cos(num2) + Vector3.up * Mathf.Sin(num2)) * thickness);
				}
			}
			for (int k = 0; k < segments; k++)
			{
				int num3 = (k + 1) % segments;
				for (int l = 0; l < sides; l++)
				{
					int num4 = (l + 1) % sides;
					int num5 = k * sides + l;
					int num6 = num3 * sides + l;
					int num7 = num3 * sides + num4;
					int num8 = k * sides + num4;
					list2.AddRange(new int[6] { num5, num6, num7, num5, num7, num8 });
				}
			}
			return BuildMesh(list, list2);
		}

		private static Mesh Cone(float baseRadius, float length, int segments)
		{
			//IL_0012: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			return Lathe((Vector2[])(object)new Vector2[3]
			{
				new Vector2(0f, 0f),
				new Vector2(baseRadius, 0f),
				new Vector2(0f, length)
			}, segments);
		}

		private static Mesh Teardrop(float width, float height, int segments, int steps)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] array = (Vector2[])(object)new Vector2[steps + 1];
			for (int i = 0; i <= steps; i++)
			{
				float num = MathF.PI * (float)i / (float)steps;
				float num2 = width * 0.5f * Mathf.Sin(num) * (1f - Mathf.Cos(num)) * 0.5f * 1.3f;
				array[steps - i] = new Vector2(num2, (0f - height) * (1f - Mathf.Cos(num)) * 0.5f);
			}
			return Lathe(array, segments);
		}

		private static Mesh Lathe(Vector2[] profile, int segments)
		{
			//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_003c: 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_0052: 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)
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			foreach (Vector2 val in profile)
			{
				for (int j = 0; j < segments; j++)
				{
					float num = (float)j * MathF.PI * 2f / (float)segments;
					list.Add(new Vector3(Mathf.Sin(num) * val.x, val.y, Mathf.Cos(num) * val.x));
				}
			}
			for (int k = 0; k < profile.Length - 1; k++)
			{
				for (int l = 0; l < segments; l++)
				{
					int num2 = (l + 1) % segments;
					int num3 = k * segments + l;
					int num4 = k * segments + num2;
					int num5 = (k + 1) * segments + num2;
					int num6 = (k + 1) * segments + l;
					list2.AddRange(new int[6] { num3, num4, num5, num3, num5, num6 });
				}
			}
			return BuildMesh(list, list2);
		}

		private static Mesh BuildMesh(List<Vector3> verts, List<int> tris)
		{
			//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_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Mesh val = new Mesh();
			val.SetVertices(verts);
			val.SetTriangles(tris, 0);
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("prana.AnkletOfBloodlust", "AnkletOfBloodlust", "1.0.0")]
	public class AnkletOfBloodlustPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<DamageReport> <0>__OnCharacterDeath;

			public static Action<DamageReport> <1>__OnServerDamageDealt;

			public static StatHookEventHandler <2>__OnGetStatCoefficients;
		}

		public const string PluginGUID = "prana.AnkletOfBloodlust";

		public const string PluginName = "AnkletOfBloodlust";

		public const string PluginVersion = "1.0.0";

		private const string ItemName = "Anklet of Bloodlust";

		private const string BuffName = "Bloodlust";

		private static ItemDef itemDef;

		private static BuffDef bloodlustBuff;

		private static ConfigEntry<int> maxStacksPerItem;

		private static ConfigEntry<float> attackSpeedPerStack;

		private static ConfigEntry<float> moveSpeedPerStack;

		private static ConfigEntry<float> healthPenaltyPerItem;

		private static ConfigEntry<float> stacksLostOnHit;

		private static ConfigEntry<float> minHitFraction;

		public void Awake()
		{
			//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: Expected O, but got Unknown
			BindConfig();
			CreateBuff();
			CreateItem();
			AddLanguage();
			GlobalEventManager.onCharacterDeathGlobal += OnCharacterDeath;
			GlobalEventManager.onServerDamageDealt += OnServerDamageDealt;
			object obj = <>O.<2>__OnGetStatCoefficients;
			if (obj == null)
			{
				StatHookEventHandler val = OnGetStatCoefficients;
				<>O.<2>__OnGetStatCoefficients = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				ItemDisplays.ApplyDisplayRules(itemDef, ((BaseUnityPlugin)this).Logger);
			});
		}

		private void BindConfig()
		{
			maxStacksPerItem = ((BaseUnityPlugin)this).Config.Bind<int>("Bloodlust", "MaxStacksPerItem", 10, "Maximum Bloodlust stacks granted per copy of the item.");
			attackSpeedPerStack = ((BaseUnityPlugin)this).Config.Bind<float>("Bloodlust", "AttackSpeedPerStack", 0.05f, "Attack speed bonus per Bloodlust stack (0.05 = +5%).");
			moveSpeedPerStack = ((BaseUnityPlugin)this).Config.Bind<float>("Bloodlust", "MoveSpeedPerStack", 0.04f, "Movement speed bonus per Bloodlust stack (0.04 = +4%).");
			stacksLostOnHit = ((BaseUnityPlugin)this).Config.Bind<float>("Bloodlust", "StacksLostOnHit", 0.5f, "Fraction of Bloodlust stacks lost when hit, rounded up (0.5 = half, 1 = all).");
			minHitFraction = ((BaseUnityPlugin)this).Config.Bind<float>("Bloodlust", "MinHitFraction", 0.05f, "Hits smaller than this fraction of your max health + shield don't remove stacks (0.05 = 5%).");
			healthPenaltyPerItem = ((BaseUnityPlugin)this).Config.Bind<float>("Downside", "HealthPenaltyPerItem", 0.15f, "Max health reduction per copy, applied multiplicatively (0.15 = -15%, two copies = -27.75%).");
		}

		private static void CreateBuff()
		{
			//IL_002d: 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)
			bloodlustBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)bloodlustBuff).name = "bdAnkletOfBloodlust";
			bloodlustBuff.buffColor = new Color(0.8f, 0.1f, 0.15f);
			bloodlustBuff.canStack = true;
			bloodlustBuff.isDebuff = false;
			bloodlustBuff.isCooldown = false;
			bloodlustBuff.isHidden = false;
			bloodlustBuff.iconSprite = AnkletAssets.LoadSprite("texBloodlustBuffIcon.png");
			ContentAddition.AddBuffDef(bloodlustBuff);
		}

		private static void CreateItem()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			itemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)itemDef).name = "ANKLETOFBLOODLUST";
			itemDef.nameToken = "ANKLETOFBLOODLUST_NAME";
			itemDef.pickupToken = "ANKLETOFBLOODLUST_PICKUP";
			itemDef.descriptionToken = "ANKLETOFBLOODLUST_DESC";
			itemDef.loreToken = "ANKLETOFBLOODLUST_LORE";
			SetLunarTier(itemDef);
			itemDef.canRemove = true;
			itemDef.hidden = false;
			itemDef.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)1,
				(ItemTag)3
			};
			itemDef.pickupModelPrefab = AnkletAssets.CreatePickupModel();
			itemDef.pickupIconSprite = AnkletAssets.LoadSprite("texAnkletOfBloodlustIcon.png");
			ItemAPI.Add(new CustomItem(itemDef, ItemDisplays.Create(AnkletAssets.CreateDisplayModel())));
		}

		private static void SetLunarTier(ItemDef def)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			ItemTierDef value = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/LunarTierDef.asset").WaitForCompletion();
			typeof(ItemDef).GetField("_itemTierDef", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(def, value);
			typeof(ItemDef).GetField("deprecatedTier", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(def, (object)(ItemTier)3);
		}

		private void AddLanguage()
		{
			LanguageAPI.Add("ANKLETOFBLOODLUST_NAME", "Anklet of Bloodlust");
			LanguageAPI.Add("ANKLETOFBLOODLUST_PICKUP", "Kills build Bloodlust, increasing attack and movement speed. Big hits lose half your Bloodlust. <style=cDeath>Reduces maximum health.</style>");
			LanguageAPI.Add("ANKLETOFBLOODLUST_DESC", string.Format("Killing an enemy grants a stack of <style=cIsDamage>{0}</style>, up to <style=cIsUtility>{1}</style> <style=cStack>(+{2} per stack)</style>. ", "Bloodlust", maxStacksPerItem.Value, maxStacksPerItem.Value) + $"Each stack gives <style=cIsDamage>+{attackSpeedPerStack.Value * 100f:0.#}% attack speed</style> and <style=cIsUtility>+{moveSpeedPerStack.Value * 100f:0.#}% movement speed</style>. " + $"Taking at least <style=cIsHealth>{minHitFraction.Value * 100f:0.#}% of your max health</style> in one hit <style=cDeath>removes {stacksLostOnHit.Value * 100f:0.#}% of your stacks</style>. " + $"<style=cDeath>Reduces maximum health by {healthPenaltyPerItem.Value * 100f:0.#}%</style> <style=cStack>(+{healthPenaltyPerItem.Value * 100f:0.#}% per stack, multiplicative)</style>.");
			LanguageAPI.Add("ANKLETOFBLOODLUST_LORE", "Every death feeds the next. Every wound drains it all.");
		}

		private static int GetItemCount(CharacterBody body)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				return 0;
			}
			return body.inventory.GetItemCountEffective(itemDef);
		}

		private static void OnCharacterDeath(DamageReport report)
		{
			if (!NetworkServer.active)
			{
				return;
			}
			CharacterBody attackerBody = report.attackerBody;
			int itemCount = GetItemCount(attackerBody);
			if (itemCount > 0)
			{
				int num = maxStacksPerItem.Value * itemCount;
				if (attackerBody.GetBuffCount(bloodlustBuff) < num)
				{
					attackerBody.AddBuff(bloodlustBuff);
				}
			}
		}

		private static void OnServerDamageDealt(DamageReport report)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			CharacterBody victimBody = report.victimBody;
			if (!Object.op_Implicit((Object)(object)victimBody) || report.damageDealt <= 0f || (Object)(object)report.attackerBody == (Object)(object)victimBody)
			{
				return;
			}
			int buffCount = victimBody.GetBuffCount(bloodlustBuff);
			if (buffCount > 0)
			{
				HealthComponent healthComponent = victimBody.healthComponent;
				if (!Object.op_Implicit((Object)(object)healthComponent) || !(report.damageDealt < healthComponent.fullCombinedHealth * minHitFraction.Value))
				{
					int num = Mathf.CeilToInt((float)buffCount * Mathf.Clamp01(stacksLostOnHit.Value));
					victimBody.SetBuffCount(bloodlustBuff.buffIndex, buffCount - num);
				}
			}
		}

		private static void OnGetStatCoefficients(CharacterBody body, StatHookEventArgs args)
		{
			int itemCount = GetItemCount(body);
			if (itemCount > 0)
			{
				int buffCount = body.GetBuffCount(bloodlustBuff);
				args.attackSpeedMultAdd += attackSpeedPerStack.Value * (float)buffCount;
				args.moveSpeedMultAdd += moveSpeedPerStack.Value * (float)buffCount;
				float num = Mathf.Pow(1f - healthPenaltyPerItem.Value, (float)itemCount);
				args.healthMultAdd -= 1f - num;
			}
		}
	}
	internal static class ItemDisplays
	{
		private const float CommandoScale = 0.2f;

		private static readonly Vector3 AnkletAngles = new Vector3(180f, 0f, 0f);

		private const float AnkletInnerRadius = 0.32f;

		private const float LegClearance = 1.15f;

		private static GameObject displayPrefab;

		public static ItemDisplayRuleDict Create(GameObject display)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			displayPrefab = display;
			return new ItemDisplayRuleDict((ItemDisplayRule[])null);
		}

		private static Dictionary<string, ItemDisplayRule> HandPlaced()
		{
			//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_0045: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00f5: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_018b: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: 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)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 angles = default(Vector3);
			((Vector3)(ref angles))..ctor(-1E-05f, 180f, 180f);
			return new Dictionary<string, ItemDisplayRule>
			{
				["CommandoBody"] = Rule("CalfR", new Vector3(-0.0019f, 0.34219f, 0.01456f), angles, Vector3.one * 0.2f),
				["HuntressBody"] = Rule("CalfR", new Vector3(0.0144f, 0.3496f, 0.01774f), angles, Vector3.one * 0.17647f),
				["Bandit2Body"] = Rule("CalfR", new Vector3(0.00564f, 0.33653f, 0.01252f), angles, Vector3.one * 0.2f),
				["EngiBody"] = Rule("CalfR", new Vector3(0.00236f, 0.27453f, 0.02143f), angles, Vector3.one * 0.29349f),
				["MercBody"] = Rule("CalfR", new Vector3(-0.00708f, 0.32992f, 0.01145f), angles, Vector3.one * 0.21176f),
				["LoaderBody"] = Rule("CalfR", new Vector3(0.01126f, 0.412f, 0.00776f), angles, Vector3.one * 0.28235f),
				["CrocoBody"] = Rule("CalfR", new Vector3(0.10253f, 2.68812f, -0.01258f), angles, Vector3.one * 1.88235f),
				["CaptainBody"] = Rule("CalfR", new Vector3(-0.00282f, 0.30095f, 0.02098f), angles, Vector3.one * 0.23529f),
				["VoidSurvivorBody"] = Rule("CalfR", new Vector3(0.00669f, 0.37404f, -0.00169f), angles, Vector3.one * 0.2f),
				["SeekerBody"] = Rule("CalfR", new Vector3(-0.00105f, 0.42784f, 0.00928f), angles, Vector3.one * 0.20366f),
				["FalseSonBody"] = Rule("CalfR", new Vector3(-0.02895f, 0.51184f, 0.00256f), angles, Vector3.one * 0.27812f),
				["DrifterBody"] = Rule("CalfR", new Vector3(-0.07849f, -0.01391f, -0.01058f), new Vector3(344.7775f, 167.481f, 268.9557f), Vector3.one * 0.37632f),
				["DroneTechBody"] = Rule("CalfR", new Vector3(0.53767f, -0.00194f, -0.03339f), new Vector3(34.70116f, 187.0946f, 280.0397f), Vector3.one * 0.18549f)
			};
		}

		public static ItemDisplayRule Rule(string bone, Vector3 position, Vector3 angles, Vector3 scale)
		{
			//IL_0002: 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_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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			return new ItemDisplayRule
			{
				ruleType = (ItemDisplayRuleType)0,
				followerPrefab = displayPrefab,
				childName = bone,
				localPos = position,
				localAngles = angles,
				localScale = scale
			};
		}

		public static void ApplyDisplayRules(ItemDef anklet, ManualLogSource log)
		{
			//IL_0082: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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)
			ItemDef hoof = Items.Hoof;
			FieldInfo runtimeGroups = typeof(ItemDisplayRuleSet).GetField("runtimeItemRuleGroups", BindingFlags.Instance | BindingFlags.NonPublic);
			int num = 0;
			foreach (KeyValuePair<string, ItemDisplayRule> item in HandPlaced())
			{
				ItemDisplayRuleSet val = RuleSetOf(BodyCatalog.FindBodyPrefab(item.Key));
				if (!Object.op_Implicit((Object)(object)val))
				{
					log.LogWarning((object)("No body named " + item.Key + "; its hand-placed anklet was skipped."));
					continue;
				}
				SetRule(val, item.Value);
				num++;
			}
			log.LogInfo((object)$"Anklet hand-placed on {num} survivors.");
			float num2 = 0f;
			ItemDisplayRuleSet val2 = RuleSetOf(BodyCatalog.FindBodyPrefab("CommandoBody"));
			if (Object.op_Implicit((Object)(object)val2) && TryGetHoofRule(val2, hoof, out var rule))
			{
				num2 = 0.2f / rule.localScale.x;
			}
			if (num2 <= 0f)
			{
				log.LogWarning((object)"Couldn't read Commando's hoof placement; the anklet won't show on survivors without a hand-placed rule.");
				return;
			}
			int num3 = 0;
			int num4 = 0;
			Vector3 position = default(Vector3);
			foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
			{
				ItemDisplayRuleSet val3 = RuleSetOf(allBodyPrefab);
				if (!Object.op_Implicit((Object)(object)val3))
				{
					continue;
				}
				DisplayRuleGroup itemDisplayRuleGroup = val3.GetItemDisplayRuleGroup(anklet.itemIndex);
				if (((DisplayRuleGroup)(ref itemDisplayRuleGroup)).isEmpty && TryGetHoofRule(val3, hoof, out var rule2))
				{
					float y = rule2.localPos.y;
					((Vector3)(ref position))..ctor(0f, y, 0f);
					float num5 = rule2.localScale.x * num2;
					if (TryMeasureLeg(allBodyPrefab, rule2.childName, y, out var center, out var radius))
					{
						((Vector3)(ref position))..ctor(center.x, y, center.y);
						num5 = radius * 1.15f / 0.32f;
						num4++;
					}
					SetRule(val3, Rule(rule2.childName, position, AnkletAngles, Vector3.one * num5));
					num3++;
				}
			}
			log.LogInfo((object)$"Anklet placed on {num3} survivors/bodies from their Goat Hoof positions ({num4} fitted to the measured leg mesh).");
			void SetRule(ItemDisplayRuleSet ruleSet, ItemDisplayRule val5)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Invalid comparison between Unknown and I4
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				DisplayRuleGroup val4 = new DisplayRuleGroup
				{
					rules = (ItemDisplayRule[])(object)new ItemDisplayRule[1] { val5 }
				};
				ruleSet.SetDisplayRuleGroup((Object)(object)anklet, val4);
				if (runtimeGroups?.GetValue(ruleSet) is DisplayRuleGroup[] array && (int)anklet.itemIndex < array.Length)
				{
					array[anklet.itemIndex] = val4;
				}
			}
		}

		private static bool TryMeasureLeg(GameObject body, string boneName, float height, out Vector2 center, out float radius)
		{
			//IL_0001: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: 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_023e: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			center = Vector2.zero;
			radius = 0f;
			ModelLocator component = body.GetComponent<ModelLocator>();
			Transform val = (Object.op_Implicit((Object)(object)component) ? component.modelTransform : null);
			ChildLocator val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<ChildLocator>() : null);
			Transform val3 = (Object.op_Implicit((Object)(object)val2) ? val2.FindChild(boneName) : null);
			if (!Object.op_Implicit((Object)(object)val3))
			{
				return false;
			}
			List<(float, Vector3)> list = new List<(float, Vector3)>();
			SkinnedMeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val4 in componentsInChildren)
			{
				Mesh sharedMesh = val4.sharedMesh;
				if (!Object.op_Implicit((Object)(object)sharedMesh) || !sharedMesh.isReadable)
				{
					continue;
				}
				int num = Array.IndexOf(val4.bones, val3);
				if (num < 0 || num >= sharedMesh.bindposes.Length)
				{
					continue;
				}
				Matrix4x4 val5 = sharedMesh.bindposes[num];
				Vector3[] vertices = sharedMesh.vertices;
				BoneWeight[] boneWeights = sharedMesh.boneWeights;
				for (int j = 0; j < vertices.Length && j < boneWeights.Length; j++)
				{
					if (((BoneWeight)(ref boneWeights[j])).boneIndex0 == num && !(((BoneWeight)(ref boneWeights[j])).weight0 < 0.5f))
					{
						Vector3 val6 = ((Matrix4x4)(ref val5)).MultiplyPoint3x4(vertices[j]);
						list.Add((Mathf.Abs(val6.y - height), val6));
					}
				}
			}
			if (list.Count < 12)
			{
				return false;
			}
			list.Sort(((float dy, Vector3 p) a, (float dy, Vector3 p) b) => a.dy.CompareTo(b.dy));
			int num2 = Mathf.Min(list.Count, 48);
			Vector2 val7 = Vector2.zero;
			for (int num3 = 0; num3 < num2; num3++)
			{
				val7 += new Vector2(list[num3].Item2.x, list[num3].Item2.z);
			}
			center = val7 / (float)num2;
			float num4 = 0f;
			for (int num5 = 0; num5 < num2; num5++)
			{
				num4 += Vector2.Distance(center, new Vector2(list[num5].Item2.x, list[num5].Item2.z));
			}
			radius = num4 / (float)num2;
			return radius > 0f;
		}

		private static ItemDisplayRuleSet RuleSetOf(GameObject body)
		{
			if (!Object.op_Implicit((Object)(object)body))
			{
				return null;
			}
			ModelLocator component = body.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.modelTransform))
			{
				return null;
			}
			CharacterModel component2 = ((Component)component.modelTransform).GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				return null;
			}
			return component2.itemDisplayRuleSet;
		}

		private static bool TryGetHoofRule(ItemDisplayRuleSet ruleSet, ItemDef hoof, out ItemDisplayRule rule)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_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)
			ItemDisplayRule[] rules = ruleSet.GetItemDisplayRuleGroup(hoof.itemIndex).rules;
			if (rules != null)
			{
				ItemDisplayRule[] array = rules;
				foreach (ItemDisplayRule val in array)
				{
					if ((int)val.ruleType == 0 && !string.IsNullOrEmpty(val.childName))
					{
						rule = val;
						return true;
					}
				}
			}
			rule = default(ItemDisplayRule);
			return false;
		}
	}
}