Decompiled source of UKPyrovision v1.0.0

UKPyrovision.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UKPyrovision")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UKPyrovision")]
[assembly: AssemblyTitle("UKPyrovision")]
[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 UKPyrovision
{
	public enum Look
	{
		Original,
		Hidden,
		Bubbles,
		Hearts,
		Recolored
	}
	public enum BloodColor
	{
		Red,
		Orange,
		Yellow,
		Green,
		Cyan,
		Blue,
		Purple,
		Pink,
		White,
		Black,
		Rainbow,
		Custom
	}
	[BepInPlugin("local.ultrakill.pyrovision", "UK Pyrovision", "1.0.0")]
	public class PyrovisionPlugin : BaseUnityPlugin
	{
		private enum Kind
		{
			None,
			Blood,
			Explosion
		}

		private class HiddenState
		{
			public int MaxParticles;

			public bool Emission;

			public bool Renderer;
		}

		private class DecalEntry
		{
			public Renderer R;

			public Material[] Originals;

			public bool WasEnabled;
		}

		private class MatEntry
		{
			public Material Orig;

			public Material Copy;

			public int Version = -1;

			public readonly List<Texture2D> Texs = new List<Texture2D>();
		}

		public const string PluginGuid = "local.ultrakill.pyrovision";

		public const string PluginName = "UK Pyrovision";

		public const string PluginVersion = "1.0.0";

		private ConfigEntry<bool> enabledCfg;

		private ConfigEntry<KeyCode> toggleKey;

		private ConfigEntry<float> tintStrength;

		private ConfigEntry<Color> tintColor;

		private ConfigEntry<Look> bloodLook;

		private ConfigEntry<Look> explosionLook;

		private ConfigEntry<BloodColor> bloodColor;

		private ConfigEntry<Color> customBloodColor;

		private ConfigEntry<bool> tintBloodMaterials;

		private ConfigEntry<KeyCode> cycleKey;

		private ConfigEntry<string> bloodKeysCfg;

		private ConfigEntry<string> explosionKeysCfg;

		private ConfigEntry<string> decalKeysCfg;

		private ConfigEntry<float> decalScanInterval;

		private ConfigEntry<bool> recolorTextures;

		private ConfigEntry<float> scanInterval;

		private ConfigEntry<bool> logNames;

		private string[] bloodKeys = new string[0];

		private string[] explosionKeys = new string[0];

		private string[] decalKeys = new string[0];

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

		private int styleVersion;

		private readonly Dictionary<int, HiddenState> hiddenStates = new Dictionary<int, HiddenState>();

		private string toast = "";

		private float toastUntil;

		private GUIStyle toastStyle;

		private readonly List<DecalEntry> decals = new List<DecalEntry>();

		private readonly HashSet<int> seenDecalRenderers = new HashSet<int>();

		private readonly Dictionary<int, float> decalRetryAt = new Dictionary<int, float>();

		private readonly HashSet<string> loggedDecals = new HashSet<string>();

		private readonly Dictionary<int, MatEntry> recolorMats = new Dictionary<int, MatEntry>();

		private int appliedDecalVersion = -1;

		private float nextDecalScan;

		private float nextRainbowDecalRefresh;

		private static readonly string[] BroadWords = new string[10] { "blood", "gore", "splat", "stain", "decal", "viscera", "flesh", "wound", "bullethole", "gib" };

		private readonly HashSet<int> seenRenderers = new HashSet<int>();

		private readonly HashSet<string> loggedNames = new HashSet<string>();

		private float nextScan;

		private static Texture2D bubbleTex;

		private static Texture2D heartTex;

		private static Shader particleShader;

		private static bool shaderSearched;

		private readonly Dictionary<int, Material> bubbleMats = new Dictionary<int, Material>();

		private readonly Dictionary<int, Material> heartMats = new Dictionary<int, Material>();

		private static readonly string[] ColorProps = new string[5] { "_Color", "_TintColor", "_BaseColor", "_EmissiveColor", "_EmissionColor" };

		private static readonly string[] TextureProps = new string[4] { "_MainTex", "_BaseMap", "_BaseColorMap", "_Texture" };

		private readonly HashSet<int> decalIds = new HashSet<int>();

		private void Awake()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00a9: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Expected O, but got Unknown
			enabledCfg = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for everything.");
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)290, "Key that switches Pyrovision on/off.");
			tintStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Tint", "Strength", 0.18f, new ConfigDescription("How strong the rose tint over the screen is (0 = none).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.6f), Array.Empty<object>()));
			tintColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Tint", "Color", new Color(1f, 0.45f, 0.7f, 1f), "Color of the screen tint.");
			bloodLook = ((BaseUnityPlugin)this).Config.Bind<Look>("Look", "Blood", Look.Hidden, "What blood effects become: Original, Hidden, Bubbles, Hearts, or Recolored (keeps the blood but changes its color, see BloodColor).");
			explosionLook = ((BaseUnityPlugin)this).Config.Bind<Look>("Look", "Explosions", Look.Bubbles, "What explosion effects become: Original, Hidden, Bubbles or Hearts. Damage is unchanged.");
			bloodColor = ((BaseUnityPlugin)this).Config.Bind<BloodColor>("Look", "BloodColor", BloodColor.Blue, "Blood color used when Blood = Recolored. Pick Custom to use CustomBloodColor.");
			customBloodColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Look", "CustomBloodColor", new Color(0.2f, 1f, 0.3f, 1f), "Used when BloodColor = Custom.");
			tintBloodMaterials = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "TintBloodMaterials", true, "Also tint the blood's material, not just the particle colors. Turn off if the colors look too dark or wrong.");
			cycleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "CycleBloodColorKey", (KeyCode)289, "Press to switch blood to Recolored and step through the colors.");
			bloodLook.SettingChanged += delegate
			{
				styleVersion++;
			};
			explosionLook.SettingChanged += delegate
			{
				styleVersion++;
			};
			bloodColor.SettingChanged += delegate
			{
				styleVersion++;
			};
			customBloodColor.SettingChanged += delegate
			{
				styleVersion++;
			};
			tintBloodMaterials.SettingChanged += delegate
			{
				styleVersion++;
			};
			bloodKeysCfg = ((BaseUnityPlugin)this).Config.Bind<string>("Matching", "BloodKeywords", "blood,gore,splatter,viscera,gib", "Effects whose object name (or a parent's name) contains one of these words count as blood. Comma separated, not case sensitive.");
			explosionKeysCfg = ((BaseUnityPlugin)this).Config.Bind<string>("Matching", "ExplosionKeywords", "explosion,explode", "Effects whose object name (or a parent's name) contains one of these words count as explosions.");
			scanInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Matching", "ScanInterval", 0.1f, new ConfigDescription("Seconds between scans for new effects. Lower = fewer red flashes, higher = less CPU.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 1f), Array.Empty<object>()));
			logNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Matching", "LogEffectNames", true, "Write the name of every new particle effect to BepInEx/LogOutput.log, with what it was treated as. Use this to find the right keywords, then turn it off.");
			decalKeysCfg = ((BaseUnityPlugin)this).Config.Bind<string>("Matching", "DecalKeywords", "blood,splat,gore", "Wall and floor blood splatters are found by these words in an object's name, material name, shader name or texture name. Comma separated, not case sensitive.");
			decalScanInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Matching", "DecalScanInterval", 0.5f, new ConfigDescription("Seconds between scans for new splatters on walls and floors.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			recolorTextures = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "RecolorTextures", true, "Rebuild the splatter textures in the new color. Needed when the blood color is baked into the texture. Turn off if splatters look wrong.");
			bloodKeysCfg.SettingChanged += delegate
			{
				ParseKeys();
			};
			explosionKeysCfg.SettingChanged += delegate
			{
				ParseKeys();
			};
			decalKeysCfg.SettingChanged += delegate
			{
				ParseKeys();
			};
			recolorTextures.SettingChanged += delegate
			{
				styleVersion++;
			};
			ParseKeys();
		}

		private void ParseKeys()
		{
			bloodKeys = Split(bloodKeysCfg.Value);
			explosionKeys = Split(explosionKeysCfg.Value);
			decalKeys = Split(decalKeysCfg.Value);
		}

		private static string[] Split(string csv)
		{
			List<string> list = new List<string>();
			string[] array = (csv ?? "").Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim().ToLowerInvariant();
				if (text.Length > 0)
				{
					list.Add(text);
				}
			}
			return list.ToArray();
		}

		private void Update()
		{
			if (!enabledCfg.Value || Time.unscaledTime < nextScan)
			{
				return;
			}
			nextScan = Time.unscaledTime + scanInterval.Value;
			ParticleSystem[] array = Object.FindObjectsOfType<ParticleSystem>();
			foreach (ParticleSystem val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)val).GetInstanceID();
				if (!seenSystems.TryGetValue(instanceID, out var value) || value != styleVersion)
				{
					seenSystems[instanceID] = styleVersion;
					try
					{
						Process(val);
					}
					catch (Exception ex)
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not restyle " + ((Object)val).name + ": " + ex.Message));
					}
				}
			}
			try
			{
				ScanDecals();
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Decal scan failed: " + ex2.Message));
			}
			if (seenSystems.Count > 20000)
			{
				seenSystems.Clear();
			}
			if (seenRenderers.Count > 20000)
			{
				seenRenderers.Clear();
			}
			if (seenDecalRenderers.Count > 40000)
			{
				seenDecalRenderers.Clear();
			}
			if (decalRetryAt.Count > 40000)
			{
				decalRetryAt.Clear();
			}
		}

		private static string PathOf(Transform t)
		{
			StringBuilder stringBuilder = new StringBuilder(((Object)t).name);
			Transform parent = t.parent;
			for (int i = 0; i < 2; i++)
			{
				if (!((Object)(object)parent != (Object)null))
				{
					break;
				}
				stringBuilder.Append(" < ").Append(((Object)parent).name);
				parent = parent.parent;
			}
			return stringBuilder.ToString();
		}

		private static bool Matches(string lower, string[] keys)
		{
			for (int i = 0; i < keys.Length; i++)
			{
				if (lower.Contains(keys[i]))
				{
					return true;
				}
			}
			return false;
		}

		private Kind Classify(string lower)
		{
			if (Matches(lower, bloodKeys))
			{
				return Kind.Blood;
			}
			if (Matches(lower, explosionKeys))
			{
				return Kind.Explosion;
			}
			return Kind.None;
		}

		private void Process(ParticleSystem ps)
		{
			string text = PathOf(((Component)ps).transform);
			Kind kind = Classify(text.ToLowerInvariant());
			if (logNames.Value && loggedNames.Count < 800 && loggedNames.Add(text))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[effect] " + text + "  ->  " + kind));
			}
			if (kind == Kind.None)
			{
				return;
			}
			RestoreHidden(ps);
			Look look = ((kind == Kind.Blood) ? bloodLook.Value : explosionLook.Value);
			switch (look)
			{
			case Look.Original:
				return;
			case Look.Recolored:
				if (kind == Kind.Blood)
				{
					RecolorBlood(ps);
				}
				return;
			}
			RestyleParticles(ps, look);
			if (kind == Kind.Explosion)
			{
				RestyleExplosionExtras(((Component)ps).transform, look);
			}
		}

		private void RestyleParticles(ParticleSystem ps, Look look)
		{
			//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_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_00d3: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_010c: 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_0126: 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_0136: 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)
			ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
			if (look == Look.Hidden)
			{
				EmissionModule emission = ps.emission;
				MainModule main = ps.main;
				int instanceID = ((Object)ps).GetInstanceID();
				if (!hiddenStates.ContainsKey(instanceID))
				{
					hiddenStates[instanceID] = new HiddenState
					{
						MaxParticles = ((MainModule)(ref main)).maxParticles,
						Emission = ((EmissionModule)(ref emission)).enabled,
						Renderer = ((Object)(object)component != (Object)null && ((Renderer)component).enabled)
					};
				}
				((EmissionModule)(ref emission)).enabled = false;
				((MainModule)(ref main)).maxParticles = 0;
				ps.Clear(false);
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).enabled = false;
				}
				return;
			}
			if ((Object)(object)component != (Object)null)
			{
				Material material = GetMaterial(look, ((Renderer)component).sharedMaterial);
				if ((Object)(object)material != (Object)null)
				{
					component.renderMode = (ParticleSystemRenderMode)0;
					((Renderer)component).sharedMaterial = material;
				}
			}
			MainModule main2 = ps.main;
			MinMaxGradient startColor = default(MinMaxGradient);
			((MinMaxGradient)(ref startColor))..ctor(Rainbow());
			((MinMaxGradient)(ref startColor)).mode = (ParticleSystemGradientMode)4;
			((MainModule)(ref main2)).startColor = startColor;
			((MainModule)(ref main2)).gravityModifier = new MinMaxCurve(-0.08f);
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = false;
			ColorBySpeedModule colorBySpeed = ps.colorBySpeed;
			((ColorBySpeedModule)(ref colorBySpeed)).enabled = false;
			TrailModule trails = ps.trails;
			((TrailModule)(ref trails)).enabled = false;
			TextureSheetAnimationModule textureSheetAnimation = ps.textureSheetAnimation;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = false;
			RecolorLiveParticles(ps);
		}

		private void ScanDecals()
		{
			if (appliedDecalVersion != styleVersion)
			{
				appliedDecalVersion = styleVersion;
				for (int num = decals.Count - 1; num >= 0; num--)
				{
					if ((Object)(object)decals[num].R == (Object)null)
					{
						decals.RemoveAt(num);
					}
					else
					{
						ApplyDecal(decals[num]);
					}
				}
			}
			if (bloodLook.Value == Look.Original || Time.unscaledTime < nextDecalScan)
			{
				return;
			}
			nextDecalScan = Time.unscaledTime + decalScanInterval.Value;
			if (bloodLook.Value == Look.Recolored && bloodColor.Value == BloodColor.Rainbow && Time.unscaledTime >= nextRainbowDecalRefresh)
			{
				nextRainbowDecalRefresh = Time.unscaledTime + 0.5f;
				foreach (KeyValuePair<int, MatEntry> recolorMat in recolorMats)
				{
					if (recolorMat.Value != null)
					{
						recolorMat.Value.Version = -1;
					}
				}
				for (int i = 0; i < decals.Count; i++)
				{
					ApplyDecal(decals[i]);
				}
			}
			Renderer[] array = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val in array)
			{
				if ((Object)(object)val == (Object)null || val is ParticleSystemRenderer || val is TrailRenderer || val is LineRenderer)
				{
					continue;
				}
				int instanceID = ((Object)val).GetInstanceID();
				if (!seenDecalRenderers.Contains(instanceID) && (!decalRetryAt.TryGetValue(instanceID, out var value) || !(Time.unscaledTime < value)))
				{
					if (decalIds.Contains(instanceID))
					{
						seenDecalRenderers.Add(instanceID);
					}
					else if (InspectRenderer(val, instanceID))
					{
						seenDecalRenderers.Add(instanceID);
						decalRetryAt.Remove(instanceID);
					}
					else
					{
						decalRetryAt[instanceID] = Time.unscaledTime + 2f;
					}
				}
			}
		}

		private static Texture FirstTexture(Material m)
		{
			string[] textureProps = TextureProps;
			foreach (string text in textureProps)
			{
				if (m.HasProperty(text))
				{
					Texture texture = m.GetTexture(text);
					if ((Object)(object)texture != (Object)null)
					{
						return texture;
					}
				}
			}
			return null;
		}

		private bool InspectRenderer(Renderer r, int id)
		{
			string text = PathOf(((Component)r).transform).ToLowerInvariant();
			Material[] sharedMaterials = r.sharedMaterials;
			bool flag = Matches(text, decalKeys);
			bool flag2 = Matches(text, BroadWords);
			StringBuilder stringBuilder = new StringBuilder(text);
			foreach (Material val in sharedMaterials)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string lower = ((Object)val).name.ToLowerInvariant();
					string lower2 = (((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name.ToLowerInvariant() : "");
					Texture val2 = FirstTexture(val);
					string lower3 = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name.ToLowerInvariant() : "");
					if (Matches(lower, decalKeys) || Matches(lower2, decalKeys) || Matches(lower3, decalKeys))
					{
						flag = true;
					}
					if (Matches(lower, BroadWords) || Matches(lower2, BroadWords) || Matches(lower3, BroadWords))
					{
						flag2 = true;
					}
					stringBuilder.Append("  | mat=").Append(((Object)val).name).Append(" shader=")
						.Append(((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : "?");
					if ((Object)(object)val2 != (Object)null)
					{
						stringBuilder.Append(" tex=").Append(((Object)val2).name);
					}
				}
			}
			if (logNames.Value && (flag || flag2) && loggedDecals.Count < 600 && loggedDecals.Add(stringBuilder.ToString()))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[decal] " + stringBuilder?.ToString() + "  ->  " + (flag ? "MATCHED" : "not matched")));
			}
			if (!flag)
			{
				return false;
			}
			DecalEntry decalEntry = new DecalEntry
			{
				R = r,
				Originals = sharedMaterials,
				WasEnabled = r.enabled
			};
			decals.Add(decalEntry);
			decalIds.Add(id);
			ApplyDecal(decalEntry);
			return true;
		}

		private void ApplyDecal(DecalEntry d)
		{
			Renderer r = d.R;
			if ((Object)(object)r == (Object)null)
			{
				return;
			}
			Look value = bloodLook.Value;
			if (value == Look.Hidden)
			{
				r.enabled = false;
				return;
			}
			r.enabled = d.WasEnabled;
			if (value == Look.Recolored)
			{
				Material[] array = (Material[])(object)new Material[d.Originals.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = (((Object)(object)d.Originals[i] != (Object)null) ? GetRecoloredMaterial(d.Originals[i]) : null);
				}
				r.sharedMaterials = array;
			}
			else
			{
				r.sharedMaterials = d.Originals;
			}
		}

		private Material GetRecoloredMaterial(Material orig)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			int instanceID = ((Object)orig).GetInstanceID();
			if (!recolorMats.TryGetValue(instanceID, out var value) || (Object)(object)value.Copy == (Object)null)
			{
				value = new MatEntry
				{
					Orig = orig,
					Copy = new Material(orig)
				};
				((Object)value.Copy).hideFlags = (HideFlags)61;
				recolorMats[instanceID] = value;
			}
			if (value.Version != styleVersion)
			{
				ApplyRecolor(value);
			}
			return value.Copy;
		}

		private Color DecalTarget()
		{
			//IL_0031: 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)
			if (bloodColor.Value == BloodColor.Rainbow)
			{
				return Color.HSVToRGB(Time.unscaledTime * 0.25f % 1f, 0.85f, 1f);
			}
			return BloodTarget();
		}

		private void ApplyRecolor(MatEntry e)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0135: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: 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)
			e.Version = styleVersion;
			foreach (Texture2D tex in e.Texs)
			{
				if ((Object)(object)tex != (Object)null)
				{
					Object.Destroy((Object)(object)tex);
				}
			}
			e.Texs.Clear();
			Color val = DecalTarget();
			bool flag = false;
			string[] textureProps;
			if (recolorTextures.Value)
			{
				textureProps = TextureProps;
				foreach (string text in textureProps)
				{
					if (!e.Copy.HasProperty(text))
					{
						continue;
					}
					Texture texture = e.Orig.GetTexture(text);
					if (!((Object)(object)texture == (Object)null))
					{
						Texture2D val2 = RecolorTexture(texture, val);
						if (!((Object)(object)val2 == (Object)null))
						{
							e.Copy.SetTexture(text, (Texture)(object)val2);
							e.Texs.Add(val2);
							flag = true;
						}
					}
				}
			}
			textureProps = ColorProps;
			Color val3 = default(Color);
			foreach (string text2 in textureProps)
			{
				if (e.Copy.HasProperty(text2))
				{
					Color color = e.Orig.GetColor(text2);
					if (text2.IndexOf("Emis", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						float num = Mathf.Max(color.r, Mathf.Max(color.g, color.b));
						((Color)(ref val3))..ctor(val.r * num, val.g * num, val.b * num, color.a);
					}
					else if (flag)
					{
						((Color)(ref val3))..ctor(1f, 1f, 1f, color.a);
					}
					else
					{
						((Color)(ref val3))..ctor(val.r, val.g, val.b, color.a);
					}
					e.Copy.SetColor(text2, val3);
				}
			}
		}

		private Texture2D RecolorTexture(Texture src, Color target)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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)
			RenderTexture val = null;
			RenderTexture active = RenderTexture.active;
			try
			{
				int num = Mathf.Clamp(src.width, 4, 256);
				int num2 = Mathf.Clamp(src.height, 4, 256);
				val = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0);
				Graphics.Blit(src, val);
				RenderTexture.active = val;
				Texture2D val2 = new Texture2D(num, num2, (TextureFormat)4, true);
				val2.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
				RenderTexture.active = active;
				Color32[] pixels = val2.GetPixels32();
				float num3 = 0.0001f;
				for (int i = 0; i < pixels.Length; i++)
				{
					if (pixels[i].a >= 20)
					{
						float num4 = (float)Mathf.Max((int)pixels[i].r, Mathf.Max((int)pixels[i].g, (int)pixels[i].b)) / 255f;
						if (num4 > num3)
						{
							num3 = num4;
						}
					}
				}
				for (int j = 0; j < pixels.Length; j++)
				{
					float num5 = Mathf.Clamp01((float)Mathf.Max((int)pixels[j].r, Mathf.Max((int)pixels[j].g, (int)pixels[j].b)) / 255f / num3);
					pixels[j] = new Color32((byte)(target.r * 255f * num5), (byte)(target.g * 255f * num5), (byte)(target.b * 255f * num5), pixels[j].a);
				}
				val2.SetPixels32(pixels);
				val2.Apply(true);
				((Texture)val2).wrapMode = src.wrapMode;
				((Texture)val2).filterMode = (FilterMode)1;
				((Object)val2).hideFlags = (HideFlags)61;
				return val2;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not recolor texture " + ((Object)src).name + ": " + ex.Message));
				return null;
			}
			finally
			{
				RenderTexture.active = active;
				if ((Object)(object)val != (Object)null)
				{
					RenderTexture.ReleaseTemporary(val);
				}
			}
		}

		private void RestoreHidden(ParticleSystem ps)
		{
			//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_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)
			int instanceID = ((Object)ps).GetInstanceID();
			if (hiddenStates.TryGetValue(instanceID, out var value))
			{
				MainModule main = ps.main;
				((MainModule)(ref main)).maxParticles = value.MaxParticles;
				EmissionModule emission = ps.emission;
				((EmissionModule)(ref emission)).enabled = value.Emission;
				ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).enabled = value.Renderer;
				}
				hiddenStates.Remove(instanceID);
			}
		}

		private Color BloodTarget()
		{
			//IL_005b: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_0145: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(bloodColor.Value switch
			{
				BloodColor.Red => new Color(0.8f, 0.05f, 0.05f, 1f), 
				BloodColor.Orange => new Color(1f, 0.5f, 0.05f, 1f), 
				BloodColor.Yellow => new Color(1f, 0.9f, 0.1f, 1f), 
				BloodColor.Green => new Color(0.1f, 0.85f, 0.2f, 1f), 
				BloodColor.Cyan => new Color(0.1f, 0.85f, 0.9f, 1f), 
				BloodColor.Blue => new Color(0.15f, 0.35f, 1f, 1f), 
				BloodColor.Purple => new Color(0.6f, 0.2f, 0.9f, 1f), 
				BloodColor.Pink => new Color(1f, 0.4f, 0.7f, 1f), 
				BloodColor.White => new Color(1f, 1f, 1f, 1f), 
				BloodColor.Black => new Color(0.04f, 0.04f, 0.04f, 1f), 
				BloodColor.Custom => customBloodColor.Value, 
				_ => Color.white, 
			});
		}

		private static Gradient VividRainbow()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008d: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_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_00fd: 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_0113: 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)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[6]
			{
				new GradientColorKey(new Color(1f, 0.15f, 0.15f), 0f),
				new GradientColorKey(new Color(1f, 0.85f, 0.1f), 0.2f),
				new GradientColorKey(new Color(0.15f, 0.95f, 0.25f), 0.4f),
				new GradientColorKey(new Color(0.1f, 0.85f, 1f), 0.6f),
				new GradientColorKey(new Color(0.25f, 0.3f, 1f), 0.8f),
				new GradientColorKey(new Color(0.85f, 0.2f, 1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(1f, 1f)
			});
			return val;
		}

		private void RecolorBlood(ParticleSystem ps)
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0026: 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_0032: 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_006f: 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_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)
			//IL_0091: 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_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_00bd: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Invalid comparison between Unknown and I4
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0129: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			bool flag = bloodColor.Value == BloodColor.Rainbow;
			bool value = tintBloodMaterials.Value;
			Color val = BloodTarget();
			Color val2 = (value ? new Color(Mathf.Sqrt(val.r), Mathf.Sqrt(val.g), Mathf.Sqrt(val.b), 1f) : new Color(val.r, val.g, val.b, 1f));
			MainModule main = ps.main;
			if (flag)
			{
				MinMaxGradient startColor = default(MinMaxGradient);
				((MinMaxGradient)(ref startColor))..ctor(VividRainbow());
				((MinMaxGradient)(ref startColor)).mode = (ParticleSystemGradientMode)4;
				((MainModule)(ref main)).startColor = startColor;
			}
			else
			{
				((MainModule)(ref main)).startColor = new MinMaxGradient(val2);
			}
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
			{
				MinMaxGradient color = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color;
				if (!flag && (int)((MinMaxGradient)(ref color)).mode == 1 && ((MinMaxGradient)(ref color)).gradient != null)
				{
					Gradient gradient = ((MinMaxGradient)(ref color)).gradient;
					GradientColorKey[] colorKeys = gradient.colorKeys;
					for (int i = 0; i < colorKeys.Length; i++)
					{
						colorKeys[i].color = val2;
					}
					Gradient val3 = new Gradient();
					val3.SetKeys(colorKeys, gradient.alphaKeys);
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
				}
				else
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = false;
				}
			}
			TrailModule trails = ps.trails;
			if (((TrailModule)(ref trails)).enabled && !flag)
			{
				((TrailModule)(ref trails)).colorOverLifetime = new MinMaxGradient(val2);
			}
			if (value && !flag)
			{
				ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial != (Object)null)
				{
					Material material = ((Renderer)component).material;
					string[] colorProps = ColorProps;
					foreach (string text in colorProps)
					{
						if (material.HasProperty(text))
						{
							Color color2 = material.GetColor(text);
							Color val4 = val2;
							val4.a = color2.a;
							material.SetColor(text, val4);
						}
					}
				}
			}
			RecolorLiveParticles(ps, flag ? ((Color?)null) : new Color?(val2));
		}

		private static Gradient Rainbow()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008d: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[5]
			{
				new GradientColorKey(new Color(1f, 0.7f, 0.85f), 0f),
				new GradientColorKey(new Color(1f, 0.9f, 0.7f), 0.25f),
				new GradientColorKey(new Color(0.75f, 1f, 0.85f), 0.5f),
				new GradientColorKey(new Color(0.7f, 0.9f, 1f), 0.75f),
				new GradientColorKey(new Color(0.9f, 0.78f, 1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(0.9f, 0f),
				new GradientAlphaKey(0.9f, 1f)
			});
			return val;
		}

		private static Color32 RandomPastel()
		{
			//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_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)
			Color val = Color.HSVToRGB(Random.value, 0.35f, 1f);
			val.a = 0.9f;
			return Color32.op_Implicit(val);
		}

		private static void RecolorLiveParticles(ParticleSystem ps, Color? fixedColor = null)
		{
			//IL_0049: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			int particleCount = ps.particleCount;
			if (particleCount <= 0)
			{
				return;
			}
			Particle[] array = (Particle[])(object)new Particle[particleCount];
			int particles = ps.GetParticles(array);
			for (int i = 0; i < particles; i++)
			{
				if (fixedColor.HasValue)
				{
					((Particle)(ref array[i])).startColor = Color32.op_Implicit(fixedColor.Value);
				}
				else
				{
					((Particle)(ref array[i])).startColor = RandomPastel();
				}
			}
			ps.SetParticles(array, particles);
		}

		private void RestyleExplosionExtras(Transform from, Look look)
		{
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			Transform val = from;
			Transform parent = from.parent;
			int num = 0;
			while (num < 3 && (Object)(object)parent != (Object)null)
			{
				if (Matches(((Object)parent).name.ToLowerInvariant(), explosionKeys))
				{
					val = parent;
				}
				num++;
				parent = parent.parent;
			}
			MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>(true);
			if (componentsInChildren.Length > 30)
			{
				return;
			}
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val2 in array)
			{
				if ((Object)(object)val2 == (Object)null || !seenRenderers.Add(((Object)val2).GetInstanceID()))
				{
					continue;
				}
				if (look == Look.Hidden)
				{
					((Renderer)val2).enabled = false;
					continue;
				}
				Material[] materials = ((Renderer)val2).materials;
				for (int j = 0; j < materials.Length; j++)
				{
					if ((Object)(object)materials[j] != (Object)null)
					{
						TintMaterial(materials[j]);
					}
				}
			}
			Light[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Light>(true);
			foreach (Light val3 in componentsInChildren2)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					if (look == Look.Hidden)
					{
						((Behaviour)val3).enabled = false;
					}
					else
					{
						val3.color = Color.HSVToRGB(Random.value, 0.3f, 1f);
					}
				}
			}
		}

		private static void TintMaterial(Material m)
		{
			//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_002e: 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_0049: 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_0065: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			Color val = Color.HSVToRGB(Random.value, 0.35f, 1f);
			string[] colorProps = ColorProps;
			foreach (string text in colorProps)
			{
				if (m.HasProperty(text))
				{
					Color color = m.GetColor(text);
					bool flag = text.IndexOf("Emis", StringComparison.OrdinalIgnoreCase) >= 0;
					Color val2 = val;
					val2.a = (flag ? color.a : Mathf.Min(color.a, 0.45f));
					m.SetColor(text, val2);
				}
			}
		}

		private static Shader FindParticleShader()
		{
			if (shaderSearched)
			{
				return particleShader;
			}
			shaderSearched = true;
			string[] array = new string[4] { "Sprites/Default", "Legacy Shaders/Particles/Alpha Blended", "Particles/Standard Unlit", "UI/Default" };
			for (int i = 0; i < array.Length; i++)
			{
				Shader val = Shader.Find(array[i]);
				if ((Object)(object)val != (Object)null)
				{
					particleShader = val;
					break;
				}
			}
			return particleShader;
		}

		private Material GetMaterial(Look look, Material basis)
		{
			//IL_0071: 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_0078: Expected O, but got Unknown
			//IL_00cc: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, Material> dictionary = ((look == Look.Hearts) ? heartMats : bubbleMats);
			Texture2D val = ((look == Look.Hearts) ? HeartTexture() : BubbleTexture());
			Shader val2 = FindParticleShader();
			int key = 0;
			if ((Object)(object)val2 == (Object)null)
			{
				if ((Object)(object)basis == (Object)null)
				{
					return null;
				}
				key = ((Object)basis).GetInstanceID();
			}
			if (dictionary.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = (((Object)(object)val2 != (Object)null) ? new Material(val2) : new Material(basis));
			((Object)value).hideFlags = (HideFlags)61;
			string[] textureProps = TextureProps;
			foreach (string text in textureProps)
			{
				if (value.HasProperty(text))
				{
					value.SetTexture(text, (Texture)(object)val);
				}
			}
			if (value.HasProperty("_Color"))
			{
				value.SetColor("_Color", Color.white);
			}
			if (value.HasProperty("_TintColor"))
			{
				value.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f));
			}
			if (value.HasProperty("_BaseColor"))
			{
				value.SetColor("_BaseColor", Color.white);
			}
			dictionary[key] = value;
			return value;
		}

		private static Texture2D BubbleTexture()
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bubbleTex != (Object)null)
			{
				return bubbleTex;
			}
			Color32[] array = (Color32[])(object)new Color32[4096];
			float num = 31.5f;
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num2 = ((float)j - num) / num;
					float num3 = ((float)i - num) / num;
					float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
					float num5 = 0f;
					if (num4 <= 1f)
					{
						float num6 = Mathf.SmoothStep(0.62f, 0.95f, num4) * (1f - Mathf.SmoothStep(0.95f, 1f, num4));
						float num7 = 0.12f * (1f - num4);
						float num8 = num2 + 0.35f;
						float num9 = num3 - 0.35f;
						float num10 = Mathf.Clamp01(1f - Mathf.Sqrt(num8 * num8 + num9 * num9) / 0.22f);
						num5 = Mathf.Clamp01(num6 * 0.85f + num7 + num10 * 0.9f);
					}
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f));
				}
			}
			bubbleTex = MakeTexture(64, array);
			return bubbleTex;
		}

		private static Texture2D HeartTexture()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)heartTex != (Object)null)
			{
				return heartTex;
			}
			Color32[] array = (Color32[])(object)new Color32[4096];
			float num = 31.5f;
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num2 = ((float)j - num) / num * 1.3f;
					float num3 = ((float)i - num) / num * 1.3f + 0.2f;
					float num4 = num2 * num2 + num3 * num3 - 1f;
					float num5 = Mathf.Clamp01((0f - (num4 * num4 * num4 - num2 * num2 * num3 * num3 * num3)) * 20f);
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f));
				}
			}
			heartTex = MakeTexture(64, array);
			return heartTex;
		}

		private static Texture2D MakeTexture(int size, Color32[] pixels)
		{
			//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_0017: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			val.SetPixels32(pixels);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		private void OnGUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_0059: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Invalid comparison between Unknown and I4
			//IL_009c: 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_00bf: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_0123: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			Event current = Event.current;
			if ((int)current.type == 4 && current.keyCode == toggleKey.Value)
			{
				enabledCfg.Value = !enabledCfg.Value;
				current.Use();
			}
			if (!enabledCfg.Value)
			{
				return;
			}
			if ((int)current.type == 4 && current.keyCode == cycleKey.Value)
			{
				CycleBloodColor();
				current.Use();
			}
			GUI.depth = 1000;
			if ((int)current.type == 7 && tintStrength.Value > 0.001f)
			{
				Color color = GUI.color;
				Color value = tintColor.Value;
				value.a = tintStrength.Value;
				GUI.color = value;
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = color;
			}
			if ((int)current.type == 7 && Time.unscaledTime < toastUntil)
			{
				if (toastStyle == null)
				{
					toastStyle = new GUIStyle(GUI.skin.label)
					{
						fontSize = 26,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)1
					};
				}
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, 60f, (float)Screen.width, 50f);
				toastStyle.normal.textColor = Color.black;
				GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), toast, toastStyle);
				toastStyle.normal.textColor = Color.white;
				GUI.Label(val, toast, toastStyle);
			}
		}

		private void CycleBloodColor()
		{
			BloodColor[] array = (BloodColor[])Enum.GetValues(typeof(BloodColor));
			int num = Array.IndexOf(array, bloodColor.Value);
			if (num < 0)
			{
				num = 0;
			}
			if (bloodLook.Value == Look.Recolored)
			{
				num = (num + 1) % array.Length;
			}
			bloodLook.Value = Look.Recolored;
			bloodColor.Value = array[num];
			toast = "Blood: " + array[num];
			toastUntil = Time.unscaledTime + 2f;
		}
	}
}