Decompiled source of Visuals Modifier v0.2.0

VisualsModifier.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<a93693c2-4568-48d4-8914-6dfb12dc7bc8>Embedded]
	internal sealed class <a93693c2-4568-48d4-8914-6dfb12dc7bc8>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<a93693c2-4568-48d4-8914-6dfb12dc7bc8>Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <3b64ce3b-0775-471d-a42b-da39acf52a2e>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <3b64ce3b-0775-471d-a42b-da39acf52a2e>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <3b64ce3b-0775-471d-a42b-da39acf52a2e>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<a93693c2-4568-48d4-8914-6dfb12dc7bc8>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace VisualsModifier
{
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class Colour
	{
		private static Color GRAYSCALE = new Color(0.2126729f, 0.7151522f, 0.072175f);

		public static Texture2D CloneTexture(Texture2D texture)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
			Graphics.Blit((Texture)(object)texture, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			return val;
		}

		public static Color Screen(Color pixel, Color screen)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			Color result = pixel + screen - pixel * screen;
			result.a = pixel.a;
			return result;
		}

		public static Color Multiply(Color pixel, Color multiply)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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)
			Color result = pixel * multiply;
			result.a = pixel.a;
			return result;
		}

		public static Color Overlay(Color pixel, Color overlay)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//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)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!((double)((Color)(ref pixel)).grayscale < 0.5))
			{
				return Color.white - Color.white * 2f * (Color.white - pixel) * (Color.white - overlay);
			}
			return 2f * pixel * overlay;
		}

		private static float Luminance(Color a)
		{
			//IL_000a: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			return GRAYSCALE.r * a.r + GRAYSCALE.g * a.g + GRAYSCALE.b * a.b;
		}

		public static Color32 Cell(Color32 initial, Color32 high, Color32 low, Color32 mid, float midHigh = 0.66f, float midLow = 0.33f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			float num = Luminance(Color32.op_Implicit(initial));
			if (num >= midHigh)
			{
				Color val = Color.Lerp(Color32.op_Implicit(initial), Color32.op_Implicit(high), num / 2f);
				val.a = (int)initial.a;
				return Color32.op_Implicit(val);
			}
			if (num <= midLow)
			{
				Color val2 = Color.Lerp(Color32.op_Implicit(initial), Color32.op_Implicit(low), num / 2f);
				val2.a = (int)initial.a;
				return Color32.op_Implicit(val2);
			}
			return Color32.op_Implicit(Color.Lerp(Color32.op_Implicit(initial), Color32.op_Implicit(mid), num / 2f));
		}

		public static Texture2D AsGrayscale(Texture2D texture)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = CloneTexture(texture);
			try
			{
				Color[] pixels = val.GetPixels();
				Color[] array = (Color[])(object)new Color[pixels.Length];
				for (uint num = 0u; num < ((Texture)texture).width; num++)
				{
					for (uint num2 = 0u; num2 < ((Texture)texture).height; num2++)
					{
						Color val2 = pixels[num + num2 * ((Texture)texture).width];
						array[num + num2 * ((Texture)texture).width] = val2 * GRAYSCALE;
					}
				}
				val.SetPixels(array);
				val.Apply();
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.Message);
			}
			return val;
		}

		public static Texture2D AsGrayscaleColoured(Texture2D texture, Color colour)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = CloneTexture(texture);
			try
			{
				Color[] pixels = val.GetPixels();
				Color[] array = (Color[])(object)new Color[pixels.Length];
				for (uint num = 0u; num < ((Texture)texture).width; num++)
				{
					for (uint num2 = 0u; num2 < ((Texture)texture).height; num2++)
					{
						Color val2 = pixels[num + num2 * ((Texture)texture).width];
						array[num + num2 * ((Texture)texture).width] = Screen(val2 * GRAYSCALE, colour);
					}
				}
				val.SetPixels(array);
				val.Apply();
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.Message);
			}
			return val;
		}

		public static Texture2D AsScreen(Texture2D texture, Color colour)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = CloneTexture(texture);
			try
			{
				Color32[] pixels = val.GetPixels32();
				Color32[] array = (Color32[])(object)new Color32[pixels.Length];
				for (uint num = 0u; num < ((Texture)texture).width; num++)
				{
					for (uint num2 = 0u; num2 < ((Texture)texture).height; num2++)
					{
						Color32 val2 = pixels[num + num2 * ((Texture)texture).width];
						array[num + num2 * ((Texture)texture).width] = Color32.op_Implicit(Screen(Color32.op_Implicit(val2), colour));
					}
				}
				val.SetPixels32(array);
				val.Apply();
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.Message);
			}
			return val;
		}

		public static Texture2D AsMultiply(Texture2D texture, Color colour)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = CloneTexture(texture);
			try
			{
				Color32[] pixels = val.GetPixels32();
				Color32[] array = (Color32[])(object)new Color32[pixels.Length];
				for (uint num = 0u; num < ((Texture)texture).width; num++)
				{
					for (uint num2 = 0u; num2 < ((Texture)texture).height; num2++)
					{
						Color32 val2 = pixels[num + num2 * ((Texture)texture).width];
						array[num + num2 * ((Texture)texture).width] = Color32.op_Implicit(Multiply(Color32.op_Implicit(val2), colour));
					}
				}
				val.SetPixels32(array);
				val.Apply();
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.Message);
			}
			return val;
		}

		public static Texture2D AsCell(Texture2D texture, Color32 high, Color32 low, Color32? mid)
		{
			//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)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = CloneTexture(texture);
			try
			{
				Color32[] pixels = val.GetPixels32();
				Color32[] array = (Color32[])(object)new Color32[pixels.Length];
				for (uint num = 0u; num < ((Texture)texture).width; num++)
				{
					for (uint num2 = 0u; num2 < ((Texture)texture).height; num2++)
					{
						Color32 val2 = pixels[num + num2 * ((Texture)texture).width];
						if (mid.HasValue)
						{
							array[num + num2 * ((Texture)texture).width] = Cell(val2, high, low, mid.Value);
						}
						else
						{
							array[num + num2 * ((Texture)texture).width] = Cell(val2, high, low, val2);
						}
					}
				}
				val.SetPixels32(array);
				val.Apply();
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.Message);
			}
			return val;
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public static class DataManager
	{
		private static ColorConverter cc;

		private static ValheimTimeConverter vtc;

		private static ISerializer _serializer;

		private static IDeserializer _deserializer;

		public static Dictionary<string, Material> cache;

		public static Dictionary<string, Material> materials;

		public static event EventHandler<MaterialEventArgs> OnMaterialAdd;

		public static event EventHandler<MaterialEventArgs> OnMaterialChange;

		static DataManager()
		{
			cc = new ColorConverter();
			vtc = new ValheimTimeConverter();
			_serializer = new SerializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).WithTypeConverter(cc).WithTypeConverter(vtc)
				.Build();
			_deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).WithTypeConverter(cc).WithTypeConverter(vtc)
				.Build();
			cache = new Dictionary<string, Material>();
			materials = new Dictionary<string, Material>();
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val in array)
			{
				cache.Add(((Object)val).name, val);
			}
		}

		public static void LoadMaterials(string path)
		{
			string[] files = Directory.GetFiles(path, "*.yml", SearchOption.AllDirectories);
			for (int i = 0; i < files.Length; i++)
			{
				LoadMaterial(files[i]);
			}
		}

		public static MaterialInstance LoadMaterial(string file)
		{
			MaterialInstance materialInstance = _deserializer.Deserialize<MaterialInstance>(File.ReadAllText(file));
			if (!materials.ContainsKey(materialInstance.Name) && cache.ContainsKey(materialInstance.Original))
			{
				Material val = Object.Instantiate<Material>(cache[materialInstance.Original]);
				DataManager.OnMaterialAdd(null, new MaterialEventArgs(val, materialInstance));
				materials.Add(materialInstance.Name, val);
			}
			else if (materials.ContainsKey(materialInstance.Name))
			{
				DataManager.OnMaterialChange(null, new MaterialEventArgs(materials[materialInstance.Name], materialInstance));
			}
			return materialInstance;
		}

		public static void SaveTexture(string name, Material material, string property)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			byte[] bytes = ImageConversion.EncodeToPNG((Texture2D)material.GetTexture(property));
			File.WriteAllBytes(Path.Combine(Plugin.Storage, "Materials", name + ".png"), bytes);
		}

		public static Texture2D LoadTexture(string name)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_003e: Expected O, but got Unknown
			string path = Path.Combine(Plugin.Storage, "Materials", name + ".png");
			if (!File.Exists(path))
			{
				return null;
			}
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(16, 16);
			ImageConversion.LoadImage(val, array);
			return val;
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class MaterialEventArgs : EventArgs
	{
		public Material Material { get; private set; }

		public MaterialInstance MaterialInstance { get; private set; }

		public MaterialEventArgs(Material m, MaterialInstance mi)
		{
			Material = m;
			MaterialInstance = mi;
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public interface IManipulator
	{
		void Invoke(Renderer m, GameObject prefab);

		void Invoke(Material m, GameObject prefab);
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	internal class MaterialsManipulator : IManipulator
	{
		private List<List<IMaterialEffect>> effects = new List<List<IMaterialEffect>>();

		public MaterialsManipulator(MaterialData[] materialChanges)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < materialChanges.Length; i++)
			{
				MaterialData materialData = materialChanges[i];
				effects.Add(new List<IMaterialEffect>());
				if (materialData.Colors != null)
				{
					foreach (KeyValuePair<string, Color> color in materialData.Colors)
					{
						effects[i].Add(new MaterialColorEffect(color.Key, color.Value));
					}
				}
				if (materialData.Floats == null)
				{
					continue;
				}
				foreach (KeyValuePair<string, float> @float in materialData.Floats)
				{
					effects[i].Add(new MaterialFloatEffect(@float.Key, @float.Value));
				}
			}
		}

		public void Invoke(Renderer smr, GameObject prefab)
		{
			for (int j = 0; j < smr.sharedMaterials.Length && j < effects.Count; j++)
			{
				Material i = smr.sharedMaterials[j];
				if (effects[j] != null)
				{
					effects[j].ForEach(delegate(IMaterialEffect e)
					{
						e.Apply(i);
					});
				}
			}
		}

		public void Invoke(Material m, GameObject prefab)
		{
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public interface IMaterialEffect
	{
		void Apply(Material m);

		void Apply(MaterialPropertyBlock m);
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	internal interface IRealtimeApplicator
	{
		void Apply(Transform transform, GameObject prefab);
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RealtimeApplicator : IRealtimeApplicator
	{
		private Type _type;

		public RealtimeApplicator(Type type)
		{
			_type = type;
		}

		public void Apply(Transform transform, GameObject prefab)
		{
			object obj = ((Component)transform).gameObject.GetComponent(_type);
			if (obj == null)
			{
				obj = ((Component)transform).gameObject.AddComponent(_type);
			}
			((IRealtimeEffector)obj).SetVisuals(VisualController.GetVisualIndex(((Object)prefab).name));
		}
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class RealtimeColorEffect : RealtimeMaterialEffect<Color>
	{
		public RealtimeColorEffect(string name, Color value)
			: base(name, value)
		{
		}//IL_0002: Unknown result type (might be due to invalid IL or missing references)


		public override void Apply(MaterialPropertyBlock mpb, Material m, RealtimeEffectData context, float ratio)
		{
			//IL_0029: 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_0010: 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)
			if (!Cached)
			{
				Cache = m.GetColor(base.Name);
				Cached = true;
			}
			mpb.SetColor(base.Name, Color.Lerp(Cache, base.Value, ratio));
		}
	}
	[Serializable]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public abstract class RealtimeComponentEffect<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T> : IRealtimeEffect
	{
		protected T Component;

		protected bool Cached;

		public RealtimeComponentEffect()
		{
			Cached = false;
		}

		public static T GetNearestComponent<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T>(Transform transform)
		{
			T component = ((Component)transform).GetComponent<T>();
			if (component != null)
			{
				return component;
			}
			if ((Object)(object)transform.parent != (Object)null)
			{
				return GetNearestComponent<T>(transform.parent);
			}
			return component;
		}

		public static T GetChildComponent<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T>(Transform t, string name)
		{
			Transform val = t.Find(name);
			if (Object.op_Implicit((Object)(object)val))
			{
				return ((Component)val).GetComponent<T>();
			}
			return default(T);
		}

		public abstract void Apply(Transform t, float ratio);

		public void Apply(MaterialPropertyBlock mpb, Material m, RealtimeEffectData data, float ratio)
		{
		}
	}
	[Serializable]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public abstract class RealtimeMaterialEffect<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T> : IRealtimeEffect
	{
		protected T Cache;

		protected bool Cached;

		public string Name { get; set; }

		public T Value { get; set; }

		public RealtimeMaterialEffect(string name, T value)
		{
			Name = name;
			Value = value;
			Cached = false;
		}

		public void Restore(T value)
		{
			Cache = value;
		}

		public abstract void Apply(MaterialPropertyBlock mpb, Material m, RealtimeEffectData context, float ratio);

		public void Apply(Transform t, float ratio)
		{
		}
	}
	[Serializable]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RealtimeFloatEffect : RealtimeMaterialEffect<float>
	{
		public RealtimeFloatEffect(string name, float value)
			: base(name, value)
		{
		}

		public override void Apply(MaterialPropertyBlock mpb, Material m, RealtimeEffectData context, float ratio)
		{
			if (!Cached)
			{
				Cache = m.GetFloat(base.Name);
				Cached = true;
			}
			mpb.SetFloat(base.Name, Mathf.Lerp(Cache, base.Value, ratio));
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RealtimeManipulator : IManipulator
	{
		private RealtimeEffectData Effect;

		private List<IRealtimeApplicator> Applicators = new List<IRealtimeApplicator>();

		public RealtimeManipulator(RealtimeEffectData effect)
		{
			Effect = effect;
			switch (Effect.Type)
			{
			case RealtimeEffectType.Time:
				AddValue(new RealtimeApplicator(typeof(TimeEffector)));
				break;
			case RealtimeEffectType.Proximity:
				AddValue(new RealtimeApplicator(typeof(ProximityEffector)));
				break;
			case RealtimeEffectType.Biome:
				AddValue(new RealtimeApplicator(typeof(BiomeEffector)));
				break;
			}
		}

		public void AddValue<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] IRealtimeApplicator>(IRealtimeApplicator data)
		{
			Applicators.Add((VisualsModifier.IRealtimeApplicator)(object)data);
		}

		public void Invoke(Renderer renderer, GameObject prefab)
		{
			Applicators.ForEach(delegate(IRealtimeApplicator e)
			{
				e.Apply(((Component)renderer).transform, prefab);
			});
		}

		public void Invoke(Material m, GameObject prefab)
		{
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	internal class MaterialManipulator : IManipulator
	{
		private List<IMaterialEffect> properties = new List<IMaterialEffect>();

		public MaterialManipulator(MaterialData data)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (data.Colors != null)
			{
				foreach (KeyValuePair<string, Color> color in data.Colors)
				{
					AddValue(new MaterialColorEffect(color.Key, color.Value));
				}
			}
			if (data.Floats == null)
			{
				return;
			}
			foreach (KeyValuePair<string, float> @float in data.Floats)
			{
				AddValue(new MaterialFloatEffect(@float.Key, @float.Value));
			}
		}

		public void Invoke(Renderer smr, GameObject prefab)
		{
			properties.ForEach(delegate(IMaterialEffect p)
			{
				Material[] sharedMaterials = smr.sharedMaterials;
				foreach (Material val in sharedMaterials)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						p.Apply(val);
					}
				}
			});
		}

		public void Invoke(Material m, GameObject prefab)
		{
			properties.ForEach(delegate(IMaterialEffect e)
			{
				if (Object.op_Implicit((Object)(object)m))
				{
					e.Apply(m);
				}
			});
		}

		public void AddValue<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] IMaterialEffect>(IMaterialEffect p)
		{
			if (p != null)
			{
				properties.Add((VisualsModifier.IMaterialEffect)(object)p);
			}
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class MaterialColorEffect : MaterialEffect<Color>, IMaterialEffect
	{
		public MaterialColorEffect(string name, Color value)
			: base(name, value)
		{
		}//IL_0002: Unknown result type (might be due to invalid IL or missing references)


		public void Apply(Material m)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			m.SetColor(Name, Value);
		}

		public void Apply(MaterialPropertyBlock m)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			m.SetColor(Name, Value);
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public abstract class MaterialEffect<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T>
	{
		protected string Name;

		protected T Value;

		public MaterialEffect(string name, T value)
		{
			Name = name;
			Value = value;
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class MaterialFloatEffect : MaterialEffect<float>, IMaterialEffect
	{
		public MaterialFloatEffect(string name, float value)
			: base(name, value)
		{
		}

		public void Apply(Material m)
		{
			m.SetFloat(Name, Value);
		}

		public void Apply(MaterialPropertyBlock m)
		{
			m.SetFloat(Name, Value);
		}
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(new byte[] { 0, 1 })]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class RealtimeLightEffect : RealtimeComponentEffect<Light>
	{
		private float RangeCache;

		private Color ColorCache = new Color(1f, 1f, 1f, 1f);

		private LightData Value;

		public RealtimeLightEffect(LightData data)
		{
			//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)
			Value = data;
		}

		public override void Apply(Transform t, float ratio)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00d5: 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)
			if (!Cached)
			{
				Component = RealtimeComponentEffect<Light>.GetNearestComponent<Light>(t);
				if ((Object)(object)Component != (Object)null)
				{
					RangeCache = Component.range;
					ColorCache = Component.color;
					Cached = true;
				}
			}
			if ((Object)(object)Component == (Object)null)
			{
				Debug.LogError((object)"Visuals Modifier: Unable to update light effect, component not found.");
				Cached = true;
				return;
			}
			((Behaviour)Component).enabled = ratio > 0f;
			if (Value.Range.HasValue)
			{
				Component.range = Mathf.Lerp(RangeCache, Value.Range.Value, ratio);
			}
			_ = Value.Color;
			Component.color = Color.Lerp(ColorCache, Value.Color, ratio);
		}
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(new byte[] { 0, 1 })]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class RealtimeParticleEffect : RealtimeComponentEffect<ParticleSystem>
	{
		private MainModule Cache;

		private LightData Value;

		private Transform Flare;

		private Renderer Renderer;

		private Vector3 ScaleCache = Vector3.one;

		public RealtimeParticleEffect(LightData data)
		{
			//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)
			Value = data;
		}

		public override void Apply(Transform t, float ratio)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			if (!Cached)
			{
				Flare = t.Find("flare");
				Component = RealtimeComponentEffect<ParticleSystem>.GetChildComponent<ParticleSystem>(t, "flare");
				Renderer = ((Component)Flare).GetComponent<Renderer>();
				if ((Object)(object)Component != (Object)null)
				{
					Cache = Component.main;
					ScaleCache = ((Component)Component).transform.localScale;
					Cached = true;
				}
			}
			if ((Object)(object)Component == (Object)null)
			{
				Debug.LogError((object)"Visuals Modifier: Unable to update particle effect, component not found.");
				Cached = true;
				return;
			}
			Renderer.enabled = ratio > 0f;
			if (Value.Range.HasValue)
			{
				((Component)Component).transform.localScale = Vector3.Lerp(ScaleCache, Value.Range.Value * ScaleCache, ratio);
			}
			((MainModule)(ref Cache)).startColor = MinMaxGradient.op_Implicit(Color.Lerp(Color.black, Value.Color, ratio));
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	internal class RendererManipulator : IManipulator
	{
		private List<IRendererEffect> effects = new List<IRendererEffect>();

		public RendererManipulator(ShaderData data)
		{
			if (data.MaterialInstances != null)
			{
				AddValue(new RendererMaterialsEffect(data.MaterialInstances));
			}
			else if ((Object)(object)data.MaterialInstance != (Object)null)
			{
				AddValue(new RendererMaterialEffect(data.MaterialInstance));
			}
			if (data.Name != null && data.Name != "")
			{
				AddValue(new RendererShaderEffect(data.Name));
			}
		}

		public void Invoke(Renderer smr, GameObject _prefab)
		{
			effects.ForEach(delegate(IRendererEffect e)
			{
				e.Apply(smr);
			});
		}

		public void Invoke(Material m, GameObject prefab)
		{
			throw new NotImplementedException();
		}

		public void AddValue<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] IRendererEffect>(IRendererEffect e)
		{
			if (e != null)
			{
				effects.Add((VisualsModifier.IRendererEffect)(object)e);
			}
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public interface IRendererEffect
	{
		void Apply(Renderer r);
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RendererMaterialEffect : IRendererEffect
	{
		public Material Value { get; set; }

		public RendererMaterialEffect(Material material)
		{
			Value = material;
		}

		public void Apply(Renderer r)
		{
			if (r.sharedMaterials.Length > 1)
			{
				Material[] sharedMaterials = r.sharedMaterials;
				for (int i = 0; i < sharedMaterials.Length; i++)
				{
					sharedMaterials[i] = Value;
				}
				r.sharedMaterials = sharedMaterials;
			}
			else
			{
				r.sharedMaterial = Value;
			}
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RendererMaterialsEffect : IRendererEffect
	{
		public Material[] Value { get; set; }

		public RendererMaterialsEffect(Material[] materials)
		{
			Value = materials;
		}

		public void Apply(Renderer r)
		{
			if (r.sharedMaterials.Length > 1)
			{
				r.sharedMaterials = Value;
			}
			else
			{
				r.sharedMaterial = Value[0];
			}
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RendererShaderEffect : IRendererEffect
	{
		public string Value { get; set; }

		private Shader Shader { get; set; }

		public RendererShaderEffect(string shader)
		{
			Value = shader;
			Shader = Shader.Find(shader);
		}

		public void Apply(Renderer r)
		{
			Material[] sharedMaterials = r.sharedMaterials;
			for (int i = 0; i < sharedMaterials.Length; i++)
			{
				sharedMaterials[i].shader = Shader;
			}
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class TextureManipulator : IManipulator
	{
		private List<ITextureEffect> effects = new List<ITextureEffect>();

		private Texture2D _texture;

		public TextureManipulator(TextureData data, Texture2D texture = null)
		{
			//IL_006a: 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)
			if (Object.op_Implicit((Object)(object)texture))
			{
				_texture = texture;
			}
			switch (data.Effect)
			{
			case TextureEffect.Multiply:
				AddValue(new TextureMultiplyEffect(data.Name, data.Colors[0]));
				break;
			case TextureEffect.Screen:
				AddValue(new TextureScreenEffect(data.Name, data.Colors[0]));
				break;
			case TextureEffect.Edge:
				AddValue(new TextureToonEffect(data.Name, data.Colors.ToArray()));
				break;
			case TextureEffect.Overlay:
				break;
			}
		}

		public void AddValue<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] ITextureEffect>(ITextureEffect value)
		{
			if (value != null)
			{
				effects.Add((VisualsModifier.ITextureEffect)(object)value);
			}
		}

		public void Invoke(Renderer smr, GameObject _prefab)
		{
			effects.ForEach(delegate(ITextureEffect e)
			{
				Material[] sharedMaterials = smr.sharedMaterials;
				foreach (Material m in sharedMaterials)
				{
					e.Apply(m, _texture);
				}
			});
		}

		public void Invoke(Material m, GameObject prefab)
		{
			effects.ForEach(delegate(ITextureEffect e)
			{
				e.Apply(m, _texture);
			});
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public interface ITextureEffect
	{
		void Apply(Material m, Texture2D t = null);

		void Apply(MaterialPropertyBlock m, Texture2D t = null);
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public abstract class TextureEffect<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T>
	{
		public T Value { get; set; }

		public string Name { get; set; }

		protected Texture2D Cache { get; set; }

		public TextureEffect(string name, T value)
		{
			Name = name;
			Value = value;
		}

		public Texture2D GetTexture(Material m)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)Cache))
			{
				Cache = (Texture2D)m.GetTexture(Name);
			}
			return Cache;
		}

		public Texture2D GetTexture(MaterialPropertyBlock m)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)Cache))
			{
				Cache = (Texture2D)m.GetTexture(Name);
			}
			return Cache;
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class TextureMultiplyEffect : TextureEffect<Color>, ITextureEffect
	{
		public TextureMultiplyEffect(string name, Color value)
			: base(name, value)
		{
		}//IL_0002: Unknown result type (might be due to invalid IL or missing references)


		public void Apply(Material m, Texture2D tex = null)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tex == (Object)null)
			{
				tex = GetTexture(m);
			}
			if ((Object)(object)tex != (Object)null && m.HasProperty(base.Name))
			{
				m.SetTexture(base.Name, (Texture)(object)Colour.AsMultiply(tex, base.Value));
			}
		}

		public void Apply(MaterialPropertyBlock m, Texture2D tex = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tex == (Object)null)
			{
				tex = GetTexture(m);
			}
			if ((Object)(object)tex != (Object)null)
			{
				m.SetTexture(base.Name, (Texture)(object)Colour.AsMultiply(tex, base.Value));
			}
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class TextureScreenEffect : TextureEffect<Color>, ITextureEffect
	{
		public TextureScreenEffect(string name, Color value)
			: base(name, value)
		{
		}//IL_0002: Unknown result type (might be due to invalid IL or missing references)


		public void Apply(Material m, Texture2D tex = null)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			_ = ((Object)m).name.Split(new string[1] { "(Clone)" }, StringSplitOptions.None)[0];
			if (!VisualController.ProcessedTextures.ContainsKey(((Object)m).name) && m.HasProperty(base.Name))
			{
				if ((Object)(object)tex == (Object)null)
				{
					tex = GetTexture(m);
				}
				if ((Object)(object)tex != (Object)null && m.HasProperty(base.Name))
				{
					m.SetTexture(base.Name, (Texture)(object)Colour.AsScreen(tex, base.Value));
				}
			}
		}

		public void Apply(MaterialPropertyBlock m, Texture2D tex = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tex == (Object)null)
			{
				tex = GetTexture(m);
			}
			if ((Object)(object)tex != (Object)null)
			{
				m.SetTexture(base.Name, (Texture)(object)Colour.AsScreen(tex, base.Value));
			}
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(new byte[] { 0, 1 })]
	public class TextureToonEffect : TextureEffect<Color[]>, ITextureEffect
	{
		public TextureToonEffect(string name, Color[] value)
			: base(name, value)
		{
		}

		public void Apply(Material m, Texture2D tex = null)
		{
			//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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tex == (Object)null)
			{
				tex = GetTexture(m);
			}
			if ((Object)(object)tex != (Object)null && base.Value.Length >= 3)
			{
				m.SetTexture(base.Name, (Texture)(object)Colour.AsCell(tex, Color32.op_Implicit(base.Value[0]), Color32.op_Implicit(base.Value[1]), Color32.op_Implicit(base.Value[2])));
			}
		}

		public void Apply(MaterialPropertyBlock m, Texture2D tex = null)
		{
			//IL_002a: 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_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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tex == (Object)null)
			{
				tex = GetTexture(m);
			}
			if ((Object)(object)tex != (Object)null)
			{
				m.SetTexture(base.Name, (Texture)(object)Colour.AsCell(tex, Color32.op_Implicit(base.Value[0]), Color32.op_Implicit(base.Value[1]), Color32.op_Implicit(base.Value[2])));
			}
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public static class MaterialManager
	{
		private static Dictionary<string, Material> _materials = new Dictionary<string, Material>();

		private static Dictionary<string, Material> _shared = new Dictionary<string, Material>();

		public static Material RegisterMaterial(string name, Material original)
		{
			if (_materials.ContainsKey(name))
			{
				return _materials[name];
			}
			Material val = Object.Instantiate<Material>(original);
			((Object)val).name = name;
			_materials[name] = val;
			return val;
		}

		public static void Clone(string name, Renderer[] renderers)
		{
			Dictionary<string, bool> dictionary = new Dictionary<string, bool>();
			foreach (Renderer val in renderers)
			{
				bool flag = false;
				if ((Object)(object)val == (Object)null || dictionary.ContainsKey(((Object)val).name))
				{
					continue;
				}
				dictionary[((Object)val).name] = true;
				if (val.sharedMaterials == null)
				{
					continue;
				}
				List<Material> list = new List<Material>();
				for (int j = 0; j < val.sharedMaterials.Length; j++)
				{
					Material val2 = val.sharedMaterials[j];
					if (!((Object)(object)val2 == (Object)null))
					{
						string text = name + ((((Object)val2).name != null) ? ((Object)val2).name : "Unknown");
						if (!_shared.ContainsKey(text) && !_shared.ContainsKey(((Object)val2).name))
						{
							Material val3 = Object.Instantiate<Material>(val2);
							((Object)val3).name = text;
							_shared[text] = val3;
							list.Add(val3);
							flag = true;
						}
						else if (_shared.ContainsKey(((Object)val2).name))
						{
							list.Add(_shared[((Object)val2).name]);
							flag = true;
						}
						else
						{
							list.Add(_shared[text]);
							flag = true;
						}
					}
				}
				if (flag)
				{
					val.sharedMaterials = list.ToArray();
				}
			}
		}

		public static void Clear()
		{
			foreach (Material value in _materials.Values)
			{
				Object.DestroyImmediate((Object)(object)value);
			}
			_materials.Clear();
		}

		public static Material Get(string name)
		{
			return _materials[name];
		}

		public static bool Contains(string name)
		{
			return _materials.ContainsKey(name);
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class BiomeEffector : MonoBehaviour, IRealtimeEffector
	{
		private const int UPDATE_INTERVAL = 1;

		private const int TRANSITION_DURATION = 1;

		private Renderer _renderer;

		private MaterialPropertyBlock _block;

		private List<IRealtimeEffect> _effects = new List<IRealtimeEffect>();

		private float _currentRatio;

		private RealtimeEffectData _effectContext;

		private void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			_block = new MaterialPropertyBlock();
			_renderer = ((Component)this).GetComponentInChildren<Renderer>();
			if ((Object)(object)_renderer == (Object)null)
			{
				Debug.LogError((object)"BiomeEffector: Failed to retrieve renderer");
			}
			VisualData visualByIndex = VisualController.GetVisualByIndex(_renderer.sharedMaterial.GetInt("_Item"));
			if (visualByIndex != null && visualByIndex.Effect != null)
			{
				ApplyContext(visualByIndex.Effect);
			}
		}

		private void Start()
		{
			_ = _effectContext;
		}

		private void Run()
		{
			ValheimTime.Get();
			_currentRatio = Mathf.MoveTowards(_currentRatio, GetRatio(), 1f * Time.deltaTime);
			_effects.ForEach(delegate(IRealtimeEffect e)
			{
				e.Apply(_block, _renderer.sharedMaterial, _effectContext, _currentRatio);
				e.Apply(((Component)this).transform, _currentRatio);
			});
			_renderer.SetPropertyBlock(_block);
		}

		private void LateUpdate()
		{
			if (_effectContext != null && Time.frameCount % 1 == 0)
			{
				Run();
			}
		}

		private float GetRatio()
		{
			//IL_0005: 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)
			if (EnvMan.instance.GetBiome() != _effectContext.Trigger.Biome)
			{
				return 0f;
			}
			return 1f;
		}

		public void ApplyContext(RealtimeEffectData data)
		{
			_effectContext = data;
			_effects = Effector.ApplyContext(data);
		}

		public void SetVisuals(int item)
		{
			Material[] sharedMaterials = ((Component)this).GetComponent<Renderer>().sharedMaterials;
			for (int i = 0; i < sharedMaterials.Length; i++)
			{
				sharedMaterials[i].SetInt("_Item", item);
			}
		}
	}
	internal class Effector
	{
		[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
		public static List<IRealtimeEffect> ApplyContext(RealtimeEffectData data)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			List<IRealtimeEffect> list = new List<IRealtimeEffect>();
			try
			{
				if (data.Material.Colors != null && data.Material.Colors.Count > 0)
				{
					foreach (KeyValuePair<string, Color> color in data.Material.Colors)
					{
						list.Add(new RealtimeColorEffect(color.Key, color.Value));
					}
				}
				if (data.Material.Floats != null && data.Material.Floats.Count > 0)
				{
					foreach (KeyValuePair<string, float> @float in data.Material.Floats)
					{
						list.Add(new RealtimeFloatEffect(@float.Key, @float.Value));
					}
				}
				if (data.Light != null)
				{
					list.Add(new RealtimeLightEffect(data.Light));
				}
				if (data.Particle != null)
				{
					list.Add(new RealtimeParticleEffect(data.Light));
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)ex.Message);
				Debug.LogError((object)ex.InnerException);
			}
			return list;
		}
	}
	internal interface IRealtimeEffector
	{
		void SetVisuals(int visuals);
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[RequireComponent(typeof(SphereCollider))]
	public class ProximityEffector : MonoBehaviour, IRealtimeEffector
	{
		private const int UPDATE_INTERVAL = 8;

		private const int CHARACTER_TRIGGER = 14;

		private const int CHARACTER = 9;

		private const int TRANSITION_DURATION = 1;

		private float _currentRatio;

		private Renderer _renderer;

		private MaterialPropertyBlock _block;

		private SphereCollider _sphere;

		private RealtimeEffectData _effectContext;

		private List<IRealtimeEffect> _effects = new List<IRealtimeEffect>();

		private Collider[] _hits = (Collider[])(object)new Collider[10];

		private Collider[] _targets = (Collider[])(object)new Collider[5];

		private bool _isClear = true;

		public void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			_renderer = ((Component)this).GetComponentInChildren<Renderer>();
			_sphere = ((Component)this).GetComponent<SphereCollider>();
			_block = new MaterialPropertyBlock();
			VisualData visualByIndex = VisualController.GetVisualByIndex(_renderer.sharedMaterial.GetInt("_Item"));
			if (visualByIndex != null && visualByIndex.Effect != null)
			{
				ApplyContext(visualByIndex.Effect);
				RealtimeEffectData effect = visualByIndex.Effect;
				if (effect.Trigger != null)
				{
					((Component)this).gameObject.layer = 14;
					((Collider)_sphere).isTrigger = true;
					_sphere.radius = effect.Trigger.Radius;
					((Collider)_sphere).enabled = true;
				}
			}
		}

		public void Start()
		{
			if (!((Collider)_sphere).enabled)
			{
				((Collider)_sphere).enabled = true;
			}
			UpdateTargets();
			Run();
		}

		private void Run()
		{
			ValheimTime.Get();
			_currentRatio = Mathf.MoveTowards(_currentRatio, GetRatio(), 8f * Time.deltaTime);
			_effects.ForEach(delegate(IRealtimeEffect e)
			{
				e.Apply(_block, _renderer.sharedMaterial, _effectContext, _currentRatio);
				e.Apply(((Component)this).transform, _currentRatio);
			});
			_renderer.SetPropertyBlock(_block);
		}

		public void LateUpdate()
		{
			if (_effectContext != null)
			{
				if (!_isClear && Time.frameCount % 8 == 0)
				{
					VerifyTargets();
				}
				if (Time.frameCount % 8 == 0)
				{
					Run();
				}
			}
		}

		private float GetRatio()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			float num = _sphere.radius;
			for (int i = 0; i < 5; i++)
			{
				if ((Object)(object)_targets[i] != (Object)null)
				{
					float num2 = Vector3.Distance(((Component)_targets[i]).transform.position, ((Component)this).transform.position);
					if (num2 < num)
					{
						num = num2;
					}
				}
			}
			return 1f - num / _sphere.radius;
		}

		public void OnTriggerEnter(Collider other)
		{
			if (_effectContext != null && _effectContext.Trigger != null && _effectContext.Trigger.Entities.Count > 0 && _effectContext.Trigger.Entities.Contains(((Object)other).name))
			{
				UpdateTargets();
			}
		}

		private void UpdateTargets()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, _sphere.radius, _hits, 512);
			int num2 = 0;
			for (int i = 0; i < num; i++)
			{
				if (_effectContext.Trigger.Entities.Contains(((Object)_hits[i]).name))
				{
					_targets[num2++] = _hits[i];
				}
			}
		}

		private void VerifyTargets()
		{
			bool isClear = true;
			for (int i = 0; i < 5; i++)
			{
				if ((Object)(object)_targets[i] != (Object)null)
				{
					isClear = false;
				}
			}
			_isClear = isClear;
			if (!_isClear)
			{
				UpdateTargets();
			}
		}

		public void SetVisuals(int item)
		{
			Material[] sharedMaterials = ((Component)this).GetComponent<Renderer>().sharedMaterials;
			for (int i = 0; i < sharedMaterials.Length; i++)
			{
				sharedMaterials[i].SetInt("_Item", item);
			}
		}

		public void ApplyContext(RealtimeEffectData data)
		{
			_effectContext = data;
			_effects = Effector.ApplyContext(data);
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class TimeEffector : MonoBehaviour, IRealtimeEffector
	{
		private const int UPDATE_INTERVAL = 15;

		private Renderer _renderer;

		private MaterialPropertyBlock _block;

		private List<IRealtimeEffect> _effects = new List<IRealtimeEffect>();

		public RealtimeEffectData _effectContext;

		private void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			_block = new MaterialPropertyBlock();
			_renderer = ((Component)this).GetComponentInChildren<Renderer>();
			if ((Object)(object)_renderer == (Object)null)
			{
				Debug.LogError((object)"TimeEffector: Failed to retrieve renderer");
			}
			VisualData visualByIndex = VisualController.GetVisualByIndex(_renderer.sharedMaterial.GetInt("_Item"));
			if (visualByIndex != null && visualByIndex.Effect != null)
			{
				ApplyContext(visualByIndex.Effect);
			}
		}

		private void Start()
		{
			if (_effectContext != null)
			{
				Run();
			}
		}

		private void LateUpdate()
		{
			if (_effectContext != null && Time.frameCount % 15 == 0)
			{
				Run();
			}
		}

		private void Run()
		{
			try
			{
				if ((Object)(object)_renderer == (Object)null)
				{
					Debug.LogError((object)"TimeEffector: Failed to retrieve renderer");
				}
				if ((Object)(object)_renderer.sharedMaterial == (Object)null)
				{
					Debug.LogError((object)"TimeEffector: No material in renderer");
				}
				ValheimTime a = ValheimTime.Get();
				if (_effectContext == null)
				{
					Debug.LogError((object)"TimeEffector: Bad context");
				}
				if (_effectContext.Trigger == null)
				{
					Debug.LogError((object)"TimeEffector: Bad Trigger");
				}
				if (_effectContext.Trigger.Time == null)
				{
					Debug.LogError((object)"TimeEffector: Bad Time");
				}
				if (_effectContext.Trigger.TimeSpan == null)
				{
					Debug.LogError((object)"TimeEffector: Bad Time Span");
				}
				float ratio = ValheimTime.RatioUntilTime(a, _effectContext.Trigger.Time, _effectContext.Trigger.TimeSpan);
				_effects.ForEach(delegate(IRealtimeEffect e)
				{
					e.Apply(_block, _renderer.sharedMaterial, _effectContext, ratio);
					e.Apply(((Component)this).transform, ratio);
				});
				_renderer.SetPropertyBlock(_block);
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.StackTrace);
			}
		}

		public void ApplyContext(RealtimeEffectData data)
		{
			_effectContext = data;
			_effects = Effector.ApplyContext(data);
		}

		public void SetVisuals(int item)
		{
			Material[] sharedMaterials = ((Component)this).GetComponent<Renderer>().sharedMaterials;
			for (int i = 0; i < sharedMaterials.Length; i++)
			{
				sharedMaterials[i].SetInt("_Item", item);
			}
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	[HarmonyPriority(0)]
	public static class Patch_ObjectDBInit
	{
		[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
		private static void Postfix(ObjectDB __instance)
		{
			VisualController.LoadVisuals();
			VisualController.Apply();
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public static class Console_Patch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__0_0;

			public static ConsoleEvent <>9__0_1;

			internal void <Postfix>b__0_0(ConsoleEventArgs args)
			{
				VisualController.Export(VisualController.Describe(args[1]));
			}

			internal void <Postfix>b__0_1(ConsoleEventArgs args)
			{
				VisualController.LoadVisuals();
				VisualController.Apply();
			}
		}

		private static void Postfix()
		{
			//IL_0032: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_006a: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate(ConsoleEventArgs args)
				{
					VisualController.Export(VisualController.Describe(args[1]));
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("vm_describe", "Export visual description information for an item", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj2 = <>c.<>9__0_1;
			if (obj2 == null)
			{
				ConsoleEvent val2 = delegate
				{
					VisualController.LoadVisuals();
					VisualController.Apply();
				};
				<>c.<>9__0_1 = val2;
				obj2 = (object)val2;
			}
			new ConsoleCommand("vm_refresh", "Refresh materials, textures, and other effects on items", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	internal static class SetItemData_Patch
	{
		private static Type t = Type.GetType("wackydatabase.SetData.SetData, WackysDatabase");

		private static FieldInfo fi = t.GetField("name", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);

		public static void Postfix(object data, ObjectDB Instant)
		{
			string text = (string)fi.GetValue(data);
			if (VisualController.GetVisualByName(text) != null)
			{
				VisualController.UpdateVisuals(text, Instant);
			}
		}
	}
	internal static class GetRecipeDataFromFiles_Patch
	{
		public static void Prefix()
		{
			VisualController.LoadVisuals();
		}
	}
	internal static class GetAllMaterials_Patch
	{
		public static void Postfix()
		{
			VisualController.LoadMaterials();
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[BepInPlugin("org.bepinex.visualsmodifier", "Visuals Modifier", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginID = "org.bepinex.visualsmodifier";

		public const string PluginName = "Visuals Modifier";

		public const string PluginVersion = "0.2.0";

		public static readonly string Storage = Path.Combine(Paths.ConfigPath, "Visuals");

		private static ConfigSync configSync = new ConfigSync("org.bepinex.visualsmodifier");

		public static CustomSyncedValue<Dictionary<string, string>> YamlData = new CustomSyncedValue<Dictionary<string, string>>(configSync, "Visual YAML", new Dictionary<string, string>());

		private FileSystemWatcher fileSystemWatcher;

		private Harmony _harmony;

		public Plugin()
		{
			if (!Directory.Exists(Storage))
			{
				Directory.CreateDirectory(Storage);
			}
			fileSystemWatcher = new FileSystemWatcher(Path.Combine(Paths.ConfigPath, "Visuals"), "Visual_*.yml");
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.Changed += OnVisualFileChanged;
			fileSystemWatcher.Created += OnVisualFileChanged;
			fileSystemWatcher.Renamed += OnVisualFileChanged;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		[UsedImplicitly]
		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			_harmony = new Harmony("org.bepinex.visualsmodifier");
			if (Type.GetType("wackydatabase, WackysDatabase") != null)
			{
				_harmony.Patch((MethodBase)AccessTools.DeclaredMethod(Type.GetType("wackydatabase.SetData.SetData, WackysDatabase"), "SetItemData", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SetItemData_Patch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)AccessTools.DeclaredMethod(Type.GetType("wackydatabase.Read.ReadFlies, WackysDatabase"), "GetRecipeDataFromFiles", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(GetRecipeDataFromFiles_Patch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_harmony.Patch((MethodBase)AccessTools.DeclaredMethod(Type.GetType("wackydatabase.Util.Functions, WackysDatabase"), "GetAllMaterials", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(GetAllMaterials_Patch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			_harmony.PatchAll();
			YamlData.AssignLocalValue(Reload());
			YamlData.ValueChanged += VisualSyncDetected;
		}

		private Dictionary<string, string> Reload()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			string[] files = Directory.GetFiles(Storage, "Visual_*.yml", SearchOption.AllDirectories);
			foreach (string text in files)
			{
				try
				{
					dictionary.Add(Path.GetFileName(text), File.ReadAllText(text));
				}
				catch (Exception)
				{
					Debug.LogError((object)("[$Visuals Modifier]: Failed to load visual data from " + text));
				}
			}
			VisualController.LoadVisuals(dictionary);
			return dictionary;
		}

		[UsedImplicitly]
		public void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}

		private void OnVisualFileChanged(object sender, FileSystemEventArgs args)
		{
			try
			{
				if (configSync.IsSourceOfTruth)
				{
					Debug.Log((object)("[Visuals Modifier]: Config file changed: " + args.Name + "."));
					VisualController.UpdateVisuals(VisualController.Import(args.FullPath).PrefabName, ObjectDB.instance);
					YamlData.Value = Reload();
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Detected config file change, but importing failed with an error.\n" + ex.Message + ((ex.InnerException != null) ? (": " + ex.InnerException.Message) : "")));
			}
		}

		private void VisualSyncDetected()
		{
			Debug.Log((object)"[$Visuals Modifier]: Config sync detected");
			VisualController.LoadVisuals(YamlData.Value);
			VisualController.Apply();
			if (!configSync.IsSourceOfTruth)
			{
				Save(YamlData.Value);
			}
		}

		public static void Save(Dictionary<string, string> visuals)
		{
			foreach (KeyValuePair<string, string> visual in visuals)
			{
				File.WriteAllText(Path.Combine(Storage, visual.Key), visual.Value);
			}
		}

		private ConfigEntry<T> config<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description);
			configSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting;
			return val;
		}

		private ConfigEntry<T> config<[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class ColorConverter : IYamlTypeConverter
	{
		public bool Accepts(Type type)
		{
			return type == typeof(Color);
		}

		public object ReadYaml(IParser parser, Type type)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			parser.Consume<SequenceStart>();
			List<float> list = new List<float>();
			SequenceEnd @event;
			while (!parser.TryConsume<SequenceEnd>(out @event))
			{
				string value = parser.Consume<YamlDotNet.Core.Events.Scalar>().Value;
				list.Add(float.Parse(value));
			}
			return (object)new Color((list.Count > 0) ? list[0] : 0f, (list.Count > 1) ? list[1] : 0f, (list.Count > 2) ? list[2] : 0f, (list.Count > 3) ? list[3] : 0f);
		}

		public void WriteYaml(IEmitter emitter, object value, Type type)
		{
			//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)
			emitter.Emit(new SequenceStart(null, null, isImplicit: false, SequenceStyle.Flow));
			Color val = (Color)value;
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(val.r.ToString()));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(val.g.ToString()));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(val.b.ToString()));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(val.a.ToString()));
			emitter.Emit(new SequenceEnd());
		}
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class DescriptorData
	{
		public string Name;

		public List<RendererDescriptor> Renderers = new List<RendererDescriptor>();
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class MaterialPropertyDescriptor
	{
		public string Name;

		public string Type;

		public string Value;

		public string Range;
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class MaterialDescriptor
	{
		public string Name;

		public string Shader;

		public List<MaterialPropertyDescriptor> MaterialProperties = new List<MaterialPropertyDescriptor>();
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class RendererDescriptor
	{
		public string Name;

		public List<MaterialDescriptor> Materials = new List<MaterialDescriptor>();
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class MaterialInstance
	{
		public string Name;

		public string Original;

		public MaterialData Changes;
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class MaterialProperties
	{
		public Dictionary<string, Color> Colors;

		public Dictionary<string, float> Floats;
	}
	[Serializable]
	public enum TextureEffect
	{
		Screen,
		Multiply,
		Overlay,
		Edge
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class TextureData
	{
		public string Name;

		public TextureEffect Effect;

		public List<Color> Colors;

		public TextureData()
		{
			Name = "";
			Effect = TextureEffect.Screen;
			Colors = new List<Color>();
		}
	}
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class ValheimTimeConverter : IYamlTypeConverter
	{
		public bool Accepts(Type type)
		{
			return type == typeof(ValheimTime);
		}

		public object ReadYaml(IParser parser, Type type)
		{
			parser.Consume<SequenceStart>();
			List<int> list = new List<int>();
			SequenceEnd @event;
			while (!parser.TryConsume<SequenceEnd>(out @event))
			{
				string value = parser.Consume<YamlDotNet.Core.Events.Scalar>().Value;
				list.Add(int.Parse(value));
			}
			return new ValheimTime((list.Count > 0) ? list[0] : 0, (list.Count > 1) ? list[1] : 0, (list.Count > 2) ? list[2] : 0, (list.Count > 3) ? list[3] : 0);
		}

		public void WriteYaml(IEmitter emitter, object value, Type type)
		{
			ValheimTime valheimTime = (ValheimTime)value;
			emitter.Emit(new SequenceStart(null, null, isImplicit: false, SequenceStyle.Flow));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(valheimTime.Hour.ToString()));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(valheimTime.Minute.ToString()));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(valheimTime.Second.ToString()));
			emitter.Emit(new YamlDotNet.Core.Events.Scalar(valheimTime.Day.ToString()));
			emitter.Emit(new SequenceEnd());
		}
	}
	[Serializable]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class VisualData
	{
		public string PrefabName;

		public bool Base;

		public ShaderData Shader;

		public MaterialData Material;

		public MaterialData[] Materials;

		public MaterialData Particle;

		public TextureData Texture;

		public LightData Light;

		public RealtimeEffectData Effect;

		public Vector3 Icon = Vector3.zero;
	}
	public class LightData
	{
		public Color Color;

		public float? Range;
	}
	public class ParticleData
	{
		public Color Color;

		public float? Range;
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class ShaderData
	{
		public string Material;

		public string[] Materials;

		public string Name;

		[YamlIgnore]
		public Material MaterialInstance;

		[YamlIgnore]
		public Material[] MaterialInstances;
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class MaterialData
	{
		public Dictionary<string, Color> Colors;

		public Dictionary<string, float> Floats;
	}
	[Serializable]
	public enum RealtimeEffectType
	{
		Proximity,
		Time,
		Biome
	}
	[Serializable]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public class RealtimeEffectTrigger
	{
		public ValheimTime Time;

		public ValheimTime TimeSpan;

		public List<string> Entities;

		public float Radius;

		public Biome Biome;
	}
	[Serializable]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class RealtimeEffectData
	{
		public RealtimeEffectType Type;

		public RealtimeEffectTrigger Trigger;

		public MaterialData Material;

		public LightData Light;

		public ParticleData Particle;
	}
	[Serializable]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	public class ValheimTime
	{
		private const int DAY_LENGTH = 86400;

		public int Hour { get; }

		public int Minute { get; }

		public int Second { get; }

		public int Day { get; }

		public ValheimTime(int hour = 0, int minute = 0, int second = 0, int day = -1)
		{
			Day = day;
			Hour = hour;
			Minute = minute;
			Second = second;
		}

		public string ToDataString()
		{
			return Hour + ":" + Minute + ":" + Second + " (" + Day + ")";
		}

		public int ToSeconds()
		{
			return (int)new TimeSpan(Hour, Minute, Second).TotalSeconds;
		}

		public static float RatioUntilTime(ValheimTime a, ValheimTime b, ValheimTime span)
		{
			if (Mathf.Abs(a.ToSeconds() - b.ToSeconds()) < span.ToSeconds())
			{
				float num = Mathf.Abs(a.ToSeconds() - b.ToSeconds());
				return 1f - num / (float)span.ToSeconds();
			}
			if (Mathf.Abs(a.ToSeconds() + 86400 - b.ToSeconds()) < span.ToSeconds())
			{
				float num2 = Mathf.Abs(a.ToSeconds() + 86400 - b.ToSeconds());
				return 1f - num2 / (float)span.ToSeconds();
			}
			if (Mathf.Abs(a.ToSeconds() - (b.ToSeconds() + 86400)) < span.ToSeconds())
			{
				float num3 = Mathf.Abs(a.ToSeconds() - (b.ToSeconds() + 86400));
				return 1f - num3 / (float)span.ToSeconds();
			}
			return 0f;
		}

		public static ValheimTime Get()
		{
			if (!Object.op_Implicit((Object)(object)EnvMan.instance))
			{
				return new ValheimTime(-1);
			}
			float smoothDayFraction = EnvMan.instance.m_smoothDayFraction;
			int currentDay = EnvMan.instance.GetCurrentDay();
			int num = (int)(smoothDayFraction * 24f);
			int num2 = (int)((smoothDayFraction * 24f - (float)num) * 60f);
			int second = (int)(((smoothDayFraction * 24f - (float)num) * 60f - (float)num2) * 60f);
			return new ValheimTime(num, num2, second, currentDay);
		}
	}
	[<3b64ce3b-0775-471d-a42b-da39acf52a2e>Nullable(0)]
	[<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(1)]
	public static class VisualController
	{
		public static Dictionary<string, int> _visualsByName;

		public static Dictionary<int, int> _visualsByHash;

		public static List<VisualData> _visuals;

		public static Dictionary<string, Texture2D> _initialTextures;

		public static Dictionary<string, Material> _initialMaterials;

		public static Dictionary<string, bool> ProcessedTextures;

		public static Dictionary<string, Material> Materials;

		private static ColorConverter cc;

		private static ValheimTimeConverter vtc;

		private static ISerializer _serializer;

		private static IDeserializer _deserializer;

		static VisualController()
		{
			_visualsByName = new Dictionary<string, int>();
			_visualsByHash = new Dictionary<int, int>();
			_visuals = new List<VisualData>();
			_initialTextures = new Dictionary<string, Texture2D>();
			_initialMaterials = new Dictionary<string, Material>();
			ProcessedTextures = new Dictionary<string, bool>();
			Materials = new Dictionary<string, Material>();
			cc = new ColorConverter();
			vtc = new ValheimTimeConverter();
			_serializer = new SerializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).WithTypeConverter(cc).WithTypeConverter(vtc)
				.Build();
			_deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).WithTypeConverter(cc).WithTypeConverter(vtc)
				.Build();
			DataManager.OnMaterialAdd += DataManager_OnMaterialAdd;
			DataManager.OnMaterialChange += DataManager_OnMaterialChange;
		}

		private static void DataManager_OnMaterialChange(object sender, MaterialEventArgs e)
		{
			new MaterialManipulator(e.MaterialInstance.Changes).Invoke(e.Material, null);
		}

		private static void DataManager_OnMaterialAdd(object sender, MaterialEventArgs e)
		{
			new MaterialManipulator(e.MaterialInstance.Changes).Invoke(e.Material, null);
		}

		public static void Reload(List<VisualData> visuals)
		{
			foreach (VisualData visual in visuals)
			{
				Add(visual.PrefabName, visual);
			}
		}

		public static void Add(string prefabName, VisualData data)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName);
			if (_visualsByName.ContainsKey(prefabName))
			{
				int visualIndex = GetVisualIndex(prefabName);
				_visuals[visualIndex] = data;
				_visualsByHash[stableHashCode] = visualIndex;
				_visualsByName[prefabName] = visualIndex;
			}
			else
			{
				_visuals.Add(data);
				_visualsByHash.Add(stableHashCode, _visuals.Count - 1);
				_visualsByName.Add(prefabName, _visuals.Count - 1);
			}
		}

		public static VisualData Import(string file)
		{
			try
			{
				VisualData visualData = _deserializer.Deserialize<VisualData>(File.ReadAllText(file));
				Add(visualData.PrefabName, visualData);
				return visualData;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Found Visuals Modifier config error in file " + file + ".\n" + ex.Message + ((ex.InnerException != null) ? (": " + ex.InnerException.Message) : "")));
				return null;
			}
		}

		public static void Export(VisualData visual)
		{
			string contents = _serializer.Serialize(visual);
			string text = Path.Combine(Paths.ConfigPath, "Visuals");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			File.WriteAllText(Path.Combine(text, "Visual_" + visual.PrefabName + ".yml"), contents);
		}

		public static void Export(DescriptorData data)
		{
			string contents = _serializer.Serialize(data);
			string text = Path.Combine(Paths.ConfigPath, "Visuals");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			File.WriteAllText(Path.Combine(text, "Describe_" + data.Name + ".yml"), contents);
		}

		public static DescriptorData Describe(string prefabName)
		{
			//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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Invalid comparison between Unknown and I4
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Invalid comparison between Unknown and I4
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Invalid comparison between Unknown and I4
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Invalid comparison between Unknown and I4
			//IL_0184: 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)
			DescriptorData descriptorData = new DescriptorData
			{
				Name = prefabName
			};
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
			if (!Object.op_Implicit((Object)(object)itemPrefab))
			{
				return descriptorData;
			}
			Transform val = itemPrefab.transform.Find("attach_skin") ?? itemPrefab.transform.Find("attach");
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = GetDropChild(itemPrefab);
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					RendererDescriptor rendererDescriptor = new RendererDescriptor
					{
						Name = ((Object)val).name
					};
					for (int j = 0; j < componentsInChildren[i].sharedMaterials.Length; j++)
					{
						Material val2 = componentsInChildren[i].sharedMaterials[j];
						MaterialDescriptor materialDescriptor = new MaterialDescriptor
						{
							Name = ((Object)componentsInChildren[i].sharedMaterials[j]).name,
							Shader = ((Object)val2.shader).name
						};
						int propertyCount = val2.shader.GetPropertyCount();
						for (int k = 0; k < propertyCount; k++)
						{
							ShaderPropertyType propertyType = val2.shader.GetPropertyType(k);
							string propertyName = val2.shader.GetPropertyName(k);
							MaterialPropertyDescriptor obj = new MaterialPropertyDescriptor
							{
								Name = propertyName,
								Type = ((object)(ShaderPropertyType)(ref propertyType)).ToString(),
								Range = (((int)propertyType == 3) ? $"{val2.shader.GetPropertyRangeLimits(k).x} to {val2.shader.GetPropertyRangeLimits(k).y}" : null)
							};
							object value;
							if ((int)propertyType != 0)
							{
								if ((int)propertyType != 3)
								{
									if ((int)propertyType != 2)
									{
										if ((int)propertyType != 1)
										{
											value = null;
										}
										else
										{
											Vector4 vector = val2.GetVector(propertyName);
											value = ((object)(Vector4)(ref vector)).ToString();
										}
									}
									else
									{
										value = val2.GetFloat(propertyName).ToString();
									}
								}
								else
								{
									value = val2.GetFloat(propertyName).ToString();
								}
							}
							else
							{
								Color color = val2.GetColor(propertyName);
								value = ((object)(Color)(ref color)).ToString();
							}
							obj.Value = (string)value;
							MaterialPropertyDescriptor item = obj;
							materialDescriptor.MaterialProperties.Add(item);
						}
						rendererDescriptor.Materials.Add(materialDescriptor);
					}
					descriptorData.Renderers.Add(rendererDescriptor);
				}
			}
			else
			{
				Debug.LogError((object)("[Visuals Modifier]: Unable to find base Renderer for " + prefabName));
			}
			return descriptorData;
		}

		public static bool TryUpdateTexture(VisualData data, string prefabName, GameObject armor)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			if (data.Texture == null)
			{
				return false;
			}
			ItemDrop component = armor.GetComponent<ItemDrop>();
			Material val = (Object.op_Implicit((Object)(object)component) ? component.m_itemData.m_shared.m_armorMaterial : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			try
			{
				string key = ((Object)val).name.Split(new string[1] { "(Clone)" }, StringSplitOptions.None)[0];
				if (!_initialMaterials.ContainsKey(key))
				{
					_initialMaterials.Add(key, Object.Instantiate<Material>(val));
				}
				val = _initialMaterials[key];
				if (!_initialTextures.ContainsKey(key))
				{
					_initialTextures.Add(key, Colour.CloneTexture((Texture2D)val.GetTexture(data.Texture.Name)));
				}
				new TextureManipulator(data.Texture, _initialTextures[key]).Invoke(val, armor);
				component.m_itemData.m_shared.m_armorMaterial = val;
				ProcessedTextures.Add(key, value: true);
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		public static Transform GetDropChild(GameObject item)
		{
			for (int i = 0; i < item.transform.childCount; i++)
			{
				Transform child = item.transform.GetChild(i);
				if (!((Object)child).name.Contains("attach"))
				{
					return child;
				}
			}
			return null;
		}

		public static void UpdateVisuals(string prefabName, ObjectDB instance)
		{
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			VisualData visualByName = GetVisualByName(prefabName);
			GameObject item = instance.GetItemPrefab(prefabName);
			if ((Object)(object)item == (Object)null)
			{
				return;
			}
			try
			{
				Transform val = item.transform.Find("attach_skin");
				Transform val2 = item.transform.Find("attach");
				Transform dropChild = GetDropChild(item);
				List<Renderer> renderers = new List<Renderer>();
				Renderer[] array = (Renderer[])(object)(((Object)(object)val != (Object)null) ? ((Component)val).GetComponentsInChildren<SkinnedMeshRenderer>(true) : null);
				Renderer[] array2 = array;
				array = (Renderer[])(object)(((Object)(object)dropChild != (Object)null) ? ((Component)dropChild).GetComponentsInChildren<MeshRenderer>(true) : null);
				Renderer[] array3 = array;
				array = (Renderer[])(object)(((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentsInChildren<MeshRenderer>(true) : null);
				Renderer[] array4 = array;
				if (array2 != null)
				{
					renderers.AddRange(array2);
				}
				if (array3 != null)
				{
					renderers.AddRange(array3);
				}
				if (array4 != null)
				{
					renderers.AddRange(array4);
				}
				List<IManipulator> rendererChanges = GetRendererChanges(prefabName);
				foreach (Renderer renderer in renderers)
				{
					if (!(((object)renderer).GetType() == typeof(ParticleSystemRenderer)))
					{
						rendererChanges.ForEach(delegate(IManipulator change)
						{
							change.Invoke(renderer, item);
						});
					}
				}
				if (array2 != null)
				{
					MaterialManager.Clone("skn_" + prefabName, array2);
				}
				if (array4 != null)
				{
					MaterialManager.Clone("msh_" + prefabName, array4);
				}
				if (array3 != null)
				{
					MaterialManager.Clone("drp_" + prefabName, array3);
				}
				List<IManipulator> manipulations = GetManipulations(prefabName);
				List<IManipulator> particleChanges = GetParticleChanges(prefabName);
				TryUpdateTexture(visualByName, prefabName, item);
				Transform val3 = val2 ?? val;
				if ((Object)(object)val3 == (Object)null)
				{
					val3 = dropChild;
				}
				if (val3.childCount > 0)
				{
					val3 = val3.GetChild(0);
				}
				if ((Object)(object)val3 != (Object)null)
				{
					UpdateComponents(visualByName, val3);
				}
				int i;
				for (i = 0; i < renderers.Count; i++)
				{
					if (((object)renderers[i]).GetType() == typeof(ParticleSystemRenderer))
					{
						particleChanges.ForEach(delegate(IManipulator change)
						{
							change.Invoke(renderers[i], item);
						});
					}
					else
					{
						manipulations.ForEach(delegate(IManipulator change)
						{
							change.Invoke(renderers[i], item);
						});
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[Visuals Modifier]: Failed to update material - " + ex.Message));
			}
			ItemDrop component = item.GetComponent<ItemDrop>();
			if (Object.op_Implicit((Object)(object)component))
			{
				_ = visualByName.Icon;
				UpdateIcon(component, visualByName.Icon);
			}
		}

		private static Transform AddFlare(Transform t)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = Object.Instantiate<Transform>(ObjectDB.instance.GetItemPrefab("BattleaxeCrystal").transform.Find("attach").Find("flare"), t, false);
			((Object)obj).name = "flare";
			obj.localPosition = Vector3.zero;
			return obj;
		}

		private static void UpdateComponents(VisualData data, Transform t)
		{
			//IL_0033: 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)
			if (data.Light != null)
			{
				Light val = ((Component)t).GetComponent<Light>();
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)t).gameObject.AddComponent<Light>();
				}
				if ((Object)(object)val != (Object)null)
				{
					_ = data.Light.Color;
					val.color = data.Light.Color;
					if (data.Light.Range.HasValue)
					{
						val.range = data.Light.Range.Value;
					}
				}
			}
			if (data.Particle != null)
			{
				AddFlare(t);
			}
		}

		public static void UpdateIcon(ItemDrop item, Vector3 r)
		{
			//IL_0018: 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_006e: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_01b5: 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_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			Camera component = new GameObject("Camera", new Type[1] { typeof(Camera) }).GetComponent<Camera>();
			component.backgroundColor = Color.clear;
			component.clearFlags = (CameraClearFlags)2;
			component.fieldOfView = 0.5f;
			component.farClipPlane = 10000000f;
			component.cullingMask = 1073741824;
			Light component2 = new GameObject("Light", new Type[1] { typeof(Light) }).GetComponent<Light>();
			((Component)component2).transform.rotation = Quaternion.Euler(60f, -5f, 0f);
			component2.type = (LightType)1;
			component2.cullingMask = 1073741824;
			component2.intensity = 0.7f;
			try
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, 0f, 64f, 64f);
				Quaternion val2 = Quaternion.Euler(r.x, r.y, r.z);
				Transform val3 = ((Component)item).transform.Find("attach");
				if (!Object.op_Implicit((Object)(object)val3))
				{
					val3 = GetDropChild(((Component)item).gameObject);
				}
				GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, Vector3.zero, val2);
				Transform[] componentsInChildren = val4.GetComponentsInChildren<Transform>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Component)componentsInChildren[i]).gameObject.layer = 30;
				}
				Renderer[] componentsInChildren2 = val4.GetComponentsInChildren<Renderer>(true);
				Vector3 val5 = componentsInChildren2.Aggregate<Renderer, Vector3>(Vector3.positiveInfinity, [<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(0)] (Vector3 cur, Renderer renderer) =>
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_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)
					if (!(renderer is ParticleSystemRenderer))
					{
						Bounds bounds2 = renderer.bounds;
						return Vector3.Min(cur, ((Bounds)(ref bounds2)).min);
					}
					return cur;
				});
				Vector3 val6 = componentsInChildren2.Aggregate<Renderer, Vector3>(Vector3.negativeInfinity, [<7e95fbe5-0192-49cc-9c04-eabf3a488096>NullableContext(0)] (Vector3 cur, Renderer renderer) =>
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_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)
					if (!(renderer is ParticleSystemRenderer))
					{
						Bounds bounds = renderer.bounds;
						return Vector3.Max(cur, ((Bounds)(ref bounds)).max);
					}
					return cur;
				});
				Vector3 val7 = val6 - val5;
				component.targetTexture = RenderTexture.GetTemporary((int)((Rect)(ref val)).width, (int)((Rect)(ref val)).height);
				float num = Mathf.Max(val7.x, val7.y) * 1.05f / Mathf.Tan(component.fieldOfView * ((float)Math.PI / 180f));
				Transform transform = ((Component)component).transform;
				transform.position = (val5 + val6) / 2f + new Vector3(0f, 0f, 0f - num);
				((Component)component2).transform.position = transform.position + new Vector3(-2f, 0.2f) / 3f * num;
				component.Render();
				RenderTexture active = RenderTexture.active;
				RenderTexture.active = component.targetTexture;
				Texture2D val8 = new Texture2D((int)((Rect)(ref val)).width, (int)((Rect)(ref val)).height, (TextureFormat)4, false);
				val8.ReadPixels(val, 0, 0);
				val8.Apply();
				RenderTexture.active = active;
				item.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val8, val, new Vector2(0.5f, 0.5f)) };
				Object.DestroyImmediate((Object)(object)val4);
				component.targetTexture.Release();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[Visuals Modifier]: Failed to update icon - " + ex.Message));
			}
			finally
			{
				Object.Destroy((Object)(object)component);
				Object.Destroy((Object)(object)component2);
			}
		}

		public static int GetVisualIndex(string name)
		{
			return _visualsByName[name];
		}

		public static int GetVisualIndex(int hash)
		{
			return _visualsByHash[hash];
		}

		public static VisualData GetVisualByIndex(int index)
		{
			return _visuals[index];
		}

		public static VisualData GetVisualByName(string name)
		{
			if (_visualsByName.ContainsKey(name))
			{
				return _visuals[_visualsByName[name]];
			}
			return null;
		}

		public static VisualData GetVisualByHash(int hash)
		{
			if (_visualsByHash.ContainsKey(hash))
			{
				return _visuals[_visualsByHash[hash]];
			}
			return null;
		}

		public static void LoadVisuals()
		{
			ProcessedTextures.Clear();
			string[] files = Directory.GetFiles(Path.Combine(Paths.ConfigPath, "Visuals"), "Visual_*.yml", SearchOption.AllDirectories);
			foreach (string text in files)
			{
				try
				{
					Import(text);
				}
				catch (Exception)
				{
					Debug.LogError((object)("[Visuals Modifier]: Failed to load visual data from " + text));
				}
			}
		}

		public static VisualData LoadYaml(string yaml)
		{
			try
			{
				VisualData visualData = _deserializer.Deserialize<VisualData>(yaml);
				Add(visualData.PrefabName, visualData);
				return visualData;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Found Visuals Modifier config error in yaml.\n" + ex.Message + ((ex.InnerException != null) ? (": " + ex.InnerException.Message) : "")));
				return null;
			}
		}

		public static void LoadVisuals(Dictionary<string, string> data)
		{
			ProcessedTextures.Clear();
			foreach (KeyValuePair<string, string> datum in data)
			{
				LoadYaml(datum.Value);
			}
		}

		public static void LoadMaterials()
		{
			DataManager.LoadMaterials(Path.Combine(Paths.ConfigPath, "Materials"));
		}

		public static void LoadFromYaml(string yaml)
		{
			VisualData[] array = _deserializer.Deserialize<VisualData[]>(yaml);
			foreach (VisualData visualData in array)
			{
				Add(visualData.PrefabName, visualData);
			}
		}

		public static void Apply()
		{
			ObjectDB instance = ObjectDB.instance;
			_visuals.ForEach(delegate(VisualData action)
			{
				UpdateVisuals(action.PrefabName, instance);
			});
		}

		public static List<IManipulator> GetRendererChanges(string prefab)
		{
			List<IManipulator> list = new List<IManipulator>();
			VisualData visualByName = GetVisualByName(prefab);
			if (visualByName != null && visualByName.Shader != null)
			{
				if (visualByName.Shader.Material != null && visualByName.Shader.Material != "" && Materials.ContainsKey(visualByName.Shader.Material))
				{
					visualByName.Shader.MaterialInstance = Materials[visualByName.Shader.Material];
				}
				if (visualByName.Shader.Materials != null && visualByName.Shader.Materials.Length != 0)
				{
					visualByName.Shader.MaterialInstances = (Material[])(object)new Material[visualByName.Shader.Materials.Leng