Decompiled source of Water Features v1.0.2

Water_Features.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Xml.Serialization;
using BepInEx;
using Colossal;
using Colossal.Entities;
using Colossal.IO.AssetDatabase;
using Colossal.Localization;
using Colossal.Logging;
using Colossal.PSI.Environment;
using Colossal.Serialization.Entities;
using Colossal.UI;
using Game;
using Game.Common;
using Game.Input;
using Game.Modding;
using Game.Objects;
using Game.Prefabs;
using Game.Prefabs.Climate;
using Game.Rendering;
using Game.SceneFlow;
using Game.Settings;
using Game.Simulation;
using Game.Tools;
using Game.UI;
using Game.UI.Localization;
using Game.UI.Tooltip;
using Game.UI.Widgets;
using HarmonyLib;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using Water_Features.Components;
using Water_Features.Prefabs;
using Water_Features.Settings;
using Water_Features.Systems;
using Water_Features.Tools;
using Water_Features.Utils;
using cohtml.Net;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Water_Features_BepInEx")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Water_Features_BepInEx")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a243b333-5cdd-4f65-9450-58058230f3ca")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace Water_Features
{
	[BepInPlugin("Water_Features", "Water Features", "1.0.1")]
	[HarmonyPatch]
	public class WaterFeaturesPlugin : BaseUnityPlugin
	{
		internal static WaterFeaturesMod _mod;

		public void Awake()
		{
			_mod = new WaterFeaturesMod();
			_mod.OnLoad();
			_mod.Log.Info((object)"WaterFeaturesPlugin.Awake");
			Harmony.CreateAndPatchAll(typeof(WaterFeaturesPlugin).Assembly, "Water_Features");
		}

		[HarmonyPatch(typeof(SystemOrder), "Initialize", new Type[] { typeof(UpdateSystem) })]
		[HarmonyPostfix]
		private static void InjectSystems(UpdateSystem updateSystem)
		{
			_mod.Log.Info((object)"WaterFeaturesPlugin.InjectSystems");
			_mod.OnCreateWorld(updateSystem);
		}
	}
	public class WaterFeaturesMod : IMod
	{
		private static string m_modInstallFolder;

		public static WaterFeaturesSettings Settings { get; set; }

		public static WaterFeaturesMod Instance { get; private set; }

		public static string ModInstallFolder
		{
			get
			{
				if (m_modInstallFolder == null)
				{
					m_modInstallFolder = Path.GetDirectoryName(typeof(WaterFeaturesPlugin).Assembly.Location);
				}
				return m_modInstallFolder;
			}
		}

		internal ILog Log { get; private set; }

		public void OnLoad()
		{
			Instance = this;
			Log = LogManager.GetLogger("Mods_Yenyang_Water_Features", false);
			Log.Info((object)"[WaterFeaturesMod] OnLoad");
		}

		public void OnCreateWorld(UpdateSystem updateSystem)
		{
			Log.effectivenessLevel = Level.Info;
			Log.Info((object)"Initializing Settings.");
			Settings = new WaterFeaturesSettings((IMod)(object)this);
			((ModSetting)Settings).RegisterInOptionsUI();
			AssetDatabase.global.LoadSettings("Mods_Yenyang_Water_Features", (object)Settings, (object)new WaterFeaturesSettings((IMod)(object)this));
			Settings.Contra = false;
			IResourceHandler resourceHandler = GameManager.instance.userInterface.view.uiSystem.resourceHandler;
			GameUIResourceHandler val = (GameUIResourceHandler)(object)((resourceHandler is GameUIResourceHandler) ? resourceHandler : null);
			if (val != null)
			{
				((DefaultResourceHandler)val).HostLocationsMap.Add("yy-water-tool", new List<string> { UIFileUtils.AssemblyPath });
			}
			Log.Info((object)"Handling create world");
			Log.Info((object)("ModInstallFolder = " + ModInstallFolder));
			LoadLocales();
			updateSystem.UpdateAt<CustomWaterToolSystem>((SystemUpdatePhase)17);
			updateSystem.UpdateAfter<WaterTooltipSystem>((SystemUpdatePhase)23);
			updateSystem.UpdateBefore<FindWaterSourcesSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateAt<AutofillingLakesSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateAt<DetentionBasinSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateAt<RetentionBasinSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateBefore<ChangeWaterSystemValues>((SystemUpdatePhase)12);
			updateSystem.UpdateAt<TidesAndWavesSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateBefore<BeforeSerializeSystem>((SystemUpdatePhase)20);
			updateSystem.UpdateAfter<TidesAndWavesSystem>((SystemUpdatePhase)20);
			updateSystem.UpdateAt<SeasonalStreamsSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateAt<DisableSeasonalStreamSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateAt<DisableWavesAndTidesSystem>((SystemUpdatePhase)12);
			updateSystem.UpdateAfter<SeasonalStreamsSystem>((SystemUpdatePhase)20);
			updateSystem.UpdateAfter<AutofillingLakesSystem>((SystemUpdatePhase)20);
			updateSystem.UpdateAfter<DetentionBasinSystem>((SystemUpdatePhase)20);
			updateSystem.UpdateAfter<RetentionBasinSystem>((SystemUpdatePhase)20);
			updateSystem.UpdateAt<AddPrefabsSystem>((SystemUpdatePhase)24);
			updateSystem.UpdateAt<WaterToolUISystem>((SystemUpdatePhase)22);
		}

		public void OnDispose()
		{
			Log.Info((object)"[WaterFeaturesMod] OnDispose");
		}

		private void LoadLocales()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			LocaleEN localeEN = new LocaleEN(Settings);
			string path = Path.Combine(ModInstallFolder, "l10n.csv");
			if (File.Exists(path))
			{
				IEnumerable<string[]> source = from x in File.ReadAllLines(path)
					select x.Split(new char[1] { '\t' });
				int enColumn = Array.IndexOf(source.First(), "en-US");
				MemorySource val = new MemorySource(source.Skip(1).ToDictionary((string[] x) => x[0], (string[] x) => x.ElementAtOrDefault(enColumn)));
				string[] supportedLocales = GameManager.instance.localizationManager.GetSupportedLocales();
				foreach (string text in supportedLocales)
				{
					try
					{
						GameManager.instance.localizationManager.AddSource(text, (IDictionarySource)(object)val);
						if (!(text != "en-US"))
						{
							continue;
						}
						int valueColumn = Array.IndexOf(source.First(), text);
						if (valueColumn > 0)
						{
							MemorySource val2 = new MemorySource(source.Skip(1).ToDictionary((string[] x) => x[0], (string[] x) => x.ElementAtOrDefault(valueColumn)));
							GameManager.instance.localizationManager.AddSource(text, (IDictionarySource)(object)val2);
						}
					}
					catch (Exception ex)
					{
						Log.Warn((object)string.Format("{0}.{1} Encountered exception {2} while trying to localize {3}.", "WaterFeaturesMod", "LoadLocales", ex, text));
					}
				}
			}
			else
			{
				Log.Warn((object)"WaterFeaturesMod.LoadLocales couldn't find localization file and loaded default for every language.");
				string[] supportedLocales2 = GameManager.instance.localizationManager.GetSupportedLocales();
				foreach (string text2 in supportedLocales2)
				{
					GameManager.instance.localizationManager.AddSource(text2, (IDictionarySource)(object)localeEN);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Water_Features";

		public const string PLUGIN_NAME = "";

		public const string PLUGIN_VERSION = "1.0.0.0";
	}
}
namespace Water_Features.Utils
{
	public static class ReflectionExtensions
	{
		public static readonly BindingFlags AllFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.GetProperty;

		public static object GetMemberValue(this object obj, string memberName)
		{
			MemberInfo memberInfo = GetMemberInfo(obj, memberName);
			if (memberInfo == null)
			{
				WaterFeaturesMod.Instance.Log.Error(new Exception("memberName"), (object)"ReflectionExtensions GetMemberInfo Couldn't find member name! ");
			}
			if (memberInfo is PropertyInfo)
			{
				return memberInfo.As<PropertyInfo>().GetValue(obj, null);
			}
			if (memberInfo is FieldInfo)
			{
				return memberInfo.As<FieldInfo>().GetValue(obj);
			}
			throw new Exception();
		}

		public static object SetMemberValue(this object obj, string memberName, object newValue)
		{
			MemberInfo memberInfo = GetMemberInfo(obj, memberName);
			if (memberInfo == null)
			{
				WaterFeaturesMod.Instance.Log.Error(new Exception("memberName"), (object)"ReflectionExtensions GetMemberInfo Couldn't find member name! ");
			}
			object memberValue = obj.GetMemberValue(memberName);
			if (memberInfo is PropertyInfo)
			{
				memberInfo.As<PropertyInfo>().SetValue(obj, newValue, null);
			}
			else
			{
				if (!(memberInfo is FieldInfo))
				{
					throw new Exception();
				}
				memberInfo.As<FieldInfo>().SetValue(obj, newValue);
			}
			return memberValue;
		}

		private static MemberInfo GetMemberInfo(object obj, string memberName)
		{
			List<PropertyInfo> source = new List<PropertyInfo> { obj.GetType().GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy) };
			source = source.Where((PropertyInfo i) => (object)i != null).ToList();
			if (source.Count != 0)
			{
				return source[0];
			}
			List<FieldInfo> source2 = new List<FieldInfo> { obj.GetType().GetField(memberName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy) };
			source2 = source2.Where((FieldInfo i) => (object)i != null).ToList();
			if (source2.Count != 0)
			{
				return source2[0];
			}
			return null;
		}

		[DebuggerHidden]
		private static T As<T>(this object obj)
		{
			return (T)obj;
		}
	}
	internal static class UIFileUtils
	{
		private static string s_assemblyPath;

		public static string AssemblyPath
		{
			get
			{
				if (string.IsNullOrWhiteSpace(s_assemblyPath))
				{
					s_assemblyPath = Path.GetDirectoryName(typeof(WaterFeaturesPlugin).Assembly.Location);
				}
				return s_assemblyPath;
			}
		}

		internal static void ExecuteScript(View view, string script)
		{
			if (!string.IsNullOrEmpty(script) && view != null)
			{
				view.ExecuteScript(script);
			}
		}

		internal static void ReadUIFiles(View uiView, string directoryName)
		{
			try
			{
				string text = Path.Combine(AssemblyPath, directoryName);
				if (!Directory.Exists(text))
				{
					WaterFeaturesMod.Instance.Log.Error(new Exception("unable to locate UI file directory "), (object)text);
					return;
				}
				string[] files = Directory.GetFiles(text, "*.css");
				foreach (string fileName in files)
				{
					ExecuteScript(uiView, ReadCSS(fileName));
				}
				string[] files2 = Directory.GetFiles(text, "*.html");
				foreach (string fileName2 in files2)
				{
					ExecuteScript(uiView, ReadHTML(fileName2));
				}
				string[] files3 = Directory.GetFiles(text, "*.js");
				foreach (string fileName3 in files3)
				{
					ExecuteScript(uiView, ReadJS(fileName3));
				}
			}
			catch (Exception ex)
			{
				WaterFeaturesMod.Instance.Log.Error(ex, (object)"exception reading UI files");
			}
		}

		internal static string ReadHTML(string fileName, string injectionPostfix = "document.body.appendChild(yyWaterTool.div);")
		{
			try
			{
				string text = ReadUIFile(fileName);
				if (!string.IsNullOrEmpty(text))
				{
					return "yyWaterTool.div = document.createElement('div'); yyWaterTool.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; " + injectionPostfix;
				}
			}
			catch (Exception ex)
			{
				WaterFeaturesMod.Instance.Log.Error(ex, (object)(" exception reading HTML file " + fileName));
			}
			return null;
		}

		internal static string ReadHTML(string fileName)
		{
			try
			{
				string text = ReadUIFile(fileName);
				if (!string.IsNullOrEmpty(text))
				{
					return "yyWaterTool.div = document.createElement('div'); yyWaterTool.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.body.appendChild(yyWaterTool.div);";
				}
			}
			catch (Exception ex)
			{
				WaterFeaturesMod.Instance.Log.Error(ex, (object)(" exception reading HTML file " + fileName));
			}
			return null;
		}

		internal static string ReadJS(string fileName)
		{
			try
			{
				string text = ReadUIFile(fileName);
				if (!string.IsNullOrEmpty(text))
				{
					return text;
				}
			}
			catch (Exception ex)
			{
				WaterFeaturesMod.Instance.Log.Error(ex, (object)(" exception reading JS file " + fileName));
			}
			return null;
		}

		private static string ReadCSS(string fileName)
		{
			try
			{
				string text = ReadUIFile(fileName);
				if (!string.IsNullOrEmpty(text))
				{
					return "yyWaterTool.style = document.createElement('style'); yyWaterTool.style.type = 'text/css'; yyWaterTool.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.head.appendChild(yyWaterTool.style);";
				}
			}
			catch (Exception ex)
			{
				WaterFeaturesMod.Instance.Log.Error(ex, (object)(" exception reading CSS file " + fileName));
			}
			return null;
		}

		private static string ReadUIFile(string fileName)
		{
			try
			{
				if (File.Exists(fileName))
				{
					return File.ReadAllText(fileName);
				}
			}
			catch (Exception ex)
			{
				WaterFeaturesMod.Instance.Log.Error(ex, (object)(" exception reading UI file " + fileName));
			}
			return null;
		}

		private static string EscapeToJavaScript(string sourceString)
		{
			int length = sourceString.Length;
			StringBuilder stringBuilder = new StringBuilder(length * 2);
			int num = -1;
			while (++num < length)
			{
				char c = sourceString[num];
				if (c != '\n' && c != '\r')
				{
					if (c == '"' || c == '\'')
					{
						stringBuilder.Append('\\');
					}
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString();
		}
	}
}
namespace Water_Features.Tools
{
	public class WaterTooltipSystem : TooltipSystemBase
	{
		private Vector3 m_HitPosition = default(Vector3);

		private bool m_RadiusTooSmall = false;

		private ToolSystem m_ToolSystem;

		private CustomWaterToolSystem m_CustomWaterTool;

		private float m_TimeLastWarned;

		private float m_StartedHoveringTime;

		private ILog m_Log;

		private WaterToolUISystem m_WaterToolUISystem;

		public Vector3 HitPosition
		{
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				m_HitPosition = value;
			}
		}

		public bool RadiusTooSmall
		{
			set
			{
				m_RadiusTooSmall = value;
			}
		}

		protected override void OnCreate()
		{
			((TooltipSystemBase)this).OnCreate();
			m_Log = WaterFeaturesMod.Instance.Log;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolSystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_CustomWaterTool = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<CustomWaterToolSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_WaterToolUISystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<WaterToolUISystem>() : null);
			m_Log.Info((object)"[WaterTooltipSystem] OnCreate");
		}

		protected override void OnUpdate()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_0196: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_0733: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0798: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Expected O, but got Unknown
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Expected O, but got Unknown
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Expected O, but got Unknown
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Expected O, but got Unknown
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Expected O, but got Unknown
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Expected O, but got Unknown
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Expected O, but got Unknown
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Expected O, but got Unknown
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Expected O, but got Unknown
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Expected O, but got Unknown
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Expected O, but got Unknown
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Expected O, but got Unknown
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Expected O, but got Unknown
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Expected O, but got Unknown
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Expected O, but got Unknown
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Expected O, but got Unknown
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Expected O, but got Unknown
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Expected O, but got Unknown
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Expected O, but got Unknown
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Expected O, but got Unknown
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Expected O, but got Unknown
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Expected O, but got Unknown
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Expected O, but got Unknown
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Expected O, but got Unknown
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_067c: Expected O, but got Unknown
			//IL_067d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Expected O, but got Unknown
			if (m_ToolSystem.activeTool != m_CustomWaterTool)
			{
				return;
			}
			PrefabBase prefab = ((ToolBaseSystem)m_CustomWaterTool).GetPrefab();
			if ((Object)(object)prefab == (Object)null || !(prefab is WaterSourcePrefab))
			{
				return;
			}
			WaterSourcePrefab waterSourcePrefab = prefab as WaterSourcePrefab;
			if (waterSourcePrefab.m_SourceType == WaterToolUISystem.SourceType.River)
			{
				if (!m_CustomWaterTool.IsPositionNearBorder(float3.op_Implicit(m_HitPosition), m_WaterToolUISystem.Radius, fixedMaxDistance: true))
				{
					StringTooltip val = new StringTooltip
					{
						path = PathSegment.op_Implicit("Tooltip.LABEL[YY.WT.PlaceNearBorder]"),
						value = LocalizedString.IdWithFallback("Tooltip.LABEL[YY.WT.PlaceNearBorder]", "Rivers must be placed near map border.")
					};
					((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val);
				}
			}
			else if (waterSourcePrefab.m_SourceType == WaterToolUISystem.SourceType.Sea)
			{
				if (!m_CustomWaterTool.IsPositionNearBorder(float3.op_Implicit(m_HitPosition), m_WaterToolUISystem.Radius, fixedMaxDistance: false))
				{
					StringTooltip val2 = new StringTooltip
					{
						path = PathSegment.op_Implicit("Tooltip.LABEL[YY.WT.MustTouchBorder]"),
						value = LocalizedString.IdWithFallback("Tooltip.LABEL[YY.WT.MustTouchBorder]", "Sea water sources must touch the map border.")
					};
					((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val2);
				}
			}
			else if (!m_CustomWaterTool.IsPositionWithinBorder(float3.op_Implicit(m_HitPosition)))
			{
				StringTooltip val3 = new StringTooltip
				{
					path = PathSegment.op_Implicit("Tooltip.LABEL[YY.WT.PlaceInsideBorder]"),
					value = LocalizedString.IdWithFallback("Tooltip.LABEL[YY.WT.PlaceInsideBorder]", "This water source must be placed inside the playable map.")
				};
				((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val3);
			}
			if (m_RadiusTooSmall || Time.time < m_TimeLastWarned + 3f)
			{
				StringTooltip val4 = new StringTooltip
				{
					path = PathSegment.op_Implicit("Tooltip.LABEL[YY.WT.RadiusTooSmall]"),
					value = LocalizedString.IdWithFallback("Tooltip.LABEL[YY.WT.RadiusTooSmall]", "The radius is too small and has been automically increased.")
				};
				((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val4);
				if (m_RadiusTooSmall)
				{
					m_TimeLastWarned = Time.time;
				}
				m_RadiusTooSmall = false;
			}
			if (m_CustomWaterTool.CanDeleteWaterSource())
			{
				if (m_StartedHoveringTime == 0f)
				{
					m_StartedHoveringTime = Time.time;
				}
				if (Time.time > m_StartedHoveringTime + 1f)
				{
					Entity hoveredEntity = m_CustomWaterTool.GetHoveredEntity(float3.op_Implicit(m_HitPosition));
					if (hoveredEntity != Entity.Null)
					{
						WaterSourceData val5 = default(WaterSourceData);
						if (EntitiesExtensions.TryGetComponent<WaterSourceData>(((ComponentSystemBase)this).EntityManager, hoveredEntity, ref val5))
						{
							string text = "YY_WATER_FEATURES.Elevation";
							string text2 = "Elevation";
							if (val5.m_ConstantDepth == 0)
							{
								text = "YY_WATER_FEATURES.Flow";
								text2 = "Flow";
							}
							FloatTooltip val6 = new FloatTooltip();
							((NumberTooltip<float>)val6).value = val5.m_Amount;
							((NumberTooltip<float>)val6).unit = "floatSingleFraction";
							((Widget)val6).path = PathSegment.op_Implicit(text);
							((LabelIconTooltip)val6).label = LocalizedString.IdWithFallback(text, text2);
							FloatTooltip val7 = val6;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val7);
							FloatTooltip val8 = new FloatTooltip();
							((NumberTooltip<float>)val8).value = val5.m_Radius;
							((NumberTooltip<float>)val8).unit = "floatSingleFraction";
							((Widget)val8).path = PathSegment.op_Implicit("YY_WATER_FEATURES.Radius");
							((LabelIconTooltip)val8).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.Radius", "Radius");
							FloatTooltip val9 = val8;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val9);
						}
						DetentionBasin detentionBasin = default(DetentionBasin);
						AutofillingLake autofillingLake = default(AutofillingLake);
						RetentionBasin retentionBasin = default(RetentionBasin);
						SeasonalStreamsData seasonalStreamsData = default(SeasonalStreamsData);
						TidesAndWavesData tidesAndWavesData = default(TidesAndWavesData);
						if (EntitiesExtensions.TryGetComponent<DetentionBasin>(((ComponentSystemBase)this).EntityManager, hoveredEntity, ref detentionBasin))
						{
							FloatTooltip val10 = new FloatTooltip();
							((NumberTooltip<float>)val10).value = detentionBasin.m_MaximumWaterHeight;
							((NumberTooltip<float>)val10).unit = "floatSingleFraction";
							((Widget)val10).path = PathSegment.op_Implicit("YY_WATER_FEATURES.MaxElevation");
							((LabelIconTooltip)val10).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.MaxElevation", "Max Elevation");
							FloatTooltip val11 = val10;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val11);
							if (WaterFeaturesMod.Settings.SimulateSnowMelt)
							{
								FloatTooltip val12 = new FloatTooltip();
								((NumberTooltip<float>)val12).value = detentionBasin.m_SnowAccumulation;
								((NumberTooltip<float>)val12).unit = "floatSingleFraction";
								((Widget)val12).path = PathSegment.op_Implicit("YY_WATER_FEATURES.SnowAccumulation");
								((LabelIconTooltip)val12).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.SnowAccumulation", "Snow Accumulation");
								FloatTooltip val13 = val12;
								((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val13);
							}
						}
						else if (EntitiesExtensions.TryGetComponent<AutofillingLake>(((ComponentSystemBase)this).EntityManager, hoveredEntity, ref autofillingLake))
						{
							FloatTooltip val14 = new FloatTooltip();
							((NumberTooltip<float>)val14).value = autofillingLake.m_MaximumWaterHeight;
							((NumberTooltip<float>)val14).unit = "floatSingleFraction";
							((Widget)val14).path = PathSegment.op_Implicit("YY_WATER_FEATURES.MaxElevation");
							((LabelIconTooltip)val14).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.MaxElevation", "Max Elevation");
							FloatTooltip val15 = val14;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val15);
						}
						else if (EntitiesExtensions.TryGetComponent<RetentionBasin>(((ComponentSystemBase)this).EntityManager, hoveredEntity, ref retentionBasin))
						{
							FloatTooltip val16 = new FloatTooltip();
							((NumberTooltip<float>)val16).value = retentionBasin.m_MaximumWaterHeight;
							((NumberTooltip<float>)val16).unit = "floatSingleFraction";
							((Widget)val16).path = PathSegment.op_Implicit("YY_WATER_FEATURES.MaxElevation");
							((LabelIconTooltip)val16).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.MaxElevation", "Max Elevation");
							FloatTooltip val17 = val16;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val17);
							FloatTooltip val18 = new FloatTooltip();
							((NumberTooltip<float>)val18).value = retentionBasin.m_MinimumWaterHeight;
							((NumberTooltip<float>)val18).unit = "floatSingleFraction";
							((Widget)val18).path = PathSegment.op_Implicit("YY_WATER_FEATURES.MinElevation");
							((LabelIconTooltip)val18).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.MinElevation", "Min Elevation");
							FloatTooltip val19 = val18;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val19);
							if (WaterFeaturesMod.Settings.SimulateSnowMelt)
							{
								FloatTooltip val20 = new FloatTooltip();
								((NumberTooltip<float>)val20).value = retentionBasin.m_SnowAccumulation;
								((NumberTooltip<float>)val20).unit = "floatSingleFraction";
								((Widget)val20).path = PathSegment.op_Implicit("YY_WATER_FEATURES.SnowAccumulation");
								((LabelIconTooltip)val20).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.SnowAccumulation", "Snow Accumulation");
								FloatTooltip val21 = val20;
								((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val21);
							}
						}
						else if (EntitiesExtensions.TryGetComponent<SeasonalStreamsData>(((ComponentSystemBase)this).EntityManager, hoveredEntity, ref seasonalStreamsData))
						{
							FloatTooltip val22 = new FloatTooltip();
							((NumberTooltip<float>)val22).value = seasonalStreamsData.m_OriginalAmount;
							((NumberTooltip<float>)val22).unit = "floatSingleFraction";
							((Widget)val22).path = PathSegment.op_Implicit("YY_WATER_FEATURES.OriginalFlow");
							((LabelIconTooltip)val22).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.OriginalFlow", "Original Flow");
							FloatTooltip val23 = val22;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val23);
							if (WaterFeaturesMod.Settings.SimulateSnowMelt)
							{
								FloatTooltip val24 = new FloatTooltip();
								((NumberTooltip<float>)val24).value = seasonalStreamsData.m_SnowAccumulation;
								((NumberTooltip<float>)val24).unit = "floatSingleFraction";
								((Widget)val24).path = PathSegment.op_Implicit("YY_WATER_FEATURES.SnowAccumulation");
								((LabelIconTooltip)val24).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.SnowAccumulation", "Snow Accumulation");
								FloatTooltip val25 = val24;
								((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val25);
							}
						}
						else if (EntitiesExtensions.TryGetComponent<TidesAndWavesData>(((ComponentSystemBase)this).EntityManager, hoveredEntity, ref tidesAndWavesData))
						{
							FloatTooltip val26 = new FloatTooltip();
							((NumberTooltip<float>)val26).value = tidesAndWavesData.m_OriginalAmount;
							((NumberTooltip<float>)val26).unit = "floatSingleFraction";
							((Widget)val26).path = PathSegment.op_Implicit("YY_WATER_FEATURES.MaxElevation");
							((LabelIconTooltip)val26).label = LocalizedString.IdWithFallback("YY_WATER_FEATURES.MaxElevation", "Max Elevation");
							FloatTooltip val27 = val26;
							((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val27);
						}
					}
				}
				StringTooltip val28 = new StringTooltip
				{
					path = PathSegment.op_Implicit("Tooltip.LABEL[YY.WT.RemoveWaterSource]"),
					value = LocalizedString.IdWithFallback("Tooltip.LABEL[YY.WT.RemoveWaterSource]", "Right click to remove water source.")
				};
				((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val28);
			}
			else if (waterSourcePrefab.m_SourceType != 0 && !m_WaterToolUISystem.AmountIsAnElevation)
			{
				m_StartedHoveringTime = 0f;
				StringTooltip val29 = new StringTooltip
				{
					path = PathSegment.op_Implicit("Tooltip.LABEL[YY.WT.LockElevation]"),
					value = LocalizedString.IdWithFallback("Tooltip.LABEL[YY.WT.LockElevation]", "Right click to designate the water surface elevation.")
				};
				((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)val29);
			}
			else
			{
				m_StartedHoveringTime = 0f;
			}
		}

		protected override void OnDestroy()
		{
			((GameSystemBase)this).OnDestroy();
		}
	}
	public class WaterToolUISystem : UISystemBase
	{
		public enum SourceType
		{
			Stream,
			VanillaLake,
			River,
			Sea,
			Lake,
			DetentionBasin,
			RetentionBasin
		}

		private View m_UiView;

		private ToolSystem m_ToolSystem;

		private string m_InjectedJS = string.Empty;

		private string m_AmountItemScript = string.Empty;

		private string m_RadiusItemScript = string.Empty;

		private string m_MinDepthItemScript = string.Empty;

		private CustomWaterToolSystem m_CustomWaterToolSystem;

		private TerrainSystem m_TerrainSystem;

		private ILog m_Log;

		private bool m_WaterToolPanelShown;

		private List<BoundEventHandle> m_BoundEventHandles;

		private float m_Radius = 10f;

		private float m_Amount = 5f;

		private float m_MinDepth = 10f;

		private Dictionary<string, Action> m_ChangeValueActions;

		private bool m_ButtonPressed = false;

		private float m_AmountRateOfChange = 1f;

		private float m_RadiusRateOfChange = 1f;

		private float m_MinDepthRateOfChange = 1f;

		private bool m_ResetValues = true;

		private bool m_FirstTimeInjectingJS = true;

		private bool m_AmountIsElevation = false;

		private string m_ContentFolder;

		private Dictionary<WaterSourcePrefab, WaterSourcePrefabValuesRepository> m_WaterSourcePrefabValuesRepositories;

		public float Radius => m_Radius;

		public float Amount => m_Amount;

		public float MinDepth => m_MinDepth;

		public bool AmountIsAnElevation => m_AmountIsElevation;

		public void SetElevation(float elevation)
		{
			m_Amount = Mathf.Round(elevation * 10f) / 10f;
			m_AmountIsElevation = true;
			string text = "YY_WATER_FEATURES.Elevation";
			UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyWaterTool != 'object') var yyWaterTool = {};");
			UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.amount = document.getElementById(\"YYWT-amount-label\"); if (yyWaterTool.amount) { yyWaterTool.amount.localeKey = \"" + text + "\"; yyWaterTool.amount.innerHTML = engine.translate(yyWaterTool.amount.localeKey); }");
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.amountField = document.getElementById(\"YYWT-amount-field\"); if (yyWaterTool.amountField) yyWaterTool.amountField.innerHTML = \"{m_Amount} m\";");
		}

		public bool TrySaveDefaultValuesForWaterSource(WaterSourcePrefab waterSource, float amount, float radius)
		{
			string path = Path.Combine(m_ContentFolder, $"{waterSource.m_SourceType}.xml");
			WaterSourcePrefabValuesRepository waterSourcePrefabValuesRepository = new WaterSourcePrefabValuesRepository
			{
				Amount = amount,
				Radius = radius
			};
			try
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(WaterSourcePrefabValuesRepository));
				using (FileStream stream = File.Create(path))
				{
					xmlSerializer.Serialize(stream, waterSourcePrefabValuesRepository);
				}
				if (m_WaterSourcePrefabValuesRepositories.ContainsKey(waterSource))
				{
					m_WaterSourcePrefabValuesRepositories[waterSource].Amount = amount;
					m_WaterSourcePrefabValuesRepositories[waterSource].Radius = radius;
					m_Log.Debug((object)string.Format("{0}.{1} updating repository for {2}.", "WaterToolUISystem", "TrySaveDefaultValuesForWaterSource", waterSource.m_SourceType));
				}
				else
				{
					m_WaterSourcePrefabValuesRepositories.Add(waterSource, waterSourcePrefabValuesRepository);
					m_Log.Debug((object)string.Format("{0}.{1} adding repository for {2}.", "WaterToolUISystem", "TrySaveDefaultValuesForWaterSource", waterSource.m_SourceType));
				}
				return true;
			}
			catch (Exception ex)
			{
				m_Log.Warn((object)string.Format("{0}.{1} Could not save values for water source WaterSource {2}. Encountered exception {3}", "WaterToolUISystem", "TryGetDefaultValuesForWaterSource", waterSource.m_SourceType, ex));
				return false;
			}
		}

		public bool TrySaveDefaultValuesForWaterSource(WaterSourcePrefab waterSource, float radius)
		{
			if (m_WaterSourcePrefabValuesRepositories.ContainsKey(waterSource))
			{
				float amount = m_WaterSourcePrefabValuesRepositories[waterSource].Amount;
				return TrySaveDefaultValuesForWaterSource(waterSource, amount, radius);
			}
			return false;
		}

		protected override void OnCreate()
		{
			m_Log = WaterFeaturesMod.Instance.Log;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolSystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_CustomWaterToolSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<CustomWaterToolSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_TerrainSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<TerrainSystem>() : null);
			m_UiView = GameManager.instance.userInterface.view.View;
			ToolSystem toolSystem = m_ToolSystem;
			m_ToolSystem.EventToolChanged = (Action<ToolBaseSystem>)Delegate.Combine(toolSystem.EventToolChanged, new Action<ToolBaseSystem>(OnToolChanged));
			ToolSystem toolSystem2 = m_ToolSystem;
			m_ToolSystem.EventPrefabChanged = (Action<PrefabBase>)Delegate.Combine(toolSystem2.EventPrefabChanged, new Action<PrefabBase>(OnPrefabChanged));
			m_ContentFolder = Path.Combine(EnvPath.kUserDataPath, "ModsData", "Mods_Yenyang_Water_Features");
			Directory.CreateDirectory(m_ContentFolder);
			m_BoundEventHandles = new List<BoundEventHandle>();
			m_InjectedJS = UIFileUtils.ReadJS(Path.Combine(UIFileUtils.AssemblyPath, "ui.js"));
			m_AmountItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYWT-Amount-Item.html"), "if (document.getElementById(\"YYWT-amount-item\") == null) { yyWaterTool.div.className = \"item_bZY\"; yyWaterTool.div.id = \"YYWT-amount-item\"; yyWaterTool.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyWaterTool.entities[0] != null) { yyWaterTool.entities[0].insertAdjacentElement('afterbegin', yyWaterTool.div); } }");
			m_RadiusItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYWT-Radius-Item.html"), "if (document.getElementById(\"YYWT-radius-item\") == null) { yyWaterTool.div.className = \"item_bZY\"; yyWaterTool.div.id = \"YYWT-radius-item\"; yyWaterTool.amountItem = document.getElementById(\"YYWT-amount-item\"); if (yyWaterTool.amountItem != null) { yyWaterTool.amountItem.insertAdjacentElement('afterend', yyWaterTool.div); } }");
			m_MinDepthItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYWT-Min-Depth-Item.html"), "if (document.getElementById(\"YYWT-min-depth-item\") == null) { yyWaterTool.div.className = \"item_bZY\"; yyWaterTool.div.id = \"YYWT-min-depth-item\"; yyWaterTool.amountItem = document.getElementById(\"YYWT-amount-item\"); if (yyWaterTool.amountItem != null) { yyWaterTool.amountItem.insertAdjacentElement('afterend', yyWaterTool.div); } }");
			if (m_UiView == null)
			{
				m_Log.Warn((object)"WaterToolUISystem.OnCreate m_UiView == null");
			}
			m_ChangeValueActions = new Dictionary<string, Action>
			{
				{ "YYWT-amount-down-arrow", DecreaseAmount },
				{ "YYWT-amount-up-arrow", IncreaseAmount },
				{ "YYWT-radius-down-arrow", DecreaseRadius },
				{ "YYWT-radius-up-arrow", IncreaseRadius },
				{ "YYWT-min-depth-down-arrow", DecreaseMinDepth },
				{ "YYWT-min-depth-up-arrow", IncreaseMinDepth },
				{ "YYWT-amount-rate-of-change", AmountRateOfChangePressed },
				{ "YYWT-radius-rate-of-change", RadiusRateOfChangePressed },
				{ "YYWT-min-depth-rate-of-change", MinDepthRateOfChangePressed }
			};
			m_WaterSourcePrefabValuesRepositories = new Dictionary<WaterSourcePrefab, WaterSourcePrefabValuesRepository>();
			((UISystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			if (m_UiView == null)
			{
				return;
			}
			if (m_ToolSystem.activeTool != m_CustomWaterToolSystem)
			{
				if (m_WaterToolPanelShown)
				{
					UnshowWaterToolPanel();
					((ComponentSystemBase)this).Enabled = false;
				}
				return;
			}
			m_ButtonPressed = false;
			if (!m_WaterToolPanelShown)
			{
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyWaterTool != 'object') var yyWaterTool = {};");
				if (m_InjectedJS == string.Empty)
				{
					m_Log.Warn((object)"WaterToolUISystem.OnUpdate m_InjectedJS was empty. Did you put the ui.js file in the mod install folder?");
					m_InjectedJS = UIFileUtils.ReadJS(Path.Combine(UIFileUtils.AssemblyPath, "ui.js"));
					m_AmountItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYWT-Amount-Item.html"), "if (document.getElementById(\"YYWT-amount-item\") == null) { yyWaterTool.div.className = \"item_bZY\"; yyWaterTool.div.id = \"YYWT-amount-item\"; yyWaterTool.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyWaterTool.entities[0] != null) { yyWaterTool.entities[0].insertAdjacentElement('afterbegin', yyWaterTool.div); } }");
					m_RadiusItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYWT-Radius-Item.html"), "if (document.getElementById(\"YYWT-radius-item\") == null) { yyWaterTool.div.className = \"item_bZY\"; yyWaterTool.div.id = \"YYWT-radius-item\"; yyWaterTool.amountItem = document.getElementById(\"YYWT-amount-item\"); if (yyWaterTool.amountItem != null) { yyWaterTool.amountItem.insertAdjacentElement('afterend', yyWaterTool.div); } }");
					m_MinDepthItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYWT-Min-Depth-Item.html"), "if (document.getElementById(\"YYWT-min-depth-item\") == null) { yyWaterTool.div.className = \"item_bZY\"; yyWaterTool.div.id = \"YYWT-min-depth-item\"; yyWaterTool.amountItem = document.getElementById(\"YYWT-amount-item\"); if (yyWaterTool.amountItem != null) { yyWaterTool.amountItem.insertAdjacentElement('afterend', yyWaterTool.div); } }");
				}
				UIFileUtils.ExecuteScript(m_UiView, m_AmountItemScript);
				UIFileUtils.ExecuteScript(m_UiView, m_RadiusItemScript);
				UIFileUtils.ExecuteScript(m_UiView, m_InjectedJS);
				if (m_FirstTimeInjectingJS)
				{
					m_FirstTimeInjectingJS = false;
					return;
				}
				string arg = " m";
				if ((Object)(object)((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() != (Object)null)
				{
					WaterSourcePrefab waterSourcePrefab = ((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() as WaterSourcePrefab;
					string text = waterSourcePrefab.m_AmountLocaleKey;
					if (m_AmountIsElevation)
					{
						text = "YY_WATER_FEATURES.Elevation";
					}
					UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.amount = document.getElementById(\"YYWT-amount-label\"); if (yyWaterTool.amount) { yyWaterTool.amount.localeKey = \"" + text + "\"; yyWaterTool.amount.innerHTML = engine.translate(yyWaterTool.amount.localeKey); }");
					if (m_ResetValues)
					{
						m_Radius = waterSourcePrefab.m_DefaultRadius;
						m_Amount = waterSourcePrefab.m_DefaultAmount;
						TryGetDefaultValuesForWaterSource(waterSourcePrefab, ref m_Amount, ref m_Radius);
						m_AmountIsElevation = false;
					}
					if (waterSourcePrefab.m_SourceType == SourceType.Stream)
					{
						arg = string.Empty;
					}
					if (waterSourcePrefab.m_SourceType == SourceType.RetentionBasin)
					{
						UIFileUtils.ExecuteScript(m_UiView, m_MinDepthItemScript);
						if (m_ResetValues)
						{
							m_MinDepth = 10f;
						}
						UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.minDepthField = document.getElementById(\"YYWT-min-depth-field\"); if (yyWaterTool.minDepthField) yyWaterTool.minDepthField.innerHTML = \"{m_MinDepth} m\";");
						UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.applyLocalization(document.getElementById(\"YYWT-min-depth-item\")); yyWaterTool.setupButton(\"YYWT-min-depth-down-arrow\", \"min-depth-down-arrow\"); yyWaterTool.setupButton(\"YYWT-min-depth-up-arrow\", \"min-depth-up-arrow\");  yyWaterTool.setupButton(\"YYWT-min-depth-rate-of-change\", \"min-depth-rate-of-change\");");
						SetRateIcon(m_MinDepthRateOfChange, "min-depth");
					}
					m_ResetValues = false;
				}
				UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.radiusField = document.getElementById(\"YYWT-radius-field\"); if (yyWaterTool.radiusField) yyWaterTool.radiusField.innerHTML = \"{m_Radius} m\";");
				UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.amountField = document.getElementById(\"YYWT-amount-field\"); if (yyWaterTool.amountField) yyWaterTool.amountField.innerHTML = \"{m_Amount}{arg}\";");
				SetRateIcon(m_RadiusRateOfChange, "radius");
				SetRateIcon(m_AmountRateOfChange, "amount");
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYWT-log", (Delegate)new Action<string>(LogFromJS)));
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("CheckForElement-YYWT-amount-item", (Delegate)new Action<bool>(ElementCheck)));
				foreach (KeyValuePair<string, Action> changeValueAction in m_ChangeValueActions)
				{
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("Change-Value", (Delegate)new Action<string>(ChangeValue)));
				}
				m_WaterToolPanelShown = true;
			}
			else
			{
				UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYWT-amount-item\") == null) engine.trigger('CheckForElement-YYWT-amount-item', false);");
			}
			((UISystemBase)this).OnUpdate();
		}

		protected override void OnGameLoadingComplete(Purpose purpose, GameMode mode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			((GameSystemBase)this).OnGameLoadingComplete(purpose, mode);
		}

		private string DestroyElementByID(string id)
		{
			return "yyWaterTool.itemElement = document.getElementById(\"" + id + "\"); if (yyWaterTool.itemElement) yyWaterTool.itemElement.parentElement.removeChild(yyWaterTool.itemElement);";
		}

		private void LogFromJS(string log)
		{
			m_Log.Debug((object)("WaterToolUISystem.LogFromJS " + log));
		}

		private string BoolToString(bool flag)
		{
			if (flag)
			{
				return "true";
			}
			return "false";
		}

		private void ChangeValue(string buttonID)
		{
			if (buttonID == null)
			{
				m_Log.Warn((object)"WaterToolUISystem.ChangeValue buttonID was null.");
			}
			else if (!m_ButtonPressed)
			{
				m_Log.Debug((object)("WaterToolUISystem.ChangeValue buttonID = " + buttonID));
				if (m_ChangeValueActions.ContainsKey(buttonID))
				{
					m_ChangeValueActions[buttonID]();
				}
				m_ButtonPressed = true;
			}
		}

		private void IncreaseRadius()
		{
			float num = Mathf.Pow(10f, -1f * Mathf.Log(m_RadiusRateOfChange, 2f));
			if (m_Radius >= 1000f && m_Radius < 10000f)
			{
				m_Radius += 500f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.01f * num) / (0.01f * num);
			}
			else if (m_Radius >= 500f && m_Radius < 1000f)
			{
				m_Radius += 100f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.01f * num) / (0.01f * num);
			}
			else if (m_Radius >= 100f && m_Radius < 500f)
			{
				m_Radius += 50f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.1f * num) / (0.1f * num);
			}
			else if (m_Radius >= 10f && m_Radius < 100f)
			{
				m_Radius += 10f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.1f * num) / (0.1f * num);
			}
			else if (m_Radius < 10000f)
			{
				m_Radius += 1f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * num) / num;
			}
			if (WaterFeaturesMod.Settings.TrySmallerRadii)
			{
				m_Radius = Mathf.Clamp(m_Radius, 1f, 10000f);
			}
			else
			{
				m_Radius = Mathf.Clamp(m_Radius, 5f, 10000f);
			}
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.radiusField = document.getElementById(\"YYWT-radius-field\"); if (yyWaterTool.radiusField) yyWaterTool.radiusField.innerHTML = \"{m_Radius} m\";");
		}

		private void DecreaseRadius()
		{
			float num = Mathf.Pow(10f, -1f * Mathf.Log(m_RadiusRateOfChange, 2f));
			if (m_Radius <= 10f && m_Radius > 1f)
			{
				m_Radius -= 1f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * num) / num;
			}
			else if (m_Radius <= 100f && m_Radius > 10f)
			{
				m_Radius -= 10f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.1f * num) / (0.1f * num);
			}
			else if (m_Radius <= 500f && m_Radius > 100f)
			{
				m_Radius -= 50f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.1f * num) / (0.1f * num);
			}
			else if (m_Radius <= 1000f && m_Radius > 500f)
			{
				m_Radius -= 100f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.01f * num) / (0.01f * num);
			}
			else if (m_Radius > 1000f)
			{
				m_Radius -= 500f * m_RadiusRateOfChange;
				m_Radius = Mathf.Round(m_Radius * 0.01f * num) / (0.01f * num);
			}
			if (WaterFeaturesMod.Settings.TrySmallerRadii)
			{
				m_Radius = Mathf.Clamp(m_Radius, 1f, 10000f);
			}
			else
			{
				m_Radius = Mathf.Clamp(m_Radius, 5f, 10000f);
			}
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.radiusField = document.getElementById(\"YYWT-radius-field\"); if (yyWaterTool.radiusField) yyWaterTool.radiusField.innerHTML = \"{m_Radius} m\";");
		}

		private void IncreaseMinDepth()
		{
			float num = Mathf.Pow(10f, -1f * Mathf.Log(m_MinDepthRateOfChange, 2f));
			if (m_MinDepth >= 500f && m_MinDepth < 1000f)
			{
				m_MinDepth += 100f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 0.01f * num) / (0.01f * num);
			}
			else if (m_MinDepth >= 100f && m_MinDepth < 500f)
			{
				m_MinDepth += 50f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 0.1f * num) / (0.1f * num);
			}
			else if (m_MinDepth < 100f && m_MinDepth >= 10f)
			{
				m_MinDepth += 10f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 0.1f * num) / (0.1f * num);
			}
			else if (m_MinDepth < 10f && m_MinDepth >= 1f)
			{
				m_MinDepth += 1f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * num) / num;
			}
			else if (m_MinDepth < 1f)
			{
				if (m_MinDepth == 0.01f && m_MinDepthRateOfChange == 1f)
				{
					m_MinDepth = 0.1f;
				}
				else
				{
					m_MinDepth += 0.1f * m_MinDepthRateOfChange;
					m_MinDepth = Mathf.Round(m_MinDepth * 10f * num) / (10f * num);
				}
			}
			m_MinDepth = Mathf.Clamp(m_MinDepth, 0.01f, 1000f);
			if (m_MinDepth > m_Amount)
			{
				m_Amount = m_MinDepth;
				string arg = " m";
				if ((Object)(object)((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() != (Object)null)
				{
					WaterSourcePrefab waterSourcePrefab = ((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() as WaterSourcePrefab;
					if (waterSourcePrefab.m_SourceType == SourceType.Stream)
					{
						arg = string.Empty;
					}
				}
				UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.amountField = document.getElementById(\"YYWT-amount-field\"); if (yyWaterTool.amountField) yyWaterTool.amountField.innerHTML = \"{m_Amount}{arg}\";");
			}
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.minDepthField = document.getElementById(\"YYWT-min-depth-field\"); if (yyWaterTool.minDepthField) yyWaterTool.minDepthField.innerHTML = \"{m_MinDepth} m\";");
		}

		private void DecreaseMinDepth()
		{
			float num = Mathf.Pow(10f, -1f * Mathf.Log(m_MinDepthRateOfChange, 2f));
			if (m_MinDepth <= 1f)
			{
				m_MinDepth -= 0.1f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 10f * num) / (10f * num);
			}
			else if (m_MinDepth <= 10f && m_MinDepth > 1f)
			{
				m_MinDepth -= 1f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * num) / num;
			}
			else if (m_MinDepth <= 100f && m_MinDepth > 10f)
			{
				m_MinDepth -= 10f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 0.1f * num) / (0.1f * num);
			}
			else if (m_MinDepth <= 500f && m_MinDepth > 100f)
			{
				m_MinDepth -= 50f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 0.1f * num) / (0.1f * num);
			}
			else if (m_MinDepth > 500f)
			{
				m_MinDepth -= 100f * m_MinDepthRateOfChange;
				m_MinDepth = Mathf.Round(m_MinDepth * 0.01f * num) / (0.01f * num);
			}
			m_MinDepth = Mathf.Clamp(m_MinDepth, 0.01f, 1000f);
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.minDepthField = document.getElementById(\"YYWT-min-depth-field\"); if (yyWaterTool.minDepthField) yyWaterTool.minDepthField.innerHTML = \"{m_MinDepth} m\";");
		}

		private void IncreaseAmount()
		{
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Pow(10f, -1f * Mathf.Log(m_AmountRateOfChange, 2f));
			if (!m_AmountIsElevation)
			{
				if (m_Amount >= 500f && m_Amount < 1000f)
				{
					m_Amount += 100f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 0.01f * num) / (0.01f * num);
				}
				else if (m_Amount >= 100f && m_Amount < 500f)
				{
					m_Amount += 50f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 0.1f * num) / (0.1f * num);
				}
				else if (m_Amount < 100f && m_Amount >= 10f)
				{
					m_Amount += 10f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 0.1f * num) / (0.1f * num);
				}
				else if (m_Amount < 10f && m_Amount >= 1f)
				{
					m_Amount += 1f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * num) / num;
				}
				else if (m_Amount < 1f)
				{
					if (m_Amount == 0.01f && m_AmountRateOfChange == 1f)
					{
						m_Amount = 0.1f;
					}
					else
					{
						m_Amount += 0.1f * m_AmountRateOfChange;
						m_Amount = Mathf.Round(m_Amount * 10f * num) / (10f * num);
					}
				}
				m_Amount = Mathf.Clamp(m_Amount, 0.01f, 1000f);
			}
			else
			{
				m_Amount += 10f * m_AmountRateOfChange;
				m_Amount = Mathf.Round(m_Amount * 10f) / 10f;
				float amount = m_Amount;
				Bounds terrainBounds = m_TerrainSystem.GetTerrainBounds();
				float y = ((Bounds)(ref terrainBounds)).min.y;
				terrainBounds = m_TerrainSystem.GetTerrainBounds();
				m_Amount = Mathf.Clamp(amount, y, ((Bounds)(ref terrainBounds)).max.y);
			}
			string arg = " m";
			if ((Object)(object)((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() != (Object)null)
			{
				WaterSourcePrefab waterSourcePrefab = ((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() as WaterSourcePrefab;
				if (waterSourcePrefab.m_SourceType == SourceType.Stream)
				{
					arg = string.Empty;
				}
			}
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.amountField = document.getElementById(\"YYWT-amount-field\"); if (yyWaterTool.amountField) yyWaterTool.amountField.innerHTML = \"{m_Amount}{arg}\";");
		}

		private void DecreaseAmount()
		{
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Pow(10f, -1f * Mathf.Log(m_AmountRateOfChange, 2f));
			if (!m_AmountIsElevation)
			{
				if (m_Amount <= 1f)
				{
					m_Amount -= 0.1f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 10f * num) / (10f * num);
				}
				else if (m_Amount <= 10f && m_Amount > 1f)
				{
					m_Amount -= 1f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * num) / num;
				}
				else if (m_Amount <= 100f && m_Amount > 10f)
				{
					m_Amount -= 10f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 0.1f * num) / (0.1f * num);
				}
				else if (m_Amount <= 500f && m_Amount > 100f)
				{
					m_Amount -= 50f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 0.1f * num) / (0.1f * num);
				}
				else if (m_Amount > 500f)
				{
					m_Amount -= 100f * m_AmountRateOfChange;
					m_Amount = Mathf.Round(m_Amount * 0.01f * num) / (0.01f * num);
				}
				m_Amount = Mathf.Clamp(m_Amount, 0.01f, 1000f);
			}
			else
			{
				m_Amount -= 10f * m_AmountRateOfChange;
				m_Amount = Mathf.Round(m_Amount * 10f) / 10f;
				float amount = m_Amount;
				Bounds terrainBounds = m_TerrainSystem.GetTerrainBounds();
				float y = ((Bounds)(ref terrainBounds)).min.y;
				terrainBounds = m_TerrainSystem.GetTerrainBounds();
				m_Amount = Mathf.Clamp(amount, y, ((Bounds)(ref terrainBounds)).max.y);
			}
			if (m_Amount < m_MinDepth)
			{
				m_MinDepth = m_Amount;
				UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.minDepthField = document.getElementById(\"YYWT-min-depth-field\"); if (yyWaterTool.minDepthField) yyWaterTool.minDepthField.innerHTML = \"{m_MinDepth} m\";");
			}
			string arg = " m";
			if ((Object)(object)((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() != (Object)null)
			{
				WaterSourcePrefab waterSourcePrefab = ((ToolBaseSystem)m_CustomWaterToolSystem).GetPrefab() as WaterSourcePrefab;
				if (waterSourcePrefab.m_SourceType == SourceType.Stream)
				{
					arg = string.Empty;
				}
			}
			UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.amountField = document.getElementById(\"YYWT-amount-field\"); if (yyWaterTool.amountField) yyWaterTool.amountField.innerHTML = \"{m_Amount}{arg}\";");
		}

		private void RadiusRateOfChangePressed()
		{
			m_RadiusRateOfChange /= 2f;
			if (m_RadiusRateOfChange < 0.125f)
			{
				m_RadiusRateOfChange = 1f;
			}
			SetRateIcon(m_RadiusRateOfChange, "radius");
		}

		private void AmountRateOfChangePressed()
		{
			m_AmountRateOfChange /= 2f;
			if (m_AmountRateOfChange < 0.125f)
			{
				m_AmountRateOfChange = 1f;
			}
			SetRateIcon(m_AmountRateOfChange, "amount");
		}

		private void MinDepthRateOfChangePressed()
		{
			m_MinDepthRateOfChange /= 2f;
			if (m_MinDepthRateOfChange < 0.125f)
			{
				m_MinDepthRateOfChange = 1f;
			}
			SetRateIcon(m_MinDepthRateOfChange, "min-depth");
		}

		private void SetRateIcon(float field, string id)
		{
			if (field == 1f)
			{
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-1\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#1e83aa\");");
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-0pt5\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#1e83aa\");");
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-0pt25\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#1e83aa\");");
			}
			else if (field == 0.5f)
			{
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-1\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#424242\");");
			}
			else if (field == 0.25f)
			{
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-1\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#424242\");");
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-0pt5\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#424242\");");
			}
			else
			{
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-1\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#424242\");");
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-0pt5\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#424242\");");
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.rateOfChange = document.getElementById(\"YYWT-" + id + "-roc-0pt25\"); if (yyWaterTool.rateOfChange) yyWaterTool.rateOfChange.setAttribute(\"fill\",\"#424242\");");
			}
		}

		private void ElementCheck(bool flag)
		{
			m_WaterToolPanelShown = flag;
		}

		private void UnshowWaterToolPanel()
		{
			//IL_006a: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			if (m_UiView == null)
			{
				return;
			}
			UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYWT-amount-item"));
			UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYWT-radius-item"));
			UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYWT-min-depth-item"));
			foreach (BoundEventHandle boundEventHandle in m_BoundEventHandles)
			{
				m_UiView.UnregisterFromEvent(boundEventHandle);
			}
			m_BoundEventHandles.Clear();
			m_WaterToolPanelShown = false;
		}

		private void OnToolChanged(ToolBaseSystem tool)
		{
			if (tool != m_CustomWaterToolSystem)
			{
				if (m_WaterToolPanelShown)
				{
					UnshowWaterToolPanel();
				}
				((ComponentSystemBase)this).Enabled = false;
			}
			else
			{
				((ComponentSystemBase)this).Enabled = true;
			}
		}

		private void OnPrefabChanged(PrefabBase prefabBase)
		{
			m_Log.Debug((object)"WaterToolUISystem.OnPrefabChanged");
			if (prefabBase is WaterSourcePrefab && m_UiView != null)
			{
				m_Log.Debug((object)"WaterToolUISystem.OnPrefabChanged prefab is water source.");
				WaterSourcePrefab waterSourcePrefab = prefabBase as WaterSourcePrefab;
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyWaterTool != 'object') var yyWaterTool = {};");
				UIFileUtils.ExecuteScript(m_UiView, "yyWaterTool.amount = document.getElementById(\"YYWT-amount-label\"); if (yyWaterTool.amount) { yyWaterTool.amount.localeKey = \"" + waterSourcePrefab.m_AmountLocaleKey + "\"; yyWaterTool.amount.innerHTML = engine.translate(yyWaterTool.amount.localeKey); }");
				m_Radius = waterSourcePrefab.m_DefaultRadius;
				m_Amount = waterSourcePrefab.m_DefaultAmount;
				TryGetDefaultValuesForWaterSource(waterSourcePrefab, ref m_Amount, ref m_Radius);
				m_AmountIsElevation = false;
				UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.radiusField = document.getElementById(\"YYWT-radius-field\"); if (yyWaterTool.radiusField) yyWaterTool.radiusField.innerHTML = \"{m_Radius} m\";");
				string arg = " m";
				if (waterSourcePrefab.m_SourceType == SourceType.Stream)
				{
					arg = string.Empty;
				}
				UIFileUtils.ExecuteScript(m_UiView, $"yyWaterTool.amountField = document.getElementById(\"YYWT-amount-field\"); if (yyWaterTool.amountField) yyWaterTool.amountField.innerHTML = \"{m_Amount}{arg}\";");
				if (waterSourcePrefab.m_SourceType == SourceType.RetentionBasin)
				{
					m_WaterToolPanelShown = false;
				}
				else
				{
					UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYWT-min-depth-item"));
				}
				m_ResetValues = true;
			}
		}

		private bool TryGetDefaultValuesForWaterSource(WaterSourcePrefab waterSource, ref float amount, ref float radius)
		{
			string path = Path.Combine(m_ContentFolder, $"{waterSource.m_SourceType}.xml");
			if (m_WaterSourcePrefabValuesRepositories.ContainsKey(waterSource))
			{
				amount = m_WaterSourcePrefabValuesRepositories[waterSource].Amount;
				radius = m_WaterSourcePrefabValuesRepositories[waterSource].Radius;
				m_Log.Debug((object)string.Format("{0}.{1} found repository for {2}.", "WaterToolUISystem", "TryGetDefaultValuesForWaterSource", waterSource.m_SourceType));
				return true;
			}
			if (File.Exists(path))
			{
				try
				{
					XmlSerializer xmlSerializer = new XmlSerializer(typeof(WaterSourcePrefabValuesRepository));
					using FileStream stream = new FileStream(path, FileMode.Open);
					WaterSourcePrefabValuesRepository waterSourcePrefabValuesRepository = (WaterSourcePrefabValuesRepository)xmlSerializer.Deserialize(stream);
					if (waterSourcePrefabValuesRepository.Amount >= 0.125f && waterSourcePrefabValuesRepository.Amount <= 1000f)
					{
						amount = waterSourcePrefabValuesRepository.Amount;
					}
					if (waterSourcePrefabValuesRepository.Radius >= 5f && waterSourcePrefabValuesRepository.Radius <= 10000f)
					{
						radius = waterSourcePrefabValuesRepository.Radius;
					}
					if (!m_WaterSourcePrefabValuesRepositories.ContainsKey(waterSource))
					{
						m_WaterSourcePrefabValuesRepositories.Add(waterSource, waterSourcePrefabValuesRepository);
						m_Log.Debug((object)string.Format("{0}.{1} adding repository for {2}.", "WaterToolUISystem", "TryGetDefaultValuesForWaterSource", waterSource.m_SourceType));
					}
					m_Log.Debug((object)string.Format("{0}.{1} loaded repository for {2}.", "WaterToolUISystem", "TryGetDefaultValuesForWaterSource", waterSource.m_SourceType));
					return true;
				}
				catch (Exception ex)
				{
					m_Log.Warn((object)string.Format("{0}.{1} Could not get default values for WaterSource {2}. Encountered exception {3}", "WaterToolUISystem", "TryGetDefaultValuesForWaterSource", waterSource.m_SourceType, ex));
					return false;
				}
			}
			if (TrySaveDefaultValuesForWaterSource(waterSource, amount, radius))
			{
				m_Log.Debug((object)string.Format("{0}.{1} Saved {2}'s default values because the file didn't exist.", "WaterToolUISystem", "TryGetDefaultValuesForWaterSource", waterSource.m_SourceType));
			}
			return false;
		}
	}
	public class CustomWaterToolSystem : ToolBaseSystem
	{
		private struct RemoveEntityJob : IJob
		{
			public Entity m_Entity;

			public EntityCommandBuffer buffer;

			public void Execute()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				((EntityCommandBuffer)(ref buffer)).DestroyEntity(m_Entity);
			}
		}

		private struct RemoveWaterSourcesJob : IJobChunk
		{
			[ReadOnly]
			public EntityTypeHandle m_EntityType;

			[ReadOnly]
			public ComponentTypeHandle<WaterSourceData> m_SourceType;

			[ReadOnly]
			public ComponentTypeHandle<Transform> m_TransformType;

			public float3 m_Position;

			public EntityCommandBuffer buffer;

			public float m_MapExtents;

			public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: 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_0077: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(m_EntityType);
				NativeArray<WaterSourceData> nativeArray2 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<WaterSourceData>(ref m_SourceType);
				NativeArray<Transform> nativeArray3 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<Transform>(ref m_TransformType);
				for (int i = 0; i < ((ArchetypeChunk)(ref chunk)).Count; i++)
				{
					Entity val = nativeArray[i];
					WaterSourceData val2 = nativeArray2[i];
					Transform val3 = nativeArray3[i];
					m_Position.y = 0f;
					val3.m_Position.y = 0f;
					if (math.distance(m_Position, val3.m_Position) < Mathf.Clamp(val2.m_Radius, 25f, 150f))
					{
						((EntityCommandBuffer)(ref buffer)).DestroyEntity(val);
					}
				}
			}

			void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
			{
				Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask);
			}
		}

		private struct AddWaterSourceJob : IJob
		{
			public WaterSourceData waterSourceData;

			public Transform transform;

			public EntityCommandBuffer buffer;

			public EntityArchetype entityArchetype;

			public void Execute()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: 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_002e: 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)
				Entity val = ((EntityCommandBuffer)(ref buffer)).CreateEntity(entityArchetype);
				((EntityCommandBuffer)(ref buffer)).SetComponent<WaterSourceData>(val, waterSourceData);
				((EntityCommandBuffer)(ref buffer)).SetComponent<Transform>(val, transform);
				((EntityCommandBuffer)(ref buffer)).AddComponent<Updated>(val);
			}
		}

		private struct AddAutoFillingLakeJob : IJob
		{
			public WaterSourceData waterSourceData;

			public Transform transform;

			public AutofillingLake autoFillingLakeData;

			public EntityCommandBuffer buffer;

			public EntityArchetype entityArchetype;

			public void Execute()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: 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_002e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
				Entity val = ((EntityCommandBuffer)(ref buffer)).CreateEntity(entityArchetype);
				((EntityCommandBuffer)(ref buffer)).SetComponent<WaterSourceData>(val, waterSourceData);
				((EntityCommandBuffer)(ref buffer)).SetComponent<Transform>(val, transform);
				((EntityCommandBuffer)(ref buffer)).SetComponent<AutofillingLake>(val, autoFillingLakeData);
				((EntityCommandBuffer)(ref buffer)).AddComponent<Updated>(val);
			}
		}

		private struct AddDetentionBasinJob : IJob
		{
			public WaterSourceData waterSourceData;

			public Transform transform;

			public DetentionBasin detentionBasinData;

			public EntityCommandBuffer buffer;

			public EntityArchetype entityArchetype;

			public void Execute()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: 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_002e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
				Entity val = ((EntityCommandBuffer)(ref buffer)).CreateEntity(entityArchetype);
				((EntityCommandBuffer)(ref buffer)).SetComponent<WaterSourceData>(val, waterSourceData);
				((EntityCommandBuffer)(ref buffer)).SetComponent<Transform>(val, transform);
				((EntityCommandBuffer)(ref buffer)).SetComponent<DetentionBasin>(val, detentionBasinData);
				((EntityCommandBuffer)(ref buffer)).AddComponent<Updated>(val);
			}
		}

		private struct AddRetentionBasinJob : IJob
		{
			public WaterSourceData waterSourceData;

			public Transform transform;

			public RetentionBasin retentionBasinData;

			public EntityCommandBuffer buffer;

			public EntityArchetype entityArchetype;

			public void Execute()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: 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_002e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
				Entity val = ((EntityCommandBuffer)(ref buffer)).CreateEntity(entityArchetype);
				((EntityCommandBuffer)(ref buffer)).SetComponent<WaterSourceData>(val, waterSourceData);
				((EntityCommandBuffer)(ref buffer)).SetComponent<Transform>(val, transform);
				((EntityCommandBuffer)(ref buffer)).SetComponent<RetentionBasin>(val, retentionBasinData);
				((EntityCommandBuffer)(ref buffer)).AddComponent<Updated>(val);
			}
		}

		private struct WaterSourceCirclesRenderJob : IJobChunk
		{
			public Buffer m_OverlayBuffer;

			[ReadOnly]
			public ComponentTypeHandle<Transform> m_TransformType;

			[ReadOnly]
			public ComponentTypeHandle<WaterSourceData> m_SourceType;

			[ReadOnly]
			public EntityTypeHandle m_EntityType;

			public TerrainHeightData m_TerrainHeightData;

			public WaterSurfaceData m_WaterSurfaceData;

			[ReadOnly]
			public ComponentLookup<RetentionBasin> m_RetentionBasinLookup;

			[ReadOnly]
			public ComponentLookup<DetentionBasin> m_DetentionBasinLookup;

			[ReadOnly]
			public ComponentLookup<AutofillingLake> m_AutofillingLakeLookup;

			public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//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_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: 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_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: 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_00fe: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_023c: Unknown result type (might be due to invalid IL or missing references)
				//IL_023e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0253: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0272: Unknown result type (might be due to invalid IL or missing references)
				//IL_0278: Unknown result type (might be due to invalid IL or missing references)
				//IL_027a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0292: Unknown result type (might be due to invalid IL or missing references)
				//IL_0297: Unknown result type (might be due to invalid IL or missing references)
				//IL_0299: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: 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_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0208: Unknown result type (might be due to invalid IL or missing references)
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				NativeArray<WaterSourceData> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray<WaterSourceData>(ref m_SourceType);
				NativeArray<Transform> nativeArray2 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<Transform>(ref m_TransformType);
				NativeArray<Entity> nativeArray3 = ((ArchetypeChunk)(ref chunk)).GetNativeArray(m_EntityType);
				float3 val3 = default(float3);
				float3 val4 = default(float3);
				for (int i = 0; i < ((ArchetypeChunk)(ref chunk)).Count; i++)
				{
					WaterSourceData val = nativeArray[i];
					if (val.m_Radius != 0f)
					{
						Transform val2 = nativeArray2[i];
						((float3)(ref val3))..ctor(val2.m_Position.x, TerrainUtils.SampleHeight(ref m_TerrainHeightData, val2.m_Position), val2.m_Position.z);
						((float3)(ref val4))..ctor(val2.m_Position.x, WaterUtils.SampleHeight(ref m_WaterSurfaceData, ref m_TerrainHeightData, val2.m_Position), val2.m_Position.z);
						float3 val5 = val3;
						if (val4.y > val3.y)
						{
							val5 = val4;
						}
						Color val6 = GetWaterSourceColor(val.m_ConstantDepth);
						if (m_RetentionBasinLookup.HasComponent(nativeArray3[i]))
						{
							val6 = Color.magenta;
						}
						else if (m_DetentionBasinLookup.HasComponent(nativeArray3[i]))
						{
							((Color)(ref val6))..ctor(0.95f, 0.44f, 0.13f, 1f);
						}
						else if (m_AutofillingLakeLookup.HasComponent(nativeArray3[i]))
						{
							((Color)(ref val6))..ctor(0.422f, 0.242f, 0.152f);
						}
						Color val7 = val6;
						val7.a = 0.1f;
						float num = Mathf.Clamp(val.m_Radius, 25f, 150f);
						if (num > val.m_Radius)
						{
							((Buffer)(ref m_OverlayBuffer)).DrawCircle(val6, val7, val.m_Radius / 20f, (StyleFlags)0, new float2(0f, 1f), val5, val.m_Radius * 2f);
							((Buffer)(ref m_OverlayBuffer)).DrawCircle(val6, default(Color), num / 20f, (StyleFlags)0, new float2(0f, 1f), val5, num * 2.05f);
						}
						else
						{
							((Buffer)(ref m_OverlayBuffer)).DrawCircle(val6, val7, num / 20f, (StyleFlags)0, new float2(0f, 1f), val5, num * 2f);
							((Buffer)(ref m_OverlayBuffer)).DrawCircle(val6, default(Color), val.m_Radius / 20f, (StyleFlags)0, new float2(0f, 1f), val5, val.m_Radius * 2.05f);
						}
					}
				}
			}

			private Color GetWaterSourceColor(int constantDepth)
			{
				//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_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: 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)
				return (Color)(constantDepth switch
				{
					0 => Color.red, 
					1 => new Color(0.422f, 0.242f, 0.152f), 
					2 => Color.yellow, 
					3 => Color.green, 
					_ => Color.red, 
				});
			}

			void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
			{
				Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask);
			}
		}

		private struct WaterToolRadiusJob : IJob
		{
			public Buffer m_OverlayBuffer;

			public float3 m_Position;

			public float m_Radius;

			public WaterToolUISystem.SourceType m_SourceType;

			public void Execute()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: 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_00cf: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: 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_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				Color waterSourceColor = GetWaterSourceColor();
				Color val = waterSourceColor;
				val.a = 0.1f;
				float num = Mathf.Clamp(m_Radius, 25f, 150f);
				if (num > m_Radius)
				{
					((Buffer)(ref m_OverlayBuffer)).DrawCircle(waterSourceColor, val, m_Radius / 20f, (StyleFlags)0, new float2(0f, 1f), m_Position, m_Radius * 2f);
					((Buffer)(ref m_OverlayBuffer)).DrawCircle(waterSourceColor, default(Color), num / 20f, (StyleFlags)0, new float2(0f, 1f), m_Position, num * 2.05f);
				}
				else
				{
					((Buffer)(ref m_OverlayBuffer)).DrawCircle(waterSourceColor, val, num / 20f, (StyleFlags)0, new float2(0f, 1f), m_Position, num * 2f);
					((Buffer)(ref m_OverlayBuffer)).DrawCircle(waterSourceColor, default(Color), m_Radius / 20f, (StyleFlags)0, new float2(0f, 1f), m_Position, m_Radius * 2.05f);
				}
			}

			private Color GetWaterSourceColor()
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: 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_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_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_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_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				return (Color)(m_SourceType switch
				{
					WaterToolUISystem.SourceType.Stream => Color.red, 
					WaterToolUISystem.SourceType.VanillaLake => new Color(0.422f, 0.242f, 0.152f), 
					WaterToolUISystem.SourceType.River => Color.yellow, 
					WaterToolUISystem.SourceType.Sea => Color.green, 
					WaterToolUISystem.SourceType.Lake => new Color(0.422f, 0.242f, 0.152f), 
					WaterToolUISystem.SourceType.DetentionBasin => new Color(0.95f, 0.44f, 0.13f, 1f), 
					WaterToolUISystem.SourceType.RetentionBasin => Color.magenta, 
					_ => Color.red, 
				});
			}
		}

		private struct WaterLevelProjectionJob : IJob
		{
			public Buffer m_OverlayBuffer;

			public float3 m_Position;

			public float m_Radius;

			public void Execute()
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				((Buffer)(ref m_OverlayBuffer)).DrawCircle(new Color(0f, 0f, 1f, 0.375f), m_Position, m_Radius * 6f);
			}
		}

		private struct HoverOverWaterSourceJob : IJobChunk
		{
			[ReadOnly]
			public EntityTypeHandle m_EntityType;

			[ReadOnly]
			public ComponentTypeHandle<WaterSourceData> m_SourceType;

			[ReadOnly]
			public ComponentTypeHandle<Transform> m_TransformType;

			public float3 m_Position;

			public NativeList<Entity> m_Entities;

			public float m_MapExtents;

			public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: 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_0087: 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_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(m_EntityType);
				NativeArray<WaterSourceData> nativeArray2 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<WaterSourceData>(ref m_SourceType);
				NativeArray<Transform> nativeArray3 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<Transform>(ref m_TransformType);
				for (int i = 0; i < ((ArchetypeChunk)(ref chunk)).Count; i++)
				{
					Entity val = nativeArray[i];
					WaterSourceData val2 = nativeArray2[i];
					if (val2.m_Radius != 0f)
					{
						Transform val3 = nativeArray3[i];
						m_Position.y = 0f;
						val3.m_Position.y = 0f;
						if (math.distance(m_Position, val3.m_Position) < Mathf.Clamp(val2.m_Radius, 25f, 150f))
						{
							m_Entities.Add(ref val);
						}
					}
				}
			}

			void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
			{
				Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask);
			}
		}

		private struct TypeHandle
		{
			[ReadOnly]
			public ComponentTypeHandle<WaterSourceData> __Game_Simulation_WaterSourceData_RO_ComponentTypeHandle;

			[ReadOnly]
			public EntityTypeHandle __Unity_Entities_Entity_TypeHandle;

			[ReadOnly]