Decompiled source of Rotheart v1.0.0

plugins/Rotheart/Rotheart.dll

Decompiled 6 days 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 HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
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("Rotheart")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+130b66e3d3db1edb93ad302127765a95723a38bb")]
[assembly: AssemblyProduct("Rotheart")]
[assembly: AssemblyTitle("Rotheart")]
[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 Rotheart
{
	[BepInPlugin("jarki.rotheart", "Rotheart", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Player), "GetMaxAdrenaline")]
		private static class AdrenalineCapacity
		{
			private static void Postfix(Player __instance, ref float __result)
			{
				if (IsEquipped((Humanoid)(object)__instance))
				{
					__result = 10f;
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
		private static class EndMiasmaOnUnequip
		{
			private static void Postfix(Humanoid __instance)
			{
				if (__instance is Player && !IsEquipped(__instance))
				{
					((Character)__instance).GetSEMan().RemoveStatusEffect(AuraHash, false);
				}
			}
		}

		public const string Guid = "jarki.rotheart";

		public const string ItemName = "Rotheart";

		internal static readonly int AuraHash = StringExtensionMethods.GetStableHashCode("RotheartAura");

		private static readonly FieldRef<Humanoid, ItemData> Trinket = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_trinketItem");

		private Harmony patches;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			patches = new Harmony("jarki.rotheart");
			patches.PatchAll();
			PrefabManager.OnVanillaPrefabsAvailable += Register;
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			Harmony obj = patches;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		internal static bool IsEquipped(Humanoid wearer)
		{
			ItemData val = Trinket.Invoke(wearer);
			if (val != null && Object.op_Implicit((Object)(object)val.m_dropPrefab))
			{
				return ((Object)val.m_dropPrefab).name == "Rotheart";
			}
			return false;
		}

		private void Register()
		{
			//IL_003c: 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_0051: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = RotheartAssets.Icon();
			SE_Stats val2 = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val2).name = "RotheartResistance";
			((StatusEffect)val2).m_name = "Rotheart ward";
			((StatusEffect)val2).m_icon = val;
			((StatusEffect)val2).m_tooltip = "50% less poison damage while equipped.";
			val2.m_mods.Add(new DamageModPair
			{
				m_type = (DamageType)256,
				m_modifier = (DamageModifier)1
			});
			GameObject val3 = PrefabManager.Instance.CreateEmptyPrefab("RotheartMiasma", true);
			val3.GetComponent<ZNetView>().m_persistent = false;
			Object.DestroyImmediate((Object)(object)val3.GetComponent<Collider>());
			Object.DestroyImmediate((Object)(object)val3.GetComponent<MeshRenderer>());
			Object.DestroyImmediate((Object)(object)val3.GetComponent<MeshFilter>());
			GameObject obj = RotheartAssets.CreateAuraPrefab();
			obj.transform.SetParent(val3.transform, false);
			obj.SetActive(true);
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val3, false));
			RotheartAura rotheartAura = ScriptableObject.CreateInstance<RotheartAura>();
			((Object)rotheartAura).name = "RotheartAura";
			((StatusEffect)rotheartAura).m_name = "Rotheart miasma";
			((StatusEffect)rotheartAura).m_icon = val;
			((StatusEffect)rotheartAura).m_ttl = 10f;
			((StatusEffect)rotheartAura).m_tooltip = "Every 2s: lose 1 health (minimum 1 HP) and deal 12 blunt damage to hostile creatures within 6m.\nSpare other players, tamed creatures and structures. Ends when unequipped.";
			EffectList val4 = new EffectList();
			val4.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = val3,
					m_enabled = true,
					m_attach = true
				}
			};
			((StatusEffect)rotheartAura).m_startEffects = val4;
			if (!ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val2, false)) || !ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)rotheartAura, false)))
			{
				throw new InvalidOperationException("Could not register Rotheart status effects");
			}
			ItemConfig val5 = new ItemConfig();
			val5.Name = "Rotheart";
			val5.Description = "A swamp trinket of living ooze, caged in iron and bound with rancid entrails.\nAt 10 adrenaline, automatically unleash a 10-second miasma.";
			val5.CraftingStation = "forge";
			val5.MinStationLevel = 1;
			val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
			{
				new RequirementConfig("Ooze", 10, 0, true),
				new RequirementConfig("Guck", 5, 0, true),
				new RequirementConfig("Entrails", 5, 0, true),
				new RequirementConfig("Iron", 5, 0, true)
			};
			CustomItem val6 = new CustomItem("Rotheart", "BeltStrength", val5);
			SharedData shared = val6.ItemDrop.m_itemData.m_shared;
			shared.m_itemType = (ItemType)24;
			shared.m_attachOverride = (ItemType)0;
			shared.m_weight = 2f;
			shared.m_maxStackSize = 1;
			shared.m_maxQuality = 1;
			shared.m_useDurability = false;
			shared.m_movementModifier = 0f;
			shared.m_maxAdrenaline = 0f;
			shared.m_equipStatusEffect = (StatusEffect)(object)val2;
			shared.m_fullAdrenalineSE = (StatusEffect)(object)rotheartAura;
			shared.m_setStatusEffect = null;
			shared.m_setName = "";
			shared.m_damageModifiers.Clear();
			shared.m_icons = (Sprite[])(object)new Sprite[1] { val };
			ReplaceVisual(val6.ItemPrefab);
			if (!ItemManager.Instance.AddItem(val6))
			{
				throw new InvalidOperationException("Could not register Rotheart");
			}
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Rotheart registered: swamp trinket, poison ward, 10-adrenaline miasma and forge recipe.");
		}

		private static void ReplaceVisual(GameObject prefab)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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)
			MeshRenderer componentInChildren = prefab.GetComponentInChildren<MeshRenderer>(true);
			Material fallback = (Object.op_Implicit((Object)(object)componentInChildren) ? ((Renderer)componentInChildren).sharedMaterial : null);
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			MeshFilter[] componentsInChildren2 = prefab.GetComponentsInChildren<MeshFilter>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			for (int num = prefab.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = prefab.transform.GetChild(num);
				if (((Object)child).name == "attach" || ((Object)child).name.StartsWith("attach_", StringComparison.Ordinal))
				{
					Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
				}
			}
			Transform transform = new GameObject("attach").transform;
			transform.SetParent(prefab.transform, false);
			RotheartAssets.Create(transform, fallback);
			GameObject val = new GameObject("attach_Hips");
			val.transform.SetParent(prefab.transform, false);
			RotheartAssets.Create(val.transform, fallback).transform.localPosition = new Vector3(0.19f, -0.13f, 0.12f);
			val.SetActive(false);
		}
	}
	internal static class RotheartAssets
	{
		private sealed class MeshPart
		{
			internal int Material;

			internal Mesh Mesh;
		}

		private static MeshPart[] meshes;

		private static Material[] materials;

		private static Material particleMaterial;

		private static Sprite icon;

		private static Stream Resource(string extension)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream("Rotheart.Assets.Models.rotheart." + extension) ?? throw new InvalidDataException("Missing embedded Rotheart " + extension + " asset");
		}

		internal static GameObject Create(Transform parent, Material fallback)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0041: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			EnsureMaterials(fallback);
			GameObject val = new GameObject("Rotheart_Visual");
			val.transform.SetParent(parent, false);
			MeshPart[] array = LoadMeshes();
			foreach (MeshPart meshPart in array)
			{
				GameObject val2 = new GameObject("Heart_" + meshPart.Material);
				val2.transform.SetParent(val.transform, false);
				val2.AddComponent<MeshFilter>().sharedMesh = meshPart.Mesh;
				((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = materials[meshPart.Material];
			}
			return val;
		}

		internal static Sprite Icon()
		{
			//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_003c: 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_004b: Expected O, but got Unknown
			//IL_007e: 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)
			if (Object.op_Implicit((Object)(object)icon))
			{
				return icon;
			}
			using Stream stream = Resource("png");
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2)
			{
				name = "Rotheart inventory icon",
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), true))
			{
				throw new InvalidDataException("Invalid Rotheart inventory icon");
			}
			icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)icon).name = "Rotheart";
			return icon;
		}

		private static MeshPart[] LoadMeshes()
		{
			//IL_00a2: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0152: Expected O, but got Unknown
			if (meshes != null)
			{
				return meshes;
			}
			using BinaryReader binaryReader = new BinaryReader(Resource("mesh"));
			if (new string(binaryReader.ReadChars(4)) != "FHM1")
			{
				throw new InvalidDataException("Unknown Rotheart mesh format");
			}
			MeshPart[] array = new MeshPart[binaryReader.ReadInt32()];
			for (int i = 0; i < array.Length; i++)
			{
				string text = new string(binaryReader.ReadChars(binaryReader.ReadInt32()));
				int material = binaryReader.ReadInt32();
				int num = binaryReader.ReadInt32();
				Vector3[] array2 = (Vector3[])(object)new Vector3[num];
				Vector3[] array3 = (Vector3[])(object)new Vector3[num];
				for (int j = 0; j < num; j++)
				{
					array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
					array3[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				int[] array4 = new int[binaryReader.ReadInt32()];
				for (int k = 0; k < array4.Length; k++)
				{
					array4[k] = binaryReader.ReadInt32();
				}
				Mesh val = new Mesh
				{
					name = "Rotheart/" + text + "/" + material,
					indexFormat = (IndexFormat)(num > 65535),
					vertices = array2,
					normals = array3,
					triangles = array4
				};
				val.RecalculateBounds();
				val.UploadMeshData(true);
				array[i] = new MeshPart
				{
					Material = material,
					Mesh = val
				};
			}
			meshes = array;
			return meshes;
		}

		private static void EnsureMaterials(Material fallback)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			if (materials != null && Object.op_Implicit((Object)(object)materials[0]))
			{
				return;
			}
			Shader val = Shader.Find("Standard") ?? (Object.op_Implicit((Object)(object)fallback) ? fallback.shader : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("No Rotheart mesh shader available");
			}
			Color[] array = (Color[])(object)new Color[8]
			{
				new Color(0.095f, 0.115f, 0.105f),
				new Color(0.29f, 0.115f, 0.045f),
				new Color(0.69f, 0.65f, 0.43f),
				new Color(0.19f, 0.145f, 0.075f),
				new Color(0.38f, 0.59f, 0.19f),
				new Color(0.69f, 0.86f, 0.39f),
				new Color(0.16f, 0.27f, 0.075f),
				new Color(0.25f, 0.28f, 0.22f)
			};
			float[] array2 = new float[8] { 0.72f, 0.22f, 0f, 0f, 0f, 0f, 0f, 0.65f };
			float[] array3 = new float[8] { 0.7f, 0.92f, 0.86f, 1f, 0.36f, 0.3f, 0.58f, 0.65f };
			float[] array4 = new float[8] { 0f, 0f, 0f, 0f, 0.32f, 0.65f, 0.12f, 0f };
			materials = (Material[])(object)new Material[array.Length];
			for (int i = 0; i < materials.Length; i++)
			{
				Material val2 = new Material(val)
				{
					name = "Rotheart finish " + i,
					color = array[i]
				};
				if (val2.HasProperty("_Metallic"))
				{
					val2.SetFloat("_Metallic", array2[i]);
				}
				if (val2.HasProperty("_Glossiness"))
				{
					val2.SetFloat("_Glossiness", 1f - array3[i]);
				}
				if (array4[i] > 0f && val2.HasProperty("_EmissionColor"))
				{
					val2.EnableKeyword("_EMISSION");
					val2.SetColor("_EmissionColor", array[i] * array4[i]);
				}
				materials[i] = val2;
			}
		}

		internal static GameObject CreateAuraPrefab()
		{
			//IL_000a: 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_0016: 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_0039: Expected O, but got Unknown
			EnsureParticleMaterial();
			GameObject val = new GameObject("vfx_RotheartAura");
			val.SetActive(false);
			CreateParticles(val.transform, "GroundMotes", wisps: false);
			CreateParticles(val.transform, "OozeWisps", wisps: true);
			return val;
		}

		private static void CreateParticles(Transform parent, string name, bool wisps)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_015d: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: 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_01d5: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, -0.8f, 0f);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).duration = 3f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(wisps ? 1.8f : 1.1f, wisps ? 2.8f : 2f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(wisps ? 0.19f : 0.035f, wisps ? 0.34f : 0.065f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(wisps ? new Color(0.47f, 0.68f, 0.23f, 0.12f) : new Color(0.7f, 0.86f, 0.39f, 0.44f));
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f);
			((MainModule)(ref main)).maxParticles = (wisps ? 18 : 32);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).cullingMode = (ParticleSystemCullingMode)1;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit((float)(wisps ? 5 : 12));
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
			((ShapeModule)(ref shape)).radius = 6f;
			((ShapeModule)(ref shape)).radiusThickness = 1f;
			((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
			VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f, 0f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f, 0f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.08f, wisps ? 0.18f : 0.28f);
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(1f, 0.2f),
				new GradientAlphaKey(0.6f, 0.65f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.55f, 1f, wisps ? 1.6f : 0.8f));
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = particleMaterial;
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			((Renderer)component).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0;
			component.maxParticleSize = 0.08f;
		}

		private static void EnsureParticleMaterial()
		{
			//IL_004d: 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_005d: 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_006c: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)particleMaterial))
			{
				return;
			}
			Shader val = Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("No Rotheart particle shader available");
			}
			Texture2D val2 = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				name = "Rotheart soft mote",
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[1024];
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = ((float)j + 0.5f) * 2f / 32f - 1f;
					float num2 = ((float)i + 0.5f) * 2f / 32f - 1f;
					float num3 = Mathf.Clamp01(1f - num * num - num2 * num2);
					array[i * 32 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(255f * num3 * num3));
				}
			}
			val2.SetPixels32(array);
			val2.Apply(false, true);
			particleMaterial = new Material(val)
			{
				name = "Rotheart translucent motes",
				mainTexture = (Texture)(object)val2,
				renderQueue = 3000
			};
			if (particleMaterial.HasProperty("_Color"))
			{
				particleMaterial.SetColor("_Color", Color.white);
			}
			if (particleMaterial.HasProperty("_TintColor"))
			{
				particleMaterial.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f));
			}
			if (particleMaterial.HasProperty("_Mode"))
			{
				particleMaterial.SetFloat("_Mode", 2f);
			}
			if (particleMaterial.HasProperty("_SrcBlend"))
			{
				particleMaterial.SetInt("_SrcBlend", 5);
			}
			if (particleMaterial.HasProperty("_DstBlend"))
			{
				particleMaterial.SetInt("_DstBlend", 10);
			}
			if (particleMaterial.HasProperty("_ZWrite"))
			{
				particleMaterial.SetInt("_ZWrite", 0);
			}
			particleMaterial.EnableKeyword("_ALPHABLEND_ON");
			particleMaterial.DisableKeyword("_ALPHATEST_ON");
			particleMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		}
	}
	public sealed class RotheartAura : StatusEffect
	{
		public const float Duration = 10f;

		private const float Interval = 2f;

		private const float Radius = 6f;

		private List<Character> targets;

		private int pulses;

		public override void Setup(Character character)
		{
			targets = new List<Character>(32);
			pulses = 0;
			((StatusEffect)this).Setup(character);
		}

		public override void ResetTime()
		{
			((StatusEffect)this).ResetTime();
			pulses = 0;
		}

		public override bool IsDone()
		{
			Character character = base.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null && !((Character)val).IsDead() && Plugin.IsEquipped((Humanoid)(object)val))
			{
				return ((StatusEffect)this).IsDone();
			}
			return true;
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			Character character = base.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer || ((Character)val).IsDead() || !Plugin.IsEquipped((Humanoid)(object)val) || ((Character)val).IsTeleporting() || ((Character)val).InCutscene())
			{
				return;
			}
			ZNetView component = ((Component)val).GetComponent<ZNetView>();
			if (Object.op_Implicit((Object)(object)component) && component.IsValid() && component.IsOwner())
			{
				int num = Mathf.Min(5, Mathf.FloorToInt((base.m_time + 0.0001f) / 2f));
				while (pulses < num)
				{
					pulses++;
					Pulse(val);
				}
			}
		}

		private void Pulse(Player player)
		{
			//IL_0037: 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_00a5: 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_00b9: 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_00c0: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00ea: 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)
			//IL_00ff: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_0120: Expected O, but got Unknown
			float health = ((Character)player).GetHealth();
			if (health > 1f)
			{
				((Character)player).SetHealth(Mathf.Max(1f, health - 1f));
			}
			targets.Clear();
			Character.GetCharactersInRange(((Component)player).transform.position, 6f, targets);
			foreach (Character target in targets)
			{
				if (Object.op_Implicit((Object)(object)target) && !target.IsPlayer() && !target.IsTamed() && !target.IsDead() && BaseAI.IsEnemy((Character)(object)player, target))
				{
					HitData val = new HitData
					{
						m_damage = new DamageTypes
						{
							m_blunt = 12f
						},
						m_point = target.GetCenterPoint()
					};
					Vector3 val2 = ((Component)target).transform.position - ((Component)player).transform.position;
					val.m_dir = ((Vector3)(ref val2)).normalized;
					val.m_pushForce = 0f;
					val.m_dodgeable = false;
					val.m_blockable = false;
					val.m_staggerMultiplier = 0f;
					val.m_skill = (SkillType)0;
					HitData val3 = val;
					val3.SetAttacker((Character)(object)player);
					target.Damage(val3);
				}
			}
			targets.Clear();
		}
	}
}