Decompiled source of Tree Controller v1.1.5
Tree_Controller.dll
Decompiled 8 months ago
The result has been truncated due to the large size, download it to view full contents!
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 System.Xml.Serialization; using BepInEx; using Colossal; using Colossal.Annotations; using Colossal.Entities; using Colossal.IO.AssetDatabase; using Colossal.Localization; using Colossal.Logging; using Colossal.PSI.Environment; using Colossal.Serialization.Entities; using Game; using Game.Areas; using Game.Common; using Game.Input; using Game.Modding; using Game.Net; using Game.Objects; using Game.Prefabs; using Game.Prefabs.Climate; using Game.Rendering; using Game.SceneFlow; using Game.Settings; using Game.Simulation; using Game.Tools; using Game.UI; using Game.UI.InGame; using Game.UI.Localization; using Game.UI.Tooltip; using Game.UI.Widgets; using HarmonyLib; using Tree_Controller.Settings; using Tree_Controller.Systems; using Tree_Controller.Tools; using Tree_Controller.Utils; using Unity.Burst.Intrinsics; using Unity.Collections; using Unity.Entities; using Unity.Jobs; using Unity.Mathematics; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; 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("Tree_Controller")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Tree_Controller_BepInEx")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8bed8c70-8373-4215-acd3-8ea2a6e7fdd4")] [assembly: AssemblyFileVersion("1.1.4")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.1.4.0")] namespace Tree_Controller { [BepInPlugin("Tree_Controller", "Tree Controller", "1.1.4")] [HarmonyPatch] public class TreeControllerPlugin : BaseUnityPlugin { internal static TreeControllerMod _mod; public void Awake() { _mod = new TreeControllerMod(); _mod.OnLoad(); _mod.Logger.Info((object)"TreeControllerPlugin.InjectSystems"); Harmony.CreateAndPatchAll(typeof(TreeControllerPlugin).Assembly, "Tree_Controller"); } [HarmonyPatch(typeof(SystemOrder), "Initialize", new Type[] { typeof(UpdateSystem) })] [HarmonyPostfix] private static void InjectSystems(UpdateSystem updateSystem) { _mod.OnCreateWorld(updateSystem); } } public struct DeciduousData : IComponentData, IQueryTypeParameter, ISerializable { public TreeState m_PreviousTreeState; public bool m_TechnicallyDead; public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected I4, but got Unknown ((IWriter)writer).Write(1); ((IWriter)writer).Write((byte)(int)m_PreviousTreeState); ((IWriter)writer).Write(m_TechnicallyDead); } public void Deserialize<TReader>(TReader reader) where TReader : IReader { //IL_0023: Unknown result type (might be due to invalid IL or missing references) int num = default(int); ((IReader)reader).Read(ref num); byte b = default(byte); ((IReader)reader).Read(ref b); m_PreviousTreeState = (TreeState)b; ((IReader)reader).Read(ref m_TechnicallyDead); } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Vegetation : IComponentData, IQueryTypeParameter { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Evergreen : IComponentData, IQueryTypeParameter, IEmptySerializable { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Lumber : IComponentData, IQueryTypeParameter, IEmptySerializable { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct RecentlyChanged : IComponentData, IQueryTypeParameter { } public class TreeControllerMod : IMod { private static string m_modInstallFolder; public static TreeControllerMod Instance { get; private set; } public static TreeControllerSettings Settings { get; set; } public static string ModInstallFolder { get { if (m_modInstallFolder == null) { m_modInstallFolder = Path.GetDirectoryName(typeof(TreeControllerPlugin).Assembly.Location); } return m_modInstallFolder; } } internal ILog Logger { get; private set; } public void OnLoad() { Instance = this; Logger = LogManager.GetLogger("Mods_Yenyang_Tree_Controller", false); Logger.Info((object)"[TreeControllerMod] OnLoad"); } public void OnCreateWorld(UpdateSystem updateSystem) { Logger.Info((object)"[TreeControllerMod] OnCreateWorld"); Logger.effectivenessLevel = Level.Debug; Settings = new TreeControllerSettings((IMod)(object)this); ((ModSetting)Settings).RegisterInOptionsUI(); AssetDatabase.global.LoadSettings("TreeControllerMod", (object)Settings, (object)new TreeControllerSettings((IMod)(object)this)); Settings.Contra = false; Logger.Info((object)"[TreeControllerMod] OnCreateWorld finished loading settings."); LoadLocales(); Logger.Info((object)"[TreeControllerMod] OnCreateWorld finished i18n."); updateSystem.UpdateAt<TreeControllerTool>((SystemUpdatePhase)17); updateSystem.UpdateBefore<TreeObjectDefinitionSystem>((SystemUpdatePhase)2); updateSystem.UpdateAt<TreeControllerUISystem>((SystemUpdatePhase)22); updateSystem.UpdateAt<TreeControllerTooltipSystem>((SystemUpdatePhase)23); updateSystem.UpdateAt<ClearTreeControllerTool>((SystemUpdatePhase)18); updateSystem.UpdateBefore<FindTreesAndBushesSystem>((SystemUpdatePhase)12); updateSystem.UpdateBefore<DeciduousSystem>((SystemUpdatePhase)12); updateSystem.UpdateBefore<ReloadFoliageColorDataSystem>((SystemUpdatePhase)12); updateSystem.UpdateAfter<ReloadFoliageColorDataSystem>((SystemUpdatePhase)24); updateSystem.UpdateBefore<ModifyTreeGrowthSystem>((SystemUpdatePhase)12); updateSystem.UpdateBefore<SafelyRemoveSystem>((SystemUpdatePhase)12); updateSystem.UpdateBefore<LumberSystem>((SystemUpdatePhase)12); updateSystem.UpdateAt<DetectAreaChangeSystem>((SystemUpdatePhase)9); Logger.Info((object)"[TreeControllerMod] OnCreateWorld finished systems"); } public void OnDispose() { Logger.Info((object)"Disposing.."); } private void LoadLocales() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown LocaleEN localeEN = new LocaleEN(Settings); string path = Path.Combine(ModInstallFolder, "l10n.csv"); if (File.Exists(path)) { IEnumerable<string[]> source = from x in File.ReadAllLines(path) select x.Split(new char[1] { '\t' }); int enColumn = Array.IndexOf(source.First(), "en-US"); MemorySource val = new MemorySource(source.Skip(1).ToDictionary((string[] x) => x[0], (string[] x) => x.ElementAtOrDefault(enColumn))); string[] supportedLocales = GameManager.instance.localizationManager.GetSupportedLocales(); foreach (string text in supportedLocales) { try { GameManager.instance.localizationManager.AddSource(text, (IDictionarySource)(object)val); if (!(text != "en-US")) { continue; } int valueColumn = Array.IndexOf(source.First(), text); if (valueColumn > 0) { MemorySource val2 = new MemorySource(source.Skip(1).ToDictionary((string[] x) => x[0], (string[] x) => x.ElementAtOrDefault(valueColumn))); GameManager.instance.localizationManager.AddSource(text, (IDictionarySource)(object)val2); } } catch (Exception ex) { Logger.Warn((object)string.Format("{0}.{1} Encountered exception {2} while trying to localize {3}.", "TreeControllerMod", "LoadLocales", ex, text)); } } } else { Logger.Warn((object)"TreeControllerMod.LoadLocales couldn't find localization file and loaded default for every language."); string[] supportedLocales2 = GameManager.instance.localizationManager.GetSupportedLocales(); foreach (string text2 in supportedLocales2) { GameManager.instance.localizationManager.AddSource(text2, (IDictionarySource)(object)localeEN); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tree_Controller"; public const string PLUGIN_NAME = ""; public const string PLUGIN_VERSION = "1.0.0.0"; } } namespace Tree_Controller.Utils { public static class FoliageUtils { public enum Season { Spring, Summer, Autumn, Winter } private static readonly Dictionary<string, Season> SeasonDictionary = new Dictionary<string, Season> { { "Climate.SEASON[Spring]", Season.Spring }, { "Climate.SEASON[Summer]", Season.Summer }, { "Climate.SEASON[Autumn]", Season.Autumn }, { "Climate.SEASON[Winter]", Season.Winter } }; public static Dictionary<string, Season> SeasonDictionary1 => SeasonDictionary; public static Season GetSeasonFromSeasonID(string seasonID) { if (SeasonDictionary1.ContainsKey(seasonID)) { return SeasonDictionary1[seasonID]; } TreeControllerMod.Instance.Logger.Info((object)("[FoliageColorData.GetSeasonFromSeasonID] couldn't find season for " + seasonID + ".")); return Season.Spring; } public static ColorSet LerpColorSet(ColorSet colorSet1, ColorSet colorSet2, float balance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005a: Unknown result type (might be due to invalid IL or missing references) ColorSet result = default(ColorSet); result.m_Channel0 = Color.Lerp(colorSet1.m_Channel0, colorSet2.m_Channel0, balance); result.m_Channel1 = Color.Lerp(colorSet1.m_Channel1, colorSet2.m_Channel1, balance); result.m_Channel2 = Color.Lerp(colorSet1.m_Channel2, colorSet2.m_Channel2, balance); return result; } } 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) { TreeControllerMod.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) { TreeControllerMod.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(TreeControllerPlugin).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)) { TreeControllerMod.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) { TreeControllerMod.Instance.Logger.Error(ex, (object)"exception reading UI files"); } } internal static string ReadHTML(string fileName, string injectionPostfix = "document.body.appendChild(yyTreeController.div);") { try { string text = ReadUIFile(fileName); if (!string.IsNullOrEmpty(text)) { return "yyTreeController.div = document.createElement('div'); yyTreeController.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; " + injectionPostfix; } } catch (Exception ex) { TreeControllerMod.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 "yyTreeController.div = document.createElement('div'); yyTreeController.div.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.body.appendChild(yyTreeController.div);"; } } catch (Exception ex) { TreeControllerMod.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) { TreeControllerMod.Instance.Logger.Error(ex, (object)(" exception reading JS file " + fileName)); } return null; } internal static string ReadCSS(string fileName) { try { string text = ReadUIFile(fileName); if (!string.IsNullOrEmpty(text)) { return "yyTreeController.styleType = document.createElement('style'); yyTreeController.styleType.type = 'text/css'; yyTreeController.styleType.innerHTML = \"" + EscapeToJavaScript(text) + "\"; document.head.appendChild(yyTreeController.styleType);"; } } catch (Exception ex) { TreeControllerMod.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) { TreeControllerMod.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 Tree_Controller.Tools { public class TreeControllerUISystem : UISystemBase { private readonly List<PrefabID> m_VanillaDeciduousPrefabIDs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "EU_AlderTree01"), new PrefabID("StaticObjectPrefab", "BirchTree01"), new PrefabID("StaticObjectPrefab", "NA_LondonPlaneTree01"), new PrefabID("StaticObjectPrefab", "NA_LindenTree01"), new PrefabID("StaticObjectPrefab", "NA_HickoryTree01"), new PrefabID("StaticObjectPrefab", "EU_ChestnutTree01"), new PrefabID("StaticObjectPrefab", "OakTree01") }; private readonly List<PrefabID> m_VanillaEvergreenPrefabIDs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "PineTree01"), new PrefabID("StaticObjectPrefab", "SpruceTree01") }; private readonly List<PrefabID> m_VanillaWildBushPrefabs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "GreenBushWild01"), new PrefabID("StaticObjectPrefab", "GreenBushWild02"), new PrefabID("StaticObjectPrefab", "FlowerBushWild01"), new PrefabID("StaticObjectPrefab", "FlowerBushWild02") }; private readonly List<PrefabID> m_DefaultCustomSet1Prefabs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "NA_LondonPlaneTree01"), new PrefabID("StaticObjectPrefab", "NA_LindenTree01"), new PrefabID("StaticObjectPrefab", "NA_HickoryTree01") }; private readonly List<PrefabID> m_DefaultCustomSet2Prefabs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "EU_AlderTree01"), new PrefabID("StaticObjectPrefab", "EU_ChestnutTree01"), new PrefabID("StaticObjectPrefab", "EU_PoplarTree01") }; private readonly List<PrefabID> m_DefaultCustomSet3Prefabs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "BirchTree01"), new PrefabID("StaticObjectPrefab", "OakTree01"), new PrefabID("StaticObjectPrefab", "AppleTree01") }; private readonly List<PrefabID> m_DefaultCustomSet4Prefabs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "BirchTree01"), new PrefabID("StaticObjectPrefab", "EU_PoplarTree01") }; private readonly List<PrefabID> m_DefaultCustomSet5Prefabs = new List<PrefabID> { new PrefabID("StaticObjectPrefab", "EU_ChestnutTree01"), new PrefabID("StaticObjectPrefab", "NA_LondonPlaneTree01"), new PrefabID("StaticObjectPrefab", "NA_LindenTree01") }; private readonly Dictionary<string, TreeControllerTool.TCSelectionMode> ToolModeLookup = new Dictionary<string, TreeControllerTool.TCSelectionMode> { { "YYTC-single-tree", TreeControllerTool.TCSelectionMode.SingleTree }, { "YYTC-building-or-net", TreeControllerTool.TCSelectionMode.WholeBuildingOrNet }, { "YYTC-radius", TreeControllerTool.TCSelectionMode.Radius }, { "YYTC-whole-map", TreeControllerTool.TCSelectionMode.WholeMap } }; private readonly Dictionary<TreeControllerTool.TCSelectionMode, string> ToolModeButtonLookup = new Dictionary<TreeControllerTool.TCSelectionMode, string> { { TreeControllerTool.TCSelectionMode.SingleTree, "YYTC-single-tree" }, { TreeControllerTool.TCSelectionMode.WholeBuildingOrNet, "YYTC-building-or-net" }, { TreeControllerTool.TCSelectionMode.Radius, "YYTC-radius" }, { TreeControllerTool.TCSelectionMode.WholeMap, "YYTC-whole-map" } }; private View m_UiView; private ToolSystem m_ToolSystem; private PrefabSystem m_PrefabSystem; private ObjectToolSystem m_ObjectToolSystem; private TreeObjectDefinitionSystem m_TreeObjectDefinitionSystem; private TreeControllerTool m_TreeControllerTool; private string m_InjectedJS = string.Empty; private ILog m_Log; private PrefabBase m_LastObjectToolPrefab; private List<BoundEventHandle> m_BoundEvents; private Dictionary<string, List<PrefabID>> m_PrefabSetsLookup; private string m_TreeControllerPanelScript = string.Empty; private string m_SelectionRowItemScript = string.Empty; private string m_ToolModeItemScript = string.Empty; private string m_AgeChangingToolModeItemScript = string.Empty; private string m_InjectedCSS = string.Empty; private bool m_ToolIsActive; private bool m_ObjectToolPlacingTree = false; private string m_SelectedPrefabSet = string.Empty; private bool m_RecentlySelectedPrefabSet = false; private bool m_PreviousPanelsCleared = false; private bool m_FirstTimeInjectingJS = true; private string m_ContentFolder; private bool m_UpdateSelectionSet = false; private int m_FrameCount = 0; private bool m_MultiplePrefabsSelected = false; private EntityQuery m_VegetationQuery; private Entity m_ThemeEntity = Entity.Null; private bool m_LastToolWasLineTool = false; public bool UpdateSelectionSet { get { return m_UpdateSelectionSet; } set { m_UpdateSelectionSet = value; } } public Entity ThemeEntity { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return m_ThemeEntity; } set { //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) m_ThemeEntity = value; } } public bool RecentlySelectedPrefabSet => m_RecentlySelectedPrefabSet; public void ResetPrefabSets() { if (m_RecentlySelectedPrefabSet) { return; } m_SelectedPrefabSet = string.Empty; UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectedPrefabSet = \"\";"); foreach (KeyValuePair<string, List<PrefabID>> item in m_PrefabSetsLookup) { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.element = document.getElementById(\"" + item.Key + "\"); if (yyTreeController.element != null) { yyTreeController.element.classList.remove(\"selected\"); }"); } m_Log.Debug((object)"TreeControllerUISystem.ResetPrefabSets Resetting prefab sets."); } public void SelectPrefab(PrefabBase prefab) { if (!((Object)(object)prefab == (Object)null)) { UIFileUtils.ExecuteScript(m_UiView, "if (yyTreeController == null) var yyTreeController = {};"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.tagElements = document.getElementsByTagName(\"img\"); for (yyTreeController.i = 0; yyTreeController.i < yyTreeController.tagElements.length; yyTreeController.i++) { if (yyTreeController.tagElements[yyTreeController.i].src.includes(\"" + ((Object)prefab).name + "\")) { yyTreeController.tagElements[yyTreeController.i].parentNode.classList.add(\"selected\"); } } "); } } protected override void OnCreate() { //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) m_Log = TreeControllerMod.Instance.Logger; World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld; m_ToolSystem = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolSystem>() : null); World defaultGameObjectInjectionWorld2 = World.DefaultGameObjectInjectionWorld; m_PrefabSystem = ((defaultGameObjectInjectionWorld2 != null) ? defaultGameObjectInjectionWorld2.GetOrCreateSystemManaged<PrefabSystem>() : null); m_UiView = GameManager.instance.userInterface.view.View; World defaultGameObjectInjectionWorld3 = World.DefaultGameObjectInjectionWorld; m_ObjectToolSystem = ((defaultGameObjectInjectionWorld3 != null) ? defaultGameObjectInjectionWorld3.GetOrCreateSystemManaged<ObjectToolSystem>() : null); World defaultGameObjectInjectionWorld4 = World.DefaultGameObjectInjectionWorld; m_TreeObjectDefinitionSystem = ((defaultGameObjectInjectionWorld4 != null) ? defaultGameObjectInjectionWorld4.GetOrCreateSystemManaged<TreeObjectDefinitionSystem>() : null); World defaultGameObjectInjectionWorld5 = World.DefaultGameObjectInjectionWorld; m_TreeControllerTool = ((defaultGameObjectInjectionWorld5 != null) ? defaultGameObjectInjectionWorld5.GetOrCreateSystemManaged<TreeControllerTool>() : null); m_ContentFolder = Path.Combine(EnvPath.kUserDataPath, "ModsData", "Mods_Yenyang_Tree_Controller", "CustomSets"); Directory.CreateDirectory(m_ContentFolder); ToolSystem toolSystem = m_ToolSystem; m_ToolSystem.EventToolChanged = (Action<ToolBaseSystem>)Delegate.Combine(toolSystem.EventToolChanged, new Action<ToolBaseSystem>(OnToolChanged)); ToolSystem toolSystem2 = m_ToolSystem; toolSystem2.EventPrefabChanged = (Action<PrefabBase>)Delegate.Combine(toolSystem2.EventPrefabChanged, new Action<PrefabBase>(OnPrefabChanged)); m_BoundEvents = new List<BoundEventHandle>(); m_PrefabSetsLookup = new Dictionary<string, List<PrefabID>> { { "YYTC-wild-deciduous-trees", m_VanillaDeciduousPrefabIDs }, { "YYTC-evergreen-trees", m_VanillaEvergreenPrefabIDs }, { "YYTC-wild-bushes", m_VanillaWildBushPrefabs }, { "YYTC-custom-set-1", m_DefaultCustomSet1Prefabs }, { "YYTC-custom-set-2", m_DefaultCustomSet2Prefabs }, { "YYTC-custom-set-3", m_DefaultCustomSet3Prefabs }, { "YYTC-custom-set-4", m_DefaultCustomSet4Prefabs }, { "YYTC-custom-set-5", m_DefaultCustomSet5Prefabs } }; for (int i = 1; i <= 5; i++) { TryLoadCustomPrefabSet($"YYTC-custom-set-{i}"); } m_InjectedJS = UIFileUtils.ReadJS(Path.Combine(UIFileUtils.AssemblyPath, "ui.js")); m_TreeControllerPanelScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-selection-mode-item.html"), "if (document.getElementById(\"tree-controller-panel\") == null) { yyTreeController.div.className = \"tool-options-panel_Se6\"; yyTreeController.div.id = \"tree-controller-panel\"; yyTreeController.ToolColumns = document.getElementsByClassName(\"tool-side-column_l9i\"); if (yyTreeController.ToolColumns[0] != null) yyTreeController.ToolColumns[0].appendChild(yyTreeController.div); if (typeof yyTreeController.setupYYTCSelectionModeItem == 'function') yyTreeController.setupYYTCSelectionModeItem(); }"); m_SelectionRowItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-selection-mode-content.html"), "if (document.getElementById(\"YYTC-selection-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id = \"YYTC-selection-mode-item\"; yyTreeController.AgesElement = document.getElementById(\"YYTC-tree-age-item\"); if (yyTreeController.AgesElement != null) yyTreeController.AgesElement.insertAdjacentElement('afterend', yyTreeController.div);if (typeof yyTreeController.setupYYTCSelectionModeItem == 'function') yyTreeController.setupYYTCSelectionModeItem(); }"); m_ToolModeItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-tool-mode-content.html"), "if (document.getElementById(\"YYTC-tool-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id =\"YYTC-tool-mode-item\"; yyTreeController.OptionsPanels = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.OptionsPanels[0] != null) { yyTreeController.OptionsPanels[0].appendChild(yyTreeController.div); if (typeof yyTreeController.setupToolModeButtons == 'function') yyTreeController.setupToolModeButtons(); } }"); m_AgeChangingToolModeItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-tool-mode-content.html"), "if (document.getElementById(\"YYTC-tool-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id =\"YYTC-tool-mode-item\"; yyTreeController.panel = document.getElementById(\"tree-controller-panel\"); if (yyTreeController.panel != null) { yyTreeController.panel.appendChild(yyTreeController.div); if (typeof yyTreeController.setupToolModeButtons == 'function') yyTreeController.setupToolModeButtons(); } }"); m_InjectedCSS = UIFileUtils.ReadCSS(Path.Combine(UIFileUtils.AssemblyPath, "ui.css")); if (m_UiView == null) { m_Log.Warn((object)"TreeControllerUISystem.OnCreate m_UiView == null"); } m_VegetationQuery = ((ComponentSystemBase)this).GetEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<Vegetation>() }); m_Log.Info((object)"TreeControllerUISystem.OnCreate"); ((ComponentSystemBase)this).Enabled = false; ((UISystemBase)this).OnCreate(); } protected override void OnUpdate() { //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092c: Invalid comparison between Unknown and I4 //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_066d: Unknown result type (might be due to invalid IL or missing references) //IL_0695: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_080b: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_0e37: Unknown result type (might be due to invalid IL or missing references) //IL_0e3d: Invalid comparison between Unknown and I4 //IL_0ffe: Unknown result type (might be due to invalid IL or missing references) //IL_1004: Invalid comparison between Unknown and I4 //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0c2c: Unknown result type (might be due to invalid IL or missing references) //IL_0c31: Unknown result type (might be due to invalid IL or missing references) //IL_0c35: Unknown result type (might be due to invalid IL or missing references) //IL_0c84: Unknown result type (might be due to invalid IL or missing references) //IL_0c89: Unknown result type (might be due to invalid IL or missing references) //IL_0c92: Unknown result type (might be due to invalid IL or missing references) //IL_0cde: Unknown result type (might be due to invalid IL or missing references) //IL_0d06: Unknown result type (might be due to invalid IL or missing references) //IL_0d2e: Unknown result type (might be due to invalid IL or missing references) //IL_0d56: Unknown result type (might be due to invalid IL or missing references) //IL_0d7e: Unknown result type (might be due to invalid IL or missing references) //IL_0da6: Unknown result type (might be due to invalid IL or missing references) //IL_0dce: Unknown result type (might be due to invalid IL or missing references) //IL_0df6: Unknown result type (might be due to invalid IL or missing references) //IL_0e1e: Unknown result type (might be due to invalid IL or missing references) List<PrefabBase> selectedPrefabs = m_TreeControllerTool.GetSelectedPrefabs(); EntityManager entityManager; if (m_ToolSystem.activeTool == m_TreeControllerTool && m_UiView != null) { UIFileUtils.ExecuteScript(m_UiView, "if (yyTreeController == null) var yyTreeController = {};"); if (m_ToolIsActive) { if ((Object)(object)((ToolBaseSystem)m_TreeControllerTool).GetPrefab() == (Object)null) { UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"tree-controller-panel\") == null) engine.trigger('YYTC-tree-controller-panel-missing');"); return; } UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYTC-selection-mode-item\") == null) engine.trigger('YYTC-selection-mode-item-missing');"); if (!m_MultiplePrefabsSelected && m_TreeControllerTool.GetSelectedPrefabs().Count > 1) { m_UpdateSelectionSet = true; } if (m_UpdateSelectionSet && m_FrameCount <= 5) { UnselectPrefabs(); foreach (PrefabBase item in selectedPrefabs) { SelectPrefab(item); } if (selectedPrefabs.Count > 1) { m_MultiplePrefabsSelected = true; } else { m_MultiplePrefabsSelected = false; } if (m_FrameCount == 5) { m_UpdateSelectionSet = false; m_RecentlySelectedPrefabSet = false; m_FrameCount = 6; } else { m_FrameCount++; } } else if (m_UpdateSelectionSet) { if (m_FrameCount == 6) { m_FrameCount = 0; } m_FrameCount++; } return; } if (!m_PreviousPanelsCleared && (Object)(object)((ToolBaseSystem)m_TreeControllerTool).GetPrefab() == (Object)null) { UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); m_PreviousPanelsCleared = true; return; } if (!m_PreviousPanelsCleared) { UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-rotation-row") + " " + DestroyElementByID("YYTC-ActivateAgeChange") + " " + DestroyElementByID("YYTC-ActivatePrefabChange") + " " + DestroyElementByID("YYTC-tool-mode-item")); foreach (BoundEventHandle boundEvent in m_BoundEvents) { m_UiView.UnregisterFromEvent(boundEvent); } m_BoundEvents.Clear(); UnshowTreeControllerToolPanel(); m_PreviousPanelsCleared = true; return; } if (m_InjectedJS == string.Empty) { m_Log.Warn((object)"TreeControllerUISystem.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_TreeControllerPanelScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-selection-mode-item.html"), "if (document.getElementById(\"tree-controller-panel\") == null) { yyTreeController.div.className = \"tool-options-panel_Se6\"; yyTreeController.div.id = \"tree-controller-panel\"; yyTreeController.ToolColumns = document.getElementsByClassName(\"tool-side-column_l9i\"); if (yyTreeController.ToolColumns[0] != null) yyTreeController.ToolColumns[0].appendChild(yyTreeController.div); if (typeof yyTreeController.setupYYTCSelectionModeItem == 'function') yyTreeController.setupYYTCSelectionModeItem(); }"); m_SelectionRowItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-selection-mode-content.html"), "if (document.getElementById(\"YYTC-selection-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id = \"YYTC-selection-mode-item\"; yyTreeController.AgesElement = document.getElementById(\"YYTC-tree-age-item\"); if (yyTreeController.AgesElement != null) yyTreeController.AgesElement.insertAdjacentElement('afterend', yyTreeController.div);if (typeof yyTreeController.setupYYTCSelectionModeItem == 'function') yyTreeController.setupYYTCSelectionModeItem(); }"); m_ToolModeItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-tool-mode-content.html"), "if (document.getElementById(\"YYTC-tool-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id =\"YYTC-tool-mode-item\"; yyTreeController.OptionsPanels = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.OptionsPanels[0] != null) { yyTreeController.OptionsPanels[0].appendChild(yyTreeController.div); if (typeof yyTreeController.setupToolModeButtons == 'function') yyTreeController.setupToolModeButtons(); } }"); m_AgeChangingToolModeItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-tool-mode-content.html"), "if (document.getElementById(\"YYTC-tool-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id =\"YYTC-tool-mode-item\"; yyTreeController.panel = document.getElementById(\"tree-controller-panel\"); if (yyTreeController.panel != null) { yyTreeController.panel.appendChild(yyTreeController.div); if (typeof yyTreeController.setupToolModeButtons == 'function') yyTreeController.setupToolModeButtons(); } }"); m_InjectedCSS = UIFileUtils.ReadCSS(Path.Combine(UIFileUtils.AssemblyPath, "ui.css")); } bool[] selectedAges = m_TreeControllerTool.GetSelectedAges(); UIFileUtils.ExecuteScript(m_UiView, m_InjectedCSS); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectedAges = new Map([[\"YYTC-child\", " + BoolToString(selectedAges[0]) + "],[\"YYTC-teen\", " + BoolToString(selectedAges[1]) + "],[\"YYTC-adult\", " + BoolToString(selectedAges[2]) + "],[\"YYTC-elderly\", " + BoolToString(selectedAges[3]) + "],[\"YYTC-dead\", " + BoolToString(selectedAges[4]) + "],]);"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectionMode = \"" + ToolModeButtonLookup[m_TreeControllerTool.SelectionMode] + "\";"); UIFileUtils.ExecuteScript(m_UiView, $"yyTreeController.radius = {m_TreeControllerTool.Radius};"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectedPrefabSet = \"" + m_SelectedPrefabSet + "\";"); UIFileUtils.ExecuteScript(m_UiView, m_InjectedJS); if (m_FirstTimeInjectingJS) { m_FirstTimeInjectingJS = false; return; } m_BoundEvents.Add(m_UiView.RegisterForEvent("TClog", (Delegate)new Action<string>(LogFromJS))); if ((Object)(object)((ToolBaseSystem)m_TreeControllerTool).GetPrefab() == (Object)null) { UIFileUtils.ExecuteScript(m_UiView, m_TreeControllerPanelScript + " yyTreeController.selectionModeItem = document.getElementById(\"YYTC-selection-mode-item\"); if (yyTreeController.selectionModeItem != null && typeof yyTreeController.buildTreeAgeItem == 'function') yyTreeController.buildTreeAgeItem(yyTreeController.selectionModeItem,'afterend'); if (typeof yyTreeController.checkIfNeedToBuildRadius == 'function') yyTreeController.checkIfNeedToBuildRadius();"); UIFileUtils.ExecuteScript(m_UiView, m_AgeChangingToolModeItemScript + " yyTreeController.selectedToolMode = document.getElementById(\"YYTC-ActivateAgeChange\"); if (yyTreeController.selectedToolMode != null) yyTreeController.selectedToolMode.classList.add(\"selected\"); "); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ActivatePrefabChange", (Delegate)new Action(ActivatePrefabChange))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-tree-controller-panel-missing", (Delegate)new Action(ResetPanel))); } else { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.entities[0] != null) { if (yyTreeController.entities[0].firstChild != null && typeof yyTreeController.buildTreeAgeItem == 'function') { yyTreeController.buildTreeAgeItem(yyTreeController.entities[0].firstChild, 'beforebegin'); } }"); UIFileUtils.ExecuteScript(m_UiView, m_SelectionRowItemScript + " if (typeof yyTreeController.checkIfNeedToBuildRadius == 'function') yyTreeController.checkIfNeedToBuildRadius();"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.ageItem = document.getElementById(\"YYTC-tree-age-item\"); if (yyTreeController.ageItem != null && typeof yyTreeController.buildPrefabSetsRow == 'function') yyTreeController.buildPrefabSetsRow(yyTreeController.ageItem,'afterend');"); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-Prefab-Set-Changed", (Delegate)new Action<string>(ChangePrefabSet))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ActivateAgeChange", (Delegate)new Action(ActivateTreeControllerTool))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-selection-mode-item-missing", (Delegate)new Action(ResetPanel))); UIFileUtils.ExecuteScript(m_UiView, m_ToolModeItemScript + " yyTreeController.selectedToolMode = document.getElementById(\"YYTC-ActivatePrefabChange\"); if (yyTreeController.selectedToolMode != null) yyTreeController.selectedToolMode.classList.add(\"selected\");"); bool flag = true; Entity val = default(Entity); foreach (PrefabBase item2 in selectedPrefabs) { if (m_PrefabSystem.TryGetEntity(item2, ref val)) { entityManager = ((ComponentSystemBase)this).EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<TreeData>(val)) { flag = false; break; } } } if (flag) { UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tree-age-item") ?? ""); } } m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ChangeSelectedAges", (Delegate)new Action<bool[]>(ChangeSelectedAges))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ToolModeChanged", (Delegate)new Action<string>(ChangeToolMode))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-AdjustRadius", (Delegate)new Action<int>(ChangeRadius))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-brush-trees", (Delegate)new Action(ActivateBrushTrees))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-plop-tree", (Delegate)new Action(ActivatePlopTrees))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-tree-age-item-missing", (Delegate)new Action(ResetPanel))); m_ToolIsActive = true; m_ObjectToolPlacingTree = false; m_PreviousPanelsCleared = false; return; } if (m_ToolIsActive) { UnshowTreeControllerToolPanel(); UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); m_ToolIsActive = false; return; } if (m_ToolSystem.activeTool != m_ObjectToolSystem || m_UiView == null || ((int)m_ObjectToolSystem.mode != 0 && (int)m_ObjectToolSystem.mode != 3)) { ((ComponentSystemBase)this).Enabled = false; return; } if (m_LastToolWasLineTool) { m_LastToolWasLineTool = false; return; } if (m_ObjectToolPlacingTree && !((ToolBaseSystem)m_ObjectToolSystem).brushing) { UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYTC-rotation-row\") == null) engine.trigger('YYTC-rotation-row-missing');"); } else if (m_ObjectToolPlacingTree) { UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYTC-prefab-sets-row\") == null) engine.trigger('YYTC-prefab-sets-row-missing');"); } UIFileUtils.ExecuteScript(m_UiView, "if (yyTreeController == null) var yyTreeController = {};"); UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYTC-ActivateAgeChange\") == null) { yyTreeController.tagElements = document.getElementsByTagName(\"img\"); for (yyTreeController.i = 0; yyTreeController.i < yyTreeController.tagElements.length; yyTreeController.i++) { if (yyTreeController.tagElements[yyTreeController.i].src == \"Media/Tools/Object%20Tool/Brush.svg\" && typeof yyTreeController.buildActivateToolButton == 'function') { yyTreeController.buildActivateToolButton(\"YYTC-ActivateAgeChange\", \"coui://uil/Standard/ReplaceTreeAge.svg\", yyTreeController.tagElements[yyTreeController.i].parentNode.parentNode, \"change-age-tool\"); yyTreeController.buildActivateToolButton(\"YYTC-ActivatePrefabChange\", \"coui://uil/Standard/Replace.svg\", yyTreeController.tagElements[yyTreeController.i].parentNode.parentNode, \"change-prefab-tool\"); } } }"); if (!m_ObjectToolPlacingTree) { bool[] selectedAges2 = m_TreeControllerTool.GetSelectedAges(); if (m_InjectedJS == string.Empty) { m_Log.Warn((object)"TreeControllerUISystem.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_TreeControllerPanelScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-selection-mode-item.html"), "if (document.getElementById(\"tree-controller-panel\") == null) { yyTreeController.div.className = \"tool-options-panel_Se6\"; yyTreeController.div.id = \"tree-controller-panel\"; yyTreeController.ToolColumns = document.getElementsByClassName(\"tool-side-column_l9i\"); if (yyTreeController.ToolColumns[0] != null) yyTreeController.ToolColumns[0].appendChild(yyTreeController.div); if (typeof yyTreeController.setupYYTCSelectionModeItem == 'function') yyTreeController.setupYYTCSelectionModeItem(); }"); m_SelectionRowItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-selection-mode-content.html"), "if (document.getElementById(\"YYTC-selection-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id = \"YYTC-selection-mode-item\"; yyTreeController.AgesElement = document.getElementById(\"YYTC-tree-age-item\"); if (yyTreeController.AgesElement != null) yyTreeController.AgesElement.insertAdjacentElement('afterend', yyTreeController.div);if (typeof yyTreeController.setupYYTCSelectionModeItem == 'function') yyTreeController.setupYYTCSelectionModeItem(); }"); m_ToolModeItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-tool-mode-content.html"), "if (document.getElementById(\"YYTC-tool-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id =\"YYTC-tool-mode-item\"; yyTreeController.OptionsPanels = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.OptionsPanels[0] != null) { yyTreeController.OptionsPanels[0].appendChild(yyTreeController.div); if (typeof yyTreeController.setupToolModeButtons == 'function') yyTreeController.setupToolModeButtons(); } }"); m_AgeChangingToolModeItemScript = UIFileUtils.ReadHTML(Path.Combine(UIFileUtils.AssemblyPath, "YYTC-tool-mode-content.html"), "if (document.getElementById(\"YYTC-tool-mode-item\") == null) { yyTreeController.div.className = \"item_bZY\"; yyTreeController.div.id =\"YYTC-tool-mode-item\"; yyTreeController.panel = document.getElementById(\"tree-controller-panel\"); if (yyTreeController.panel != null) { yyTreeController.panel.appendChild(yyTreeController.div); if (typeof yyTreeController.setupToolModeButtons == 'function') yyTreeController.setupToolModeButtons(); } }"); m_InjectedCSS = UIFileUtils.ReadCSS(Path.Combine(UIFileUtils.AssemblyPath, "ui.css")); } UIFileUtils.ExecuteScript(m_UiView, m_InjectedCSS); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectedAges = new Map([[\"YYTC-child\", " + BoolToString(selectedAges2[0]) + "],[\"YYTC-teen\", " + BoolToString(selectedAges2[1]) + "],[\"YYTC-adult\", " + BoolToString(selectedAges2[2]) + "],[\"YYTC-elderly\", " + BoolToString(selectedAges2[3]) + "],[\"YYTC-dead\", " + BoolToString(selectedAges2[4]) + "],]);"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectedPrefabSet = \"" + m_SelectedPrefabSet + "\";"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.randomRotation = " + BoolToString(TreeControllerMod.Settings.RandomRotation) + ";"); UIFileUtils.ExecuteScript(m_UiView, m_InjectedJS); if (m_FirstTimeInjectingJS) { m_FirstTimeInjectingJS = false; return; } m_Log.Debug((object)selectedPrefabs.Count); Entity val2 = default(Entity); foreach (PrefabBase item3 in selectedPrefabs) { if (m_PrefabSystem.TryGetEntity(item3, ref val2)) { entityManager = ((ComponentSystemBase)this).EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<TreeData>(val2)) { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.entities[0] != null) { if (yyTreeController.entities[0].firstChild != null && typeof yyTreeController.buildTreeAgeItem == 'function') { yyTreeController.buildTreeAgeItem(yyTreeController.entities[0].firstChild, 'beforebegin'); } }"); break; } } } foreach (BoundEventHandle boundEvent2 in m_BoundEvents) { m_UiView.UnregisterFromEvent(boundEvent2); } m_BoundEvents.Clear(); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-Random-Rotation-Changed", (Delegate)new Action<bool>(ChangeRandomRotation))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ActivateAgeChange", (Delegate)new Action(ActivateTreeControllerTool))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ActivatePrefabChange", (Delegate)new Action(ActivatePrefabChange))); m_BoundEvents.Add(m_UiView.RegisterForEvent("TClog", (Delegate)new Action<string>(LogFromJS))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-Prefab-Set-Changed", (Delegate)new Action<string>(ChangePrefabSet))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ChangeSelectedAges", (Delegate)new Action<bool[]>(ChangeSelectedAges))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-tree-age-item-missing", (Delegate)new Action(ResetPanel))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-prefab-sets-row-missing", (Delegate)new Action(ResetPanel))); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-rotation-row-missing", (Delegate)new Action(ResetPanel))); m_ObjectToolPlacingTree = true; } if ((int)m_ObjectToolSystem.mode == 3) { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.destroyElementByID(\"YYTC-rotation-row\");"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.entities[0] != null) { if (yyTreeController.entities[0].firstChild != null && typeof yyTreeController.buildPrefabSetsRow == 'function') { yyTreeController.buildPrefabSetsRow(yyTreeController.entities[0].firstChild, 'afterend'); } }"); if (!m_MultiplePrefabsSelected && selectedPrefabs.Count > 1) { m_UpdateSelectionSet = true; } if (m_MultiplePrefabsSelected && (Object)(object)m_ObjectToolSystem.prefab != (Object)(object)m_LastObjectToolPrefab && !selectedPrefabs.Contains((PrefabBase)(object)m_ObjectToolSystem.prefab)) { UnselectPrefabs(); m_TreeControllerTool.ClearSelectedTreePrefabs(); m_MultiplePrefabsSelected = false; ResetPrefabSets(); m_Log.Debug((object)"TreeControllerUISystem.OnUpdate selectionSet Reset due to prefab changing without toggling OnPrefabChanged"); } if (m_UpdateSelectionSet && m_FrameCount <= 5) { UnselectPrefabs(); foreach (PrefabBase item4 in selectedPrefabs) { SelectPrefab(item4); } if (selectedPrefabs.Count > 1) { m_MultiplePrefabsSelected = true; } else { m_MultiplePrefabsSelected = false; } if (m_FrameCount == 5) { m_UpdateSelectionSet = false; m_RecentlySelectedPrefabSet = false; m_FrameCount = 6; } else { m_FrameCount++; } } else if (m_UpdateSelectionSet) { if (m_FrameCount == 6) { m_FrameCount = 0; } m_FrameCount++; } } else if ((int)m_ObjectToolSystem.mode == 0) { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.destroyElementByID(\"YYTC-prefab-sets-row\");"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.entities = document.getElementsByClassName(\"tool-options-panel_Se6\"); if (yyTreeController.entities[0] != null) { if (yyTreeController.entities[0].firstChild != null && typeof yyTreeController.buildRotationRow == 'function') { yyTreeController.buildRotationRow(yyTreeController.entities[0].firstChild, 'afterend'); } }"); if (m_MultiplePrefabsSelected) { UnselectPrefabs(); foreach (PrefabBase item5 in selectedPrefabs) { if (m_ToolSystem.ActivatePrefabTool(item5)) { SelectPrefab(item5); break; } } } if (!selectedPrefabs.Contains(m_ToolSystem.activePrefab)) { foreach (PrefabBase item6 in selectedPrefabs) { if (m_ToolSystem.ActivatePrefabTool(item6)) { SelectPrefab(item6); break; } } } } ((UISystemBase)this).OnUpdate(); } private void UnshowObjectToolPanelItems() { //IL_00a1: 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_00ae: Unknown result type (might be due to invalid IL or missing references) m_Log.Debug((object)"TreeControllerUISystem.UnshowObjectToolPanelItems"); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tree-age-item") + " " + DestroyElementByID("YYTC-rotation-row") + " " + DestroyElementByID("YYTC-prefab-sets-row") + " " + DestroyElementByID("YYTC-ActivateAgeChange") + " " + DestroyElementByID("YYTC-ActivatePrefabChange")); foreach (BoundEventHandle boundEvent in m_BoundEvents) { m_UiView.UnregisterFromEvent(boundEvent); } m_BoundEvents.Clear(); m_ObjectToolPlacingTree = false; } private void UnshowTreeControllerToolPanel() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) m_Log.Debug((object)"TreeControllerUISystem.UnshowTreeControllerToolPanel"); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.panel = document.getElementById(\"tree-controller-panel\"); if (yyTreeController.panel != null) yyTreeController.panel.parentElement.removeChild(yyTreeController.panel);"); m_ToolIsActive = false; foreach (BoundEventHandle boundEvent in m_BoundEvents) { m_UiView.UnregisterFromEvent(boundEvent); } m_BoundEvents.Clear(); } private string DestroyElementByID(string id) { return "yyTreeController.elementToDestroy = document.getElementById(\"" + id + "\"); if (yyTreeController.elementToDestroy != null) yyTreeController.elementToDestroy.parentElement.removeChild(yyTreeController.elementToDestroy);"; } private void ChangeRandomRotation(bool randomRotation) { TreeControllerMod.Settings.RandomRotation = randomRotation; ((Setting)TreeControllerMod.Settings).ApplyAndSave(); } private string BoolToString(bool flag) { if (flag) { return "true"; } return "false"; } private void ActivatePrefabChange() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) m_Log.Debug((object)"Enable Tool with Prefab Change please."); m_ToolSystem.selected = Entity.Null; if (m_SelectedPrefabSet == string.Empty && (Object)(object)m_ObjectToolSystem.prefab != (Object)null && m_TreeControllerTool.GetSelectedPrefabs().Count <= 1) { UnselectPrefabs(); m_TreeControllerTool.ClearSelectedTreePrefabs(); m_TreeControllerTool.SelectTreePrefab((PrefabBase)(object)m_ObjectToolSystem.prefab); } else if (m_SelectedPrefabSet != string.Empty && m_PrefabSetsLookup.ContainsKey(m_SelectedPrefabSet)) { ChangePrefabSet(m_SelectedPrefabSet); } m_UpdateSelectionSet = true; m_ToolIsActive = false; m_ToolSystem.activeTool = (ToolBaseSystem)(object)m_TreeControllerTool; } private void ChangeSelectedAges(bool[] ages) { m_Log.Debug((object)"TreeControllerUISystem.ChangeSelectedAges"); m_TreeControllerTool.ApplySelectedAges(ages); } private void ActivateTreeControllerTool() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) m_Log.Debug((object)"Enable Tool please."); m_SelectedPrefabSet = string.Empty; UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.selectedPrefabSet = \"\";"); UnselectPrefabs(); m_MultiplePrefabsSelected = false; m_TreeControllerTool.ClearSelectedTreePrefabs(); m_ToolIsActive = false; m_ToolSystem.selected = Entity.Null; m_ToolSystem.activeTool = (ToolBaseSystem)(object)m_TreeControllerTool; } private void ActivatePlopTrees() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) m_Log.Debug((object)"Enable Object Tool plopping please."); m_ToolSystem.selected = Entity.Null; m_ObjectToolSystem.mode = (Mode)0; m_ToolSystem.activeTool = (ToolBaseSystem)(object)m_ObjectToolSystem; } private void ActivateBrushTrees() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) m_Log.Debug((object)"Enable brushing trees please."); m_UpdateSelectionSet = true; m_ToolSystem.selected = Entity.Null; m_ObjectToolSystem.mode = (Mode)3; m_ToolSystem.activeTool = (ToolBaseSystem)(object)m_ObjectToolSystem; } private void ChangePrefabSet(string prefabSetID) { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) PrefabBase prefab = ((ToolBaseSystem)m_TreeControllerTool).GetPrefab(); List<PrefabBase> selectedPrefabs = m_TreeControllerTool.GetSelectedPrefabs(); if (!m_PrefabSetsLookup.ContainsKey(prefabSetID)) { UnselectPrefabs(); m_TreeControllerTool.ClearSelectedTreePrefabs(); m_SelectedPrefabSet = string.Empty; m_UpdateSelectionSet = true; { foreach (PrefabBase item in selectedPrefabs) { if (m_ToolSystem.ActivatePrefabTool(item)) { SelectPrefab(item); break; } } return; } } bool flag = ((ButtonControl)Keyboard.current.leftCtrlKey).isPressed || ((ButtonControl)Keyboard.current.rightCtrlKey).isPressed; if (prefabSetID.Contains("custom") && selectedPrefabs.Count > 1 && flag) { m_Log.Debug((object)"TreeControllerUISystem.ChangePrefabSet trying to add prefab ids to set lookup."); TrySaveCustomPrefabSet(prefabSetID, selectedPrefabs); } if (m_PrefabSetsLookup[prefabSetID].Count == 0) { m_SelectedPrefabSet = string.Empty; m_TreeControllerTool.SelectTreePrefab(prefab); UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.prefabSet = document.getElementById(\"" + prefabSetID + "\"); if (yyTreeController.prefabSet) yyTreeController.prefabSet.classList.remove(\"selected\");"); m_Log.Warn((object)"TreeControllerUISystem.ChangePrefabSet could not select empty set"); return; } if (!m_PrefabSetsLookup[prefabSetID].Contains(((PrefabBase)m_ObjectToolSystem.prefab).GetPrefabID()) && m_ToolSystem.activeTool == m_ObjectToolSystem) { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.tagElements = document.getElementsByTagName(\"img\"); for (yyTreeController.i = 0; yyTreeController.i < yyTreeController.tagElements.length; yyTreeController.i++) { if (yyTreeController.tagElements[yyTreeController.i].src.includes(\"" + ((Object)m_ObjectToolSystem.prefab).name + "\")) { yyTreeController.tagElements[yyTreeController.i].parentNode.classList.remove(\"selected\"); } } "); } m_RecentlySelectedPrefabSet = true; UnselectPrefabs(); m_TreeControllerTool.ClearSelectedTreePrefabs(); m_SelectedPrefabSet = prefabSetID; int num = 0; PrefabBase prefab2 = default(PrefabBase); foreach (PrefabID item2 in m_PrefabSetsLookup[prefabSetID]) { if (m_PrefabSystem.TryGetPrefab(item2, ref prefab2)) { m_TreeControllerTool.SelectTreePrefab(prefab2); SelectPrefab(prefab2); num++; } } if (num > 1) { m_MultiplePrefabsSelected = true; } selectedPrefabs = m_TreeControllerTool.GetSelectedPrefabs(); m_UpdateSelectionSet = true; if (selectedPrefabs.Contains(m_ToolSystem.activePrefab)) { return; } foreach (PrefabBase item3 in selectedPrefabs) { if (m_ToolSystem.ActivatePrefabTool(item3)) { break; } } } private void UnselectPrefabs() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) UIFileUtils.ExecuteScript(m_UiView, "if (yyTreeController == null) var yyTreeController = {};"); JobHandle val = default(JobHandle); NativeList<Entity> val2 = ((EntityQuery)(ref m_VegetationQuery)).ToEntityListAsync(AllocatorHandle.op_Implicit((Allocator)2), ref val); ((JobHandle)(ref val)).Complete(); Enumerator<Entity> enumerator = val2.GetEnumerator(); try { PrefabBase val3 = default(PrefabBase); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (m_PrefabSystem.TryGetPrefab<PrefabBase>(current, ref val3)) { UIFileUtils.ExecuteScript(m_UiView, "yyTreeController.tagElements = document.getElementsByTagName(\"img\"); for (yyTreeController.i = 0; yyTreeController.i < yyTreeController.tagElements.length; yyTreeController.i++) { if (yyTreeController.tagElements[yyTreeController.i].src.includes(\"" + ((Object)val3).name + "\")) { yyTreeController.tagElements[yyTreeController.i].parentNode.classList.remove(\"selected\"); } } "); } } } finally { ((IDisposable)enumerator).Dispose(); } val2.Dispose(); m_MultiplePrefabsSelected = false; m_Log.Debug((object)"TreeControllerUISystem.UnselectPrefabs"); } private void LogFromJS(string log) { m_Log.Debug((object)("TreeControllerUISystem.LogFromJS " + log)); } private void ChangeRadius(int radius) { m_TreeControllerTool.Radius = radius; } private void ChangeToolMode(string newToolMode) { if (ToolModeLookup.ContainsKey(newToolMode)) { m_TreeControllerTool.SelectionMode = ToolModeLookup[newToolMode]; } } private void OnToolChanged(ToolBaseSystem tool) { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Invalid comparison between Unknown and I4 //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) UIFileUtils.ExecuteScript(m_UiView, "if (yyTreeController == null) var yyTreeController = {};"); if (tool != null) { m_Log.Debug((object)("TreeControllerUISystem.OnToolChanged " + tool.toolID)); } if (tool.toolID != "Object Tool" && tool.toolID != "Tree Controller Tool") { if (m_ObjectToolPlacingTree || m_ToolIsActive) { UnselectPrefabs(); if ((Object)(object)m_ToolSystem.activePrefab != (Object)null) { SelectPrefab(m_ToolSystem.activePrefab); } } if (m_ObjectToolPlacingTree) { UnshowObjectToolPanelItems(); } if (m_ToolIsActive) { UnshowTreeControllerToolPanel(); UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); } if (tool.toolID == "Line Tool") { m_Log.Debug((object)"TreeControllerUISystem.OnToolChanged new tool is line tool"); foreach (BoundEventHandle boundEvent in m_BoundEvents) { m_UiView.UnregisterFromEvent(boundEvent); } m_BoundEvents.Clear(); m_BoundEvents.Add(m_UiView.RegisterForEvent("YYTC-ChangeSelectedAges", (Delegate)new Action<bool[]>(ChangeSelectedAges))); m_LastToolWasLineTool = true; } else { m_LastToolWasLineTool = false; } ((ComponentSystemBase)this).Enabled = false; } else if (tool.toolID == "Object Tool" && (Object)(object)((ToolBaseSystem)m_ObjectToolSystem).GetPrefab() != (Object)null && ((int)m_ObjectToolSystem.mode == 0 || (int)m_ObjectToolSystem.mode == 3)) { Entity val = default(Entity); if (m_PrefabSystem.TryGetEntity(((ToolBaseSystem)m_ObjectToolSystem).GetPrefab(), ref val)) { EntityManager entityManager = ((ComponentSystemBase)this).EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<Vegetation>(val)) { if (m_ObjectToolPlacingTree) { UnshowObjectToolPanelItems(); } if (m_ToolIsActive) { UnshowTreeControllerToolPanel(); UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); } ((ComponentSystemBase)this).Enabled = false; } else { m_LastObjectToolPrefab = (PrefabBase)(object)m_ObjectToolSystem.prefab; if (m_TreeControllerTool.GetSelectedPrefabs().Count == 0) { m_TreeControllerTool.SelectTreePrefab((PrefabBase)(object)m_ObjectToolSystem.prefab); m_Log.Debug((object)("TreeControllerUISystem.OnToolChanged selected " + ((Object)m_ObjectToolSystem.prefab).name)); } ((ComponentSystemBase)this).Enabled = true; } } else { if (m_ObjectToolPlacingTree) { UnshowObjectToolPanelItems(); } if (m_ToolIsActive) { UnshowTreeControllerToolPanel(); UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); } ((ComponentSystemBase)this).Enabled = false; } } else { m_ObjectToolPlacingTree = false; ((ComponentSystemBase)this).Enabled = true; } } private void ResetPanel() { m_ToolIsActive = false; m_ObjectToolPlacingTree = false; } private void OnPrefabChanged(PrefabBase prefab) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Invalid comparison between Unknown and I4 //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab != (Object)null) { m_Log.Debug((object)("TreeControllerUISystem.OnPrefabChanged " + ((Object)prefab).name + " " + prefab.uiTag)); } EntityManager entityManager; Entity val2 = default(Entity); if ((m_ToolSystem.activeTool != m_ObjectToolSystem && m_ToolSystem.activeTool != m_TreeControllerTool) || (m_ToolSystem.activeTool == m_ObjectToolSystem && (int)m_ObjectToolSystem.mode != 0 && (int)m_ObjectToolSystem.mode != 3)) { ((ComponentSystemBase)this).Enabled = false; Entity val = default(Entity); if (m_ToolSystem.activeTool.toolID == "Line Tool" && (Object)(object)prefab != (Object)null && m_PrefabSystem.TryGetEntity(prefab, ref val)) { entityManager = ((ComponentSystemBase)this).EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<TreeData>(val)) { m_UiView.ExecuteScript("if (typeof lineTool == 'object') { if (typeof lineTool.addTreeControl == 'function' && document.getElementById(\"line-tool-mode\") != null) { lineTool.addTreeControl(); } }"); m_Log.Debug((object)"TreeControllerUISystem.OnPrefabChanged Tree Controller added Tree Age Item to Line Tool."); } else { m_UiView.ExecuteScript(DestroyElementByID("YYTC-tree-age-item")); m_Log.Debug((object)"TreeControllerUISystem.OnPrefabChanged Tree Controller removed Tree Age Item from Line Tool."); } } } else if ((Object)(object)m_ObjectToolSystem.prefab != (Object)null && m_PrefabSystem.TryGetEntity((PrefabBase)(object)m_ObjectToolSystem.prefab, ref val2)) { entityManager = ((ComponentSystemBase)this).EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<Vegetation>(val2)) { UnselectPrefabs(); if (m_ObjectToolPlacingTree) { m_Log.Debug((object)"TreeControllerUISystem.OnPrefabChanged calling UnShowObjectToolPanelItems"); UnshowObjectToolPanelItems(); m_TreeControllerTool.ClearSelectedTreePrefabs(); } if (m_ToolIsActive) { UnshowTreeControllerToolPanel(); UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); } ((ComponentSystemBase)this).Enabled = false; return; } ((ComponentSystemBase)this).Enabled = true; ResetPrefabSets(); if ((m_ToolSystem.activeTool == m_TreeControllerTool || ((ToolBaseSystem)m_ObjectToolSystem).brushing) && !((ButtonControl)Keyboard.current.leftCtrlKey).isPressed && !((ButtonControl)Keyboard.current.rightCtrlKey).isPressed) { UnselectPrefabs(); } List<PrefabBase> selectedPrefabs = m_TreeControllerTool.GetSelectedPrefabs(); bool flag = false; Entity val3 = default(Entity); foreach (PrefabBase item in selectedPrefabs) { if (m_PrefabSystem.TryGetEntity(item, ref val3)) { entityManager = ((ComponentSystemBase)this).EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<TreeData>(val3)) { UIFileUtils.ExecuteScript(m_UiView, "if (document.getElementById(\"YYTC-tree-age-item\") == null) engine.trigger('YYTC-tree-age-item-missing');"); flag = true; break; } } } if (!flag) { UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tree-age-item")); } if ((Object)(object)m_ObjectToolSystem.prefab != (Object)null) { m_LastObjectToolPrefab = (PrefabBase)(object)m_ObjectToolSystem.prefab; } } else { UnselectPrefabs(); if (m_ObjectToolPlacingTree) { m_Log.Debug((object)"TreeControllerUISystem.OnPrefabChanged calling UnShowObjectToolPanelItems"); UnshowObjectToolPanelItems(); m_TreeControllerTool.ClearSelectedTreePrefabs(); } if (m_ToolIsActive) { UnshowTreeControllerToolPanel(); UnshowObjectToolPanelItems(); UIFileUtils.ExecuteScript(m_UiView, DestroyElementByID("YYTC-tool-mode-item") + " " + DestroyElementByID("YYTC-selection-mode-item") + " " + DestroyElementByID("YYTC-radius-row")); } ((ComponentSystemBase)this).Enabled = false; } } private bool TrySaveCustomPrefabSet(string prefabSetID, List<PrefabBase> prefabBases) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) List<PrefabID> list = new List<PrefabID>(); foreach (PrefabBase prefabBasis in prefabBases) { list.Add(prefabBasis.GetPrefabID()); } return TrySaveCustomPrefabSet(prefabSetID, list); } private bool TrySaveCustomPrefabSet(string prefabSetID, List<PrefabID> prefabIDs) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) string path = Path.Combine(m_ContentFolder, prefabSetID + ".xml"); CustomSetRepository o = new CustomSetRepository(prefabIDs); m_PrefabSetsLookup[prefabSetID].Clear(); foreach (PrefabID prefabID in prefabIDs) { m_PrefabSetsLookup[prefabSetID].Add(prefabID); } try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(CustomSetRepository)); using (FileStream stream = File.Create(path)) { xmlSerializer.Serialize(stream, o); } return true; } catch (Exception ex) { m_Log.Warn((object)string.Format("{0}.{1} Could not save values for {2}. Encountered exception {3}", "TreeControllerUISystem", "TrySaveCustomPrefabSet", prefabSetID, ex)); return false; } } private bool TryLoadCustomPrefabSet(string prefabSetID) { string path = Path.Combine(m_ContentFolder, prefabSetID + ".xml"); if (File.Exists(path)) { try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(CustomSetRepository)); using FileStream stream = new FileStream(path, FileMode.Open); CustomSetRepository customSetRepository = (CustomSetRepository)xmlSerializer.Deserialize(stream); if (m_PrefabSetsLookup.ContainsKey(prefabSetID) && customSetRepository.GetPrefabIDs().Count > 0) { m_PrefabSetsLookup[prefabSetID] = customSetRepository.GetPrefabIDs(); } m_Log.Debug((object)("TreeControllerUISystem.TryLoadCustomPrefabSet loaded repository for " + prefabSetID + ".")); return true; } catch (Exception ex) { m_Log.Warn((object)string.Format("{0}.{1} Could not get default values for Set {2}. Encountered exception {3}", "TreeControllerUISystem", "TryLoadCustomPrefabSet", prefabSetID, ex)); return false; } } return false; } } public class ClearTreeControllerTool : GameSystemBase { private struct TypeHandle { [ReadOnly] public EntityTypeHandle __Unity_Entities_Entity_TypeHandle; 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) __Unity_Entities_Entity_TypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle(); } } private struct RemoveRecentlyChangedComponent : IJobChunk { public EntityTypeHandle m_EntityType; 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_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) NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(m_EntityType); for (int i = 0; i < ((ArchetypeChunk)(ref chunk)).Count; i++) { Entity val = nativeArray[i]; ((ParallelWriter)(ref buffer)).RemoveComponent<RecentlyChanged>(unfilteredChunkIndex, val); } } void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) { Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask); } } private EntityQuery m_RecentlyChangedQuery; private ToolOutputBarrier m_ToolOutputBarrier; private ILog m_Log; private TypeHandle __TypeHandle; protected override void OnCreate() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references) World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld; m_ToolOutputBarrier = ((defaultGameObjectInjectionWorld != null) ? defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolOutputBarrier>() : null); m_Log = TreeControllerMod.Instance.Logger; ((GameSystemBase)this).OnCreate(); EntityQueryDesc[] array = new EntityQueryDesc[1]; EntityQueryDesc val = new EntityQueryDesc(); val.All = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<RecentlyChanged>() }; array[0] = val; m_RecentlyChangedQuery = ((ComponentSystemBase)this).GetEntityQuery((EntityQueryDesc[])(object)array); ((ComponentSystemBase)this).RequireForUpdate(m_RecentlyChangedQuery); } protected override void OnUpdate() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) ((EntityTypeHandle)(ref __TypeHandle.__Unity_Entities_Entity_TypeHandle)).Update(ref ((SystemBase)this).CheckedStateRef); RemoveRecentlyChangedComponent removeRecentlyChangedComponent = default(RemoveRecentlyChangedComponent); removeRecentlyChangedComponent.m_EntityType = __TypeHandle.__Unity_Entities_Entity_TypeHandle; EntityCommandBuffer val = ((SafeCommandBufferSystem)m_ToolOutputBarrier).CreateCommandBuffer(); removeRecentlyChangedComponent.buffer = ((EntityCommandBuffer)(ref val)).AsParallelWriter(); RemoveRecentlyChangedComponent removeRecentlyChangedComponent2 = removeRecentlyChangedComponent; JobHandle val2 = JobChunkExtensions.ScheduleParallel<RemoveRecentlyChangedComponent>(removeRecentlyChangedComponent2, m_RecentlyChangedQuery, ((SystemBase)this).Dependency); ((EntityCommandBufferSystem)m_ToolOutputBarrier).AddJobHandleForProducer(val2); ((SystemBase)this).Dependency = val2; m_Log.Debug((object)"ClearTreeControllerTool.OnUpdate Removed Recently Changed Components"); } protected override void OnCreateForCompiler() { ((ComponentSystemBase)this).OnCreateForCompiler(); __TypeHandle.__AssignHandles(ref ((SystemBase)this).CheckedStateRef); } } public class TreeControllerTool : ToolBaseSystem { public enum TCSelectionMode { SingleTree, WholeBuildingOrNet, Radius, WholeMap } private struct TypeHandle { [ReadOnly] public EntityTypeHandle __Unity_Entities_Entity_TypeHandle; public ComponentTypeHandle<Tree> __Game_Object_Tree_RW_ComponentTypeHandle; [ReadOnly] public ComponentTypeHandle<Transform> __Game_Objects_Transform_RO_ComponentTypeHandle; public ComponentTypeHandle<PrefabRef> __PrefabRef_RW_ComponentTypeHandle; [ReadOnly] public ComponentLookup<TreeData> __TreeData_RO_ComponentLookup; [ReadOnly] public ComponentLookup<Vegetation> __Vegetation_RO_ComponentLookup; [ReadOnly] public ComponentLookup<Tree> __Tree_RO_ComponentLookup; 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) __Unity_Entities_Entity_TypeHandle = ((SystemState)(ref state)).GetEntityTypeHandle(); __Game_Objects_Transform_RO_ComponentTypeHandle = ((SystemState)(ref state)).GetComponentTypeHandle<Transform>(false); __Game_Object_Tree_RW_ComponentTypeHandle = ((SystemState)(ref state)).GetComponentTypeHandle<Tree>(false); __PrefabRef_RW_ComponentTypeHandle = ((SystemState)(ref state)).GetComponentTypeHandle<PrefabRef>(false); __TreeData_RO_ComponentLookup = ((SystemState)(ref state)).GetComponentLookup<TreeData>(false); __Vegetation_RO_ComponentLookup = ((SystemState)(ref state)).GetComponentLookup<Vegetation>(false); __Tree_RO_ComponentLookup = ((SystemState)(ref state)).GetComponentLookup<Tree>(false); } } private struct TreeChangerWithinRadius : IJobChunk { public EntityTypeHandle m_EntityType; public ComponentTypeHandle<Tree> m_TreeType; public ComponentTypeHandle<Transform> m_TransformType; public bool m_OverrideState; public bool m_OverridePrefab; public NativeList<TreeState> m_Ages; public ParallelWriter buffer; public ComponentTypeHandle<PrefabRef> m_PrefabRefType; public NativeList<Entity> m_PrefabEntities; public Random m_Random; public float m_Radius; public float3 m_Position; public ComponentLookup<Tree> m_TreeLookup; public ComponentLookup<TreeData> m_TreeDataLookup; public ComponentLookup<Vegetation> m_VegetationLookup; public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b1: 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_00b8: 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_00c6: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_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_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: 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_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: 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_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) NativeArray<Entity> nativeArray = ((ArchetypeChunk)(ref chunk)).GetNativeArray(m_EntityType); NativeArray<Transform> nativeArray2 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<Transform>(ref m_TransformType); NativeArray<Tree> nativeArray3 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<Tree>(ref m_TreeType); NativeArray<PrefabRef> nativeArray4 = ((ArchetypeChunk)(ref chunk)).GetNativeArray<PrefabRef>(ref m_PrefabRefType); for (int i = 0; i < ((ArchetypeChunk)(ref chunk)).Count; i++) { if (!CheckForHoveringOverTree(m_Position, nativeArray2[i].m_Position, m_Radius)) { continue; } Entity val = nativeArray[i]; if (m_OverrideState && m_TreeLookup.HasComponent(val) && !m_OverridePrefab) { Tree val2 = nativeArray3[i]; val2.m_State = GetTreeState(m_Ages, val2); ((ParallelWriter)(ref buffer)).SetComponent<Tree>(unfilteredChunkIndex, val, val2); ((ParallelWriter)(ref buffer)).AddComponent<RecentlyChanged>(unfilteredChunkIndex, val); ((ParallelWriter)(ref buffer)).AddComponent<BatchesUpdated>(unfilteredChunkIndex, val); } else { if (!m_OverridePrefab) { continue; } PrefabRef val3 = nativeArray4[i]; if (m_VegetationLookup.HasComponent(val3.m_Prefab) && m_PrefabEntities.Length > 0) { val3.m_Prefab = m_PrefabEntities[((Random)(ref m_Random)).NextInt(m_PrefabEntities.Length)]; if (m_TreeDataLookup.HasComponent(val3.m_Prefab) && !m_TreeLookup.HasComponent(val)) { ((ParallelWriter)(ref buffer)).AddComponent<Tree>(unfilteredChunkIndex, val); Tree val4 = default(Tree); val4.m_Growth = 0; val4.m_State = GetTreeState(m_Ages, new Tree { m_Growth = 0, m_State = (TreeState)2 }); Tree val5 = val4; ((ParallelWriter)(ref buffer)).SetComponent<Tree>(unfilteredChunkIndex, val, val5); } else if (!m_TreeDataLookup.HasComponent(val3.m_Prefab) && m_TreeLookup.HasComponent(val)) { ((ParallelWriter)(ref buffer)).RemoveComponent<Tree>(unfilteredChunkIndex, val); } else if (m_OverrideState && m_TreeDataLookup.HasComponent(val3.m_Prefab) && m_TreeLookup.HasComponent(val)) { Tree val6 = nativeArray3[i]; val6.m_State = GetTreeState(m_Ages, val6); ((ParallelWriter)(ref buffer)).SetComponent<Tree>(unfilteredChunkIndex, val, val6); } ((ParallelWriter)(ref buffer)).SetComponent<PrefabRef>(unfilteredChunkIndex, val, val3); ((ParallelWriter)(ref buffer)).RemoveComponent<Evergreen>(unfilteredChunkIndex, val); ((ParallelWriter)(ref buffer)).RemoveComponent<DeciduousData>(unfilteredChunkIndex, val); ((ParallelWriter)(ref buffer)).AddComponent<RecentlyChanged>(unfilteredChunkIndex, val); ((ParallelWriter)(ref buffer)).AddComponent<Updated>(unfilteredChunkIndex, val); ((ParallelWriter)(ref buffer)).AddComponent<BatchesUpdated>(unfilteredChunkIndex, val); } } } } private bool CheckForHoveringOverTree(float3 cursorPosition, float3 treePosition, float radius) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) float num = 5f; radius = Mathf.Max(radius, num); if (math.distance(cursorPosition, treePosition) < radius) { return true; } return false; } private TreeState GetTreeState(NativeList<TreeState> ages, Tree tree) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0037: Unknown result type (might be due to invalid IL or missing references) if (ages.Length > 0) { return ages[((Random)(ref m_Random)).NextInt(ages.Length)]; } return tree.m_State; } void IJobChunk.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) { Execute(in chunk, unfilteredChunkIndex, useEnabledMask, in chunkEnabledMask); } } private struct TreeChangerWholeMap : IJobChunk { public EntityTypeHandle m_EntityType; public ComponentTypeHandle<Tree> m_TreeType; public bool m_OverrideState; public bool m_OverridePrefab; public NativeList<TreeState> m_Ages; public ParallelWriter buffer; public ComponentTypeHandle<PrefabRef> m_PrefabRefType; public NativeList<Entity> m_PrefabEntities; public Random m_Random; public ComponentLookup<Tree> m_TreeLookup; public ComponentLookup<TreeData> m_TreeDataLookup; public ComponentLookup<Vegetation> m_VegetationLookup; public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_009b: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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)