Decompiled source of ElementalEffects v1.0.0

BepInEx/plugins/ElementalEffects/ElementalEffects.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ElementalEffects
{
	internal static class DevCommands
	{
		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		private static class Register
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__0_0;

				public static ConsoleEvent <>9__0_1;

				public static ConsoleEvent <>9__0_2;

				public static ConsoleEvent <>9__0_3;

				public static Func<IceSheet, bool> <>9__0_7;

				public static ConsoleEvent <>9__0_4;

				internal void <Postfix>b__0_0(ConsoleEventArgs args)
				{
					//IL_0034: Unknown result type (might be due to invalid IL or missing references)
					//IL_0067: 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_0070: 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_008c: 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_00b0: 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_00be: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e3: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
					//IL_010e: Unknown result type (might be due to invalid IL or missing references)
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer == (Object)null)
					{
						return;
					}
					int result;
					int num = ((args.Length > 1 && int.TryParse(args[1], out result)) ? result : 4);
					if (!FindWater(((Component)localPlayer).transform.position, out var water, out var dir))
					{
						Say(args, "No open water within 400 m");
						return;
					}
					float num2 = ElementalEffectsPlugin.SheetSpacing.Value * 1.2f;
					for (int i = 0; i < num; i++)
					{
						FrostIce.FreezeAt(water + dir * (num2 * (float)i));
					}
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(water.x, Floating.GetLiquidLevel(water, 0f, (LiquidType)10) + ElementalEffectsPlugin.TopAboveWater.Value + 1f, water.z);
					((Character)localPlayer).TeleportTo(val, Quaternion.LookRotation(dir), false);
					Say(args, $"Froze {num} sheets from {water.x:0},{water.z:0} heading {dir.x:0.0},{dir.z:0.0}");
				}

				internal void <Postfix>b__0_1(ConsoleEventArgs args)
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0022: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_004c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0051: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: Unknown result type (might be due to invalid IL or missing references)
					//IL_0059: Unknown result type (might be due to invalid IL or missing references)
					//IL_005c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0061: Unknown result type (might be due to invalid IL or missing references)
					//IL_0066: Unknown result type (might be due to invalid IL or missing references)
					//IL_006d: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
					//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c4: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e7: 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_0110: 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_0125: 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_0152: 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_0160: Unknown result type (might be due to invalid IL or missing references)
					//IL_017a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0189: Unknown result type (might be due to invalid IL or missing references)
					//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
					//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer == (Object)null || WorldGenerator.instance == null)
					{
						return;
					}
					Vector3 position = ((Component)localPlayer).transform.position;
					for (float num = 0f; num < 3000f; num += 16f)
					{
						for (int i = 0; i < 32; i++)
						{
							Vector3 val = Quaternion.Euler(0f, (float)i * 11.25f, 0f) * Vector3.forward;
							Vector3 val2 = position + val * num;
							float height = WorldGenerator.instance.GetHeight(val2.x, val2.z);
							if (height < 31f || height > 34f)
							{
								continue;
							}
							for (int j = 0; j < 16; j++)
							{
								Vector3 val3 = Quaternion.Euler(0f, (float)j * 22.5f, 0f) * Vector3.forward;
								if (WorldGenerator.instance.GetHeight(val2.x + val3.x * 14f, val2.z + val3.z * 14f) < 25f && WorldGenerator.instance.GetHeight(val2.x + val3.x * 30f, val2.z + val3.z * 30f) < 24f)
								{
									((Character)localPlayer).TeleportTo(new Vector3(val2.x, height + 1f, val2.z), Quaternion.LookRotation(val3), true);
									Say(args, $"Coast at {val2.x:0},{val2.z:0} (height {height:0.0}), sea to {val3.x:0.0},{val3.z:0.0}");
									return;
								}
							}
						}
					}
					Say(args, "No coast found within 3 km");
				}

				internal void <Postfix>b__0_2(ConsoleEventArgs args)
				{
					//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
					<>c__DisplayClass0_0 CS$<>8__locals4 = new <>c__DisplayClass0_0
					{
						player = Player.m_localPlayer
					};
					if ((Object)(object)CS$<>8__locals4.player == (Object)null)
					{
						return;
					}
					Character val = (from c in Character.GetAllCharacters()
						where (Object)(object)c != (Object)(object)CS$<>8__locals4.player && !c.IsPlayer() && !c.IsDead()
						orderby Vector3.Distance(((Component)c).transform.position, ((Component)CS$<>8__locals4.player).transform.position)
						select c).FirstOrDefault();
					if ((Object)(object)val == (Object)null)
					{
						Say(args, "No creature nearby");
						return;
					}
					float result;
					float num = ((args.Length > 1 && float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result)) ? result : ElementalEffectsPlugin.FreezeSeconds.Value);
					ZDO zDO = FrostFreeze.GetZDO(val);
					if (zDO == null)
					{
						Say(args, "Creature has no network object");
						return;
					}
					if (!FrostFreeze.IsOwner(val))
					{
						zDO.SetOwner(ZDOMan.GetSessionID());
					}
					zDO.Set(FrostFreeze.ZImmuneUntil, 0L);
					FrostFreeze.Freeze(val, num);
					Say(args, $"Froze {val.m_name} at {Vector3.Distance(((Component)val).transform.position, ((Component)CS$<>8__locals4.player).transform.position):0.0} m for {num:0.0} s");
				}

				internal void <Postfix>b__0_3(ConsoleEventArgs args)
				{
					//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_009c: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00be: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c6: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
					//IL_00da: 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_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_00f5: 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_00fb: 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_0113: 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)
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZNetScene.instance == (Object)null)
					{
						return;
					}
					float result;
					float num = ((args.Length > 1 && float.TryParse(args[1], out result)) ? result : 25f);
					string text = ElementalEffectsPlugin.FrostProjectiles.Value.Split(',')[0].Trim();
					GameObject prefab = ZNetScene.instance.GetPrefab(text);
					if ((Object)(object)prefab == (Object)null)
					{
						Say(args, "No prefab " + text);
						return;
					}
					Vector3 forward = ((Component)localPlayer).transform.forward;
					forward.y = 0f;
					Vector3 val = Quaternion.AngleAxis(num, Vector3.Cross(Vector3.up, ((Vector3)(ref forward)).normalized)) * ((Vector3)(ref forward)).normalized;
					Vector3 val2 = ((Component)localPlayer).transform.position + Vector3.up * 1.5f + ((Vector3)(ref forward)).normalized * 0.8f;
					Projectile component = Object.Instantiate<GameObject>(prefab, val2, Quaternion.LookRotation(val)).GetComponent<Projectile>();
					if (component != null)
					{
						component.Setup((Character)(object)localPlayer, val * 30f, -1f, (HitData)null, (ItemData)null, (ItemData)null);
					}
					Say(args, $"Shot {text} pitch {num}");
				}

				internal void <Postfix>b__0_4(ConsoleEventArgs args)
				{
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_002c: Unknown result type (might be due to invalid IL or missing references)
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0048: 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_0070: Unknown result type (might be due to invalid IL or missing references)
					//IL_0127: Unknown result type (might be due to invalid IL or missing references)
					//IL_013f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0157: Unknown result type (might be due to invalid IL or missing references)
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer != (Object)null)
					{
						Vector3 position = ((Component)localPlayer).transform.position;
						string text = $"player at {position.x:0.0},{position.y:0.00},{position.z:0.0} water {Floating.GetLiquidLevel(position, 0f, (LiquidType)10):0.00} ground {ZoneSystem.instance.GetGroundHeight(position):0.00} ";
						object arg = ((Character)localPlayer).IsOnGround();
						object arg2 = ((Character)localPlayer).IsSwimming();
						object arg3;
						if (!((Object)(object)((Character)localPlayer).GetStandingOnShip() != (Object)null))
						{
							Collider lastGroundCollider = ((Character)localPlayer).GetLastGroundCollider();
							arg3 = ((lastGroundCollider != null) ? ((Object)lastGroundCollider).name : null) ?? "none";
						}
						else
						{
							arg3 = "ship";
						}
						Say(args, text + $"onGround={arg} swimming={arg2} standingOn={arg3}");
					}
					foreach (IceSheet item in IceSheet.Instances.Where((IceSheet s) => (Object)(object)s != (Object)null))
					{
						Say(args, $"sheet {((Component)item).transform.position.x:0.0},{((Component)item).transform.position.y:0.00},{((Component)item).transform.position.z:0.0} {item.Describe()}");
					}
				}

				internal bool <Postfix>b__0_7(IceSheet s)
				{
					return (Object)(object)s != (Object)null;
				}
			}

			[CompilerGenerated]
			private sealed class <>c__DisplayClass0_0
			{
				public Player player;

				internal bool <Postfix>b__5(Character c)
				{
					if ((Object)(object)c != (Object)(object)player && !c.IsPlayer())
					{
						return !c.IsDead();
					}
					return false;
				}

				internal float <Postfix>b__6(Character c)
				{
					//IL_0006: 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)
					return Vector3.Distance(((Component)c).transform.position, ((Component)player).transform.position);
				}
			}

			private static void Postfix()
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				//IL_006c: 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_0062: Expected O, but got Unknown
				//IL_00a5: 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_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Expected O, but got Unknown
				//IL_00de: 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_00d4: Expected O, but got Unknown
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Expected O, but got Unknown
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						//IL_0034: Unknown result type (might be due to invalid IL or missing references)
						//IL_0067: 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_0070: 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_008c: 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_00b0: 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_00be: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
						//IL_00e3: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
						//IL_010e: Unknown result type (might be due to invalid IL or missing references)
						Player localPlayer = Player.m_localPlayer;
						if (!((Object)(object)localPlayer == (Object)null))
						{
							int result;
							int num = ((args.Length > 1 && int.TryParse(args[1], out result)) ? result : 4);
							if (!FindWater(((Component)localPlayer).transform.position, out var water, out var dir))
							{
								Say(args, "No open water within 400 m");
							}
							else
							{
								float num2 = ElementalEffectsPlugin.SheetSpacing.Value * 1.2f;
								for (int i = 0; i < num; i++)
								{
									FrostIce.FreezeAt(water + dir * (num2 * (float)i));
								}
								Vector3 val6 = default(Vector3);
								((Vector3)(ref val6))..ctor(water.x, Floating.GetLiquidLevel(water, 0f, (LiquidType)10) + ElementalEffectsPlugin.TopAboveWater.Value + 1f, water.z);
								((Character)localPlayer).TeleportTo(val6, Quaternion.LookRotation(dir), false);
								Say(args, $"Froze {num} sheets from {water.x:0},{water.z:0} heading {dir.x:0.0},{dir.z:0.0}");
							}
						}
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("ee_icetest", "[count] - freeze a path of ice sheets on open water nearby and stand on it", (ConsoleEvent)obj, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj2 = <>c.<>9__0_1;
				if (obj2 == null)
				{
					ConsoleEvent val2 = delegate(ConsoleEventArgs args)
					{
						//IL_001d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0022: Unknown result type (might be due to invalid IL or missing references)
						//IL_0047: Unknown result type (might be due to invalid IL or missing references)
						//IL_004c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0051: Unknown result type (might be due to invalid IL or missing references)
						//IL_0056: Unknown result type (might be due to invalid IL or missing references)
						//IL_0058: Unknown result type (might be due to invalid IL or missing references)
						//IL_0059: Unknown result type (might be due to invalid IL or missing references)
						//IL_005c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0061: Unknown result type (might be due to invalid IL or missing references)
						//IL_0066: Unknown result type (might be due to invalid IL or missing references)
						//IL_006d: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
						//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c4: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
						//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
						//IL_00e7: 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_0110: 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_0125: 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_0152: 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_0160: Unknown result type (might be due to invalid IL or missing references)
						//IL_017a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0189: Unknown result type (might be due to invalid IL or missing references)
						//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
						//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
						Player localPlayer = Player.m_localPlayer;
						if (!((Object)(object)localPlayer == (Object)null) && WorldGenerator.instance != null)
						{
							Vector3 position = ((Component)localPlayer).transform.position;
							for (float num = 0f; num < 3000f; num += 16f)
							{
								for (int i = 0; i < 32; i++)
								{
									Vector3 val6 = Quaternion.Euler(0f, (float)i * 11.25f, 0f) * Vector3.forward;
									Vector3 val7 = position + val6 * num;
									float height = WorldGenerator.instance.GetHeight(val7.x, val7.z);
									if (!(height < 31f) && !(height > 34f))
									{
										for (int j = 0; j < 16; j++)
										{
											Vector3 val8 = Quaternion.Euler(0f, (float)j * 22.5f, 0f) * Vector3.forward;
											if (WorldGenerator.instance.GetHeight(val7.x + val8.x * 14f, val7.z + val8.z * 14f) < 25f && WorldGenerator.instance.GetHeight(val7.x + val8.x * 30f, val7.z + val8.z * 30f) < 24f)
											{
												((Character)localPlayer).TeleportTo(new Vector3(val7.x, height + 1f, val7.z), Quaternion.LookRotation(val8), true);
												Say(args, $"Coast at {val7.x:0},{val7.z:0} (height {height:0.0}), sea to {val8.x:0.0},{val8.z:0.0}");
												return;
											}
										}
									}
								}
							}
							Say(args, "No coast found within 3 km");
						}
					};
					<>c.<>9__0_1 = val2;
					obj2 = (object)val2;
				}
				new ConsoleCommand("ee_findcoast", "- teleport to the nearest coast (land with deep water ahead), facing the sea", (ConsoleEvent)obj2, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj3 = <>c.<>9__0_2;
				if (obj3 == null)
				{
					ConsoleEvent val3 = delegate(ConsoleEventArgs args)
					{
						//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
						//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
						Player player = Player.m_localPlayer;
						if (!((Object)(object)player == (Object)null))
						{
							Character val6 = (from c in Character.GetAllCharacters()
								where (Object)(object)c != (Object)(object)player && !c.IsPlayer() && !c.IsDead()
								orderby Vector3.Distance(((Component)c).transform.position, ((Component)player).transform.position)
								select c).FirstOrDefault();
							if ((Object)(object)val6 == (Object)null)
							{
								Say(args, "No creature nearby");
							}
							else
							{
								float result;
								float num = ((args.Length > 1 && float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result)) ? result : ElementalEffectsPlugin.FreezeSeconds.Value);
								ZDO zDO = FrostFreeze.GetZDO(val6);
								if (zDO == null)
								{
									Say(args, "Creature has no network object");
								}
								else
								{
									if (!FrostFreeze.IsOwner(val6))
									{
										zDO.SetOwner(ZDOMan.GetSessionID());
									}
									zDO.Set(FrostFreeze.ZImmuneUntil, 0L);
									FrostFreeze.Freeze(val6, num);
									Say(args, $"Froze {val6.m_name} at {Vector3.Distance(((Component)val6).transform.position, ((Component)player).transform.position):0.0} m for {num:0.0} s");
								}
							}
						}
					};
					<>c.<>9__0_2 = val3;
					obj3 = (object)val3;
				}
				new ConsoleCommand("ee_freeze", "[seconds] - freeze the nearest creature (as if wet and hit by frost)", (ConsoleEvent)obj3, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj4 = <>c.<>9__0_3;
				if (obj4 == null)
				{
					ConsoleEvent val4 = delegate(ConsoleEventArgs args)
					{
						//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_009c: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
						//IL_00be: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c6: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
						//IL_00da: 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_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_00f5: 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_00fb: 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_0113: 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)
						Player localPlayer = Player.m_localPlayer;
						if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)ZNetScene.instance == (Object)null))
						{
							float result;
							float num = ((args.Length > 1 && float.TryParse(args[1], out result)) ? result : 25f);
							string text = ElementalEffectsPlugin.FrostProjectiles.Value.Split(',')[0].Trim();
							GameObject prefab = ZNetScene.instance.GetPrefab(text);
							if ((Object)(object)prefab == (Object)null)
							{
								Say(args, "No prefab " + text);
							}
							else
							{
								Vector3 forward = ((Component)localPlayer).transform.forward;
								forward.y = 0f;
								Vector3 val6 = Quaternion.AngleAxis(num, Vector3.Cross(Vector3.up, ((Vector3)(ref forward)).normalized)) * ((Vector3)(ref forward)).normalized;
								Vector3 val7 = ((Component)localPlayer).transform.position + Vector3.up * 1.5f + ((Vector3)(ref forward)).normalized * 0.8f;
								Projectile component = Object.Instantiate<GameObject>(prefab, val7, Quaternion.LookRotation(val6)).GetComponent<Projectile>();
								if (component != null)
								{
									component.Setup((Character)(object)localPlayer, val6 * 30f, -1f, (HitData)null, (ItemData)null, (ItemData)null);
								}
								Say(args, $"Shot {text} pitch {num}");
							}
						}
					};
					<>c.<>9__0_3 = val4;
					obj4 = (object)val4;
				}
				new ConsoleCommand("ee_shoot", "[pitch] - fire a frost shard from you at the water ahead", (ConsoleEvent)obj4, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj5 = <>c.<>9__0_4;
				if (obj5 == null)
				{
					ConsoleEvent val5 = delegate(ConsoleEventArgs args)
					{
						//IL_0018: Unknown result type (might be due to invalid IL or missing references)
						//IL_001d: Unknown result type (might be due to invalid IL or missing references)
						//IL_002c: Unknown result type (might be due to invalid IL or missing references)
						//IL_003a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0048: 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_0070: Unknown result type (might be due to invalid IL or missing references)
						//IL_0127: Unknown result type (might be due to invalid IL or missing references)
						//IL_013f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0157: Unknown result type (might be due to invalid IL or missing references)
						Player localPlayer = Player.m_localPlayer;
						if ((Object)(object)localPlayer != (Object)null)
						{
							Vector3 position = ((Component)localPlayer).transform.position;
							string text = $"player at {position.x:0.0},{position.y:0.00},{position.z:0.0} water {Floating.GetLiquidLevel(position, 0f, (LiquidType)10):0.00} ground {ZoneSystem.instance.GetGroundHeight(position):0.00} ";
							object arg = ((Character)localPlayer).IsOnGround();
							object arg2 = ((Character)localPlayer).IsSwimming();
							object arg3;
							if (!((Object)(object)((Character)localPlayer).GetStandingOnShip() != (Object)null))
							{
								Collider lastGroundCollider = ((Character)localPlayer).GetLastGroundCollider();
								arg3 = ((lastGroundCollider != null) ? ((Object)lastGroundCollider).name : null) ?? "none";
							}
							else
							{
								arg3 = "ship";
							}
							Say(args, text + $"onGround={arg} swimming={arg2} standingOn={arg3}");
						}
						foreach (IceSheet item in IceSheet.Instances.Where((IceSheet s) => (Object)(object)s != (Object)null))
						{
							Say(args, $"sheet {((Component)item).transform.position.x:0.0},{((Component)item).transform.position.y:0.00},{((Component)item).transform.position.z:0.0} {item.Describe()}");
						}
					};
					<>c.<>9__0_4 = val5;
					obj5 = (object)val5;
				}
				new ConsoleCommand("ee_status", "log the player's footing and the loaded ice sheets", (ConsoleEvent)obj5, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}
		}

		private static void Say(ConsoleEventArgs args, string s)
		{
			Terminal context = args.Context;
			if (context != null)
			{
				context.AddString(s);
			}
			ElementalEffectsPlugin.Log.LogInfo((object)s);
		}

		private static bool FindWater(Vector3 from, out Vector3 water, out Vector3 dir)
		{
			//IL_00dc: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			for (float num = 6f; num < 400f; num += 4f)
			{
				for (int i = 0; i < 16; i++)
				{
					dir = Quaternion.Euler(0f, (float)i * 22.5f, 0f) * Vector3.forward;
					water = from + dir * num;
					if (Deep(water) && Deep(water + dir * 8f) && Deep(water + dir * 16f))
					{
						water.y = Floating.GetLiquidLevel(water, 0f, (LiquidType)10);
						return true;
					}
				}
			}
			water = from;
			dir = Vector3.forward;
			return false;
		}

		private static bool Deep(Vector3 p)
		{
			//IL_0000: 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)
			float liquidLevel = Floating.GetLiquidLevel(p, 0f, (LiquidType)0);
			if (liquidLevel > -1000f)
			{
				return ZoneSystem.instance.GetGroundHeight(p) < liquidLevel - 3f;
			}
			return false;
		}
	}
	[BepInPlugin("com.chase.elementaleffects", "ElementalEffects", "1.0.0")]
	public class ElementalEffectsPlugin : BaseUnityPlugin
	{
		public const string Guid = "com.chase.elementaleffects";

		public const string ModName = "ElementalEffects";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> FrostIceEnabled;

		internal static ConfigEntry<string> FrostProjectiles;

		internal static ConfigEntry<string> IcePrefab;

		internal static ConfigEntry<float> IceSkillBonus;

		internal static ConfigEntry<float> FreezeSkillBonus;

		internal static ConfigEntry<float> SheetDuration;

		internal static ConfigEntry<float> CrackTime;

		internal static ConfigEntry<float> SheetWidth;

		internal static ConfigEntry<float> SheetSpacing;

		internal static ConfigEntry<float> TopAboveWater;

		internal static ConfigEntry<float> NearbyRadius;

		internal static ConfigEntry<float> WaveFollow;

		internal static ConfigEntry<float> WaveTilt;

		internal static ConfigEntry<float> MaxTilt;

		internal static ConfigEntry<float> WaveClearance;

		internal static ConfigEntry<float> IceDensity;

		internal static ConfigEntry<float> Thickness;

		internal static ConfigEntry<float> WaterDrag;

		internal static ConfigEntry<float> PlayerMass;

		internal static ConfigEntry<int> MaxSheetsNearby;

		internal static ConfigEntry<bool> ShardStopsAtWater;

		internal static ConfigEntry<bool> RefreshOnHit;

		internal static ConfigEntry<bool> FreezeEnabled;

		internal static ConfigEntry<bool> FreezeRainCountsAsWet;

		internal static ConfigEntry<bool> FreezePlayers;

		internal static ConfigEntry<bool> FreezeBosses;

		internal static ConfigEntry<bool> FreezeThawOnFire;

		internal static ConfigEntry<bool> FreezeShellCollider;

		internal static ConfigEntry<float> FreezeSeconds;

		internal static ConfigEntry<float> FreezeBossSeconds;

		internal static ConfigEntry<float> FreezeImmunity;

		internal static ConfigEntry<float> FreezeShatterBonus;

		internal static ConfigEntry<float> FreezeCreepTime;

		internal static ConfigEntry<float> FreezeThawFade;

		internal static ConfigEntry<float> FreezeShellTiling;

		internal static ConfigEntry<float> FreezeShellGloss;

		internal static ConfigEntry<Color> FreezeShellTint;

		internal static ConfigEntry<string> FreezeShellSource;

		internal static ConfigEntry<string> FreezeShatterEffects;

		internal static ConfigEntry<bool> FuelEnabled;

		internal static ConfigEntry<string> FuelProjectiles;

		internal static ConfigEntry<string> FuelSmelterItems;

		internal static ConfigEntry<int> FuelCoalPerHit;

		internal static ConfigEntry<float> FuelRadius;

		internal static ConfigEntry<bool> NatureEnabled;

		internal static ConfigEntry<bool> SeedScatter;

		internal static ConfigEntry<string> NatureStaffs;

		internal static ConfigEntry<string> NatureProjectiles;

		internal static ConfigEntry<float> NatureRadius;

		internal static ConfigEntry<float> FertilizeBoost;

		internal static ConfigEntry<float> NatureEnemyRadius;

		internal static ConfigEntry<int> SeedsPerHit;

		private Harmony _harmony;

		internal static float SkillFactor(float level, float bonus)
		{
			return 1f + bonus * Mathf.Clamp01(level / 100f);
		}

		internal static float IceSeconds()
		{
			Player localPlayer = Player.m_localPlayer;
			float level = (((Object)(object)localPlayer != (Object)null) ? ((Character)localPlayer).GetSkillLevel((SkillType)9) : 0f);
			return SheetDuration.Value * SkillFactor(level, IceSkillBonus.Value);
		}

		private void Awake()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Expected O, but got Unknown
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Expected O, but got Unknown
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Expected O, but got Unknown
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Expected O, but got Unknown
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Expected O, but got Unknown
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Expected O, but got Unknown
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Expected O, but got Unknown
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Expected O, but got Unknown
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Expected O, but got Unknown
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Expected O, but got Unknown
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Expected O, but got Unknown
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Expected O, but got Unknown
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Expected O, but got Unknown
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Expected O, but got Unknown
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Expected O, but got Unknown
			//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bc: Expected O, but got Unknown
			//IL_0957: Unknown result type (might be due to invalid IL or missing references)
			//IL_0961: Expected O, but got Unknown
			//IL_0994: Unknown result type (might be due to invalid IL or missing references)
			//IL_099e: Expected O, but got Unknown
			//IL_0a0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a15: Expected O, but got Unknown
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2a: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Game.isModded = true;
			FrostIceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostIce", "Enabled", true, "Frost projectiles that hit open water freeze it into temporary ice sheets.");
			FrostProjectiles = ((BaseUnityPlugin)this).Config.Bind<string>("FrostIce", "Projectiles", "staff_iceshard_projectile", "Comma-separated projectile prefab names that freeze water (default: the Staff of Frost's shards). Read when a world loads.");
			IcePrefab = ((BaseUnityPlugin)this).Config.Bind<string>("FrostIce", "IcePrefab", "IceShore_frac", "Vanilla breakable ice sheet whose pieces the floes are cut from (Deep North shore ice). Read when a world loads.");
			SheetDuration = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "Duration2", 20f, new ConfigDescription("Seconds an ice sheet lasts after it was made or last refreshed, including the cracking time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 600f), Array.Empty<object>()));
			IceSkillBonus = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "SkillBonus", 1f, new ConfigDescription("Elemental Magic makes the ice last longer: at skill 100 it lasts this much longer (1 = twice as long), scaling evenly from skill 0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			CrackTime = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "CrackTime2", 4f, new ConfigDescription("The last seconds of a sheet's life: it cracks and slowly settles into the water as a warning, then breaks up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>()));
			SheetWidth = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "SheetWidth", 16f, new ConfigDescription("Width in metres of the ice sheet one shard freezes: the whole vanilla Deep North sheet scaled down to this (never up), already cracked into chunks that fit together, and every chunk floats on its own. Chunks are about a third of this wide.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 45f), Array.Empty<object>()));
			SheetSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "Spacing", 2.2f, new ConfigDescription("A shard landing closer than this (metres) to an existing chunk refreshes that sheet instead of freezing a new one.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			TopAboveWater = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "TopAboveWater", 0.18f, new ConfigDescription("How far the top of a fresh sheet sits above calm water level, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			WaveFollow = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "WaveFollow", 1f, new ConfigDescription("How much floes rise and fall with the waves (0 = fixed at calm level, 1 = ride the swell).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.5f), Array.Empty<object>()));
			WaveTilt = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "WaveTilt", 1f, new ConfigDescription("How much floes tilt with the slope of the waves under them (0 = stay level).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			WaveClearance = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "WaveClearance", 0.1f, new ConfigDescription("Extra metres a floe keeps its top above the highest wave under it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			MaxTilt = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "MaxTiltDegrees", 20f, new ConfigDescription("Largest tilt in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			IceDensity = ((BaseUnityPlugin)this).Config.Bind<float>("FloeSim", "IceDensity", 760f, new ConfigDescription("Buoyancy: density of the floe in kg/m3 (sea water is 1025, real sea ice ~920). Lower floats higher and bobs livelier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(300f, 1000f), Array.Empty<object>()));
			Thickness = ((BaseUnityPlugin)this).Config.Bind<float>("FloeSim", "Thickness", 0.6f, new ConfigDescription("Buoyancy: simulated slab thickness in metres. Thinner = lighter, tips more under weight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			WaterDrag = ((BaseUnityPlugin)this).Config.Bind<float>("FloeSim", "WaterDrag", 0.25f, new ConfigDescription("Damping ratio from water drag: low = rocks on after a wave, 1 = settles at once.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 2f), Array.Empty<object>()));
			PlayerMass = ((BaseUnityPlugin)this).Config.Bind<float>("FloeSim", "PlayerMass", 120f, new ConfigDescription("Weight in kg a player (with gear) puts on a floe where they stand. 0 = weightless.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2000f), Array.Empty<object>()));
			MaxSheetsNearby = ((BaseUnityPlugin)this).Config.Bind<int>("FrostIce", "MaxChunksNearby", 220, new ConfigDescription("No new chunks are made when this many already exist within NearbyRadius (existing ones are still refreshed).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 500), Array.Empty<object>()));
			NearbyRadius = ((BaseUnityPlugin)this).Config.Bind<float>("FrostIce", "NearbyRadius", 64f, new ConfigDescription("Radius in metres for MaxSheetsNearby.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 500f), Array.Empty<object>()));
			ShardStopsAtWater = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostIce", "ShardStopsAtWater", true, "The shard that freezes the water ends there (vanilla shards would keep going underwater).");
			RefreshOnHit = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostIce", "RefreshOnHit", true, "Frost shards hitting an existing ice sheet refresh its timer.");
			FreezeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostFreeze", "Enabled", true, "A Wet creature hit by frost freezes solid for a moment inside a shell of ice.");
			FreezeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "Seconds", 3f, new ConfigDescription("How long a creature stays frozen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>()));
			FreezeSkillBonus = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "SkillBonus", 1f, new ConfigDescription("The caster's Elemental Magic makes the freeze last longer: at skill 100 it lasts this much longer (1 = twice as long), scaling evenly from skill 0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			FreezeBossSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "BossSeconds", 1f, new ConfigDescription("How long a boss stays frozen (only if FreezeBosses).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			FreezeImmunity = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "ImmunitySeconds", 6f, new ConfigDescription("After thawing or shattering, a creature can't be frozen again for this long.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
			FreezeRainCountsAsWet = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostFreeze", "RainCountsAsWet", true, "Creatures out in the rain count as wet (vanilla only makes creatures Wet in water).");
			FreezePlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostFreeze", "FreezePlayers", false, "Players can be frozen too (PvP).");
			FreezeBosses = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostFreeze", "FreezeBosses", false, "Bosses can be frozen (for BossSeconds).");
			FreezeThawOnFire = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostFreeze", "FireMelts", true, "Fire damage melts a frozen creature free at once.");
			FreezeShatterBonus = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "ShatterBonus", 2f, new ConfigDescription("Damage multiplier of the blunt or pickaxe hit that shatters the ice (vanilla stagger hits are 2x).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			FreezeCreepTime = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "CreepTime", 0.45f, new ConfigDescription("Seconds the ice takes to creep from the feet to the head.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			FreezeThawFade = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "ThawFade", 2.5f, new ConfigDescription("Seconds the frost on a thawed creature takes to fade.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			FreezeShellTiling = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "IceTiling", 3f, new ConfigDescription("How many times the ice's surface (normal map) repeats across a creature's texture layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			FreezeShellTint = ((BaseUnityPlugin)this).Config.Bind<Color>("FrostFreeze", "IceTint3", new Color(0.7f, 0.82f, 0.92f, 1f), "Multiplies the vanilla ice colour on a frozen creature (below 1 = deeper, less glaring ice).");
			FreezeShellGloss = ((BaseUnityPlugin)this).Config.Bind<float>("FrostFreeze", "IceGloss", 0.75f, new ConfigDescription("Smoothness of the ice on a frozen creature (shine of the sun on it).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			FreezeShellCollider = ((BaseUnityPlugin)this).Config.Bind<bool>("FrostFreeze", "ShellCollider", true, "The ice shell is solid: you can stand on a frozen creature.");
			FreezeShellSource = ((BaseUnityPlugin)this).Config.Bind<string>("FrostFreeze", "ShellMaterialFrom", "IceShore_frac", "Vanilla prefab whose ice material the shell uses. Read when first needed.");
			FreezeShatterEffects = ((BaseUnityPlugin)this).Config.Bind<string>("FrostFreeze", "ShatterEffects2", "vfx_ice_destroyed,sfx_ice_destroyed", "Comma-separated vanilla effect prefabs played when a frozen creature shatters (empty = the ice sheet's crack effect). Read when a world loads.");
			FuelEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("FireFuel", "Enabled", true, "Staff of Embers fireballs fill torches, hearths, braziers and campfires, and add coal to smelters and furnaces, without harming your buildings.");
			FuelProjectiles = ((BaseUnityPlugin)this).Config.Bind<string>("FireFuel", "Projectiles", "staff_fireball_projectile", "Comma-separated projectile prefab names that fuel fires (default: the Staff of Embers fireball). Read when a world loads.");
			FuelSmelterItems = ((BaseUnityPlugin)this).Config.Bind<string>("FireFuel", "SmelterFuels", "Coal", "Smelters/furnaces whose fuel is one of these items can be fed by fireballs. Read when a world loads.");
			FuelCoalPerHit = ((BaseUnityPlugin)this).Config.Bind<int>("FireFuel", "CoalPerHit", 2, new ConfigDescription("Coal a fireball adds to a smelter or furnace.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			FuelRadius = ((BaseUnityPlugin)this).Config.Bind<float>("FireFuel", "Radius", 1.5f, new ConfigDescription("Metres around the impact (at least the fireball's own blast) in which fires are fed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 10f), Array.Empty<object>()));
			NatureEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("NatureStaff", "Enabled", true, "Nature staff hits fertilize plants and scatter seeds from your inventory.");
			NatureStaffs = ((BaseUnityPlugin)this).Config.Bind<string>("NatureStaff", "Staffs", "StaffGreenRoots", "Comma-separated staff item names whose projectiles tend gardens (default: the Staff of the Wild). Read when a world loads.");
			NatureProjectiles = ((BaseUnityPlugin)this).Config.Bind<string>("NatureStaff", "ExtraProjectiles", "", "Extra projectile prefab names that count as nature magic. Read when a world loads.");
			NatureRadius = ((BaseUnityPlugin)this).Config.Bind<float>("NatureStaff", "Radius", 3.5f, new ConfigDescription("Metres around the impact that get fertilized and planted.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			FertilizeBoost = ((BaseUnityPlugin)this).Config.Bind<float>("NatureStaff", "FertilizeBoost", 0.25f, new ConfigDescription("Share of a plant's grow time a fertilizing hit skips (once per plant).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			NatureEnemyRadius = ((BaseUnityPlugin)this).Config.Bind<float>("NatureStaff", "EnemyRadius", 8f, "An enemy within this many metres of the impact makes it a normal combat shot (roots spawn, no gardening).");
			SeedScatter = ((BaseUnityPlugin)this).Config.Bind<bool>("NatureStaff", "SeedScatter", true, "Hits plant seeds from your inventory in the free spots around the impact.");
			SeedsPerHit = ((BaseUnityPlugin)this).Config.Bind<int>("NatureStaff", "SeedsPerHit", 12, new ConfigDescription("Most seeds one hit plants.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 60), Array.Empty<object>()));
			_harmony = new Harmony("com.chase.elementaleffects");
			_harmony.PatchAll(typeof(ElementalEffectsPlugin).Assembly);
			Log.LogInfo((object)"ElementalEffects 1.0.0 loaded");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class FireFuel
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class LogFireballs
		{
			private static void Postfix(ZNetScene __instance)
			{
				_projectiles = Names(ElementalEffectsPlugin.FuelProjectiles.Value);
				_coalItems = Names(ElementalEffectsPlugin.FuelSmelterItems.Value);
				foreach (string projectile in _projectiles)
				{
					GameObject prefab = __instance.GetPrefab(projectile);
					Projectile val = ((prefab != null) ? prefab.GetComponent<Projectile>() : null);
					if ((Object)(object)val == (Object)null)
					{
						ElementalEffectsPlugin.Log.LogWarning((object)("Fuel projectile '" + projectile + "' not found"));
						continue;
					}
					ElementalEffectsPlugin.Log.LogInfo((object)string.Format("Fuel projectile {0}: aoe {1}, fire {2}, spawnOnHit {3}, random spawns {4}", projectile, val.m_aoe, val.m_damage.m_fire, Object.op_Implicit((Object)(object)val.m_spawnOnHit) ? ((Object)val.m_spawnOnHit).name : "-", val.m_randomSpawnOnHit?.Count ?? 0));
				}
			}
		}

		[HarmonyPatch(typeof(Projectile), "OnHit")]
		private static class OnHitPatch
		{
			private static void Prefix(Projectile __instance, Collider collider, Vector3 hitPoint, bool water, ref bool __state)
			{
				//IL_0037: 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_00a1: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
				__state = false;
				if (!ElementalEffectsPlugin.FuelEnabled.Value || water || _projectiles == null || !_projectiles.Contains(Utils.GetPrefabName(((Component)__instance).gameObject)))
				{
					return;
				}
				ProjectileHits.Trace(__instance, collider, hitPoint, Vector3.zero);
				if (ProjectileHits.Ignored(__instance, collider))
				{
					return;
				}
				if (_mask == 0)
				{
					_mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" });
				}
				float num = Mathf.Max(__instance.m_aoe, ElementalEffectsPlugin.FuelRadius.Value);
				Collider[] array = Physics.OverlapSphere(hitPoint, num, _mask, (QueryTriggerInteraction)2);
				if ((Object)(object)collider != (Object)null)
				{
					array = array.Append(collider).ToArray();
				}
				HashSet<Fireplace> fires = new HashSet<Fireplace>();
				HashSet<Smelter> smelters = new HashSet<Smelter>();
				HashSet<CookingStation> ovens = new HashSet<CookingStation>();
				Collider[] array2 = array;
				foreach (Collider val in array2)
				{
					if ((Object)(object)val != (Object)null)
					{
						Consider((Component)(object)val);
					}
				}
				_pieces.Clear();
				Piece.GetAllPiecesInRadius(hitPoint, num + 1f, _pieces);
				foreach (Piece piece in _pieces)
				{
					if ((Object)(object)piece != (Object)null)
					{
						Consider((Component)(object)piece);
					}
				}
				if (fires.Count == 0 && smelters.Count == 0 && ovens.Count == 0)
				{
					return;
				}
				bool flag = Done.Add(((Object)__instance).GetInstanceID());
				if (flag)
				{
					ElementalEffectsPlugin.Log.LogInfo((object)string.Format("Fireball at {0} (radius {1:0.0}) fuels {2}", hitPoint, num, string.Join(", ", fires.Select((Fireplace f) => ((Object)f).name).Concat(smelters.Select((Smelter m) => ((Object)m).name)).Concat(ovens.Select((CookingStation o) => ((Object)o).name)))));
				}
				if (Done.Count > 256)
				{
					Done.Clear();
					Done.Add(((Object)__instance).GetInstanceID());
				}
				foreach (Fireplace item in flag ? fires : new HashSet<Fireplace>())
				{
					ZNetView val2 = FireplaceView.Invoke(item);
					if (!((Object)(object)val2 == (Object)null) && val2.IsValid() && val2.GetZDO().GetFloat(ZDOVars.s_fuel, 0f) < item.m_maxFuel)
					{
						item.SetFuel(item.m_maxFuel);
					}
				}
				foreach (Smelter item2 in flag ? smelters : new HashSet<Smelter>())
				{
					ZNetView val3 = SmelterView.Invoke(item2);
					if (!((Object)(object)val3 == (Object)null) && val3.IsValid())
					{
						float num2 = val3.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
						int num3 = Mathf.Min(ElementalEffectsPlugin.FuelCoalPerHit.Value, Mathf.FloorToInt((float)item2.m_maxFuel - num2));
						for (int num4 = 0; num4 < num3; num4++)
						{
							val3.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
						}
					}
				}
				foreach (CookingStation item3 in flag ? ovens : new HashSet<CookingStation>())
				{
					ZNetView val4 = OvenView.Invoke(item3);
					if (!((Object)(object)val4 == (Object)null) && val4.IsValid())
					{
						int num5 = Mathf.FloorToInt((float)item3.m_maxFuel - val4.GetZDO().GetFloat(ZDOVars.s_fuel, 0f));
						for (int num6 = 0; num6 < num5; num6++)
						{
							val4.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
						}
					}
				}
				__instance.m_aoeSkipWearNTear = true;
				__instance.m_spawnOnHit = null;
				__instance.m_randomSpawnOnHit = new List<GameObject>();
				__instance.m_spawnItem = null;
				_sparePieces = true;
				__state = true;
				void Consider(Component c)
				{
					Fireplace componentInParent = c.GetComponentInParent<Fireplace>();
					if ((Object)(object)componentInParent != (Object)null && componentInParent.m_canRefill && !componentInParent.m_infiniteFuel)
					{
						fires.Add(componentInParent);
					}
					Smelter componentInParent2 = c.GetComponentInParent<Smelter>();
					if ((Object)(object)componentInParent2 != (Object)null && componentInParent2.m_maxFuel > 0 && (Object)(object)componentInParent2.m_fuelItem != (Object)null && _coalItems.Contains(((Object)componentInParent2.m_fuelItem).name))
					{
						smelters.Add(componentInParent2);
					}
					CookingStation componentInParent3 = c.GetComponentInParent<CookingStation>();
					if ((Object)(object)componentInParent3 != (Object)null && componentInParent3.m_useFuel && componentInParent3.m_maxFuel > 0)
					{
						ovens.Add(componentInParent3);
					}
				}
			}

			private static void Postfix(bool __state)
			{
				if (__state)
				{
					_sparePieces = false;
				}
			}

			private static Exception Finalizer(Exception __exception)
			{
				_sparePieces = false;
				return __exception;
			}
		}

		[HarmonyPatch(typeof(WearNTear), "Damage")]
		private static class SpareWearNTear
		{
			private static bool Prefix()
			{
				return !_sparePieces;
			}
		}

		private static HashSet<string> _projectiles;

		private static HashSet<string> _coalItems;

		private static readonly FieldRef<Smelter, ZNetView> SmelterView = AccessTools.FieldRefAccess<Smelter, ZNetView>("m_nview");

		private static readonly FieldRef<CookingStation, ZNetView> OvenView = AccessTools.FieldRefAccess<CookingStation, ZNetView>("m_nview");

		private static readonly FieldRef<Fireplace, ZNetView> FireplaceView = AccessTools.FieldRefAccess<Fireplace, ZNetView>("m_nview");

		private static int _mask;

		private static readonly List<Piece> _pieces = new List<Piece>();

		private static readonly HashSet<int> Done = new HashSet<int>();

		private static bool _sparePieces;

		private static HashSet<string> Names(string csv)
		{
			return new HashSet<string>(from s in csv.Split(',')
				select s.Trim() into s
				where s.Length > 0
				select s);
		}
	}
	internal static class FrostFreeze
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class SetupFx
		{
			[HarmonyPriority(0)]
			private static void Postfix(ZNetScene __instance)
			{
				ShatterFx.Clear();
				foreach (string item in from s in ElementalEffectsPlugin.FreezeShatterEffects.Value.Split(',')
					select s.Trim() into s
					where s.Length > 0
					select s)
				{
					GameObject prefab = __instance.GetPrefab(item);
					if ((Object)(object)prefab != (Object)null)
					{
						ShatterFx.Add(prefab);
					}
					else
					{
						ElementalEffectsPlugin.Log.LogWarning((object)("Shatter effect '" + item + "' not found"));
					}
				}
				IEnumerable<string> values = from p in __instance.m_prefabs
					where (Object)(object)p != (Object)null && (((Object)p).name.StartsWith("fx_") || ((Object)p).name.StartsWith("vfx_") || ((Object)p).name.StartsWith("sfx_"))
					select ((Object)p).name into n
					where n.IndexOf("ice", StringComparison.OrdinalIgnoreCase) >= 0 || n.IndexOf("frost", StringComparison.OrdinalIgnoreCase) >= 0
					select n;
				ElementalEffectsPlugin.Log.LogInfo((object)string.Format("Frozen creatures: shatter fx {0}; vanilla ice/frost effects: {1}", ShatterFx.Count, string.Join(", ", values)));
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class StashHitPatch
		{
			private static void Prefix(HitData hit)
			{
				_applying = hit;
			}

			private static void Finalizer()
			{
				_applying = null;
			}
		}

		[HarmonyPatch(typeof(Character), "AddFrostDamage")]
		private static class AddFrostDamagePatch
		{
			private static void Postfix(Character __instance, float damage)
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Invalid comparison between Unknown and I4
				if (ElementalEffectsPlugin.FreezeEnabled.Value && !(damage <= 0f) && IsOwner(__instance) && CanFreeze(__instance) && IsWet(__instance))
				{
					float num = (__instance.IsBoss() ? ElementalEffectsPlugin.FreezeBossSeconds.Value : ElementalEffectsPlugin.FreezeSeconds.Value);
					HitData applying = _applying;
					if (applying != null && (int)applying.m_skill == 9)
					{
						num *= ElementalEffectsPlugin.SkillFactor(applying.m_skillLevel, ElementalEffectsPlugin.FreezeSkillBonus.Value);
					}
					if (num > 0f)
					{
						Freeze(__instance, num);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class RPCDamagePatch
		{
			private static void Prefix(Character __instance, HitData hit)
			{
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Invalid comparison between Unknown and I4
				if (hit != null && IsOwner(__instance) && IsFrozen(__instance))
				{
					if (hit.m_damage.m_fire > 0f && ElementalEffectsPlugin.FreezeThawOnFire.Value)
					{
						EndFreeze(__instance, shattered: false);
					}
					else if ((hit.m_damage.m_blunt > 0f || hit.m_damage.m_pickaxe > 0f) && (int)hit.m_skill != 9)
					{
						hit.ApplyModifier(ElementalEffectsPlugin.FreezeShatterBonus.Value);
						EndFreeze(__instance, shattered: true);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "CustomFixedUpdate")]
		private static class WatchPatch
		{
			private static void Postfix(Character __instance)
			{
				ZDO zDO = GetZDO(__instance);
				if (zDO != null && zDO.GetLong(ZFrozenUntil, 0L) > Now && (Object)(object)((Component)__instance).GetComponent<FrozenCharacter>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<FrozenCharacter>();
				}
			}
		}

		[HarmonyPatch(typeof(BaseAI), "UpdateAI")]
		private static class UpdateAIPatch
		{
			private static bool Prefix(BaseAI __instance, ref bool __result)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				Character component = ((Component)__instance).GetComponent<Character>();
				if ((Object)(object)component == (Object)null || !IsFrozen(component))
				{
					return true;
				}
				component.SetMoveDir(Vector3.zero);
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Character), "UpdateMotion")]
		private static class UpdateMotionPatch
		{
			private static bool Prefix(Character __instance, float dt)
			{
				//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_003f: 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_0063: 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_0075: 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_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: 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_010e: 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)
				if (!IsFrozen(__instance) || __instance.IsDead())
				{
					return true;
				}
				Rigidbody val = Body.Invoke(__instance);
				if ((Object)(object)val == (Object)null || val.isKinematic)
				{
					return false;
				}
				Vector3 linearVelocity = val.linearVelocity;
				Vector3 position = ((Component)__instance).transform.position;
				Rigidbody val2 = GroundBody.Invoke(__instance);
				Vector3 val3 = ((__instance.IsOnGround() && (Object)(object)val2 != (Object)null) ? val2.GetPointVelocity(position) : Vector3.zero);
				linearVelocity.x = val3.x;
				linearVelocity.z = val3.z;
				float liquidLevel = Floating.GetLiquidLevel(position, 1f, (LiquidType)10);
				float height = __instance.GetHeight();
				if (liquidLevel > position.y + height * 0.5f)
				{
					val.useGravity = false;
					float num = Mathf.Clamp((liquidLevel - height * 0.6f - position.y) * 2f, -3f, 3f);
					linearVelocity.y = Mathf.MoveTowards(linearVelocity.y, num, 12f * dt);
				}
				else
				{
					val.useGravity = true;
				}
				val.linearVelocity = linearVelocity;
				val.angularVelocity = Vector3.zero;
				return false;
			}
		}

		internal static readonly int ZFrozenSince = StringExtensionMethods.GetStableHashCode("ee_frozenSince");

		internal static readonly int ZFrozenUntil = StringExtensionMethods.GetStableHashCode("ee_frozenUntil");

		internal static readonly int ZImmuneUntil = StringExtensionMethods.GetStableHashCode("ee_freezeImmune");

		internal static readonly int ZShattered = StringExtensionMethods.GetStableHashCode("ee_shattered");

		private static readonly FieldRef<Character, ZNetView> NView = AccessTools.FieldRefAccess<Character, ZNetView>("m_nview");

		internal static readonly FieldRef<Character, Rigidbody> Body = AccessTools.FieldRefAccess<Character, Rigidbody>("m_body");

		internal static readonly FieldRef<Character, Animator> Anim = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		private static int _roofMask;

		internal static readonly List<GameObject> ShatterFx = new List<GameObject>();

		private static HitData _applying;

		private static readonly FieldRef<Character, Rigidbody> GroundBody = AccessTools.FieldRefAccess<Character, Rigidbody>("m_lastGroundBody");

		internal static long Now
		{
			get
			{
				if (!((Object)(object)ZNet.instance != (Object)null))
				{
					return 0L;
				}
				return ZNet.instance.GetTime().Ticks;
			}
		}

		internal static ZDO GetZDO(Character c)
		{
			ZNetView val = (((Object)(object)c != (Object)null) ? NView.Invoke(c) : null);
			if (!((Object)(object)val != (Object)null) || !val.IsValid())
			{
				return null;
			}
			return val.GetZDO();
		}

		internal static bool IsOwner(Character c)
		{
			ZNetView val = (((Object)(object)c != (Object)null) ? NView.Invoke(c) : null);
			if ((Object)(object)val != (Object)null && val.IsValid())
			{
				return val.IsOwner();
			}
			return false;
		}

		internal static bool IsFrozen(Character c)
		{
			ZDO zDO = GetZDO(c);
			if (zDO != null)
			{
				return zDO.GetLong(ZFrozenUntil, 0L) > Now;
			}
			return false;
		}

		internal static bool IsWet(Character c)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (c.GetSEMan().HaveStatusEffect(SEMan.s_statusEffectWet))
			{
				return true;
			}
			if (!ElementalEffectsPlugin.FreezeRainCountsAsWet.Value || !EnvMan.IsWet())
			{
				return false;
			}
			if (_roofMask == 0)
			{
				_roofMask = LayerMask.GetMask(new string[4] { "Default", "static_solid", "piece", "terrain" });
			}
			return !Physics.Raycast(c.GetCenterPoint(), Vector3.up, 60f, _roofMask);
		}

		private static bool CanFreeze(Character c)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			if ((Object)(object)c == (Object)null || c.IsDead() || c.GetHealth() <= 0f)
			{
				return false;
			}
			if (c.IsPlayer() && !ElementalEffectsPlugin.FreezePlayers.Value)
			{
				return false;
			}
			if (c.IsBoss() && !ElementalEffectsPlugin.FreezeBosses.Value)
			{
				return false;
			}
			DamageModifier frost = c.GetDamageModifiers((WeakSpot)null).m_frost;
			if ((int)frost == 3 || (int)frost == 1 || (int)frost == 5 || (int)frost == 7)
			{
				return false;
			}
			ZDO zDO = GetZDO(c);
			if (zDO == null)
			{
				return false;
			}
			long now = Now;
			if (zDO.GetLong(ZFrozenUntil, 0L) <= now)
			{
				return zDO.GetLong(ZImmuneUntil, 0L) <= now;
			}
			return false;
		}

		internal static void Freeze(Character c, float seconds)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			ZDO zDO = GetZDO(c);
			if (zDO != null)
			{
				long now = Now;
				long num = now + (long)((double)seconds * 10000000.0);
				zDO.Set(ZFrozenSince, now);
				zDO.Set(ZFrozenUntil, num);
				zDO.Set(ZImmuneUntil, num + (long)((double)ElementalEffectsPlugin.FreezeImmunity.Value * 10000000.0));
				c.SetMoveDir(Vector3.zero);
				ElementalEffectsPlugin.Log.LogInfo((object)$"Froze {c.m_name} for {seconds:0.0} s");
			}
		}

		internal static void EndFreeze(Character c, bool shattered)
		{
			ZDO zDO = GetZDO(c);
			if (zDO != null)
			{
				long now = Now;
				if (shattered)
				{
					zDO.Set(ZShattered, zDO.GetLong(ZFrozenSince, 0L));
				}
				zDO.Set(ZFrozenUntil, now);
				zDO.Set(ZImmuneUntil, now + (long)((double)ElementalEffectsPlugin.FreezeImmunity.Value * 10000000.0));
			}
		}
	}
	internal static class FrostIce
	{
		[HarmonyPatch(typeof(Projectile), "OnHit")]
		private static class ProjectileOnHit
		{
			private static void Postfix(Projectile __instance, Collider collider, Vector3 hitPoint)
			{
				if (ElementalEffectsPlugin.RefreshOnHit.Value && !((Object)(object)collider == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<FrostShard>() == (Object)null))
				{
					IceSheet componentInParent = ((Component)collider).GetComponentInParent<IceSheet>();
					if (!((Object)(object)componentInParent == (Object)null))
					{
						componentInParent.Refresh(ElementalEffectsPlugin.IceSeconds());
					}
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		private static class Commands
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__0_0;

				internal void <Postfix>b__0_0(ConsoleEventArgs args)
				{
					//IL_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_005a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0061: Unknown result type (might be due to invalid IL or missing references)
					//IL_0067: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0071: 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_00a1: 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_00b1: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer == (Object)null)
					{
						return;
					}
					float result;
					float num = ((args.Length > 1 && float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result)) ? result : 5f);
					Vector3 forward = ((Component)localPlayer).transform.forward;
					forward.y = 0f;
					Vector3 val = ((Component)localPlayer).transform.position + ((Vector3)(ref forward)).normalized * num;
					float liquidLevel = Floating.GetLiquidLevel(val, 0f, (LiquidType)0);
					if (liquidLevel < -1000f)
					{
						Terminal context = args.Context;
						if (context != null)
						{
							context.AddString("No water there");
						}
						return;
					}
					FreezeAt(new Vector3(val.x, liquidLevel, val.z));
					Terminal context2 = args.Context;
					if (context2 != null)
					{
						context2.AddString($"Froze water at {val.x:0},{val.z:0} ({IceSheet.Instances.Count} sheets loaded)");
					}
				}
			}

			private static void Postfix()
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						//IL_0042: Unknown result type (might be due to invalid IL or missing references)
						//IL_0047: Unknown result type (might be due to invalid IL or missing references)
						//IL_005a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0061: Unknown result type (might be due to invalid IL or missing references)
						//IL_0067: Unknown result type (might be due to invalid IL or missing references)
						//IL_006c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0071: 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_00a1: 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_00b1: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
						Player localPlayer = Player.m_localPlayer;
						if (!((Object)(object)localPlayer == (Object)null))
						{
							float result;
							float num = ((args.Length > 1 && float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result)) ? result : 5f);
							Vector3 forward = ((Component)localPlayer).transform.forward;
							forward.y = 0f;
							Vector3 val2 = ((Component)localPlayer).transform.position + ((Vector3)(ref forward)).normalized * num;
							float liquidLevel = Floating.GetLiquidLevel(val2, 0f, (LiquidType)0);
							if (liquidLevel < -1000f)
							{
								Terminal context = args.Context;
								if (context != null)
								{
									context.AddString("No water there");
								}
							}
							else
							{
								FreezeAt(new Vector3(val2.x, liquidLevel, val2.z));
								Terminal context2 = args.Context;
								if (context2 != null)
								{
									context2.AddString($"Froze water at {val2.x:0},{val2.z:0} ({IceSheet.Instances.Count} sheets loaded)");
								}
							}
						}
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("ee_ice", "[distance] - freeze the water in front of you into an ice sheet (Elemental Effects test)", (ConsoleEvent)obj, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}
		}

		internal static void FreezeHit(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			FreezeAt(p);
		}

		internal static void FreezeAt(Vector3 p)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			if (!ElementalEffectsPlugin.FrostIceEnabled.Value || Prefabs.Chunks.Count == 0 || Prefabs.Chunks.Count != Prefabs.Pieces.Count || (Object)(object)ZNetScene.instance == (Object)null || !IsSea(p, out var _))
			{
				return;
			}
			float num = ElementalEffectsPlugin.SheetWidth.Value * 0.5f;
			float value = ElementalEffectsPlugin.SheetSpacing.Value;
			float value2 = ElementalEffectsPlugin.NearbyRadius.Value;
			float spawnSeconds = ElementalEffectsPlugin.IceSeconds();
			bool flag = false;
			int num2 = 0;
			foreach (IceSheet instance in IceSheet.Instances)
			{
				if ((Object)(object)instance != (Object)null && Flat(((Component)instance).transform.position - p) < value)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				foreach (IceSheet instance2 in IceSheet.Instances)
				{
					if ((Object)(object)instance2 != (Object)null && Flat(((Component)instance2).transform.position - p) < num)
					{
						instance2.Refresh(ElementalEffectsPlugin.IceSeconds());
					}
				}
				return;
			}
			List<Prefabs.Piece> pieces = Prefabs.Pieces;
			float num3 = Mathf.Min(1f, ElementalEffectsPlugin.SheetWidth.Value / Mathf.Max(0.1f, Prefabs.Extent));
			Vector3 middle = Prefabs.Middle;
			Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
			List<(int, Vector3, float)> list = new List<(int, Vector3, float)>();
			for (int i = 0; i < pieces.Count; i++)
			{
				Vector3 val2 = (pieces[i].Center - middle) * num3;
				val2.y = 0f;
				list.Add((i, p + val * val2, ((Vector3)(ref val2)).magnitude));
			}
			list.Sort(((int piece, Vector3 pos, float dist) x, (int piece, Vector3 pos, float dist) y) => x.dist.CompareTo(y.dist));
			foreach (IceSheet instance3 in IceSheet.Instances)
			{
				if ((Object)(object)instance3 != (Object)null && Flat(((Component)instance3).transform.position - p) < value2)
				{
					num2++;
				}
			}
			float num4 = Prefabs.TypicalWidth * num3 * 0.35f;
			Vector3 val3 = default(Vector3);
			foreach (var item in list)
			{
				if (num2 >= ElementalEffectsPlugin.MaxSheetsNearby.Value)
				{
					break;
				}
				if (!IsSea(item.Item2, out var level2))
				{
					continue;
				}
				bool flag2 = false;
				foreach (IceSheet instance4 in IceSheet.Instances)
				{
					if ((Object)(object)instance4 != (Object)null && Flat(((Component)instance4).transform.position - item.Item2) < num4)
					{
						flag2 = true;
						break;
					}
				}
				if (!flag2)
				{
					((Vector3)(ref val3))..ctor(item.Item2.x, level2 + ElementalEffectsPlugin.TopAboveWater.Value + Random.Range(0f, 0.02f), item.Item2.z);
					IceSheet.SpawnScale = num3;
					IceSheet.SpawnSeconds = spawnSeconds;
					Object.Instantiate<GameObject>(Prefabs.Chunks[item.Item1], val3, val);
					num2++;
				}
			}
		}

		private static float Flat(Vector3 d)
		{
			//IL_0000: 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_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)
			Vector2 val = new Vector2(d.x, d.z);
			return ((Vector2)(ref val)).magnitude;
		}

		private static bool IsSea(Vector3 p, out float level)
		{
			//IL_0001: 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)
			level = Floating.GetLiquidLevel(p, 0f, (LiquidType)0);
			if (level > -1000f)
			{
				if (!((Object)(object)ZoneSystem.instance == (Object)null))
				{
					return ZoneSystem.instance.GetGroundHeight(p) <= level - 0.4f;
				}
				return true;
			}
			return false;
		}
	}
	public class FrostShard : MonoBehaviour
	{
		private ZNetView _nview;

		private Projectile _projectile;

		private Vector3 _prev;

		private bool _started;

		private bool _wasAbove;

		private bool _done;

		private void Awake()
		{
			_nview = ((Component)this).GetComponent<ZNetView>();
			_projectile = ((Component)this).GetComponent<Projectile>();
		}

		private void FixedUpdate()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			if (_done || (Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner())
			{
				return;
			}
			Vector3 position = ((Component)this).transform.position;
			float liquidLevel = Floating.GetLiquidLevel(position, 1f, (LiquidType)10);
			bool flag = position.y >= liquidLevel;
			if (!_started)
			{
				_started = true;
				_wasAbove = flag;
				_prev = position;
			}
			else if (_wasAbove && !flag && liquidLevel > -1000f && ElementalEffectsPlugin.FrostIceEnabled.Value)
			{
				_done = true;
				float num = (Mathf.Approximately(_prev.y, position.y) ? 1f : Mathf.Clamp01((_prev.y - liquidLevel) / (_prev.y - position.y)));
				Vector3 val = Vector3.Lerp(_prev, position, num);
				FrostIce.FreezeHit(val);
				if (ElementalEffectsPlugin.ShardStopsAtWater.Value && (Object)(object)_projectile != (Object)null)
				{
					_projectile.m_hitWaterEffects.Create(new Vector3(val.x, liquidLevel, val.z), Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
					ZNetScene.instance.Destroy(((Component)this).gameObject);
				}
			}
			else
			{
				_wasAbove = flag;
				_prev = position;
			}
		}
	}
	internal class FrozenCharacter : MonoBehaviour
	{
		private static readonly int SnowCover = Shader.PropertyToID("_SnowCover");

		private static Material _iceMaterial;

		private static bool _loggedMaterial;

		private Character _character;

		private Animator _animator;

		private bool _animatorWasEnabled;

		private long _since;

		private float _startTime;

		private GameObject _shell;

		private readonly List<Renderer> _hidden = new List<Renderer>();

		private readonly List<(Transform src, Transform dst)> _follow = new List<(Transform, Transform)>();

		private Collider _hull;

		private Vector3 _hullOffset;

		private Vector3 _center;

		private bool _iced;

		private bool _ended;

		private bool _snowSet;

		internal float LastDirectHit = -1f;

		internal float LastShellHit = -1f;

		internal ZDOID LastDirectAttacker;

		internal ZDOID LastShellAttacker;

		private readonly List<Material> _made = new List<Material>();

		internal static Material IceMaterial
		{
			get
			{
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Expected O, but got Unknown
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: 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_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01db: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_iceMaterial != (Object)null)
				{
					return _iceMaterial;
				}
				string text = ElementalEffectsPlugin.FreezeShellSource.Value.Trim();
				GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(text) : null);
				Material val2 = (((Object)(object)val != (Object)null) ? (from r in val.GetComponentsInChildren<MeshRenderer>(true)
					select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null)) : null);
				if ((Object)(object)val2 == (Object)null)
				{
					if (!_loggedMaterial)
					{
						ElementalEffectsPlugin.Log.LogWarning((object)("No ice material on '" + text + "': frozen creatures get no shell"));
					}
					_loggedMaterial = true;
					return null;
				}
				_iceMaterial = new Material(val2)
				{
					name = "ee_frozen_ice"
				};
				float value = ElementalEffectsPlugin.FreezeShellTiling.Value;
				_iceMaterial.mainTextureScale = new Vector2(value, value);
				if (_iceMaterial.HasProperty("_BumpMap"))
				{
					_iceMaterial.SetTextureScale("_BumpMap", new Vector2(value, value));
				}
				if (_iceMaterial.HasProperty("_Color"))
				{
					_iceMaterial.color = val2.color * ElementalEffectsPlugin.FreezeShellTint.Value;
				}
				if (_iceMaterial.HasProperty("_Glossiness"))
				{
					_iceMaterial.SetFloat("_Glossiness", ElementalEffectsPlugin.FreezeShellGloss.Value);
				}
				if (!_loggedMaterial)
				{
					ManualLogSource log = ElementalEffectsPlugin.Log;
					object[] obj = new object[8]
					{
						text,
						((Object)val2).name,
						((Object)val2.shader).name,
						val2.color,
						null,
						null,
						null,
						null
					};
					Texture mainTexture = val2.mainTexture;
					obj[4] = ((mainTexture != null) ? ((Object)mainTexture).name : null);
					obj[5] = val2.mainTextureScale;
					obj[6] = (val2.HasProperty("_Glossiness") ? val2.GetFloat("_Glossiness") : (-1f));
					obj[7] = string.Join(",", val2.shaderKeywords);
					log.LogInfo((object)string.Format("Ice material from {0}: {1}, shader {2}, color {3}, tex {4} {5}, gloss {6:0.00}, keywords [{7}]", obj));
				}
				_loggedMaterial = true;
				return _iceMaterial;
			}
		}

		internal Character Character => _character;

		private void Start()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			_character = ((Component)this).GetComponent<Character>();
			ZDO zDO = FrostFreeze.GetZDO(_character);
			if (zDO == null)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			_since = zDO.GetLong(FrostFreeze.ZFrozenSince, 0L);
			_startTime = Time.time;
			_center = _character.GetCenterPoint();
			_animator = FrostFreeze.Anim.Invoke(_character);
			if ((Object)(object)_animator != (Object)null)
			{
				_animatorWasEnabled = ((Behaviour)_animator).enabled;
				_animator.keepAnimatorStateOnDisable = true;
				_animator.writeDefaultValuesOnDisable = false;
				((Behaviour)_animator).enabled = false;
			}
			if ((Object)(object)MaterialMan.instance != (Object)null)
			{
				MaterialMan.instance.SetValue<float>(((Component)_character).gameObject, SnowCover, 0f, false);
				_snowSet = true;
			}
			Prefabs.PlayLocal(Prefabs.AppearFx, _center, Quaternion.identity);
		}

		private void Update()
		{
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if (_ended)
			{
				return;
			}
			if ((Object)(object)_character == (Object)null || _character.IsDead() || _character.GetHealth() <= 0f)
			{
				End(shattered: true);
				return;
			}
			ZDO zDO = FrostFreeze.GetZDO(_character);
			if (zDO == null)
			{
				End(shattered: false);
				return;
			}
			if (zDO.GetLong(FrostFreeze.ZFrozenSince, 0L) != _since || zDO.GetLong(FrostFreeze.ZFrozenUntil, 0L) <= FrostFreeze.Now)
			{
				End(zDO.GetLong(FrostFreeze.ZShattered, 0L) == _since);
				return;
			}
			float num = Mathf.Clamp01((Time.time - _startTime) / Mathf.Max(0.01f, ElementalEffectsPlugin.FreezeCreepTime.Value));
			if (_snowSet)
			{
				MaterialMan.instance.SetValue<float>(((Component)_character).gameObject, SnowCover, num, false);
			}
			if (!_iced && num >= 1f)
			{
				_iced = true;
				try
				{
					BuildShell();
				}
				catch (Exception ex)
				{
					ElementalEffectsPlugin.Log.LogWarning((object)("Ice shell for " + _character.m_name + " failed: " + ex.Message));
				}
				Prefabs.PlayLocal(Prefabs.AppearFx, _center, Quaternion.identity);
			}
			if ((Object)(object)_animator != (Object)null && ((Behaviour)_animator).enabled)
			{
				((Behaviour)_animator).enabled = false;
			}
		}

		private void LateUpdate()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			foreach (var (val, val2) in _follow)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
				{
					val2.SetPositionAndRotation(val.position, val.rotation);
					val2.localScale = val.lossyScale;
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_hull != (Object)null && (Object)(object)_character != (Object)null && (Object)(object)_hull.attachedRigidbody != (Object)null)
			{
				_hull.attachedRigidbody.MovePosition(((Component)_character).transform.position + ((Component)_character).transform.rotation * _hullOffset);
				_hull.attachedRigidbody.MoveRotation(((Component)_character).transform.rotation);
			}
		}

		private Material IceOver(Material ice, Material src)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Texture val = (((Object)(object)src != (Object)null && src.HasProperty("_BumpMap")) ? src.GetTexture("_BumpMap") : null);
			if ((Object)(object)val == (Object)null)
			{
				return ice;
			}
			Material val2 = new Material(ice)
			{
				name = "ee_frozen_" + ((Object)src).name
			};
			val2.SetTexture("_BumpMap", val);
			val2.mainTextureScale = src.mainTextureScale;
			val2.mainTextureOffset = src.mainTextureOffset;
			if (src.HasProperty("_BumpScale") && val2.HasProperty("_BumpScale"))
			{
				val2.SetFloat("_BumpScale", src.GetFloat("_BumpScale"));
			}
			val2.EnableKeyword("_NORMALMAP");
			_made.Add(val2);
			return val2;
		}

		private void RemoveShell()
		{
			foreach (Material item in _made)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(obje