Decompiled source of Anarchy v1.3.4

Anarchy.dll

Decompiled 9 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.Components;
using Anarchy.Settings;
using Anarchy.Systems;
using Anarchy.Tooltip;
using Anarchy.Utils;
using BepInEx;
using Colossal;
using Colossal.Entities;
using Colossal.IO.AssetDatabase;
using Colossal.Localization;
using Colossal.Logging;
using Colossal.Mathematics;
using Colossal.Serialization.Entities;
using Game;
using Game.Buildings;
using Game.Citizens;
using Game.Common;
using Game.Creatures;
using Game.Modding;
using Game.Objects;
using Game.Prefabs;
using Game.Rendering;
using Game.SceneFlow;
using Game.Settings;
using Game.Tools;
using Game.UI;
using Game.UI.InGame;
using Game.UI.Tooltip;
using Game.UI.Widgets;
using Game.Vehicles;
using HarmonyLib;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.InputSystem;
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("Anachy-BepInEx")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Anachy-BepInEx")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3a0ae4d2-019b-43e8-8b30-4ceb38349599")]
[assembly: AssemblyFileVersion("1.3.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.3.3.0")]
namespace Anarchy
{
	public class AnarchyMod : IMod
	{
		private static string m_modInstallFolder;

		public static AnarchyMod Instance { get; private set; }

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

		internal AnarchyModSettings Settings { get; set; }

		internal ILog Logger { get; private set; }

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

		public void OnCreateWorld(UpdateSystem updateSystem)
		{
			Logger.effectivenessLevel = Level.Info;
			Logger.Info((object)"Initializing Settings.");
			Settings = new AnarchyModSettings((IMod)(object)this);
			((ModSetting)Settings).RegisterInOptionsUI();
			AssetDatabase.global.LoadSettings("AnarchyMod", (object)Settings, (object)new AnarchyModSettings((IMod)(object)this));
			Settings.Contra = false;
			Logger.Info((object)"Handling create world");
			Logger.Info((object)("ModInstallFolder = " + ModInstallFolder));
			LoadLocales();
			updateSystem.UpdateAfter<AnarchyTooltipSystem>((SystemUpdatePhase)23);
			updateSystem.UpdateAt<AnarchySystem>((SystemUpdatePhase)17);
			updateSystem.UpdateBefore<DisableToolErrorsSystem>((SystemUpdatePhase)9);
			updateSystem.UpdateAfter<EnableToolErrorsSystem>((SystemUpdatePhase)9);
			updateSystem.UpdateAt<AnarchyUISystem>((SystemUpdatePhase)22);
			updateSystem.UpdateBefore<AnarchyPlopSystem>((SystemUpdatePhase)9);
			updateSystem.UpdateBefore<PreventOverrideSystem>((SystemUpdatePhase)9);
			updateSystem.UpdateBefore<RemoveOverridenSystem>((SystemUpdatePhase)9);
			updateSystem.UpdateAt<PreventCullingSystem>((SystemUpdatePhase)17);
			updateSystem.UpdateBefore<ModifyNetCompositionDataSystem>((SystemUpdatePhase)6);
			updateSystem.UpdateAfter<ResetNetCompositionDataSystem>((SystemUpdatePhase)9);
		}

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

		private void LoadLocales()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			LocaleEN localeEN = new LocaleEN(Settings);
			localeEN.ExportLocalizationCSV(ModInstallFolder, GameManager.instance.localizationManager.GetSupportedLocales());
			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)
					{
						Logger.Warn((object)string.Format("{0}.{1} Encountered exception {2} while trying to localize {3}.", "AnarchyMod", "LoadLocales", ex, text));
					}
				}
			}
			else
			{
				Logger.Warn((object)"AnarchyMod.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);
				}
			}
		}
	}
	[BepInPlugin("Anarchy", "Anarchy", "1.3.3")]
	[HarmonyPatch]
	public class AnarchyPlugin : BaseUnityPlugin
	{
		internal static AnarchyMod _mod;

		public void Awake()
		{
			_mod = new AnarchyMod();
			_mod.OnLoad();
			_mod.Logger.Info((object)"AnarchyPlugin.Awake");
			Harmony.CreateAndPatchAll(typeof(AnarchyPlugin).Assembly, "Anarchy");
		}

		[HarmonyPatch(typeof(SystemOrder), "Initialize", new Type[] { typeof(UpdateSystem) })]
		[HarmonyPostfix]
		private static void InjectSystems(UpdateSystem updateSystem)
		{
			_mod.Logger.Info((object)"AnarchyPlugin.InjectSystems");
			_mod.OnCreateWorld(updateSystem);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Anarchy";

		public const string PLUGIN_NAME = "";

		public const string PLUGIN_VERSION = "1.0.0.0";
	}
}
namespace Anarchy.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)
			{
				AnarchyMod.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)
			{
				AnarchyMod.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;
		}
	}
	internal static class UIFileUtils
	{
		private static string s_assemblyPath;

		public static string AssemblyPath
		{
			get
			{
				if (string.IsNullOrWhiteSpace(s_assemblyPath))
				{
					s_assemblyPath = Path.GetDirectoryName(typeof(AnarchyPlugin).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))
				{
					AnarchyMod.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)
			{
				AnarchyMod.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 "yyAnarchy.div = document.createElement('div'); yyAnarchy.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; " + injectionPostfix;
				}
			}
			catch (Exception ex)
			{
				AnarchyMod.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 "yyAnarchy.div = document.createElement('div'); yyAnarchy.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.body.appendChild(yyAnarchy.div);";
				}
			}
			catch (Exception ex)
			{
				AnarchyMod.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)
			{
				AnarchyMod.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 "yyAnarchy.style = document.createElement('style'); yyAnarchy.style.type = 'text/css'; yyAnarchy.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.head.appendChild(yyAnarchy.style);";
				}
			}
			catch (Exception ex)
			{
				AnarchyMod.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)
			{
				AnarchyMod.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 Anarchy.Tooltip
{
	public class AnarchySystem : ToolBaseSystem
	{
		private readonly List<string> ToolIDs = new List<string> { "Object Tool", "Net Tool", "Area Tool", "Bulldoze Tool", "Terrain Tool", "Upgrade Tool", "Line Tool" };

		private readonly List<ErrorType> AllowableErrorTypes = new List<ErrorType>
		{
			(ErrorType)1,
			(ErrorType)2,
			(ErrorType)8,
			(ErrorType)9,
			(ErrorType)12,
			(ErrorType)13,
			(ErrorType)15,
			(ErrorType)16,
			(ErrorType)17,
			(ErrorType)18,
			(ErrorType)19,
			(ErrorType)20,
			(ErrorType)21,
			(ErrorType)22,
			(ErrorType)24,
			(ErrorType)25,
			(ErrorType)26,
			(ErrorType)23
		};

		private ILog m_Log;

		private AnarchyUISystem m_AnarchyUISystem;

		private ResetNetCompositionDataSystem m_ResetNetCompositionDataSystem;

		public bool AnarchyEnabled { get; set; } = false;


		public override string toolID => "Anarchy Tool";

		public bool IsToolAppropriate(string toolID)
		{
			return ToolIDs.Contains(toolID);
		}

		public bool IsErrorTypeAllowed(ErrorType errorType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return AllowableErrorTypes.Contains(errorType);
		}

		public override PrefabBase GetPrefab()
		{
			return null;
		}

		public override bool TrySetPrefab(PrefabBase prefab)
		{
			return false;
		}

		protected override void OnCreate()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_AnarchyUISystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<AnarchyUISystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_ResetNetCompositionDataSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<ResetNetCompositionDataSystem>() : null);
			m_Log.Info((object)"AnarchySystem System Created.");
			AnarchyEnabled = false;
			InputAction val = new InputAction("Anarchy", (InputActionType)0, (string)null, (string)null, (string)null, (string)null);
			CompositeSyntax val2 = InputActionSetupExtensions.AddCompositeBinding(val, "ButtonWithOneModifier", (string)null, (string)null);
			val2 = ((CompositeSyntax)(ref val2)).With("Modifier", "<Keyboard>/ctrl", (string)null, (string)null);
			((CompositeSyntax)(ref val2)).With("Button", "<Keyboard>/a", (string)null, (string)null);
			val.performed += OnKeyPressed;
			val.Enable();
			((ToolBaseSystem)this).OnCreate();
		}

		protected override JobHandle OnUpdate(JobHandle inputDeps)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return inputDeps;
		}

		protected override void OnGamePreload(Purpose purpose, GameMode mode)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			m_Log.Info((object)"AnarchySystem System OnGamePreload.");
			((GameSystemBase)this).OnGamePreload(purpose, mode);
		}

		protected override void OnDestroy()
		{
			((GameSystemBase)this).OnDestroy();
		}

		private void OnKeyPressed(CallbackContext context)
		{
			if (base.m_ToolSystem.activeTool.toolID != null && ToolIDs.Contains(base.m_ToolSystem.activeTool.toolID))
			{
				AnarchyEnabled = !AnarchyEnabled;
				m_AnarchyUISystem.ToggleAnarchyButton();
				if (AnarchyEnabled)
				{
					m_Log.Debug((object)"Anarchy Enabled.");
					return;
				}
				m_Log.Debug((object)"Anarchy Disabled.");
				((ComponentSystemBase)m_ResetNetCompositionDataSystem).Enabled = true;
			}
		}
	}
	public class AnarchyTooltipSystem : TooltipSystemBase
	{
		private StringTooltip m_Tooltip;

		private ToolSystem m_ToolSystem;

		private AnarchySystem m_AnarchySystem;

		private ILog m_Log;

		protected override void OnCreate()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			((TooltipSystemBase)this).OnCreate();
			m_Log = AnarchyMod.Instance.Logger;
			m_AnarchySystem = ((ComponentSystemBase)this).World.GetOrCreateSystemManaged<AnarchySystem>();
			m_Tooltip = new StringTooltip
			{
				icon = "coui://uil/Colored/Anarchy.svg"
			};
			m_ToolSystem = ((ComponentSystemBase)this).World.GetOrCreateSystemManaged<ToolSystem>();
			m_Log.Info((object)"AnarchyTooltipSystem Created.");
		}

		protected override void OnUpdate()
		{
			if (m_ToolSystem.activeTool.toolID != null && AnarchyMod.Instance.Settings.ShowTooltip && m_AnarchySystem.IsToolAppropriate(m_ToolSystem.activeTool.toolID) && m_AnarchySystem.AnarchyEnabled)
			{
				((TooltipSystemBase)this).AddMouseTooltip((IWidget)(object)m_Tooltip);
			}
		}

		protected override void OnDestroy()
		{
			((GameSystemBase)this).OnDestroy();
		}
	}
}
namespace Anarchy.Systems
{
	public class ResetNetCompositionDataSystem : GameSystemBase
	{
		private ToolSystem m_ToolSystem;

		private EntityQuery m_NetCompositionDataQuery;

		private AnarchySystem m_AnarchySystem;

		private ILog m_Log;

		private NetToolSystem m_NetToolSystem;

		private PrefabSystem m_PrefabSystem;

		protected override void OnCreate()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_NetToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<NetToolSystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<PrefabSystem>() : null);
			m_Log.Info((object)"ResetNetCompositionDataSystem Created.");
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<HeightRangeRecord>() };
			val.Any = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadWrite<NetCompositionData>(),
				ComponentType.ReadWrite<NetGeometryData>()
			};
			array[0] = val;
			m_NetCompositionDataQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(m_NetCompositionDataQuery);
			((ComponentSystemBase)this).Enabled = false;
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			NativeArray<Entity> val = ((EntityQuery)(ref m_NetCompositionDataQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			try
			{
				NetCompositionData val2 = default(NetCompositionData);
				HeightRangeRecord heightRangeRecord = default(HeightRangeRecord);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (EntitiesExtensions.TryGetComponent<NetCompositionData>(((ComponentSystemBase)this).EntityManager, current, ref val2))
					{
						if (EntitiesExtensions.TryGetComponent<HeightRangeRecord>(((ComponentSystemBase)this).EntityManager, current, ref heightRangeRecord))
						{
							val2.m_HeightRange.min = heightRangeRecord.min;
							val2.m_HeightRange.max = heightRangeRecord.max;
							EntityManager entityManager = ((ComponentSystemBase)this).EntityManager;
							((EntityManager)(ref entityManager)).SetComponentData<NetCompositionData>(current, val2);
						}
						else
						{
							m_Log.Warn((object)string.Format("{0}.{1} could not retrieve height range record for Entity {2}.{3}.", "ResetNetCompositionDataSystem", "OnUpdate", current.Index, current.Version));
						}
					}
					else
					{
						m_Log.Warn((object)string.Format("{0}.{1} could not retrieve net composition or net geometry data for Entity {2}.{3}.", "ResetNetCompositionDataSystem", "OnUpdate", current.Index, current.Version));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			val.Dispose();
			((ComponentSystemBase)this).Enabled = false;
		}
	}
	public class ModifyNetCompositionDataSystem : GameSystemBase
	{
		private ToolSystem m_ToolSystem;

		private EntityQuery m_NetCompositionDataQuery;

		private AnarchySystem m_AnarchySystem;

		private ILog m_Log;

		private NetToolSystem m_NetToolSystem;

		private ResetNetCompositionDataSystem m_ResetNetCompositionDataSystem;

		private PrefabSystem m_PrefabSystem;

		private bool m_FirstTime = true;

		private bool m_EnsureReset = false;

		protected override void OnCreate()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_AnarchySystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<AnarchySystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<ToolSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_NetToolSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<NetToolSystem>() : null);
			World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<PrefabSystem>() : null);
			World defaultGameObjectInjectionWorld5 = World.DefaultGameObjectInjectionWorld;
			m_ResetNetCompositionDataSystem = ((defaultGameObjectInjectionWorld5 != null) ? defaultGameObjectInjectionWorld5.GetOrCreateSystemManaged<ResetNetCompositionDataSystem>() : null);
			m_Log.Info((object)"ModifyNetCompositionDataSystem Created.");
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<NetCompositionData>() };
			val.None = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<Temp>(),
				ComponentType.ReadOnly<Deleted>()
			};
			array[0] = val;
			m_NetCompositionDataQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(m_NetCompositionDataQuery);
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0069: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: 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_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: 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_01e1: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: 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_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			if (m_ToolSystem.activeTool != m_NetToolSystem || !m_AnarchySystem.AnarchyEnabled)
			{
				if (m_EnsureReset)
				{
					((ComponentSystemBase)m_ResetNetCompositionDataSystem).Enabled = true;
					m_EnsureReset = false;
				}
				return;
			}
			NativeArray<Entity> val = ((EntityQuery)(ref m_NetCompositionDataQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			try
			{
				NetCompositionData val2 = default(NetCompositionData);
				PrefabRef val3 = default(PrefabRef);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					EntityManager entityManager;
					if (EntitiesExtensions.TryGetComponent<NetCompositionData>(((ComponentSystemBase)this).EntityManager, current, ref val2))
					{
						entityManager = ((ComponentSystemBase)this).EntityManager;
						if (!((EntityManager)(ref entityManager)).HasComponent<HeightRangeRecord>(current))
						{
							if (val2.m_HeightRange.min == 0f && val2.m_HeightRange.max == 0f)
							{
								m_Log.Debug((object)string.Format("{0}.{1} Recalculating m_HeightRange {2}+{3} for entity: {4}.{5}.", "ModifyNetCompositionDataSystem", "OnUpdate", val2.m_HeightRange.min, val2.m_HeightRange.max, current.Index, current.Version));
								val2.m_HeightRange = RecalculateHeightRange(current);
								m_Log.Debug((object)string.Format("{0}.{1} Recalculated m_HeightRange {2}+{3} for entity: {4}.{5}.", "ModifyNetCompositionDataSystem", "OnUpdate", val2.m_HeightRange.min, val2.m_HeightRange.max, current.Index, current.Version));
							}
							HeightRangeRecord heightRangeRecord = default(HeightRangeRecord);
							heightRangeRecord.min = val2.m_HeightRange.min;
							heightRangeRecord.max = val2.m_HeightRange.max;
							HeightRangeRecord heightRangeRecord2 = heightRangeRecord;
							entityManager = ((ComponentSystemBase)this).EntityManager;
							((EntityManager)(ref entityManager)).AddComponent<HeightRangeRecord>(current);
							entityManager = ((ComponentSystemBase)this).EntityManager;
							((EntityManager)(ref entityManager)).SetComponentData<HeightRangeRecord>(current, heightRangeRecord2);
							m_Log.Debug((object)string.Format("{0}.{1} Recorded m_HeightRange {2}+{3} for entity: {4}.{5}.", "ModifyNetCompositionDataSystem", "OnUpdate", val2.m_HeightRange.min, val2.m_HeightRange.max, current.Index, current.Version));
						}
						if (EntitiesExtensions.TryGetComponent<PrefabRef>(((ComponentSystemBase)this).EntityManager, current, ref val3))
						{
							entityManager = ((ComponentSystemBase)this).EntityManager;
							if (((EntityManager)(ref entityManager)).HasComponent<PowerLineData>(val3.m_Prefab))
							{
								val2.m_HeightRange.min = (val2.m_HeightRange.min + val2.m_HeightRange.max) / 2f;
								val2.m_HeightRange.max = val2.m_HeightRange.min;
								goto IL_0387;
							}
						}
						val2.m_HeightRange.min = Mathf.Clamp(-1f * AnarchyMod.Instance.Settings.MinimumClearanceBelowElevatedNetworks, val2.m_HeightRange.min, val2.m_HeightRange.max);
						val2.m_HeightRange.max = Mathf.Clamp(0f, val2.m_HeightRange.min, val2.m_HeightRange.max);
						goto IL_0387;
					}
					m_Log.Warn((object)string.Format("{0}.{1} could not retrieve net composition data for Entity {2}.{3}.", "ModifyNetCompositionDataSystem", "OnUpdate", current.Index, current.Version));
					continue;
					IL_0387:
					if (m_FirstTime)
					{
						m_Log.Debug((object)string.Format("{0}.{1} Setting m_HeightRange to {2}:{3} for entity: {4}.{5}.", "ModifyNetCompositionDataSystem", "OnUpdate", val2.m_HeightRange.min, val2.m_HeightRange.max, current.Index, current.Version));
					}
					entityManager = ((ComponentSystemBase)this).EntityManager;
					((EntityManager)(ref entityManager)).SetComponentData<NetCompositionData>(current, val2);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			m_EnsureReset = true;
			m_FirstTime = false;
			val.Dispose();
		}

		private Bounds1 RecalculateHeightRange(Entity e)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			Bounds1 val = default(Bounds1);
			((Bounds1)(ref val))..ctor(float.MaxValue, float.MinValue);
			DynamicBuffer<NetCompositionPiece> val2 = default(DynamicBuffer<NetCompositionPiece>);
			if (EntitiesExtensions.TryGetBuffer<NetCompositionPiece>(((ComponentSystemBase)this).EntityManager, e, true, ref val2))
			{
				Enumerator<NetCompositionPiece> enumerator = val2.GetEnumerator();
				try
				{
					NetPieceData val3 = default(NetPieceData);
					while (enumerator.MoveNext())
					{
						NetCompositionPiece current = enumerator.Current;
						if (EntitiesExtensions.TryGetComponent<NetPieceData>(((ComponentSystemBase)this).EntityManager, current.m_Piece, ref val3))
						{
							if (val3.m_HeightRange.min + current.m_Offset.y < val.min)
							{
								val.min = val3.m_HeightRange.min + current.m_Offset.y;
							}
							if (val3.m_HeightRange.max + current.m_Offset.y > val.max)
							{
								val.max = val3.m_HeightRange.max + current.m_Offset.y;
							}
						}
						else
						{
							m_Log.Warn((object)string.Format("{0}.{1} could not retrieve NetPieceData for Entity {2}.{3}", "ModifyNetCompositionDataSystem", "RecalculateHeightRange", current.m_Piece.Index, current.m_Piece.Version));
						}
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			else
			{
				m_Log.Warn((object)string.Format("{0}.{1} could not retrieve NetCompositionPiece buffer for Entity {2}.{3}", "ModifyNetCompositionDataSystem", "RecalculateHeightRange", e.Index, e.Version));
			}
			return val;
		}
	}
	public class RemoveOverridenSystem : GameSystemBase
	{
		private readonly List<string> m_AppropriateToolsWithAnarchy = new List<string> { "Object Tool", "Line Tool" };

		private readonly List<string> m_AppropriateTools = new List<string> { "Bulldoze Tool", "Default Tool" };

		private AnarchySystem m_AnarchySystem;

		private ILog m_Log;

		private ToolSystem m_ToolSystem;

		private NetToolSystem m_NetToolSystem;

		private ObjectToolSystem m_ObjectToolSystem;

		private PrefabSystem m_PrefabSystem;

		private EntityQuery m_OwnedAndOverridenQuery;

		protected override void OnCreate()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			m_Log.Info((object)"RemoveOverridenSystem Created.");
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_AnarchySystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<AnarchySystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<ToolSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_NetToolSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<NetToolSystem>() : null);
			World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld;
			m_ObjectToolSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<ObjectToolSystem>() : null);
			World defaultGameObjectInjectionWorld5 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld5 != null) ? defaultGameObjectInjectionWorld5.GetOrCreateSystemManaged<PrefabSystem>() : null);
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<Updated>(),
				ComponentType.ReadOnly<Overridden>(),
				ComponentType.ReadOnly<Owner>()
			};
			val.None = (ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<Temp>(),
				ComponentType.ReadOnly<Building>(),
				ComponentType.ReadOnly<Crane>()
			};
			array[0] = val;
			m_OwnedAndOverridenQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(m_OwnedAndOverridenQuery);
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			if (m_ToolSystem.activeTool.toolID == null || (GameModeExtensions.IsEditor(m_ToolSystem.actionMode) && !AnarchyMod.Instance.Settings.PreventOverrideInEditor))
			{
				return;
			}
			EntityManager entityManager;
			if ((Object)(object)m_ToolSystem.activePrefab != (Object)null)
			{
				Entity entity = m_PrefabSystem.GetEntity(m_ToolSystem.activePrefab);
				entityManager = ((ComponentSystemBase)this).EntityManager;
				if (((EntityManager)(ref entityManager)).HasComponent<BuildingData>(entity))
				{
					return;
				}
			}
			if (!((ToolBaseSystem)m_NetToolSystem).TrySetPrefab(m_ToolSystem.activePrefab) && (m_AppropriateTools.Contains(m_ToolSystem.activeTool.toolID) || (m_AppropriateToolsWithAnarchy.Contains(m_ToolSystem.activeTool.toolID) && m_AnarchySystem.AnarchyEnabled)))
			{
				entityManager = ((ComponentSystemBase)this).EntityManager;
				((EntityManager)(ref entityManager)).RemoveComponent(m_OwnedAndOverridenQuery, ComponentType.ReadWrite<Overridden>());
			}
		}
	}
	public class AnarchyUISystem : UISystemBase
	{
		private View m_UiView;

		private ToolSystem m_ToolSystem;

		private string m_InjectedJS = string.Empty;

		private string m_AnarchyItemScript = string.Empty;

		private string m_AnarchyItemLineToolScript = string.Empty;

		private ILog m_Log;

		private AnarchySystem m_AnarchySystem;

		private RenderingSystem m_RenderingSystem;

		private PrefabSystem m_PrefabSystem;

		private ObjectToolSystem m_ObjectToolSystem;

		private DefaultToolSystem m_DefaultToolSystem;

		private bool m_AnarchyOptionShown;

		private bool m_DisableAnarchyWhenCompleted;

		private string m_LastTool;

		private List<BoundEventHandle> m_BoundEventHandles;

		private BulldozeToolSystem m_BulldozeToolSystem;

		private bool m_FirstTimeLoadingJS = true;

		private NetToolSystem m_NetToolSystem;

		private ResetNetCompositionDataSystem m_ResetNetCompositionDataSystem;

		public bool DisableAnarchyWhenCompleted => m_DisableAnarchyWhenCompleted;

		public void ToggleAnarchyButton()
		{
			if (m_UiView == null)
			{
				return;
			}
			if (m_AnarchySystem.AnarchyEnabled)
			{
				m_UiView.ExecuteScript("yyAnarchy.buttonElement = document.getElementById(\"YYA-Anarchy-Button\"); if (yyAnarchy.buttonElement != null) yyAnarchy.buttonElement.classList.add(\"selected\");");
				m_UiView.ExecuteScript("yyAnarchy.imageElement = document.getElementById(\"YYA-Anarchy-Image\"); if (yyAnarchy.imageElement != null) { yyAnarchy.imageElement.src = \"coui://uil/Colored/Anarchy.svg\"; } ");
				if (AnarchyMod.Instance.Settings.FlamingChirper)
				{
					m_UiView.ExecuteScript("yyAnarchy.tagElements = document.getElementsByTagName(\"img\"); for (yyAnarchy.i = 0; yyAnarchy.i < yyAnarchy.tagElements.length; yyAnarchy.i++) { if (yyAnarchy.tagElements[yyAnarchy.i].src == \"coui://GameUI/Media/Game/Icons/Chirper.svg\" || yyAnarchy.tagElements[yyAnarchy.i].src == \"Media/Game/Icons/Chirper.svg\") yyAnarchy.tagElements[yyAnarchy.i].src = \"coui://uil/Colored/AnarchyChirper.svg\"; }");
				}
			}
			else
			{
				m_UiView.ExecuteScript("yyAnarchy.buttonElement = document.getElementById(\"YYA-Anarchy-Button\"); if (yyAnarchy.buttonElement != null) yyAnarchy.buttonElement.classList.remove(\"selected\");");
				m_UiView.ExecuteScript("yyAnarchy.imageElement = document.getElementById(\"YYA-Anarchy-Image\"); if (yyAnarchy.imageElement != null) { yyAnarchy.imageElement.src = \"coui://uil/Standard/Anarchy.svg\"; } ");
				m_UiView.ExecuteScript("yyAnarchy.tagElements = document.getElementsByTagName(\"img\"); for (yyAnarchy.i = 0; yyAnarchy.i < yyAnarchy.tagElements.length; yyAnarchy.i++) { if (yyAnarchy.tagElements[yyAnarchy.i].src == \"coui://uil/Colored/AnarchyChirper.svg\") yyAnarchy.tagElements[yyAnarchy.i].src = \"coui://GameUI/Media/Game/Icons/Chirper.svg\"; }");
				m_DisableAnarchyWhenCompleted = false;
			}
		}

		protected override void OnCreate()
		{
			m_Log = AnarchyMod.Instance.Logger;
			m_Log.effectivenessLevel = Level.Info;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolSystem>() : null);
			m_UiView = GameManager.instance.userInterface.view.View;
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_AnarchySystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<AnarchySystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_BulldozeToolSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<BulldozeToolSystem>() : null);
			World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld;
			m_RenderingSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<RenderingSystem>() : null);
			World defaultGameObjectInjectionWorld5 = World.DefaultGameObjectInjectionWorld;
			m_ResetNetCompositionDataSystem = ((defaultGameObjectInjectionWorld5 != null) ? defaultGameObjectInjectionWorld5.GetOrCreateSystemManaged<ResetNetCompositionDataSystem>() : null);
			World defaultGameObjectInjectionWorld6 = World.DefaultGameObjectInjectionWorld;
			m_ObjectToolSystem = ((defaultGameObjectInjectionWorld6 != null) ? defaultGameObjectInjectionWorld6.GetOrCreateSystemManaged<ObjectToolSystem>() : null);
			World defaultGameObjectInjectionWorld7 = World.DefaultGameObjectInjectionWorld;
			m_DefaultToolSystem = ((defaultGameObjectInjectionWorld7 != null) ? defaultGameObjectInjectionWorld7.GetOrCreateSystemManaged<DefaultToolSystem>() : null);
			World defaultGameObjectInjectionWorld8 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld8 != null) ? defaultGameObjectInjectionWorld8.GetOrCreateSystemManaged<PrefabSystem>() : null);
			ToolSystem toolSystem = m_ToolSystem;
			m_ToolSystem.EventToolChanged = (Action<ToolBaseSystem>)Delegate.Combine(toolSystem.EventToolChanged, new Action<ToolBaseSystem>(OnToolChanged));
			m_BoundEventHandles = new List<BoundEventHandle>();
			World defaultGameObjectInjectionWorld9 = World.DefaultGameObjectInjectionWorld;
			m_NetToolSystem = ((defaultGameObjectInjectionWorld9 != null) ? defaultGameObjectInjectionWorld9.GetOrCreateSystemManaged<NetToolSystem>() : null);
			m_InjectedJS = UIFileUtils.ReadJS(Path.Combine(UIFileUtils.AssemblyPath, "ui.js"));
			m_AnarchyItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYA-anarchy-tool-row.html"), "if (document.getElementById(\"YYA-anarchy-item\") == null) { yyAnarchy.div.className = \"item_bZY\"; yyAnarchy.div.id = \"YYA-anarchy-item\"; yyAnarchy.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyAnarchy.entities[0] != null) { yyAnarchy.entities[0].insertAdjacentElement('afterbegin', yyAnarchy.div); } }");
			m_AnarchyItemLineToolScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYA-anarchy-tool-row.html"), "if (document.getElementById(\"YYA-anarchy-item\") == null) { yyAnarchy.div.className = \"item_bZY\"; yyAnarchy.div.id = \"YYA-anarchy-item\"; yyAnarchy.LineToolTitle = document.getElementById(\"line-tool-title\"); if (yyAnarchy.LineToolTitle != null) { yyAnarchy.LineToolTitle.parentElement.insertAdjacentElement('afterend', yyAnarchy.div); } }");
			if (m_UiView == null)
			{
				m_Log.Info((object)"AnarchyUISystem.OnCreate m_UiView == null");
			}
			((UISystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			if (m_UiView == null)
			{
				return;
			}
			if (m_ToolSystem.activeTool.toolID == null)
			{
				if (m_AnarchyOptionShown)
				{
					UnshowAnarchyOption();
				}
				((ComponentSystemBase)this).Enabled = false;
				return;
			}
			UIFileUtils.ExecuteScript(m_UiView, "if (yyAnarchy == null) var yyAnarchy = {};");
			if (!m_AnarchySystem.IsToolAppropriate(m_ToolSystem.activeTool.toolID))
			{
				if (m_AnarchyOptionShown)
				{
					UnshowAnarchyOption();
				}
				((ComponentSystemBase)this).Enabled = false;
				return;
			}
			if (!m_AnarchyOptionShown)
			{
				SendVariablesToJS();
				if (m_InjectedJS == string.Empty)
				{
					m_Log.Warn((object)"AnarchyUISystem.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_AnarchyItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYA-anarchy-tool-row.html"), "if (document.getElementById(\"YYA-anarchy-item\") == null) { yyAnarchy.div.className = \"item_bZY\"; yyAnarchy.div.id = \"YYA-anarchy-item\"; yyAnarchy.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyAnarchy.entities[0] != null) { yyAnarchy.entities[0].insertAdjacentElement('afterbegin', yyAnarchy.div); } }");
					m_AnarchyItemLineToolScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYA-anarchy-tool-row.html"), "if (document.getElementById(\"YYA-anarchy-item\") == null) { yyAnarchy.div.className = \"item_bZY\"; yyAnarchy.div.id = \"YYA-anarchy-item\"; yyAnarchy.LineToolTitle = document.getElementById(\"line-tool-title\"); if (yyAnarchy.LineToolTitle != null) { yyAnarchy.LineToolTitle.parentElement.insertAdjacentElement('afterend', yyAnarchy.div); } }");
				}
				UIFileUtils.ExecuteScript(m_UiView, m_InjectedJS);
				m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYA-log", (Delegate)new Action<string>(LogFromJS)));
				if (m_FirstTimeLoadingJS)
				{
					m_FirstTimeLoadingJS = false;
					return;
				}
				if (AnarchyMod.Instance.Settings.ToolIcon)
				{
					if (m_ToolSystem.activeTool.toolID != "Line Tool")
					{
						UIFileUtils.ExecuteScript(m_UiView, m_AnarchyItemScript + "  yyAnarchy.setupAnarchyItem(" + BoolToString(m_AnarchySystem.AnarchyEnabled) + "); ");
					}
					else
					{
						UIFileUtils.ExecuteScript(m_UiView, m_AnarchyItemLineToolScript + " yyAnarchy.setupAnarchyItem(" + BoolToString(m_AnarchySystem.AnarchyEnabled) + "); ");
					}
					UIFileUtils.ExecuteScript(m_UiView, "if (typeof yyAnarchy.applyLocalization == 'function') { yyAnarchy.AnarchyItem = document.getElementById(\"YYA-anarchy-item\"); if (yyAnarchy.AnarchyItem)  yyAnarchy.applyLocalization(yyAnarchy.AnarchyItem); }");
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("YYA-AnarchyToggled", (Delegate)new Action<bool>(AnarchyToggled)));
					m_BoundEventHandles.Add(m_UiView.RegisterForEvent("CheckForElement-YYA-anarchy-item", (Delegate)new Action<bool>(ElementCheck)));
				}
				else if (AnarchyMod.Instance.Settings.FlamingChirper)
				{
					ToggleAnarchyButton();
				}
				m_AnarchyOptionShown = true;
			}
			else
			{
				UIFileUtils.ExecuteScript(m_UiView, "yyAnarchy.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyAnarchy.entities[0] == null) { yyAnarchy.div = document.createElement(\"div\"); yyAnarchy.div.className = \"tool-options-panel_Se6\"; yyAnarchy.toolColumns = document.getElementsByClassName(\"tool-side-column_l9i\"); if (yyAnarchy.toolColumns[0] != null) yyAnarchy.toolColumns[0].appendChild(yyAnarchy.div); }");
				UIFileUtils.ExecuteScript(m_UiView, "yyAnarchy.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyAnarchy.entities.length > 1) {  yyAnarchy.itemElement = document.getElementById(\"YYA-anarchy-item\"); if (yyAnarchy.itemElement != null) { if (yyAnarchy.itemElement.parentElement.children.length == 1) {   yyAnarchy.itemElement.parentElement.parentElement.removeChild(yyAnarchy.itemElement.parentElement); } } }");
				UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYA-anarchy-item\") == null) engine.trigger('CheckForElement-YYA-anarchy-item', false);");
				if (m_ToolSystem.activeTool.toolID != "Line Tool")
				{
					UIFileUtils.ExecuteScript(m_UiView, "yyAnarchy.itemElement = document.getElementById(\"YYA-anarchy-item\"); if (yyAnarchy.itemElement != null) {  if (yyAnarchy.itemElement.parentElement.firstChild != yyAnarchy.itemElement) {  yyAnarchy.itemElement.parentElement.removeChild(yyAnarchy.itemElement);   }  }");
				}
			}
			((UISystemBase)this).OnUpdate();
		}

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

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

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

		private void AnarchyToggled(bool flag)
		{
			if (flag)
			{
				m_AnarchySystem.AnarchyEnabled = true;
				return;
			}
			m_AnarchySystem.AnarchyEnabled = false;
			m_DisableAnarchyWhenCompleted = false;
			((ComponentSystemBase)m_ResetNetCompositionDataSystem).Enabled = true;
		}

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

		private void SendVariablesToJS()
		{
			UIFileUtils.ExecuteScript(m_UiView, "yyAnarchy.enabled = " + BoolToString(m_AnarchySystem.AnarchyEnabled) + ";");
			UIFileUtils.ExecuteScript(m_UiView, "yyAnarchy.flamingChirper = " + BoolToString(AnarchyMod.Instance.Settings.FlamingChirper) + ";");
		}

		private void UnshowAnarchyOption()
		{
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			if (m_UiView == null)
			{
				return;
			}
			UIFileUtils.ExecuteScript(m_UiView, "yyAnarchy.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyAnarchy.entities.length >= 1) {  yyAnarchy.itemElement = document.getElementById(\"YYA-anarchy-item\"); if (yyAnarchy.itemElement != null) { if (yyAnarchy.itemElement.parentElement.children.length == 1) {   yyAnarchy.itemElement.parentElement.parentElement.removeChild(yyAnarchy.itemElement.parentElement); } } }");
			UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYA-anarchy-item"));
			m_UiView.ExecuteScript("yyAnarchy.tagElements = document.getElementsByTagName(\"img\"); for (yyAnarchy.i = 0; yyAnarchy.i < yyAnarchy.tagElements.length; yyAnarchy.i++) { if (yyAnarchy.tagElements[yyAnarchy.i].src == \"coui://uil/Colored/AnarchyChirper.svg\") yyAnarchy.tagElements[yyAnarchy.i].src = \"coui://GameUI/Media/Game/Icons/Chirper.svg\"; }");
			foreach (BoundEventHandle boundEventHandle in m_BoundEventHandles)
			{
				m_UiView.UnregisterFromEvent(boundEventHandle);
			}
			m_BoundEventHandles.Clear();
			m_AnarchyOptionShown = false;
		}

		private void OnToolChanged(ToolBaseSystem tool)
		{
			UIFileUtils.ExecuteScript(m_UiView, "if (yyAnarchy == null) var yyAnarchy = {};");
			if (tool != null && tool.toolID != null)
			{
				if (m_AnarchySystem.IsToolAppropriate(tool.toolID))
				{
					((ComponentSystemBase)this).Enabled = true;
				}
				if (tool.toolID == "Bulldoze Tool" && m_LastTool != "Bulldoze Tool")
				{
					m_AnarchyOptionShown = false;
				}
				if (tool.toolID == "Line Tool")
				{
					UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYA-anarchy-item"));
					m_AnarchyOptionShown = false;
				}
				if (tool != m_BulldozeToolSystem && m_DisableAnarchyWhenCompleted)
				{
					m_AnarchySystem.AnarchyEnabled = false;
					m_DisableAnarchyWhenCompleted = false;
					ToggleAnarchyButton();
				}
				if (AnarchyMod.Instance.Settings.AnarchicBulldozer && !m_AnarchySystem.AnarchyEnabled && tool == m_BulldozeToolSystem)
				{
					m_AnarchySystem.AnarchyEnabled = true;
					m_DisableAnarchyWhenCompleted = true;
					ToggleAnarchyButton();
				}
				if (tool != m_NetToolSystem && m_LastTool == ((ToolBaseSystem)m_NetToolSystem).toolID)
				{
					((ComponentSystemBase)m_ResetNetCompositionDataSystem).Enabled = true;
				}
				m_LastTool = tool.toolID;
			}
		}
	}
	public class AnarchyPlopSystem : GameSystemBase
	{
		private readonly List<string> m_AppropriateTools = new List<string> { "Object Tool", "Line Tool" };

		private AnarchySystem m_AnarchySystem;

		private ILog m_Log;

		private ToolSystem m_ToolSystem;

		private NetToolSystem m_NetToolSystem;

		private ObjectToolSystem m_ObjectToolSystem;

		private PrefabSystem m_PrefabSystem;

		private EntityQuery m_CreatedQuery;

		private EntityQuery m_PreventOverrideQuery;

		private EntityQuery m_OwnedAndOverridenQuery;

		protected override void OnCreate()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: 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)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			m_Log.effectivenessLevel = Level.Info;
			m_Log.Info((object)"AnarchyPlopSystem Created.");
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_AnarchySystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<AnarchySystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<ToolSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_NetToolSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<NetToolSystem>() : null);
			World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld;
			m_ObjectToolSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<ObjectToolSystem>() : null);
			World defaultGameObjectInjectionWorld5 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld5 != null) ? defaultGameObjectInjectionWorld5.GetOrCreateSystemManaged<PrefabSystem>() : null);
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[4]
			{
				ComponentType.ReadOnly<Created>(),
				ComponentType.ReadOnly<Updated>(),
				ComponentType.ReadOnly<Static>(),
				ComponentType.ReadOnly<Object>()
			};
			val.None = (ComponentType[])(object)new ComponentType[10]
			{
				ComponentType.ReadOnly<Temp>(),
				ComponentType.ReadOnly<Owner>(),
				ComponentType.ReadOnly<Building>(),
				ComponentType.ReadOnly<Animal>(),
				ComponentType.ReadOnly<Pet>(),
				ComponentType.ReadOnly<Creature>(),
				ComponentType.ReadOnly<Moving>(),
				ComponentType.ReadOnly<Household>(),
				ComponentType.ReadOnly<Vehicle>(),
				ComponentType.ReadOnly<Event>()
			};
			array[0] = val;
			m_CreatedQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			EntityQueryDesc[] array2 = new EntityQueryDesc[1];
			val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[4]
			{
				ComponentType.ReadOnly<Updated>(),
				ComponentType.ReadOnly<Owner>(),
				ComponentType.ReadOnly<Static>(),
				ComponentType.ReadOnly<Overridden>()
			};
			val.None = (ComponentType[])(object)new ComponentType[10]
			{
				ComponentType.ReadOnly<Temp>(),
				ComponentType.ReadOnly<Building>(),
				ComponentType.ReadOnly<Crane>(),
				ComponentType.ReadOnly<Animal>(),
				ComponentType.ReadOnly<Pet>(),
				ComponentType.ReadOnly<Creature>(),
				ComponentType.ReadOnly<Moving>(),
				ComponentType.ReadOnly<Household>(),
				ComponentType.ReadOnly<Vehicle>(),
				ComponentType.ReadOnly<Event>()
			};
			array2[0] = val;
			m_OwnedAndOverridenQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array2);
			EntityQueryDesc[] array3 = new EntityQueryDesc[1];
			val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<PreventOverride>() };
			array3[0] = val;
			m_PreventOverrideQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array3);
			((ComponentSystemBase)this).RequireForUpdate(m_CreatedQuery);
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnGameLoadingComplete(Purpose purpose, GameMode mode)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_014e: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Invalid comparison between Unknown and I4
			NativeArray<Entity> val = ((EntityQuery)(ref m_PreventOverrideQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			try
			{
				PrefabRef val3 = default(PrefabRef);
				ObjectGeometryData val4 = default(ObjectGeometryData);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					PrefabBase val2 = null;
					EntityManager entityManager;
					if (EntitiesExtensions.TryGetComponent<PrefabRef>(((ComponentSystemBase)this).EntityManager, current, ref val3) && m_PrefabSystem.TryGetPrefab<PrefabBase>(val3.m_Prefab, ref val2))
					{
						entityManager = ((ComponentSystemBase)this).EntityManager;
						if (((EntityManager)(ref entityManager)).HasComponent<Static>(current))
						{
							entityManager = ((ComponentSystemBase)this).EntityManager;
							if (!((EntityManager)(ref entityManager)).HasComponent<Building>(current))
							{
								entityManager = ((ComponentSystemBase)this).EntityManager;
								if (!((EntityManager)(ref entityManager)).HasComponent<Owner>(current))
								{
									entityManager = ((ComponentSystemBase)this).EntityManager;
									if (!((EntityManager)(ref entityManager)).HasComponent<Crane>(current) && val2 is StaticObjectPrefab && EntitiesExtensions.TryGetComponent<ObjectGeometryData>(((ComponentSystemBase)this).EntityManager, val3.m_Prefab, ref val4) && (val4.m_Flags & 2) == 2)
									{
										continue;
									}
								}
							}
						}
					}
					if ((Object)(object)val2 != (Object)null)
					{
						m_Log.Debug((object)("AnarchyPlopSystem.OnGameLoadingComplete Removed PreventOverride from " + ((Object)val2).name));
					}
					entityManager = ((ComponentSystemBase)this).EntityManager;
					((EntityManager)(ref entityManager)).RemoveComponent<PreventOverride>(current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			val.Dispose();
			((GameSystemBase)this).OnGameLoadingComplete(purpose, mode);
		}

		protected override void OnUpdate()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Invalid comparison between Unknown and I4
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Invalid comparison between Unknown and I4
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			if (m_ToolSystem.activeTool.toolID == null || (GameModeExtensions.IsEditor(m_ToolSystem.actionMode) && !AnarchyMod.Instance.Settings.PreventOverrideInEditor))
			{
				return;
			}
			EntityManager entityManager;
			if ((Object)(object)m_ToolSystem.activePrefab != (Object)null)
			{
				Entity entity = m_PrefabSystem.GetEntity(m_ToolSystem.activePrefab);
				entityManager = ((ComponentSystemBase)this).EntityManager;
				if (((EntityManager)(ref entityManager)).HasComponent<BuildingData>(entity))
				{
					return;
				}
				ObjectGeometryData val = default(ObjectGeometryData);
				if (EntitiesExtensions.TryGetComponent<ObjectGeometryData>(((ComponentSystemBase)this).EntityManager, entity, ref val) && (val.m_Flags & 2) != 2)
				{
					m_Log.Debug((object)"AnarchyPlopSystem.OnUpdate Active prefab is not overridable.");
				}
			}
			if (!m_AnarchySystem.AnarchyEnabled || !m_AppropriateTools.Contains(m_ToolSystem.activeTool.toolID) || ((ToolBaseSystem)m_NetToolSystem).TrySetPrefab(m_ToolSystem.activePrefab))
			{
				return;
			}
			entityManager = ((ComponentSystemBase)this).EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(m_CreatedQuery, ComponentType.ReadWrite<Overridden>());
			entityManager = ((ComponentSystemBase)this).EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(m_OwnedAndOverridenQuery, ComponentType.ReadWrite<Overridden>());
			NativeArray<Entity> val2 = ((EntityQuery)(ref m_CreatedQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val2.GetEnumerator();
			try
			{
				PrefabRef val4 = default(PrefabRef);
				ObjectGeometryData val5 = default(ObjectGeometryData);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					PrefabBase val3 = null;
					if (EntitiesExtensions.TryGetComponent<PrefabRef>(((ComponentSystemBase)this).EntityManager, current, ref val4) && m_PrefabSystem.TryGetPrefab<PrefabBase>(val4.m_Prefab, ref val3) && val3 is StaticObjectPrefab && EntitiesExtensions.TryGetComponent<ObjectGeometryData>(((ComponentSystemBase)this).EntityManager, val4.m_Prefab, ref val5) && (val5.m_Flags & 2) == 2)
					{
						m_Log.Debug((object)("AnarchyPlopSystem.OnUpdate Added PreventOverride to " + ((Object)val3).name));
						entityManager = ((ComponentSystemBase)this).EntityManager;
						((EntityManager)(ref entityManager)).AddComponent<PreventOverride>(current);
					}
					else if ((Object)(object)val3 != (Object)null)
					{
						m_Log.Debug((object)("AnarchyPlopSystem.OnUpdate Would not add PreventOverride to " + ((Object)val3).name));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			val2.Dispose();
		}
	}
	public class PreventCullingSystem : GameSystemBase
	{
		private struct TypeHandle
		{
			[ReadOnly]
			public EntityTypeHandle __Unity_Entities_Entity_TypeHandle;

			[ReadOnly]
			public ComponentTypeHandle<CullingInfo> __CullingInfo_RO_ComponentTypeHandle;

			public void __AssignHandles(ref SystemState state)
			{
				//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_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				__Unity_Entities_Entity_TypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle();
				__CullingInfo_RO_ComponentTypeHandle = ((SystemState)(ref state)).GetComponentTypeHandle<CullingInfo>(false);
			}
		}

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

			[ReadOnly]
			public ComponentTypeHandle<CullingInfo> m_CullingInfoType;

			public ParallelWriter buffer;

			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_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(m_EntityType);
				NativeArray<CullingInfo> nativeArray2 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<CullingInfo>(ref m_CullingInfoType);
				for (int i = 0; i < ((ArchetypeChunk)(ref chunk)).Count; i++)
				{
					Entity val = nativeArray[i];
					CullingInfo val2 = nativeArray2[i];
					if (val2.m_PassedCulling == 0)
					{
						((ParallelWriter)(ref buffer)).AddComponent<Updated>(unfilteredChunkIndex, val);
					}
				}
			}

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

		private ILog m_Log;

		private EntityQuery m_CullingInfoQuery;

		private TypeHandle __TypeHandle;

		private ToolOutputBarrier m_ToolOutputBarrier;

		private int m_FrameCount = 0;

		private ToolSystem m_ToolSystem;

		public bool RunNow { get; set; }

		protected override void OnCreate()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_009a: 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)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			m_Log.Info((object)"PreventCullingSystem Created.");
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_ToolOutputBarrier = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolOutputBarrier>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<ToolSystem>() : null);
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<PreventOverride>(),
				ComponentType.ReadOnly<CullingInfo>()
			};
			val.None = (ComponentType[])(object)new ComponentType[10]
			{
				ComponentType.ReadOnly<Temp>(),
				ComponentType.ReadOnly<Building>(),
				ComponentType.ReadOnly<Crane>(),
				ComponentType.ReadOnly<Animal>(),
				ComponentType.ReadOnly<Pet>(),
				ComponentType.ReadOnly<Creature>(),
				ComponentType.ReadOnly<Moving>(),
				ComponentType.ReadOnly<Household>(),
				ComponentType.ReadOnly<Vehicle>(),
				ComponentType.ReadOnly<Event>()
			};
			array[0] = val;
			m_CullingInfoQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(m_CullingInfoQuery);
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0110: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			if (GameModeExtensions.IsEditor(m_ToolSystem.actionMode) && !AnarchyMod.Instance.Settings.PreventOverrideInEditor)
			{
				return;
			}
			if (m_FrameCount < AnarchyMod.Instance.Settings.PropRefreshFrequency && !RunNow)
			{
				m_FrameCount++;
				return;
			}
			m_FrameCount = 0;
			if (AnarchyMod.Instance.Settings.PreventAccidentalPropCulling || RunNow)
			{
				RunNow = false;
				__TypeHandle.__CullingInfo_RO_ComponentTypeHandle.Update(ref ((SystemBase)this).CheckedStateRef);
				((EntityTypeHandle)(ref __TypeHandle.__Unity_Entities_Entity_TypeHandle)).Update(ref ((SystemBase)this).CheckedStateRef);
				PreventCullingJob preventCullingJob = default(PreventCullingJob);
				preventCullingJob.m_CullingInfoType = __TypeHandle.__CullingInfo_RO_ComponentTypeHandle;
				preventCullingJob.m_EntityType = __TypeHandle.__Unity_Entities_Entity_TypeHandle;
				EntityCommandBuffer val = ((SafeCommandBufferSystem)m_ToolOutputBarrier).CreateCommandBuffer();
				preventCullingJob.buffer = ((EntityCommandBuffer)(ref val)).AsParallelWriter();
				PreventCullingJob preventCullingJob2 = preventCullingJob;
				JobHandle val2 = JobChunkExtensions.ScheduleParallel<PreventCullingJob>(preventCullingJob2, m_CullingInfoQuery, ((SystemBase)this).Dependency);
				((EntityCommandBufferSystem)m_ToolOutputBarrier).AddJobHandleForProducer(val2);
				((SystemBase)this).Dependency = val2;
			}
		}

		protected override void OnCreateForCompiler()
		{
			((ComponentSystemBase)this).OnCreateForCompiler();
			__TypeHandle.__AssignHandles(ref ((SystemBase)this).CheckedStateRef);
		}
	}
	public class PreventOverrideSystem : GameSystemBase
	{
		private ILog m_Log;

		private EntityQuery m_NeedToPreventOverrideQuery;

		private ToolSystem m_ToolSystem;

		protected override void OnCreate()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0093: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			m_Log.Info((object)"PreventOverrideSystem Created.");
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolSystem>() : null);
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<PreventOverride>(),
				ComponentType.ReadWrite<Overridden>()
			};
			val.None = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<Deleted>() };
			array[0] = val;
			m_NeedToPreventOverrideQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(m_NeedToPreventOverrideQuery);
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!GameModeExtensions.IsEditor(m_ToolSystem.actionMode) || AnarchyMod.Instance.Settings.PreventOverrideInEditor)
			{
				EntityManager entityManager = ((ComponentSystemBase)this).EntityManager;
				((EntityManager)(ref entityManager)).RemoveComponent(m_NeedToPreventOverrideQuery, ComponentType.ReadOnly<Overridden>());
				entityManager = ((ComponentSystemBase)this).EntityManager;
				((EntityManager)(ref entityManager)).AddComponent(m_NeedToPreventOverrideQuery, ComponentType.ReadOnly<Updated>());
			}
		}
	}
	public class DisableToolErrorsSystem : GameSystemBase
	{
		private ToolSystem m_ToolSystem;

		private EntityQuery m_ToolErrorPrefabQuery;

		private AnarchySystem m_AnarchySystem;

		private EnableToolErrorsSystem m_EnableToolErrorsSystem;

		private ILog m_Log;

		private PrefabSystem m_PrefabSystem;

		protected override void OnCreate()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			m_Log = AnarchyMod.Instance.Logger;
			World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
			m_AnarchySystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<AnarchySystem>() : null);
			World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld;
			m_EnableToolErrorsSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<EnableToolErrorsSystem>() : null);
			World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld;
			m_ToolSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<ToolSystem>() : null);
			World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld;
			m_PrefabSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<PrefabSystem>() : null);
			m_Log.Info((object)"DisableToolErrorsSystem Created.");
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = (ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadWrite<ToolErrorData>(),
				ComponentType.ReadOnly<NotificationIconData>()
			};
			array[0] = val;
			m_ToolErrorPrefabQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array);
			((ComponentSystemBase)this).RequireForUpdate(m_ToolErrorPrefabQuery);
			((GameSystemBase)this).OnCreate();
		}

		protected override void OnUpdate()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to inva