Decompiled source of VanillaMagic v0.1.2

plugins/VanillaMagic.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using VanilaMagic.DungeonRooms;
using VanilaMagic.Items;
using VanilaMagic.StatusEffects;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VanilaMagic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VanilaMagic")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.1.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
namespace VanilaMagic
{
	internal static class ModConfig
	{
		public static ConfigEntry<float> FenringHairChance;

		public static ConfigEntry<int> FenringHairAmount;

		public static ConfigEntry<float> GhostEctoplasmChance;

		public static ConfigEntry<int> GhostEctoplasmAmount;

		public static event Action DropsChanged;

		public static void Bind(ConfigFile config)
		{
			FenringHairChance = BindChance(config, "Drops", "FenringHairChance", 25f, "Chance (%) that a Fenring drops Wolf Hair Bundle.");
			FenringHairAmount = BindAmount(config, "Drops", "FenringHairAmount", 1, "How many Wolf Hair Bundles a Fenring drops.");
			GhostEctoplasmChance = BindChance(config, "Drops", "GhostEctoplasmChance", 10f, "Chance (%) that a Ghost drops Ectoplasm (vanilla: 100).");
			GhostEctoplasmAmount = BindAmount(config, "Drops", "GhostEctoplasmAmount", 1, "How much Ectoplasm a Ghost drops (vanilla: 1-5).");
		}

		private static ConfigEntry<float> BindChance(ConfigFile config, string section, string key, float value, string description)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			ConfigEntry<float> obj = config.Bind<float>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1] { AdminOnly() }));
			obj.SettingChanged += delegate
			{
				ModConfig.DropsChanged?.Invoke();
			};
			return obj;
		}

		private static ConfigEntry<int> BindAmount(ConfigFile config, string section, string key, int value, string description)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			ConfigEntry<int> obj = config.Bind<int>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), new object[1] { AdminOnly() }));
			obj.SettingChanged += delegate
			{
				ModConfig.DropsChanged?.Invoke();
			};
			return obj;
		}

		private static ConfigurationManagerAttributes AdminOnly()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			return new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
		}
	}
	[BepInPlugin("com.barnabur.vanillamagic", "VanillaMagic", "0.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class VanilaMagic : BaseUnityPlugin
	{
		public const string PluginGUID = "com.barnabur.vanillamagic";

		public const string PluginName = "VanillaMagic";

		public const string PluginVersion = "0.1.2";

		private GameObject BlueMushroomPrefab;

		private CustomLocalization Localization;

		private const string LegacyPluginGUID = "com.barnabur.vanilamagic";

		private void AddLocalizations()
		{
			Localization = LocalizationManager.Instance.GetLocalization();
			CustomLocalization localization = Localization;
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_wandfireball", "Flame Wand" },
				{ "item_staffheal", "Healing Staff" },
				{ "item_wandfireball_description", "A bronze wand crowned with a surtling core that never stops smouldering. Spits a stream of embers that burst into flame on impact." },
				{ "item_wandfrost", "Frost Wand" },
				{ "item_wandfrost_description", "A crystal-tipped wand that hurls a bolt of biting cold. Bursts on impact." },
				{ "item_wandstone", "Stone Wand" },
				{ "item_wandstone_description", "A black metal claw gripping a shard of obsidian. Hurls a heavy rock that shatters on impact and knocks foes back." },
				{ "item_staffheal_description", "Withered bone and ancient seeds bound together with ectoplasm. The greydwarves' stolen life seeps from it, mending the wounds of everyone who stands close." },
				{ "se_heal", "Healing" },
				{ "se_heal_desc", "Health per second:\n<color=#ff8000>{0}</color> <color=#ffff00>({1})</color>\nDuration: <color=#ff8000>{2}s</color>" },
				{ "item_bluemushroom", "Blue Mushroom" },
				{ "item_bluemushroom_description", "A strange mushroom pulsing with magical energy." },
				{ "item_mushroomsoup", "Mushroom Soup" },
				{ "item_mushroomsoup_description", "Red, yellow and blue simmered together in one pot. Earthy, filling, and faintly glowing." },
				{ "item_wildberries", "Wildberries" },
				{ "item_wildberries_description", "Glowing purple berries. Sweet, and humming with eitr." },
				{ "item_ghostshake", "Ghostshake" },
				{ "item_ghostshake_description", "Wildberries churned with ectoplasm until the whole thing glows. Cold all the way down, and the mist it leaves behind tastes of magic." },
				{ "item_crystalsugar", "Crystal Sugar" },
				{ "item_crystalsugar_description", "Mountain crystal run through the millstones until it is fine as frost. It never melts, and it never quite stops glittering." },
				{ "item_eyescreamsprinkles", "Eyescream with Sprinkles" },
				{ "item_eyescreamsprinkles_description", "Frozen greydwarf eyes under a scatter of crystal sugar. The sprinkles crackle with eitr on the way down." },
				{ "item_sweetbread", "Sweetbread" },
				{ "item_sweetbread_description", "An unbaked sweetbread taken out of the oven plain, with no frosting on it. Sweet enough on its own." },
				{ "item_frostedsweetbread_uncooked", "Unbaked Frosted Sweetbread" },
				{ "item_frostedsweetbread_uncooked_description", "Sweetbread dough rolled in crystal sugar. The frosting sets in the oven." },
				{ "item_wraithhood", "Wraith Hood" },
				{ "item_wraithhood_description", "A hood torn from a wraith's shroud, held together with chain. The cold never quite leaves it." },
				{ "item_wraithrobe", "Wraith Robe" },
				{ "item_wraithrobe_description", "Tattered robes bound in wraith-chain. Light as mist, and it hums with eitr." },
				{ "item_wraithlegs", "Wraith Leggings" },
				{ "item_wraithlegs_description", "Leggings stitched from shroud and chain. They do not slow the wearer." },
				{ "item_wraithcape", "Wraith Cape" },
				{ "item_wraithcape_description", "A shroud-cape trailing chains. Keeps the mountain cold at bay." },
				{ "se_wraithset", "Wraith's Shroud" },
				{ "se_wraithset_tooltip", "Bound in the wraith's chains, the dead lend you their craft." }
			});
			CustomLocalization localization2 = Localization;
			text = "Polish";
			localization2.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_wandfireball", "Różdżka żaru" },
				{ "item_staffheal", "Kostur leczenia" },
				{ "item_wandfireball_description", "Brązowa różdżka zwieńczona rdzeniem pomiotu Surtra, który nigdy nie przestaje się tlić. Pluje strumieniem żaru, który przy uderzeniu wybucha płomieniem." },
				{ "item_wandfrost", "Różdżka mrozu" },
				{ "item_wandfrost_description", "Różdżka zakończona kryształem, która ciska pocisk przeszywającego zimna. Rozpryskuje się przy uderzeniu." },
				{ "item_wandstone", "Różdżka kamienia" },
				{ "item_wandstone_description", "Szpon z czarnego metalu ściskający odłamek obsydianu. Ciska ciężkim kamieniem, który roztrzaskuje się przy uderzeniu i odrzuca wrogów." },
				{ "item_staffheal_description", "Wysuszone kości i starożytne nasiona spojone ektoplazmą. Skradzione Szarłom życie sączy się z niego, zasklepiając rany każdego, kto stoi w pobliżu." },
				{ "se_heal", "Leczenie" },
				{ "se_heal_desc", "Zdrowie na sekundę:\n<color=#ff8000>{0}</color> <color=#ffff00>({1})</color>\nCzas trwania: <color=#ff8000>{2}s</color>" },
				{ "item_bluemushroom", "Niebieski grzyb" },
				{ "item_bluemushroom_description", "Dziwny grzyb pulsujący magiczną energią." },
				{ "item_mushroomsoup", "Zupa grzybowa" },
				{ "item_mushroomsoup_description", "Czerwony, żółty i niebieski grzyb duszone razem w jednym garnku. Sycąca, pachnie lasem i lekko świeci." },
				{ "item_wildberries", "Dzikie jagody" },
				{ "item_wildberries_description", "Świecące fioletowe jagody. Słodkie i brzęczące od eitru." },
				{ "item_ghostshake", "Upiorny koktajl" },
				{ "item_ghostshake_description", "Dzikie jagody ubite z ektoplazmą, aż całość zaczyna świecić. Zimny do samego dna, a mgiełka, którą zostawia, smakuje magią." },
				{ "item_crystalsugar", "Kryształowy cukier" },
				{ "item_crystalsugar_description", "Górski kryształ zmielony w żarnach na proch drobny jak szron. Nigdy się nie topi i nigdy do końca nie przestaje lśnić." },
				{ "item_eyescreamsprinkles", "Lody z oczu z posypką" },
				{ "item_eyescreamsprinkles_description", "Zamrożone oczy Szarłów pod warstwą kryształowego cukru. Posypka trzaska od eitru przy przełykaniu." },
				{ "item_sweetbread", "Słodka bułka" },
				{ "item_sweetbread_description", "Słodka bułka wyjęta z pieca bez lukru. Wystarczająco słodka sama w sobie." },
				{ "item_frostedsweetbread_uncooked", "Nieupieczona lukrowana słodka bułka" },
				{ "item_frostedsweetbread_uncooked_description", "Ciasto na słodką bułkę obtoczone w kryształowym cukrze. Lukier zastyga w piecu." },
				{ "item_wraithhood", "Kaptur upiora" },
				{ "item_wraithhood_description", "Kaptur wydarty z całunu upiora, spięty łańcuchem. Chłód nigdy go do końca nie opuszcza." },
				{ "item_wraithrobe", "Szata upiora" },
				{ "item_wraithrobe_description", "Postrzępione szaty spięte upiornym łańcuchem. Lekkie jak mgła i brzęczące od eitru." },
				{ "item_wraithlegs", "Nogawice upiora" },
				{ "item_wraithlegs_description", "Nogawice zszyte z całunu i łańcucha. Nie spowalniają noszącego." },
				{ "item_wraithcape", "Peleryna upiora" },
				{ "item_wraithcape_description", "Całunowa peleryna ciągnąca za sobą łańcuchy. Chroni przed górskim chłodem." },
				{ "se_wraithset", "Całun upiora" },
				{ "se_wraithset_tooltip", "Spętany łańcuchami upiora – umarli użyczają ci swojego kunsztu." }
			});
		}

		private void DisableLegacyPlugin()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.barnabur.vanilamagic", out var value))
			{
				return;
			}
			string location = value.Location;
			try
			{
				File.Move(location, location + ".old");
				Logger.LogError((object)(string.Format("Old VanilaMagic {0} found next to VanillaMagic {1}: ", value.Metadata.Version, "0.1.2") + "renamed " + location + " to .old. Restart the game/server - both copies are loaded in this session."));
			}
			catch (Exception ex)
			{
				Logger.LogError((object)(string.Format("Old VanilaMagic {0} found next to VanillaMagic {1}. ", value.Metadata.Version, "0.1.2") + "Delete " + location + " and restart (" + ex.Message + ")."));
			}
		}

		private void Awake()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo((object)"VanillaMagic has landed");
			DisableLegacyPlugin();
			AddLocalizations();
			ModConfig.Bind(((BaseUnityPlugin)this).Config);
			SurtlingWand.Register();
			FrostWand.Register();
			StoneWand.Register();
			WildBerry.Register();
			GhostShake.Register();
			EctoplasmDrops.Register();
			FenringHairDrop.Register();
			CrystalSugar.Register();
			SugarFoods.Register();
			HealingStaff.Register();
			WraithArmor.Register();
			MushroomSoup.Register();
			new Harmony("com.barnabur.vanillamagic").PatchAll(typeof(VanilaMagic).Assembly);
			PrefabManager.OnVanillaPrefabsAvailable += SetupBlueMushroom;
			ServingTray.Register();
			DungeonManager.OnVanillaRoomsAvailable += delegate
			{
				MushroomCaveRooms.AddMushroomRooms(BlueMushroomPrefab);
			};
		}

		private void SetupBlueMushroom()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = PrefabManager.Instance.GetPrefab("MushroomBlue");
			BlueMushroomPrefab = PrefabManager.Instance.GetPrefab("Pickable_Mushroom_blue");
			if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)BlueMushroomPrefab))
			{
				Logger.LogWarning((object)"Nie znaleziono waniliowych prefabów niebieskiego grzybka (MushroomBlue / Pickable_Mushroom_blue)");
				return;
			}
			SharedData shared = prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_itemType = (ItemType)2;
			shared.m_name = "$item_bluemushroom";
			shared.m_description = "$item_bluemushroom_description";
			shared.m_food = 15f;
			shared.m_foodStamina = 10f;
			shared.m_foodEitr = 25f;
			shared.m_foodRegen = 1f;
			shared.m_foodBurnTime = 1200f;
			BlueMushroomPrefab.GetComponent<Pickable>().m_itemPrefab = prefab;
		}
	}
}
namespace VanilaMagic.StatusEffects
{
	public class Heal_SE : SE_Stats
	{
		private static readonly float[] DurationPerLevel = new float[4] { 12f, 15f, 20f, 25f };

		private float _baseHealPerTick = 1f;

		public override void SetLevel(int itemLevel, float skillLevel)
		{
			_baseHealPerTick = 1f + (float)itemLevel / 2f;
			base.m_healthPerTick = _baseHealPerTick + skillLevel / 20f;
			((StatusEffect)this).m_ttl = DurationPerLevel[Mathf.Clamp(itemLevel, 1, DurationPerLevel.Length) - 1];
		}

		public override string GetTooltipString()
		{
			return string.Format(Localization.instance.Localize("$se_heal_desc"), _baseHealPerTick.ToString("0.#"), base.m_healthPerTick.ToString("0.#"), ((StatusEffect)this).m_ttl.ToString("0"));
		}
	}
}
namespace VanilaMagic.Items
{
	[HarmonyPatch]
	internal static class BurstDurability
	{
		private static readonly Dictionary<string, float> Items = new Dictionary<string, float>();

		public static void Register(string sharedName, float firstShotDelay)
		{
			Items[sharedName] = firstShotDelay;
		}

		private static bool IsTracked(Attack attack, out float firstShotDelay)
		{
			firstShotDelay = 0f;
			ItemData weapon = attack.m_weapon;
			if (weapon != null && attack.m_projectileBursts > 1)
			{
				return Items.TryGetValue(weapon.m_shared.m_name, out firstShotDelay);
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Attack), "ProjectileAttackTriggered")]
		private static void DelayFirstShot(Attack __instance)
		{
			if (IsTracked(__instance, out var firstShotDelay))
			{
				__instance.m_projectileFireTimer = firstShotDelay;
				ItemData weapon = __instance.m_weapon;
				if (weapon.m_shared.m_useDurability && ((Character)__instance.m_character).IsPlayer())
				{
					weapon.m_durability += weapon.m_shared.m_useDurabilityDrain * Game.m_durabilityRate;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Attack), "FireProjectileBurst")]
		private static void DrainPerShot(Attack __instance)
		{
			if (IsTracked(__instance, out var _))
			{
				ItemData weapon = __instance.m_weapon;
				if (weapon.m_shared.m_useDurability && ((Character)__instance.m_character).IsPlayer())
				{
					weapon.m_durability -= weapon.m_shared.m_useDurabilityDrain * Game.m_durabilityRate;
				}
			}
		}
	}
	public class ClothChain : MonoBehaviour
	{
		public string m_rendererName = "cape2";

		public float m_sideX = -0.12f;

		public float m_topDrop = 0.12f;

		public float m_backZ = -0.04f;

		public float m_spacing = 0.15f;

		public float m_surfaceOffset = 0.04f;

		public float m_cuffRadius = 0.031f;

		public float m_radialScale = 0.32f;

		public float m_meshLengthY = 0.96f;

		public float m_meshTopY = 0.49f;

		private Transform[] _segments;

		private Transform _cuff;

		private Transform _character;

		private SkinnedMeshRenderer _renderer;

		private Mesh _baked;

		private Vector3[] _worldNormals;

		private int[] _indices;

		private float _retryAt;

		private string _lastFail;

		private void Start()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			List<Transform> list = new List<Transform>();
			foreach (Transform item in ((Component)this).transform)
			{
				Transform val = item;
				if (((Object)val).name == "cuff")
				{
					_cuff = val;
				}
				else
				{
					list.Add(val);
				}
			}
			_segments = list.ToArray();
			Character componentInParent = ((Component)this).GetComponentInParent<Character>();
			_character = (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).transform : ((Component)this).transform.root);
			_baked = new Mesh
			{
				name = "clothchain_bake"
			};
			SetVisible(visible: false);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_baked))
			{
				Object.Destroy((Object)(object)_baked);
			}
		}

		private void LateUpdate()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_renderer) || _indices == null)
			{
				if (Time.time < _retryAt)
				{
					return;
				}
				_retryAt = Time.time + 0.5f;
				if (!Bind())
				{
					SetVisible(visible: false);
					return;
				}
				SetVisible(visible: true);
			}
			Vector3[] array = BakeWorld();
			if (array == null)
			{
				return;
			}
			int num = _indices.Length;
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector3 up = _character.up;
			for (int i = 0; i < num; i++)
			{
				int num2 = _indices[i];
				if (num2 >= array.Length)
				{
					_renderer = null;
					return;
				}
				Vector3 val = array[num2];
				Vector3 val2 = val - _character.position;
				val2 -= up * Vector3.Dot(val2, up);
				Vector3 val3 = ((_worldNormals != null && num2 < _worldNormals.Length) ? _worldNormals[num2] : Vector3.zero);
				if (((Vector3)(ref val3)).sqrMagnitude > 1E-06f)
				{
					if (Vector3.Dot(val3, val2) < 0f)
					{
						val3 = -val3;
					}
					val += ((Vector3)(ref val3)).normalized * m_surfaceOffset;
				}
				else if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f)
				{
					val += ((Vector3)(ref val2)).normalized * m_surfaceOffset;
				}
				array2[i] = val;
			}
			Place(array2);
		}

		private Vector3[] BakeWorld()
		{
			//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)
			//IL_005a: 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_0071: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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)
			if (!Object.op_Implicit((Object)(object)_renderer) || !Object.op_Implicit((Object)(object)_renderer.sharedMesh))
			{
				return null;
			}
			_renderer.BakeMesh(_baked, false);
			Vector3[] vertices = _baked.vertices;
			if (vertices == null || vertices.Length == 0)
			{
				return null;
			}
			Transform transform = ((Component)_renderer).transform;
			Vector3 position = transform.position;
			Quaternion rotation = transform.rotation;
			Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length];
			for (int i = 0; i < vertices.Length; i++)
			{
				array[i] = position + rotation * vertices[i];
			}
			Vector3[] normals = _baked.normals;
			if (normals != null && normals.Length == vertices.Length)
			{
				if (_worldNormals == null || _worldNormals.Length != vertices.Length)
				{
					_worldNormals = (Vector3[])(object)new Vector3[vertices.Length];
				}
				for (int j = 0; j < vertices.Length; j++)
				{
					Vector3[] worldNormals = _worldNormals;
					int num = j;
					Vector3 val = rotation * normals[j];
					worldNormals[num] = ((Vector3)(ref val)).normalized;
				}
			}
			else
			{
				_worldNormals = null;
			}
			return array;
		}

		private bool Fail(string reason)
		{
			if (reason != _lastFail)
			{
				_lastFail = reason;
				Logger.LogWarning((object)("ClothChain " + ((Object)this).name + ": " + reason));
			}
			return false;
		}

		private bool Bind()
		{
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			Transform character = _character;
			SkinnedMeshRenderer[] componentsInChildren = ((Component)character).GetComponentsInChildren<SkinnedMeshRenderer>(false);
			_renderer = ((IEnumerable<SkinnedMeshRenderer>)componentsInChildren).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => ((Object)r).name == m_rendererName && Object.op_Implicit((Object)(object)r.sharedMesh))) ?? ((IEnumerable<SkinnedMeshRenderer>)componentsInChildren).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => Object.op_Implicit((Object)(object)r.sharedMesh) && ((Object)r.sharedMesh).name.StartsWith(m_rendererName)));
			if (!Object.op_Implicit((Object)(object)_renderer))
			{
				IEnumerable<string> values = componentsInChildren.Select((SkinnedMeshRenderer r) => ((Object)r).name + "/" + (Object.op_Implicit((Object)(object)r.sharedMesh) ? ((Object)r.sharedMesh).name : "-"));
				return Fail("brak peleryny '" + m_rendererName + "' pod " + ((Object)character).name + "; skinned: " + string.Join(", ", values));
			}
			Vector3[] array = BakeWorld();
			if (array == null || array.Length < 4)
			{
				return Fail($"BakeMesh {((Object)_renderer).name} dal {((array != null) ? array.Length : 0)} wierzcholkow");
			}
			float num = array.Max(delegate(Vector3 v)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = v - _character.position;
				return ((Vector3)(ref val)).magnitude;
			});
			if (num > 5f || num < 0.2f)
			{
				return Fail($"BakeMesh {((Object)_renderer).name}: wierzcholki w zlej skali (max odleglosc od postaci {num:0.00} m, lossyScale renderera {((Component)_renderer).transform.lossyScale.x:0.0})");
			}
			Vector3[] local = (Vector3[])(object)new Vector3[array.Length];
			for (int num2 = 0; num2 < array.Length; num2++)
			{
				local[num2] = _character.InverseTransformPoint(array[num2]);
			}
			List<int> list = (from i in Enumerable.Range(0, local.Length)
				where local[i].z < m_backZ
				select i).ToList();
			if (list.Count < 2)
			{
				return Fail($"za malo wierzcholkow z tylu (z < {m_backZ}): {list.Count}; x {local.Min((Vector3 p) => p.x):0.00}..{local.Max((Vector3 p) => p.x):0.00} y {local.Min((Vector3 p) => p.y):0.00}..{local.Max((Vector3 p) => p.y):0.00} z {local.Min((Vector3 p) => p.z):0.00}..{local.Max((Vector3 p) => p.z):0.00} (renderer {((Object)_renderer).name} lossyScale {((Component)_renderer).transform.lossyScale.x:0.0})");
			}
			float topY = list.Max((int i) => local[i].y);
			int num3 = (from i in list
				where local[i].y >= topY - m_topDrop
				orderby Mathf.Abs(local[i].x - m_sideX)
				select i).First();
			List<int> list2 = new List<int> { num3 };
			int num4 = num3;
			for (int num5 = 0; num5 < _segments.Length; num5++)
			{
				int num6 = -1;
				float num7 = float.MaxValue;
				foreach (int item in list)
				{
					if (list2.Contains(item))
					{
						continue;
					}
					float num8 = local[num4].y - local[item].y;
					if (!(num8 < m_spacing * 0.5f))
					{
						float num9 = Mathf.Abs(local[item].x - local[num4].x);
						float num10 = Mathf.Abs(local[item].z - local[num4].z);
						float num11 = Mathf.Abs(num8 - m_spacing) + num9 * 1.5f + num10 * 0.5f;
						if (num11 < num7)
						{
							num7 = num11;
							num6 = item;
						}
					}
				}
				if (num6 < 0)
				{
					break;
				}
				list2.Add(num6);
				num4 = num6;
			}
			if (list2.Count < 2)
			{
				return Fail("nie udalo sie zejsc po siatce ponizej startu");
			}
			_lastFail = null;
			_indices = list2.ToArray();
			Logger.LogDebug((object)($"ClothChain {((Object)this).name}: peleryna {((Object)_renderer).name} (mesh {((Object)_renderer.sharedMesh).name}, {array.Length} wierzch.), " + $"sciezka od x={m_sideX}: " + string.Join(", ", _indices.Select((int i) => $"#{i}({local[i].x:0.00},{local[i].y:0.00},{local[i].z:0.00})"))));
			return true;
		}

		private void Place(Vector3[] pts)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0052: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.identity;
			Vector3 val2 = pts[^1];
			for (int i = 0; i < _segments.Length; i++)
			{
				Transform val3 = _segments[i];
				if (i + 1 >= pts.Length)
				{
					((Component)val3).gameObject.SetActive(false);
					continue;
				}
				((Component)val3).gameObject.SetActive(true);
				Vector3 val4 = pts[i + 1] - pts[i];
				float magnitude = ((Vector3)(ref val4)).magnitude;
				if (magnitude < 0.0001f)
				{
					val4 = Vector3.down * 0.01f;
				}
				val = Quaternion.FromToRotation(Vector3.down, ((Vector3)(ref val4)).normalized);
				float num = Mathf.Max(0.05f, magnitude / m_meshLengthY);
				val3.localScale = new Vector3(m_radialScale, num, m_radialScale);
				val3.rotation = val;
				val3.position = pts[i] - val * (Vector3.up * (m_meshTopY * num));
			}
			if (Object.op_Implicit((Object)(object)_cuff))
			{
				_cuff.rotation = val;
				_cuff.position = val2 + val * (Vector3.down * m_cuffRadius);
			}
		}

		private void SetVisible(bool visible)
		{
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = visible;
			}
		}

		public static GameObject Build(string name, Mesh linkMesh, Material linkMaterial, int segments, float radialScale, float spacing, float sideX, Material cuffMaterial)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			Bounds bounds;
			for (int i = 0; i < segments; i++)
			{
				GameObject val2 = new GameObject($"link{i}");
				val2.transform.SetParent(val.transform, false);
				Transform transform = val2.transform;
				bounds = linkMesh.bounds;
				transform.localScale = new Vector3(radialScale, spacing / ((Bounds)(ref bounds)).size.y, radialScale);
				AddMesh(val2, linkMesh, linkMaterial);
			}
			if (Object.op_Implicit((Object)(object)cuffMaterial))
			{
				GameObject val3 = new GameObject("cuff");
				val3.transform.SetParent(val.transform, false);
				AddMesh(val3, DanglingChain.CuffMesh, cuffMaterial);
			}
			ClothChain clothChain = val.AddComponent<ClothChain>();
			clothChain.m_sideX = sideX;
			clothChain.m_spacing = spacing;
			clothChain.m_radialScale = radialScale;
			bounds = linkMesh.bounds;
			clothChain.m_meshLengthY = ((Bounds)(ref bounds)).size.y;
			bounds = linkMesh.bounds;
			float y = ((Bounds)(ref bounds)).center.y;
			bounds = linkMesh.bounds;
			clothChain.m_meshTopY = y + ((Bounds)(ref bounds)).extents.y;
			return val;
		}

		private static void AddMesh(GameObject go, Mesh mesh, Material material)
		{
			go.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = go.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = material;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
		}
	}
	internal static class CrystalSugar
	{
		public const string ItemName = "CrystalSugar";

		private const string BaseName = "BarleyFlour";

		private const string FromItem = "Crystal";

		private const string SackMaterial = "fi_village_containers";

		private static readonly Rect GrainUv = Rect.MinMaxRect(0.6087f, 0.0078f, 0.7573f, 0.1931f);

		private static readonly Color SugarTint = new Color(0.3f, 0.62f, 1f);

		private static readonly Color EmissionTint = new Color(0.25f, 0.6f, 1f);

		private const float EmissionBoost = 1.5f;

		private static readonly Color LightColor = new Color(0.45f, 0.75f, 1f);

		private const float LightHeight = 0.7f;

		private const float LightIntensity = 0.5f;

		private const float LightRange = 1f;

		public static void Register()
		{
			//IL_0016: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable += Create;
			ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)new SmelterConversionConfig
			{
				Station = Smelters.Windmill,
				FromItem = "Crystal",
				ToItem = "CrystalSugar"
			}));
		}

		private static void Create()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Create;
			try
			{
				Build();
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"CrystalSugar: skladanie itemu nie powiodlo sie: {arg}");
			}
		}

		private static void Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			ItemConfig val = new ItemConfig
			{
				Name = "$item_crystalsugar",
				Description = "$item_crystalsugar_description"
			};
			CustomItem val2 = new CustomItem("CrystalSugar", "BarleyFlour", val);
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			shared.m_weight = 1f;
			shared.m_maxStackSize = 50;
			Sugarize(val2.ItemPrefab);
			Sprite val3 = RuntimeTextures.LoadIcon("CrystalSugar");
			if (Object.op_Implicit((Object)(object)val3))
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val3 };
			}
			AddGlow(val2.ItemPrefab.transform);
			ItemManager.Instance.AddItem(val2);
		}

		private static void Sugarize(GameObject prefab)
		{
			bool logged = false;
			MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val in componentsInChildren)
			{
				Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
				bool flag = false;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if (Object.op_Implicit((Object)(object)sharedMaterials[j]) && ((Object)sharedMaterials[j]).name.StartsWith("fi_village_containers", StringComparison.Ordinal))
					{
						sharedMaterials[j] = SugarizeMaterial(sharedMaterials[j], ref logged);
						flag = true;
					}
				}
				if (flag)
				{
					((Renderer)val).sharedMaterials = sharedMaterials;
				}
			}
			if (!logged)
			{
				Logger.LogWarning((object)"CrystalSugar: nie znalazlem materialu fi_village_containers na klonie worka");
			}
		}

		private static Material SugarizeMaterial(Material source, ref bool logged)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(source)
			{
				name = ((Object)source).name + "_crystalsugar"
			};
			Texture mainTexture = source.mainTexture;
			if (!Object.op_Implicit((Object)(object)mainTexture))
			{
				Logger.LogWarning((object)"CrystalSugar: material worka nie ma albedo - zostaje waniliowy");
				return val;
			}
			val.mainTexture = (Texture)(object)RuntimeTextures.Recolor(mainTexture, GrainOnly(mainTexture, Blue), ((Object)mainTexture).name + "_crystalsugar");
			bool flag = val.HasProperty("_EmissionMap") && val.HasProperty("_EmissionColor");
			if (flag)
			{
				val.SetTexture("_EmissionMap", (Texture)(object)RuntimeTextures.Recolor(mainTexture, GrainOnly(mainTexture, Glow, Color.black), ((Object)mainTexture).name + "_crystalsugar_e"));
				val.SetColor("_EmissionColor", Color.white * 1.5f);
				val.EnableKeyword("_EMISSION");
				val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
			if (!logged)
			{
				logged = true;
				Logger.LogDebug((object)($"CrystalSugar: {((Object)source).name} shader={((Object)val.shader).name} albedo={((Object)mainTexture).name} {mainTexture.width}x{mainTexture.height} " + "emisja=" + (flag ? "tak" : "NIE - zostaje sam tint")));
			}
			return val;
		}

		private static Func<int, int, Color, Color> GrainOnly(Texture tex, Func<Color, Color> op, Color? outside = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			Rect grainUv = GrainUv;
			int x0 = Mathf.FloorToInt(((Rect)(ref grainUv)).xMin * (float)tex.width);
			grainUv = GrainUv;
			int x1 = Mathf.CeilToInt(((Rect)(ref grainUv)).xMax * (float)tex.width);
			grainUv = GrainUv;
			int y0 = Mathf.FloorToInt(((Rect)(ref grainUv)).yMin * (float)tex.height);
			grainUv = GrainUv;
			int y1 = Mathf.CeilToInt(((Rect)(ref grainUv)).yMax * (float)tex.height);
			return (int num, int num2, Color c) => (num < x0 || num > x1 || num2 < y0 || num2 > y1) ? (outside ?? c) : op(c);
		}

		private static Color Blue(Color c)
		{
			//IL_0000: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			return new Color(c.r * SugarTint.r, c.g * SugarTint.g, c.b * SugarTint.b, c.a);
		}

		private static Color Glow(Color c)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			float grayscale = ((Color)(ref c)).grayscale;
			return new Color(EmissionTint.r * grayscale, EmissionTint.g * grayscale, EmissionTint.b * grayscale, 1f);
		}

		private static void AddGlow(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0036: 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)
			GameObject val = new GameObject("Point light");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, 0.7f, 0f);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = LightColor;
			obj.intensity = 0.5f;
			obj.range = 1f;
			obj.shadows = (LightShadows)0;
			LightFlicker obj2 = val.AddComponent<LightFlicker>();
			obj2.m_flickerIntensity = 0.1f;
			obj2.m_flickerSpeed = 4f;
			obj2.m_movement = 0.02f;
			obj2.m_ttl = 0f;
			obj2.m_fadeDuration = 0.2f;
			obj2.m_fadeInDuration = 0f;
		}
	}
	public class DanglingChain : MonoBehaviour
	{
		public float m_segmentLength = 0.17f;

		public float m_segmentTop = 0.08f;

		public float m_cuffRadius = 0.031f;

		public float m_gravity = 14f;

		public float m_damping = 0.96f;

		public float m_maxSpeed = 12f;

		public int m_iterations = 3;

		public Vector3 m_characterOffset = Vector3.zero;

		public Vector3 m_characterForce = Vector3.zero;

		public float m_windScale = 0.6f;

		public float m_gustScale = 1.2f;

		public float m_maxStep = 0.05f;

		public bool m_collide;

		public float m_colliderRadius = 0.18f;

		public Vector3 m_colliderOffset = Vector3.zero;

		public float m_colliderTop = 0.25f;

		public float m_colliderBottom = -0.8f;

		public float m_colliderTilt;

		private float _gustSeed;

		private Transform[] _segments;

		private Transform _cuff;

		private Vector3[] _pos;

		private Vector3[] _prev;

		private Transform _character;

		private bool _ready;

		private static Mesh _cuffMesh;

		public static Mesh CuffMesh
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_cuffMesh))
				{
					return BuildCuffMesh(0.031f, 0.006f);
				}
				return _cuffMesh;
			}
		}

		private void Start()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			List<Transform> list = new List<Transform>();
			foreach (Transform item in ((Component)this).transform)
			{
				Transform val = item;
				if (((Object)val).name == "cuff")
				{
					_cuff = val;
				}
				else
				{
					list.Add(val);
				}
			}
			_segments = list.ToArray();
			if (_segments.Length == 0)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			Character componentInParent = ((Component)this).GetComponentInParent<Character>();
			_character = (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).transform : ((Component)this).transform.root);
			_gustSeed = Random.value * 100f;
			int num = _segments.Length + 1;
			_pos = (Vector3[])(object)new Vector3[num];
			_prev = (Vector3[])(object)new Vector3[num];
			Reset(Anchor());
			_ready = true;
			Place();
		}

		private void Reset(Vector3 anchor)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			for (int i = 0; i < _pos.Length; i++)
			{
				_pos[i] = anchor + Vector3.down * (m_segmentLength * (float)i);
				_prev[i] = _pos[i];
			}
		}

		private Vector3 Anchor()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position + _character.TransformVector(m_characterOffset);
		}

		private void LateUpdate()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: 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_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			if (!_ready)
			{
				return;
			}
			float num = Mathf.Min(Time.deltaTime, m_maxStep);
			Vector3 val = Anchor();
			Vector3 val2 = val - _pos[0];
			if (((Vector3)(ref val2)).sqrMagnitude > 4f)
			{
				Reset(val);
			}
			_pos[0] = val;
			Vector3 val3 = (Vector3.down * m_gravity + _character.TransformVector(m_characterForce) + Wind()) * (num * num);
			float num2 = m_maxSpeed * num;
			for (int i = 1; i < _pos.Length; i++)
			{
				Vector3 val4 = (_pos[i] - _prev[i]) * m_damping;
				if (((Vector3)(ref val4)).sqrMagnitude > num2 * num2)
				{
					val4 = ((Vector3)(ref val4)).normalized * num2;
				}
				_prev[i] = _pos[i];
				ref Vector3 reference = ref _pos[i];
				reference += val4 + val3;
			}
			Vector3 axisBase = ((Component)this).transform.position + _character.TransformVector(m_colliderOffset);
			val2 = _character.up + _character.forward * m_colliderTilt;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			for (int j = 0; j < m_iterations; j++)
			{
				_pos[0] = val;
				for (int k = 1; k < _pos.Length; k++)
				{
					Vector3 val5 = _pos[k] - _pos[k - 1];
					float magnitude = ((Vector3)(ref val5)).magnitude;
					if (!(magnitude < 1E-05f))
					{
						Vector3 val6 = val5 * ((magnitude - m_segmentLength) / magnitude);
						if (k == 1)
						{
							ref Vector3 reference2 = ref _pos[k];
							reference2 -= val6;
						}
						else
						{
							ref Vector3 reference3 = ref _pos[k - 1];
							reference3 += val6 * 0.5f;
							ref Vector3 reference4 = ref _pos[k];
							reference4 -= val6 * 0.5f;
						}
						if (m_collide)
						{
							PushOutOfBody(ref _pos[k], axisBase, normalized);
						}
					}
				}
			}
			Place();
		}

		private void PushOutOfBody(ref Vector3 p, Vector3 axisBase, Vector3 up)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003e: 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_006d: 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_0064: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp(Vector3.Dot(p - axisBase, up), m_colliderBottom, m_colliderTop);
			Vector3 val = axisBase + up * num;
			Vector3 val2 = p - val;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (!(magnitude >= m_colliderRadius))
			{
				Vector3 val3 = ((magnitude > 0.0001f) ? (val2 / magnitude) : (-_character.forward));
				p = val + val3 * m_colliderRadius;
			}
		}

		private Vector3 Wind()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			Vector3 val = Vector3.zero;
			if (Object.op_Implicit((Object)(object)EnvMan.instance))
			{
				val = EnvMan.instance.GetWindForce() * m_windScale;
			}
			float num = Time.time * 0.35f;
			Vector3 val2 = new Vector3(Mathf.PerlinNoise(num, _gustSeed) - 0.5f, 0f, Mathf.PerlinNoise(_gustSeed, num) - 0.5f) * m_gustScale;
			return val + val2;
		}

		private void Place()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ec: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.identity;
			for (int i = 0; i < _segments.Length; i++)
			{
				Vector3 val2 = _pos[i + 1] - _pos[i];
				if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f)
				{
					val2 = Vector3.down;
				}
				val = Quaternion.FromToRotation(Vector3.down, ((Vector3)(ref val2)).normalized);
				Transform obj = _segments[i];
				obj.rotation = val;
				obj.position = _pos[i] - val * (Vector3.up * m_segmentTop);
			}
			if (Object.op_Implicit((Object)(object)_cuff))
			{
				Vector3 val3 = _pos[_pos.Length - 1];
				_cuff.rotation = val;
				_cuff.position = val3 + val * (Vector3.down * m_cuffRadius);
			}
		}

		public static GameObject Build(string name, Mesh linkMesh, Material linkMaterial, int segments, float radialScale, float lengthScale, Vector3 characterOffset, Vector3 characterForce, Material cuffMaterial, bool collideWithBody = false, Vector3 colliderOffset = default(Vector3), float colliderTilt = 0f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			Bounds bounds = linkMesh.bounds;
			float segmentTop = (((Bounds)(ref bounds)).center.y + ((Bounds)(ref bounds)).extents.y) * lengthScale;
			float segmentLength = ((Bounds)(ref bounds)).size.y * lengthScale;
			for (int i = 0; i < segments; i++)
			{
				GameObject val2 = new GameObject($"link{i}");
				val2.transform.SetParent(val.transform, false);
				val2.transform.localScale = new Vector3(radialScale, lengthScale, radialScale);
				AddMesh(val2, linkMesh, linkMaterial);
			}
			float cuffRadius = 0.031f;
			if (Object.op_Implicit((Object)(object)cuffMaterial))
			{
				GameObject val3 = new GameObject("cuff");
				val3.transform.SetParent(val.transform, false);
				AddMesh(val3, CuffMesh, cuffMaterial);
			}
			DanglingChain danglingChain = val.AddComponent<DanglingChain>();
			danglingChain.m_segmentLength = segmentLength;
			danglingChain.m_segmentTop = segmentTop;
			danglingChain.m_cuffRadius = cuffRadius;
			danglingChain.m_characterOffset = characterOffset;
			danglingChain.m_characterForce = characterForce;
			danglingChain.m_collide = collideWithBody;
			danglingChain.m_colliderOffset = colliderOffset;
			danglingChain.m_colliderTilt = colliderTilt;
			return val;
		}

		private static void AddMesh(GameObject go, Mesh mesh, Material material)
		{
			go.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = go.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = material;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
		}

		public static Mesh BuildLinkChainMesh(int links, float linkLength, float linkWidth, float tubeRadius, float pitch)
		{
			TubeBuilder tubeBuilder = new TubeBuilder();
			float num = (float)(links - 1) * pitch + linkLength;
			float a = linkLength * 0.5f - tubeRadius;
			float b = linkWidth * 0.5f - tubeRadius;
			for (int i = 0; i < links; i++)
			{
				float cy = (0f - num) * 0.5f + linkLength * 0.5f + (float)i * pitch;
				bool flat = i % 2 == 0;
				tubeBuilder.AddTube(delegate(float t)
				{
					//IL_0057: 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)
					float num2 = t * 2f * (float)Math.PI;
					float num3 = cy + Mathf.Sin(num2) * a;
					float num4 = Mathf.Cos(num2) * b;
					return (!flat) ? new Vector3(0f, num3, num4) : new Vector3(num4, num3, 0f);
				}, (float t) => tubeRadius, 28, 8);
			}
			return tubeBuilder.ToMesh($"wraith_chain_{links}");
		}

		private static Mesh BuildCuffMesh(float ringRadius, float tubeRadius)
		{
			if (Object.op_Implicit((Object)(object)_cuffMesh))
			{
				return _cuffMesh;
			}
			TubeBuilder tubeBuilder = new TubeBuilder();
			tubeBuilder.AddTube((float t) => new Vector3(Mathf.Cos(t * 2f * (float)Math.PI) * ringRadius, Mathf.Sin(t * 2f * (float)Math.PI) * ringRadius, 0f), (float t) => tubeRadius, 32, 10);
			_cuffMesh = tubeBuilder.ToMesh("wraith_cuff");
			return _cuffMesh;
		}
	}
	public class DumpStaffCommand : ConsoleCommand
	{
		public override string Name => "dumpstaff";

		public override string Help => "Zrzuca hierarchie trzymanych itemow do logu (diagnostyka); 'dumpstaff armor' - zalozona zbroja";

		public override void Run(string[] args)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				Console.instance.Print("Brak lokalnego gracza");
				return;
			}
			VisEquipment component = ((Component)localPlayer).GetComponent<VisEquipment>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				Console.instance.Print("Brak VisEquipment");
			}
			else if (args.Length != 0 && args[0] == "armor")
			{
				DumpList(component, "m_chestItemInstances", "TORS");
				DumpList(component, "m_legItemInstances", "NOGI");
				DumpList(component, "m_shoulderItemInstances", "PELERYNA");
				object? obj = AccessTools.Field(typeof(VisEquipment), "m_helmetItemInstance")?.GetValue(component);
				Dump((GameObject)((obj is GameObject) ? obj : null), "HELM");
				Console.instance.Print("dumpstaff armor: hierarchia zapisana do logu");
			}
			else
			{
				Dump(component.m_leftItemInstance, "LEWA REKA");
				Dump(component.m_rightItemInstance, "PRAWA REKA");
				Console.instance.Print("dumpstaff: hierarchia zapisana do logu");
			}
		}

		private static void DumpList(VisEquipment vis, string field, string label)
		{
			if (AccessTools.Field(typeof(VisEquipment), field)?.GetValue(vis) is List<GameObject> { Count: not 0 } list)
			{
				for (int i = 0; i < list.Count; i++)
				{
					Dump(list[i], string.Format("{0} [{1}] parent={2}", label, i, (Object.op_Implicit((Object)(object)list[i]) && Object.op_Implicit((Object)(object)list[i].transform.parent)) ? ((Object)list[i].transform.parent).name : "-"));
				}
			}
			else
			{
				Logger.LogInfo((object)("dumpstaff " + label + ": (pusto)"));
			}
		}

		private static void Dump(GameObject go, string label)
		{
			if (!Object.op_Implicit((Object)(object)go))
			{
				Logger.LogInfo((object)("dumpstaff " + label + ": (pusto)"));
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("dumpstaff " + label + ":\n");
			Walk(go.transform, "", stringBuilder);
			Logger.LogInfo((object)stringBuilder.ToString());
		}

		private static void Walk(Transform t, string indent, StringBuilder sb)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			sb.Append($"{indent}{((Object)t).name} act={((Component)t).gameObject.activeSelf}/{((Component)t).gameObject.activeInHierarchy} " + $"layer={((Component)t).gameObject.layer} lossyScale={t.lossyScale}\n");
			ParticleSystem[] components = ((Component)t).GetComponents<ParticleSystem>();
			foreach (ParticleSystem val in components)
			{
				string text = $"{indent}  [PS] playing={val.isPlaying} count={val.particleCount} ";
				EmissionModule emission = val.emission;
				object arg = ((EmissionModule)(ref emission)).enabled;
				emission = val.emission;
				MinMaxCurve val2 = ((EmissionModule)(ref emission)).rateOverTime;
				string text2 = $"emissionOn={arg} rate={((MinMaxCurve)(ref val2)).constant} ";
				MainModule main = val.main;
				val2 = ((MainModule)(ref main)).startSize;
				object arg2 = ((MinMaxCurve)(ref val2)).constantMin;
				main = val.main;
				val2 = ((MainModule)(ref main)).startSize;
				sb.Append(text + text2 + $"startSize={arg2}-{((MinMaxCurve)(ref val2)).constantMax}\n");
			}
			Renderer[] components2 = ((Component)t).GetComponents<Renderer>();
			foreach (Renderer val3 in components2)
			{
				Material sharedMaterial = val3.sharedMaterial;
				sb.Append($"{indent}  [{((object)val3).GetType().Name}] enabled={val3.enabled} " + "mat=" + (Object.op_Implicit((Object)(object)sharedMaterial) ? (((Object)sharedMaterial).name + " / " + ((Object)sharedMaterial.shader).name) : "null") + "\n");
			}
			Light[] components3 = ((Component)t).GetComponents<Light>();
			foreach (Light val4 in components3)
			{
				sb.Append($"{indent}  [Light] color={val4.color} int={val4.intensity} range={val4.range}\n");
			}
			foreach (Transform item in t)
			{
				Walk(item, indent + "  ", sb);
			}
		}
	}
	internal static class EctoplasmDrops
	{
		public const string EctoplasmName = "Ectoplasm";

		private const int WraithAmountMin = 1;

		private const int WraithAmountMax = 4;

		public static void Register()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Apply;
			ModConfig.DropsChanged += Apply;
		}

		private static void Apply()
		{
			ApplyTo(GetDrops("Ghost"), "Ghost");
			ApplyTo(GetDrops("Wraith"), "Wraith");
		}

		internal static void ApplyTo(CharacterDrop drops, string creature)
		{
			if (Object.op_Implicit((Object)(object)drops))
			{
				if (creature == "Ghost")
				{
					NerfGhost(drops);
				}
				else if (creature == "Wraith")
				{
					AddToWraith(drops);
				}
			}
		}

		private static void NerfGhost(CharacterDrop drops)
		{
			Drop val = Find(drops);
			if (val != null)
			{
				val.m_amountMax = (val.m_amountMin = ModConfig.GhostEctoplasmAmount.Value);
				val.m_chance = ModConfig.GhostEctoplasmChance.Value / 100f;
				val.m_levelMultiplier = false;
			}
		}

		private static void AddToWraith(CharacterDrop drops)
		{
			//IL_0038: 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_0044: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			Drop val = Find(drops);
			if (val != null)
			{
				val.m_amountMin = 1;
				val.m_amountMax = 5;
				return;
			}
			GameObject prefab = PrefabManager.Instance.GetPrefab("Ectoplasm");
			if (Object.op_Implicit((Object)(object)prefab))
			{
				drops.m_drops.Add(new Drop
				{
					m_prefab = prefab,
					m_amountMin = 1,
					m_amountMax = 5,
					m_chance = 1f,
					m_levelMultiplier = false
				});
			}
		}

		private static CharacterDrop GetDrops(string creature)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(creature);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return null;
			}
			return prefab.GetComponent<CharacterDrop>();
		}

		private static Drop Find(CharacterDrop drops)
		{
			return drops?.m_drops?.FirstOrDefault((Func<Drop, bool>)((Drop d) => Object.op_Implicit((Object)(object)d.m_prefab) && ((Object)d.m_prefab).name == "Ectoplasm"));
		}
	}
	[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
	internal static class DropListPatch
	{
		private static void Prefix(CharacterDrop __instance)
		{
			string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject);
			EctoplasmDrops.ApplyTo(__instance, prefabName);
			FenringHairDrop.ApplyTo(__instance, prefabName);
		}
	}
	internal static class FenringHairDrop
	{
		private const string CreatureName = "Fenring";

		private const string HairName = "WolfHairBundle";

		public static void Register()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Apply;
			ModConfig.DropsChanged += Apply;
		}

		private static void Apply()
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab("Fenring");
			ApplyTo(Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<CharacterDrop>() : null, "Fenring");
		}

		internal static void ApplyTo(CharacterDrop drops, string creature)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)drops) || creature != "Fenring")
			{
				return;
			}
			Drop val = ((IEnumerable<Drop>)drops.m_drops).FirstOrDefault((Func<Drop, bool>)((Drop d) => Object.op_Implicit((Object)(object)d.m_prefab) && ((Object)d.m_prefab).name == "WolfHairBundle"));
			if (val == null)
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab("WolfHairBundle");
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					return;
				}
				val = new Drop
				{
					m_prefab = prefab,
					m_levelMultiplier = false
				};
				drops.m_drops.Add(val);
			}
			val.m_amountMax = (val.m_amountMin = ModConfig.FenringHairAmount.Value);
			val.m_chance = ModConfig.FenringHairChance.Value / 100f;
		}
	}
	internal static class FrostWand
	{
		public const string PrefabName = "FrostWand";

		private const string ProjectileName = "wand_frostbolt_projectile";

		private const float FrostDamage = 90f;

		private const float FrostDamagePerLevel = 6f;

		private const float AttackEitr = 30f;

		private const float ExplosionRadius = 1.3f;

		private const float HandleEnd = 0.3f;

		private const float CageEnd = 0.6f;

		private const float TipEnd = 0.7f;

		private const float CageCenter = 0.45000002f;

		private const float CageRadius = 0.055f;

		private const float CrystalLength = 0.275f;

		private const float CrystalWidth = 1f;

		public static void Register()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Create;
		}

		private static void Create()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Create;
			try
			{
				BuildWand(BuildProjectile());
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"FrostWand: skladanie itemu nie powiodlo sie: {arg}");
			}
		}

		private static GameObject BuildProjectile()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("wand_frostbolt_projectile", "DvergerStaffIce_projectile");
			Projectile component = val.GetComponent<Projectile>();
			component.m_aoe = 1.3f;
			component.m_gravity = 4f;
			component.m_ttl = 10f;
			component.m_doOwnerRaytest = true;
			component.m_hitNoise = 30f;
			Logger.LogDebug((object)("FrostWand: pocisk bazowy - hitEffects=" + string.Join(",", component.m_hitEffects?.m_effectPrefabs?.Select((EffectData e) => (!Object.op_Implicit((Object)(object)e.m_prefab)) ? "null" : ((Object)e.m_prefab).name) ?? new string[0]) + string.Format(", spawnOnHit={0}, rayRadius={1}", Object.op_Implicit((Object)(object)component.m_spawnOnHit) ? ((Object)component.m_spawnOnHit).name : "null", component.m_rayRadius)));
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false));
			return val;
		}

		private static void BuildWand(GameObject projectile)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			SharedData shared = PrefabManager.Instance.GetPrefab("StaffIceShards").GetComponent<ItemDrop>().m_itemData.m_shared;
			ItemConfig val = new ItemConfig();
			val.Name = "$item_wandfrost";
			val.Description = "$item_wandfrost_description";
			val.Icons = (Sprite[])(object)new Sprite[1] { shared.m_icons[0] };
			val.CraftingStation = "forge";
			val.RepairStation = "forge";
			val.MinStationLevel = 3;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Silver", 28, 12, true),
				new RequirementConfig("Crystal", 1, 1, true),
				new RequirementConfig("FreezeGland", 2, 1, true)
			};
			ItemConfig val2 = val;
			CustomItem val3 = new CustomItem("FrostWand", "StaffFireball", val2);
			ItemManager.Instance.AddItem(val3);
			SharedData shared2 = val3.ItemDrop.m_itemData.m_shared;
			shared2.m_maxDurability = 100f;
			shared2.m_durabilityPerLevel = 25f;
			shared2.m_useDurability = true;
			shared2.m_useDurabilityDrain = 1f;
			shared2.m_damages = new DamageTypes
			{
				m_frost = 90f
			};
			shared2.m_damagesPerLevel = new DamageTypes
			{
				m_frost = 6f
			};
			shared2.m_attackForce = 40f;
			shared2.m_animationState = (AnimationState)1;
			Attack attack = shared2.m_attack;
			attack.m_attackProjectile = projectile;
			attack.m_attackEitr = 30f;
			Logger.LogDebug((object)(string.Format("{0}: bazowy atak StaffFireball - vel={1}, ", "FrostWand", attack.m_projectileVel) + $"launchAngle={attack.m_launchAngle}, wysokosc={attack.m_attackHeight}, offset={attack.m_attackOffset}"));
			attack.m_attackHeight -= 0.3f;
			GameObject prefab = PrefabManager.Instance.GetPrefab("sfx_dverger_ice_projectile_start");
			if (Object.op_Implicit((Object)(object)prefab))
			{
				EffectList val4 = new EffectList();
				val4.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
				{
					new EffectData
					{
						m_prefab = prefab
					}
				};
				shared2.m_startEffect = val4;
			}
			else
			{
				Logger.LogWarning((object)"FrostWand: brak sfx_dverger_ice_projectile_start - zostaje dzwiek fire staffa");
			}
			BuildVisual(val3.ItemPrefab);
			RenderedIcons.Register("FrostWand");
		}

		private static void BuildVisual(GameObject prefab)
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Expected O, but got Unknown
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			Material val = FindModelMaterial("Silver", "bar") ?? FindLoadedMaterial("silverbar");
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("Crystal");
			Transform val2 = (Object.op_Implicit((Object)(object)prefab2) ? prefab2.transform.Find("Cube") : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
			{
				Logger.LogWarning((object)($"FrostWand: brak czesci modelu (silverbar={Object.op_Implicit((Object)(object)val)}, Crystal/Cube={Object.op_Implicit((Object)(object)val2)}) " + "- zostaje model kostura ognia"));
				return;
			}
			Transform val3 = prefab.transform.Find("attach");
			if (!Object.op_Implicit((Object)(object)val3))
			{
				Logger.LogWarning((object)"FrostWand: brak wezla 'attach' w klonie StaffFireball");
				return;
			}
			Transform[] array = ((IEnumerable)val3).Cast<Transform>().ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject);
			}
			val3.localRotation = Quaternion.Euler(0f, 0f, 180f);
			int layer = LayerMask.NameToLayer("item");
			GameObject val4 = new GameObject("wand")
			{
				layer = layer
			};
			val4.transform.SetParent(val3, false);
			val4.transform.localPosition = Vector3.zero;
			val4.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
			val4.AddComponent<MeshFilter>().sharedMesh = BuildShaftMesh();
			((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = BuildShaftMaterial(val);
			BoxCollider obj = val4.AddComponent<BoxCollider>();
			obj.size = new Vector3(0.14f, 0.71999997f, 0.14f);
			obj.center = new Vector3(0f, 0.35f, 0f);
			GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val3, false);
			((Object)val5).name = "crystal";
			val5.layer = layer;
			Collider component = val5.GetComponent<Collider>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			MeshFilter component2 = val5.GetComponent<MeshFilter>();
			Mesh val6 = (Object.op_Implicit((Object)(object)component2) ? component2.sharedMesh : null);
			Bounds val7 = (Bounds)(Object.op_Implicit((Object)(object)val6) ? val6.bounds : new Bounds(Vector3.zero, Vector3.one));
			Vector3 val8 = Vector3.Scale(((Bounds)(ref val7)).size, val2.localScale);
			int num = ((!(val8.x >= val8.y) || !(val8.x >= val8.z)) ? ((val8.y >= val8.z) ? 1 : 2) : 0);
			float num2 = Mathf.Max(new float[3] { val8.x, val8.y, val8.z });
			Vector3 val9 = val2.localScale * (0.275f / Mathf.Max(num2, 0.001f));
			if (num != 0)
			{
				val9.x *= 1f;
			}
			if (num != 1)
			{
				val9.y *= 1f;
			}
			if (num != 2)
			{
				val9.z *= 1f;
			}
			Quaternion val10 = (Quaternion)(num switch
			{
				1 => Quaternion.Euler(90f, 0f, 0f), 
				0 => Quaternion.Euler(0f, -90f, 0f), 
				_ => Quaternion.identity, 
			});
			Quaternion val11 = Quaternion.Euler(0f, 0f, 35f) * val10;
			val5.transform.localScale = val9;
			val5.transform.localRotation = val11;
			val5.transform.localPosition = new Vector3(0f, 0f, 0.45000002f) - val11 * Vector3.Scale(((Bounds)(ref val7)).center, val9);
			Logger.LogDebug((object)(string.Format("FrostWand: krysztal mesh={0} bounds.size={1} ", Object.op_Implicit((Object)(object)val6) ? ((Object)val6).name : "null", ((Bounds)(ref val7)).size) + $"center={((Bounds)(ref val7)).center} srcScale={val2.localScale} -> wymiary vanilla={val8}, dluga os={num}, skala={val9}"));
			GameObject val12 = new GameObject("Point light");
			val12.transform.SetParent(val3, false);
			val12.transform.localPosition = new Vector3(0f, 0f, 0.45000002f);
			Light obj2 = val12.AddComponent<Light>();
			obj2.type = (LightType)2;
			obj2.color = new Color(0.549f, 0.914f, 1f);
			obj2.intensity = 1.5f;
			obj2.range = 2.5f;
			obj2.shadows = (LightShadows)0;
			GameObject prefab3 = PrefabManager.Instance.GetPrefab("StaffIceShards");
			GameObject val13 = new GameObject("effects");
			val13.layer = layer;
			val13.transform.SetParent(val3, false);
			val13.transform.localPosition = new Vector3(0f, 0f, 0.45000002f);
			CloneFx(prefab3, "flare", val13.transform);
			CloneFx(prefab3, "embers", val13.transform);
		}

		private static Mesh BuildShaftMesh()
		{
			TubeBuilder tubeBuilder = new TubeBuilder();
			tubeBuilder.AddTube((float t) => new Vector3(0f, Mathf.Lerp(-0.012f, 0f, t), 0f), (float t) => Mathf.Lerp(0f, 0.018f, t), 1, 6);
			tubeBuilder.AddTube((float t) => new Vector3(0f, Mathf.Lerp(0f, 0.3f, t), 0f), (float t) => Mathf.Lerp(0.018f, 0.013f, t), 1, 6);
			tubeBuilder.AddTube((float t) => new Vector3(Mathf.Cos(t * 2f * (float)Math.PI) * 0.014f, 0.3f, Mathf.Sin(t * 2f * (float)Math.PI) * 0.014f), (float t) => 0.009f, 8, 3);
			for (int num = 0; num < 2; num++)
			{
				float phase = (float)num * (float)Math.PI;
				tubeBuilder.AddTube(delegate(float t)
				{
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					float num2 = phase + t * 2f * (float)Math.PI * 1.5f;
					float num3 = Mathf.Pow(Mathf.Max(0f, Mathf.Sin(t * (float)Math.PI)), 0.75f) * 0.055f + 0.006f;
					return new Vector3(Mathf.Cos(num2) * num3, Mathf.Lerp(0.3f, 0.6f, t), Mathf.Sin(num2) * num3);
				}, (float t) => 0.0105f, 24, 4);
			}
			tubeBuilder.AddTube((float t) => new Vector3(0f, Mathf.Lerp(0.59000003f, 0.7f, t), 0f), (float t) => Mathf.Lerp(0.013f, 0f, t), 1, 6);
			return tubeBuilder.ToMesh("frostwand_shaft");
		}

		private static Material BuildShaftMaterial(Material source)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(source)
			{
				name = ((Object)source).name + "_frostwand"
			};
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", new Color(0.5f, 0.53f, 0.58f));
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0.55f);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.72f);
			}
			return val;
		}

		private static Material FindModelMaterial(string prefabName, string meshName)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Logger.LogWarning((object)("FrostWand: nie znaleziono prefabu '" + prefabName + "'"));
				return null;
			}
			MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val.sharedMesh) && ((Object)val.sharedMesh).name == meshName)
				{
					MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
					if (!Object.op_Implicit((Object)(object)component))
					{
						return null;
					}
					return ((Renderer)component).sharedMaterial;
				}
			}
			return null;
		}

		private static void CloneFx(GameObject source, string childName, Transform parent)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (Object.op_Implicit((Object)(object)source) ? ((IEnumerable<Transform>)source.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == childName || ((Object)t).name.StartsWith(childName + " "))) : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Logger.LogWarning((object)("FrostWand: nie znaleziono fx '" + childName + "' w " + (Object.op_Implicit((Object)(object)source) ? ((Object)source).name : "null")));
				return;
			}
			GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, parent, false);
			((Object)obj).name = childName;
			obj.layer = ((Component)parent).gameObject.layer;
			obj.transform.localPosition = Vector3.zero;
			obj.transform.localRotation = Quaternion.identity;
		}

		private static Material FindLoadedMaterial(string name)
		{
			return ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name == name));
		}
	}
	internal static class GhostShake
	{
		public const string ItemName = "GhostShake";

		private const string BaseName = "ShocklateSmoothie";

		private const float GhostHue = 0.42f;

		private const float GhostSaturationMax = 0.4f;

		private static readonly Color GlowColor = new Color(0.62f, 1f, 0.78f);

		public static void Register()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Create;
		}

		private static void Create()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Create;
			try
			{
				Build();
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"GhostShake: skladanie itemu nie powiodlo sie: {arg}");
			}
		}

		private static void Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = "$item_ghostshake";
			val.Description = "$item_ghostshake_description";
			val.CraftingStation = "piece_cauldron";
			val.MinStationLevel = 2;
			val.Amount = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig("Wildberry", 4, 0, true),
				new RequirementConfig("Ectoplasm", 1, 0, true)
			};
			ItemConfig val2 = val;
			CustomItem val3 = new CustomItem("GhostShake", "ShocklateSmoothie", val2);
			SharedData shared = val3.ItemDrop.m_itemData.m_shared;
			shared.m_food = 5f;
			shared.m_foodStamina = 20f;
			shared.m_foodEitr = 40f;
			shared.m_foodRegen = 1f;
			shared.m_foodBurnTime = 1200f;
			shared.m_maxStackSize = 10;
			if (!ModAssets.ApplyModel(val3.ItemPrefab, "GhostShake_mesh", "GhostShake_d"))
			{
				Logger.LogWarning((object)"GhostShake: brak modelu w bundlu - zostaje przemalowana wanilia");
				Ghostify(val3.ItemPrefab);
			}
			Sprite val4 = RuntimeTextures.LoadIcon("GhostShake");
			if (Object.op_Implicit((Object)(object)val4))
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val4 };
			}
			AddGlow(val3.ItemPrefab.transform);
			ItemManager.Instance.AddItem(val3);
		}

		private static void Ghostify(GameObject prefab)
		{
			Dictionary<Texture, Texture2D> recolored = new Dictionary<Texture, Texture2D>();
			MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer obj in componentsInChildren)
			{
				((Renderer)obj).sharedMaterials = ((Renderer)obj).sharedMaterials.Select((Material mat) => GhostifyMaterial(mat, recolored)).ToArray();
			}
		}

		private static Material GhostifyMaterial(Material source, Dictionary<Texture, Texture2D> cache)
		{
			//IL_000b: 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_0027: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)source))
			{
				return null;
			}
			Material val = new Material(source)
			{
				name = ((Object)source).name + "_ghost"
			};
			Texture mainTexture = source.mainTexture;
			if (!Object.op_Implicit((Object)(object)mainTexture))
			{
				return val;
			}
			if (!cache.TryGetValue(mainTexture, out var value))
			{
				value = (cache[mainTexture] = RuntimeTextures.Recolor(mainTexture, Ghostify, ((Object)mainTexture).name + "_ghost"));
			}
			if (Object.op_Implicit((Object)(object)value))
			{
				val.mainTexture = (Texture)(object)value;
			}
			return val;
		}

		private static Color Ghostify(Color c)
		{
			//IL_