Decompiled source of Better Bulldozer v1.1.0

Better_Bulldozer.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Anarchy.Utils;
using BepInEx;
using Better_Bulldozer;
using Better_Bulldozer.Settings;
using Better_Bulldozer.Systems;
using Colossal;
using Colossal.Logging;
using Colossal.UI;
using Game;
using Game.Areas;
using Game.Common;
using Game.Modding;
using Game.Net;
using Game.Prefabs;
using Game.Rendering;
using Game.SceneFlow;
using Game.Tools;
using Game.UI;
using HarmonyLib;
using Unity.Entities;
using UnityEngine;
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("Better_Bulldozer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Better_Bulldozer")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9506061-6d7e-48f8-8314-105fcbf2fed8")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace Anarchy.Utils
{
	internal static class UIFileUtils
	{
		private static string s_assemblyPath;

		public static string AssemblyPath
		{
			get
			{
				if (string.IsNullOrWhiteSpace(s_assemblyPath))
				{
					s_assemblyPath = Path.GetDirectoryName(typeof(BetterBulldozerPlugin).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))
				{
					BetterBulldozerMod.Instance.Logger.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)
			{
				BetterBulldozerMod.Instance.Logger.Error(ex, (object)"exception reading UI files");
			}
		}

		internal static string ReadHTML(string fileName, string injectionPostfix = "document.body.appendChild(divYYA);")
		{
			try
			{
				string text = ReadUIFile(fileName);
				if (!string.IsNullOrEmpty(text))
				{
					return "yyBetterBulldozer.div = document.createElement('div'); yyBetterBulldozer.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; " + injectionPostfix;
				}
			}
			catch (Exception ex)
			{
				BetterBulldozerMod.Instance.Logger.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 "yyBetterBulldozer.div = document.createElement('div'); yyBetterBulldozer.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.body.appendChild(yyBetterBulldozer.div);";
				}
			}
			catch (Exception ex)
			{
				BetterBulldozerMod.Instance.Logger.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)
			{
				BetterBulldozerMod.Instance.Logger.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 "yyBetterBulldozer.style = document.createElement('style'); yyBetterBulldozer.style.type = 'text/css'; yyBetterBulldozer.style.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.head.appendChild(yyBetterBulldozer.style);";
				}
			}
			catch (Exception ex)
			{
				BetterBulldozerMod.Instance.Logger.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)
			{
				BetterBulldozerMod.Instance.Logger.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 Better_Bulldozer
{
	[BepInPlugin("Better_Bulldozer", "Better Bulldozer", "1.1.0")]
	[HarmonyPatch]
	public class BetterBulldozerPlugin : BaseUnityPlugin
	{
		internal static BetterBulldozerMod _mod;

		public void Awake()
		{
			_mod = new BetterBulldozerMod();
			_mod.OnLoad();
			_mod.Logger.Info((object)"BetterBulldozerPlugin.Awake");
			Harmony.CreateAndPatchAll(typeof(BetterBulldozerPlugin).Assembly, "Better_Bulldozer");
		}

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

		public static BetterBulldozerMod Instance { get; private set; }

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

		internal ILog Logger { get; private set; }

		public void OnLoad()
		{
			Instance = this;
			Logger = LogManager.GetLogger("Mods_Yenyang_Better_Bulldozer", false);
			Logger.Info((object)"Loading. . .");
		}

		public void OnCreateWorld(UpdateSystem updateSystem)
		{
			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-better-bulldozer", new List<string> { UIFileUtils.AssemblyPath });
			}
			Logger.effectivenessLevel = Level.Info;
			Logger.Info((object)"Handling create world");
			Logger.Info((object)("ModInstallFolder = " + ModInstallFolder));
			LoadLocales();
			updateSystem.UpdateAt<BetterBulldozerUISystem>((SystemUpdatePhase)22);
		}

		public void OnDispose()
		{
			Logger.Info((object)"Disposing..");
		}

		private void LoadLocales()
		{
			string[] supportedLocales = GameManager.instance.localizationManager.GetSupportedLocales();
			foreach (string text in supportedLocales)
			{
				GameManager.instance.localizationManager.AddSource(text, (IDictionarySource)(object)new LocaleEN());
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Better_Bulldozer";

		public const string PLUGIN_NAME = "";

		public const string PLUGIN_VERSION = "1.0.0.0";
	}
}
namespace Better_Bulldozer.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)
			{
				BetterBulldozerMod.Instance.Logger.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)
			{
				BetterBulldozerMod.Instance.Logger.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;
		}
	}
}
namespace Better_Bulldozer.Systems
{
	public class BetterBulldozerUISystem : UISystemBase
	{
		public enum RaycastTarget
		{
			Vanilla,
			Areas,
			Markers,
			Lanes
		}

		private View m_UiView;

		private ToolSystem m_ToolSystem;

		private string m_InjectedJS = string.Empty;

		private ILog m_Log;

		private RenderingSystem m_RenderingSystem;

		private PrefabSystem m_PrefabSystem;

		private bool m_BulldozeItemShown;

		private List<BoundEventHandle> m_BoundEventHandles;

		private string m_BulldozeToolItemScript;

		private BulldozeToolSystem m_BulldozeToolSystem;

		private bool m_LastGamePlayManipulation;

		private bool m_LastBypassConfrimation;

		private bool m_RecordedShowMarkers;

		private bool m_PrefabIsMarker = false;

		private RaycastTarget m_RaycastTarget;

		private bool m_FirstTimeLoadingJS = true;

		private bool m_DelayOneFrameForAnarchy = true;

		private NetToolSystem m_NetToolSystem;

		private AreaTypeMask m_AreasFilter = (AreaTypeMask)16;

		private TypeMask m_MarkersFilter = (TypeMask)8;

		private string m_AreasFiltersRowScript = string.Empty;

		private string m_MarkersFiltersRowScript = string.Empty;

		private ObjectToolSystem m_ObjectToolSystem;

		private DefaultToolSystem m_DefaultToolSystem;

		public RaycastTarget SelectedRaycastTarget => m_RaycastTarget;

		public AreaTypeMask AreasFilter => m_AreasFilter;

		public TypeMask MarkersFilter => m_MarkersFilter;

		protected override void OnCreate()
		{
			m_Log = BetterBulldozerMod.Instance.Logger;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolSystem>() : null);
			m_UiView = GameManager.instance.userInterface.view.View;
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_BulldozeToolSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<BulldozeToolSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_RenderingSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<RenderingSystem>() : null);
			World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<PrefabSystem>() : null);
			World defaultGameObjectInjectionWorld5 = World.DefaultGameObjectInjectionWorld;
			m_ObjectToolSystem = ((defaultGameObjectInjectionWorld5 != null) ? defaultGameObjectInjectionWorld5.GetOrCreateSystemManaged<ObjectToolSystem>() : null);
			World defaultGameObjectInjectionWorld6 = World.DefaultGameObjectInjectionWorld;
			m_NetToolSystem = ((defaultGameObjectInjectionWorld6 != null) ? defaultGameObjectInjectionWorld6.GetOrCreateSystemManaged<NetToolSystem>() : null);
			ToolSystem toolSystem = m_ToolSystem;
			m_ToolSystem.EventToolChanged = (Action<ToolBaseSystem>)Delegate.Combine(toolSystem.EventToolChanged, new Action<ToolBaseSystem>(OnToolChanged));
			m_BoundEventHandles = new List<BoundEventHandle>();
			World defaultGameObjectInjectionWorld7 = World.DefaultGameObjectInjectionWorld;
			m_DefaultToolSystem = ((defaultGameObjectInjectionWorld7 != null) ? defaultGameObjectInjectionWorld7.GetOrCreateSystemManaged<DefaultToolSystem>() : null);
			m_InjectedJS = UIFileUtils.ReadJS(Path.Combine(UIFileUtils.AssemblyPath, "ui.js"));
			m_BulldozeToolItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYBB-bulldoze-tool-mode-row.html"), "if (document.getElementById(\"YYA-bulldoze-tool-mode-item\") == null && document.getElementById(\"YYBB-bulldoze-tool-mode-item\") == null) { yyBetterBulldozer.div.className = \"item_bZY\"; yyBetterBulldozer.div.id = \"YYBB-bulldoze-tool-mode-item\"; yyBetterBulldozer.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyBetterBulldozer.entities[0] != null) { yyBetterBulldozer.entities[0].insertAdjacentElement('afterbegin', yyBetterBulldozer.div); } }");
			m_AreasFiltersRowScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYBB-Areas-Filters-row.html"), "if (document.getElementById(\"YYBB-area-filters-item\") == null) { yyBetterBulldozer.div.className = \"item_bZY\"; yyBetterBulldozer.div.id = \"YYBB-area-filters-item\"; yyBetterBulldozer.toolModeItem = document.getElementById(\"YYBB-bulldoze-tool-mode-item\"); if (yyBetterBulldozer.toolModeItem) { yyBetterBulldozer.toolModeItem.insertAdjacentElement('beforebegin', yyBetterBulldozer.div); } }");
			m_MarkersFiltersRowScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYBB-Markers-Filters-row.html"), "if (document.getElementById(\"YYBB-markers-filters-item\") == null) { yyBetterBulldozer.div.className = \"item_bZY\"; yyBetterBulldozer.div.id = \"YYBB-markers-filters-item\"; yyBetterBulldozer.toolModeItem = document.getElementById(\"YYBB-bulldoze-tool-mode-item\"); if (yyBetterBulldozer.toolModeItem) { yyBetterBulldozer.toolModeItem.insertAdjacentElement('beforebegin', yyBetterBulldozer.div); } }");
			ToolSystem toolSystem2 = m_ToolSystem;
			toolSystem2.EventPrefabChanged = (Action<PrefabBase>)Delegate.Combine(toolSystem2.EventPrefabChanged, new Action<PrefabBase>(OnPrefabChanged));
			if (m_UiView == null)
			{
				m_Log.Info((object)"BetterBulldozerUISystem.OnCreate m_UiView == null");
			}
			((UISystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			if (m_UiView == null)
			{
				return;
			}
			if (m_ToolSystem.activeTool != m_BulldozeToolSystem)
			{
				if (m_BulldozeItemShown)
				{
					UnshowBulldozeItem();
				}
				((ComponentSystemBase)this).Enabled = false;
				return;
			}
			UIFileUtils.ExecuteScript(m_UiView, "if (yyBetterBulldozer == null) var yyBetterBulldozer = {};");
			if (!m_BulldozeItemShown)
			{
				if (m_DelayOneFrameForAnarchy)
				{
					m_DelayOneFrameForAnarchy = false;
					return;
				}
				if (m_InjectedJS == string.Empty)
				{
					m_Log.Warn((object)"BetterBulldozerUISystem.OnUpdate m_InjectedJS is empty!!! Did you forget to include the ui.js file in the mod install folder?");
					m_InjectedJS = UIFileUtils.ReadJS(Path.Combine(UIFileUtils.AssemblyPath, "ui.js"));
					m_BulldozeToolItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYBB-bulldoze-tool-mode-row.html"), "if (document.getElementById(\"YYA-bulldoze-tool-mode-item\") == null && document.getElementById(\"YYBB-bulldoze-tool-mode-item\") == null) { yyBetterBulldozer.div.className = \"item_bZY\"; yyBetterBulldozer.div.id = \"YYBB-bulldoze-tool-mode-item\"; yyBetterBulldozer.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyBetterBulldozer.entities[0] != null) { yyBetterBulldozer.entities[0].insertAdjacentElement('afterbegin', yyBetterBulldozer.div); } }");
				}
				foreach (BoundEventHandle boundEventHandle in m_BoundEventHandles)
				{
					m_UiView.UnregisterFromEvent(boundEventHandle);
				}
				m_BoundEventHandles.Clear();
				UIFileUtils.ExecuteScript(m_UiView, m_BulldozeToolItemScript);
				UIFileUtils.ExecuteScript(m_UiView, m_InjectedJS);
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-log", (Delegate)new Action<string>(LogFromJS)));
				if (m_FirstTimeLoadingJS)
				{
					m_FirstTimeLoadingJS = false;
					return;
				}
				UIFileUtils.ExecuteScript(m_UiView, "yyBetterBulldozer.toolModeLabel = document.getElementById(\"YYBB-tool-mode-label\"); if (yyBetterBulldozer.toolModeLabel) yyBetterBulldozer.toolModeLabel.innerHTML = engine.translate(yyBetterBulldozer.toolModeLabel.getAttribute(\"localeKey\"));");
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Bypass-Confirmation-Button\", " + BoolToString(m_BulldozeToolSystem.debugBypassBulldozeConfirmation) + ", \"BypassConfirmationButton\")");
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Gameplay-Manipulation-Button\", " + BoolToString(m_BulldozeToolSystem.allowManipulation) + ", \"GameplayManipulationButton\")");
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Raycast-Markers-Button\", " + IsRaycastTargetSelected(RaycastTarget.Markers) + ", \"RaycastMarkersButton\")");
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Raycast-Areas-Button\", " + IsRaycastTargetSelected(RaycastTarget.Areas) + ", \"RaycastAreasButton\")");
				UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Raycast-Lanes-Button\", " + IsRaycastTargetSelected(RaycastTarget.Lanes) + ", \"RaycastLanesButton\")");
				if (m_RaycastTarget == RaycastTarget.Areas)
				{
					UIFileUtils.ExecuteScript(m_UiView, m_AreasFiltersRowScript);
					UIFileUtils.ExecuteScript(m_UiView, "yyBetterBulldozer.areaFilterLabel = document.getElementById(\"YYBB-areas-filter-label\"); if (yyBetterBulldozer.areaFilterLabel) yyBetterBulldozer.areaFilterLabel.innerHTML = engine.translate(yyBetterBulldozer.areaFilterLabel.getAttribute(\"localeKey\"));");
					UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Surfaces-Filter-Button\", " + IsAreaFilterSelected((AreaTypeMask)16) + ", \"SurfacesFilterButton\")");
					UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Spaces-Filter-Button\", " + IsAreaFilterSelected((AreaTypeMask)8) + ", \"SpacesFilterButton\")");
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Surfaces-Filter-Button", (Delegate)new Action<bool>(SurfacesFilterToggled)));
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Spaces-Filter-Button", (Delegate)new Action<bool>(SpacesFilterToggled)));
				}
				if (m_RaycastTarget == RaycastTarget.Markers)
				{
					UIFileUtils.ExecuteScript(m_UiView, m_MarkersFiltersRowScript);
					UIFileUtils.ExecuteScript(m_UiView, "yyBetterBulldozer.markersFilterLabel = document.getElementById(\"YYBB-markers-filter-label\"); if (yyBetterBulldozer.markersFilterLabel) yyBetterBulldozer.markersFilterLabel.innerHTML = engine.translate(yyBetterBulldozer.markersFilterLabel.getAttribute(\"localeKey\"));");
					UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-StaticObject-Filter-Button\", " + IsMarkersFilterSelected((TypeMask)2) + ", \"StaticObjectsFilterButton\")");
					UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyBetterBulldozer.setupButton == 'function') yyBetterBulldozer.setupButton(\"YYBB-Networks-Filter-Button\", " + IsMarkersFilterSelected((TypeMask)8) + ", \"NetworksFilterButton\")");
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-StaticObject-Filter-Button", (Delegate)new Action<bool>(StaticObjectsFilterToggled)));
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Networks-Filter-Button", (Delegate)new Action<bool>(NetworksFilterToggled)));
				}
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Bypass-Confirmation-Button", (Delegate)new Action<bool>(BypassConfirmationToggled)));
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Gameplay-Manipulation-Button", (Delegate)new Action<bool>(GameplayManipulationToggled)));
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Raycast-Markers-Button", (Delegate)new Action<bool>(RaycastMarkersButtonToggled)));
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Raycast-Areas-Button", (Delegate)new Action<bool>(RaycastAreasButtonToggled)));
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYBB-Raycast-Lanes-Button", (Delegate)new Action<bool>(RaycastLanesButtonToggled)));
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("CheckForElement", (Delegate)new Action<bool>(ElementCheck)));
				m_BulldozeItemShown = true;
				m_DelayOneFrameForAnarchy = true;
			}
			else
			{
				UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYBB-bulldoze-tool-mode-item\") == null) engine.trigger('CheckForElement', false);");
				if (m_RaycastTarget == RaycastTarget.Areas)
				{
					UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYBB-area-filters-item\") == null) engine.trigger('CheckForElement', false);");
				}
				else
				{
					UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYBB-area-filters-item"));
				}
				if (m_RaycastTarget == RaycastTarget.Markers)
				{
					UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYBB-markers-filters-item\") == null) engine.trigger('CheckForElement', false);");
				}
				else
				{
					UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYBB-markers-filters-item"));
				}
				if (m_LastBypassConfrimation != m_BulldozeToolSystem.debugBypassBulldozeConfirmation)
				{
					if (m_BulldozeToolSystem.debugBypassBulldozeConfirmation)
					{
						m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Bypass-Confirmation-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.add(\"selected\");");
					}
					else
					{
						m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Bypass-Confirmation-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
					}
					m_LastBypassConfrimation = m_BulldozeToolSystem.debugBypassBulldozeConfirmation;
				}
				if (m_LastGamePlayManipulation != m_BulldozeToolSystem.allowManipulation)
				{
					if (m_BulldozeToolSystem.allowManipulation)
					{
						m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Gameplay-Manipulation-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.add(\"selected\");");
					}
					else
					{
						m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Gameplay-Manipulation-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
					}
					m_LastGamePlayManipulation = m_BulldozeToolSystem.allowManipulation;
				}
			}
			((UISystemBase)this).OnUpdate();
		}

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

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

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

		private string IsRaycastTargetSelected(RaycastTarget target)
		{
			if (m_RaycastTarget == target)
			{
				return "true";
			}
			return "false";
		}

		private string IsAreaFilterSelected(AreaTypeMask areaTypeMask)
		{
			//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)
			if ((AreaTypeMask)(m_AreasFilter & areaTypeMask) == areaTypeMask)
			{
				return "true";
			}
			return "false";
		}

		private string IsMarkersFilterSelected(TypeMask typeMask)
		{
			//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)
			if ((TypeMask)(m_MarkersFilter & typeMask) == typeMask)
			{
				return "true";
			}
			return "false";
		}

		private void BypassConfirmationToggled(bool flag)
		{
			m_BulldozeToolSystem.debugBypassBulldozeConfirmation = flag;
			m_LastBypassConfrimation = flag;
		}

		private void GameplayManipulationToggled(bool flag)
		{
			m_BulldozeToolSystem.allowManipulation = flag;
			m_LastGamePlayManipulation = flag;
		}

		private void RaycastMarkersButtonToggled(bool flag)
		{
			if (flag)
			{
				m_RaycastTarget = RaycastTarget.Markers;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Raycast-Areas-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Raycast-Lanes-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_RaycastTarget = RaycastTarget.Vanilla;
			}
			HandleShowMarkers(m_ToolSystem.activePrefab);
		}

		private void SurfacesFilterToggled(bool flag)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (flag)
			{
				m_AreasFilter = (AreaTypeMask)16;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Spaces-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_AreasFilter = (AreaTypeMask)8;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Spaces-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.add(\"selected\");");
			}
		}

		private void SpacesFilterToggled(bool flag)
		{
			//IL_0026: 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)
			if (flag)
			{
				m_AreasFilter = (AreaTypeMask)8;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Surfaces-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_AreasFilter = (AreaTypeMask)16;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Surfaces-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.add(\"selected\");");
			}
		}

		private void StaticObjectsFilterToggled(bool flag)
		{
			//IL_0025: 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)
			if (flag)
			{
				m_MarkersFilter = (TypeMask)2;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Networks-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_MarkersFilter = (TypeMask)8;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Networks-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.add(\"selected\");");
			}
		}

		private void NetworksFilterToggled(bool flag)
		{
			//IL_0025: 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)
			if (flag)
			{
				m_MarkersFilter = (TypeMask)8;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-StaticObject-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_MarkersFilter = (TypeMask)2;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-StaticObject-Filter-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.add(\"selected\");");
			}
		}

		private void RaycastAreasButtonToggled(bool flag)
		{
			if (flag)
			{
				m_RaycastTarget = RaycastTarget.Areas;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Raycast-Markers-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Raycast-Lanes-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_RaycastTarget = RaycastTarget.Vanilla;
			}
			HandleShowMarkers(m_ToolSystem.activePrefab);
		}

		private void RaycastLanesButtonToggled(bool flag)
		{
			if (flag)
			{
				m_Log.Debug((object)"BetterBulldozerUISystem.RaycastLanesButtonToggled");
				m_RaycastTarget = RaycastTarget.Lanes;
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Raycast-Markers-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
				m_UiView.ExecuteScript("yyBetterBulldozer.buttonElement = document.getElementById(\"YYBB-Raycast-Areas-Button\"); if (yyBetterBulldozer.buttonElement != null) yyBetterBulldozer.buttonElement.classList.remove(\"selected\");");
			}
			else
			{
				m_RaycastTarget = RaycastTarget.Vanilla;
			}
			HandleShowMarkers(m_ToolSystem.activePrefab);
		}

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

		private void UnshowBulldozeItem()
		{
			//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("YYBB-bulldoze-tool-mode-item"));
			UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYBB-area-filters-item"));
			UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYBB-markers-filters-item"));
			foreach (BoundEventHandle boundEventHandle in m_BoundEventHandles)
			{
				m_UiView.UnregisterFromEvent(boundEventHandle);
			}
			m_BoundEventHandles.Clear();
			m_BulldozeItemShown = false;
		}

		private void HandleShowMarkers(PrefabBase prefab)
		{
			//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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			Entity val = default(Entity);
			if ((Object)(object)prefab != (Object)null && m_PrefabSystem.TryGetEntity(prefab, ref val) && m_ToolSystem.activeTool != m_DefaultToolSystem)
			{
				EntityManager entityManager = ((ComponentSystemBase)this).EntityManager;
				if (((EntityManager)(ref entityManager)).HasComponent<MarkerNetData>(val) || prefab is MarkerObjectPrefab || prefab is NetLaneGeometryPrefab || prefab is NetLanePrefab || (prefab is BulldozePrefab && SelectedRaycastTarget == RaycastTarget.Markers) || (prefab is BulldozePrefab && SelectedRaycastTarget == RaycastTarget.Lanes))
				{
					if (!m_PrefabIsMarker)
					{
						m_RecordedShowMarkers = m_RenderingSystem.markersVisible;
						m_Log.Debug((object)string.Format("{0}.{1} m_RecordedShowMarkers = {2}", "BetterBulldozerUISystem", "HandleShowMarkers", m_RecordedShowMarkers));
					}
					m_RenderingSystem.markersVisible = true;
					m_PrefabIsMarker = true;
					m_Log.Debug((object)string.Format("{0}.{1} m_PrefabIsMarker = {2}", "BetterBulldozerUISystem", "HandleShowMarkers", m_PrefabIsMarker));
				}
				else if (m_PrefabIsMarker)
				{
					m_PrefabIsMarker = false;
					m_RenderingSystem.markersVisible = m_RecordedShowMarkers;
					ILog log = m_Log;
					entityManager = ((ComponentSystemBase)this).EntityManager;
					log.Debug((object)string.Format("{0}.{1} EntityManager.HasComponent<MarkerNetData>(prefabEntity) : {2}", "BetterBulldozerUISystem", "HandleShowMarkers", ((EntityManager)(ref entityManager)).HasComponent<MarkerNetData>(val)));
					m_Log.Debug((object)string.Format("{0}.{1} prefab is MarkerObjectPrefab : {2}", "BetterBulldozerUISystem", "HandleShowMarkers", prefab is MarkerObjectPrefab));
					m_Log.Debug((object)string.Format("{0}.{1} prefab is BulldozePrefab : {2}", "BetterBulldozerUISystem", "HandleShowMarkers", prefab is BulldozePrefab));
					m_Log.Debug((object)string.Format("{0}.{1}  m_RaycastTarget == RaycastTarget.Markers: {2}", "BetterBulldozerUISystem", "HandleShowMarkers", SelectedRaycastTarget == RaycastTarget.Markers));
				}
			}
			else if (m_PrefabIsMarker)
			{
				m_Log.Debug((object)string.Format("{0}.{1} prefab != null : {2}", "BetterBulldozerUISystem", "HandleShowMarkers", (Object)(object)prefab != (Object)null));
				if ((Object)(object)prefab != (Object)null)
				{
					Entity val2 = default(Entity);
					m_Log.Debug((object)string.Format("{0}.{1} m_PrefabSystem.TryGetEntity(prefab, out Entity prefabEntity) : {2}", "BetterBulldozerUISystem", "HandleShowMarkers", m_PrefabSystem.TryGetEntity(prefab, ref val2)));
				}
				m_Log.Debug((object)string.Format("{0}.{1} m_ToolSystem.activeTool != m_DefaultToolSystem : {2}", "BetterBulldozerUISystem", "HandleShowMarkers", m_ToolSystem.activeTool != m_DefaultToolSystem));
				m_PrefabIsMarker = false;
				m_RenderingSystem.markersVisible = m_RecordedShowMarkers;
			}
		}

		private void OnToolChanged(ToolBaseSystem tool)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			UIFileUtils.ExecuteScript(m_UiView, "if (yyBetterBulldozer == null) var yyBetterBulldozer = {};");
			if (tool == null)
			{
				m_Log.Debug((object)"BetterBulldozerUISystem.OnToolChanged something is null.");
				if (m_BulldozeItemShown)
				{
					UnshowBulldozeItem();
				}
				return;
			}
			ILog log = m_Log;
			object[] obj = new object[5] { "BetterBulldozerUISystem", "OnToolChanged", tool.toolID, null, null };
			PrefabBase activePrefab = m_ToolSystem.activePrefab;
			obj[3] = ((activePrefab != null) ? new PrefabID?(activePrefab.GetPrefabID()) : null);
			PrefabBase prefab = tool.GetPrefab();
			obj[4] = ((prefab != null) ? new PrefabID?(prefab.GetPrefabID()) : null);
			log.Debug((object)string.Format("{0}.{1} {2} {3} {4}", obj));
			if (tool != m_BulldozeToolSystem && m_BulldozeItemShown)
			{
				UnshowBulldozeItem();
			}
			if (tool == m_BulldozeToolSystem)
			{
				((ComponentSystemBase)this).Enabled = true;
			}
			HandleShowMarkers(m_ToolSystem.activePrefab);
		}

		private void OnPrefabChanged(PrefabBase prefab)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab == (Object)null))
			{
				m_Log.Debug((object)string.Format("{0}.{1} {2}", "BetterBulldozerUISystem", "OnPrefabChanged", prefab.GetPrefabID()));
				HandleShowMarkers(prefab);
			}
		}
	}
}
namespace Better_Bulldozer.Settings
{
	public class LocaleEN : IDictionarySource
	{
		public IEnumerable<KeyValuePair<string, string>> ReadEntries(IList<IDictionaryEntryError> errors, Dictionary<string, int> indexCounts)
		{
			return new Dictionary<string, string>
			{
				{ "YY_BETTER_BULLDOZER.RaycastAreasButton", "Target Surfaces and/or Spaces" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.RaycastAreasButton", "Makes the bulldozer EXCLUSIVELY target surfaces and/or spaces inside or outside of buildings so you can remove them in one click. You must turn this off to bulldoze anything else." },
				{ "YY_BETTER_BULLDOZER.RaycastMarkersButton", "Target Markers" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.RaycastMarkersButton", "Shows and EXCLUSIVELY targets markers and invisible roads. With this enabled you can demolish invisible networks, invisible parking decals, various spots, points, and spawners, but SAVE FIRST! You cannot demolish these within buildings." },
				{ "YY_BETTER_BULLDOZER.GameplayManipulationButton", "Gameplay Manipulation" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.GameplayManipulationButton", "Allows you to use the bulldozer on moving objects such as vehicles or cims." },
				{ "YY_BETTER_BULLDOZER.BypassConfirmationButton", "Bypass Confirmation" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.BypassConfirmationButton", "Disables the prompt for whether you are sure you want to demolish a building." },
				{ "YY_BETTER_BULLDOZER.Filter", "Filter" },
				{ "YY_BETTER_BULLDOZER.SurfacesFilterButton", "Surfaces Filter" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.SurfacesFilterButton", "With this enabled you will be able to target surfaces inside or outside of buildings so you can remove them in one click." },
				{ "YY_BETTER_BULLDOZER.SpacesFilterButton", "Spaces Filter" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.SpacesFilterButton", "Spaces include: Walking, Park, and Hangout areas. They are not currently visible with this tool, but will be highlighted when hovered. With this enabled you can target them inside or outside buildings and remove with one click." },
				{ "YY_BETTER_BULLDOZER.StaticObjectsFilterButton", "Static Objects Filter" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.StaticObjectsFilterButton", "For removing invisible parking decals, various spots, points, and spawners. Only those outside buildings can be removed. Trying to target those inside buildings will remove the building!" },
				{ "YY_BETTER_BULLDOZER.NetworksFilterButton", "Networks Filter" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.NetworksFilterButton", "For removing invisible networks. Only those outside buildings can be removed. Trying to target those inside buildings will have no effect." },
				{ "YY_BETTER_BULLDOZER.RaycastLanesButton", "Target NetLanes" },
				{ "YY_BETTER_BULLDOZER_DESCRIPTION.RaycastLanesButton", "For removing NetLanes such as interconnected fences, interconnected hedges, linear street markings, vehicle and pedestrian lanes. Trying to target those inside networks will remove the network! You cannot create these in-game without a mod for it." }
			};
		}

		public void Unload()
		{
		}
	}
}
namespace Better_Bulldozer.Patches
{
	[HarmonyPatch(typeof(BulldozeToolSystem), "InitializeRaycast")]
	public class BulldozeToolSystemInitializeRaycastPatch
	{
		public static void Postfix()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_00b9: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			ToolRaycastSystem val = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolRaycastSystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			BetterBulldozerUISystem betterBulldozerUISystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<BetterBulldozerUISystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			RenderingSystem val2 = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<RenderingSystem>() : null);
			if (val2.markersVisible && betterBulldozerUISystem.SelectedRaycastTarget == BetterBulldozerUISystem.RaycastTarget.Markers)
			{
				val.typeMask = betterBulldozerUISystem.MarkersFilter;
				if ((betterBulldozerUISystem.MarkersFilter & 8) == 8)
				{
					val.netLayerMask = (Layer)24576;
					val.raycastFlags = (RaycastFlags)128;
				}
				else
				{
					val.raycastFlags = (RaycastFlags)16512;
				}
			}
			else if (betterBulldozerUISystem.SelectedRaycastTarget == BetterBulldozerUISystem.RaycastTarget.Areas)
			{
				val.typeMask = (TypeMask)32;
				val.areaTypeMask = betterBulldozerUISystem.AreasFilter;
				val.raycastFlags = (RaycastFlags)(val.raycastFlags | 0x20);
			}
			else if (betterBulldozerUISystem.SelectedRaycastTarget == BetterBulldozerUISystem.RaycastTarget.Lanes)
			{
				BetterBulldozerMod.Instance.Logger.Debug((object)"BulldozeToolSystemInitializeRaycastPatch.Postfix Targetting lanes.");
				val.typeMask = (TypeMask)8;
				val.netLayerMask = (Layer)69632;
				val.raycastFlags = (RaycastFlags)(val.raycastFlags | 0x8080);
			}
		}
	}
}