Decompiled source of LGTuner v1.2.2
Plugins/LGTuner.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using System.Text.Json.Serialization; using AIGraph; using AssetShards; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Expedition; using GTFO.API; using GTFO.API.Utilities; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LGTuner.Configs; using LGTuner.Manager; using LGTuner.Utils; using LevelGeneration; using LevelGeneration.Core; using LogUtils; using Microsoft.CodeAnalysis; using SNetwork; using UnityEngine; using UnityEngine.SceneManagement; using XXHashing; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("LGTuner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+gitc8bce57-dirty-master.c8bce578aac34cdac66af591417e728397a714ef")] [assembly: AssemblyProduct("LGTuner")] [assembly: AssemblyTitle("LGTuner")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LGTuner { public static class BuilderInfo { private static readonly List<Complex> _extraComplexResourceToLoad = new List<Complex>(); public static IEnumerable<Complex> ExtraComplexResourceToLoad => _extraComplexResourceToLoad; public static ComplexResourceSetDataBlock ComplexResourceSet { get; private set; } public static int GridSize { get; private set; } public static int GridCenter { get; private set; } public static int GridZeroOffset { get; private set; } public static float AltitudeOffset { get; private set; } public static LayoutConfig MainLayer { get; private set; } public static LayoutConfig SecondaryLayer { get; private set; } public static LayoutConfig ThirdLayer { get; private set; } public static LayoutConfig[] DimensionLayer { get; private set; } = Array.Empty<LayoutConfig>(); internal static void OnResourceSetSelected() { //IL_0156: Unknown result type (might be due to invalid IL or missing references) ComplexResourceSet = Builder.ComplexResourceSetBlock; GridSize = ComplexResourceSet.LevelGenConfig.GridSize; GridCenter = GridSize / 2; GridZeroOffset = -GridCenter; AltitudeOffset = ComplexResourceSet.LevelGenConfig.AltitudeOffset; MainLayer = null; SecondaryLayer = null; ThirdLayer = null; DimensionLayer = new LayoutConfig[Enum.GetValues(typeof(eDimensionIndex)).Length]; _extraComplexResourceToLoad.Clear(); ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition; if (ConfigManager.TryGetConfig(activeExpedition.LevelLayoutData, out var config)) { MainLayer = config; } if (activeExpedition.SecondaryLayerEnabled && ConfigManager.TryGetConfig(activeExpedition.SecondaryLayout, out var config2)) { SecondaryLayer = config2; } if (activeExpedition.ThirdLayerEnabled && ConfigManager.TryGetConfig(activeExpedition.ThirdLayout, out var config3)) { ThirdLayer = config3; } Enumerator<Dimension> enumerator = Builder.CurrentFloor.m_dimensions.GetEnumerator(); while (enumerator.MoveNext()) { Dimension current = enumerator.Current; if (!current.IsMainDimension && !current.DimensionData.IsStaticDimension) { LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(current.DimensionData.LevelLayoutData); if (block != null && ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out var config4)) { Logger.Info("loysimme dimension ja levellayoutin"); config4.Reset(((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)current.Grid).m_sizeX); DimensionLayer[current.DimensionIndex] = config4; } } } MainLayer?.Reset(GridSize); SecondaryLayer?.Reset(GridSize); ThirdLayer?.Reset(GridSize); AddExtraShard(MainLayer); AddExtraShard(SecondaryLayer); AddExtraShard(ThirdLayer); Array.ForEach(DimensionLayer, delegate(LayoutConfig x) { AddExtraShard(x); }); } private static void AddExtraShard(LayoutConfig layerConfig) { //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_0025: Unknown result type (might be due to invalid IL or missing references) if (layerConfig == null) { return; } Complex[] extraComplexResourceToLoad = layerConfig.ExtraComplexResourceToLoad; foreach (Complex item in extraComplexResourceToLoad) { if (!_extraComplexResourceToLoad.Contains(item)) { _extraComplexResourceToLoad.Add(item); } } } public static bool TryGetConfig(LG_Zone zone, out LayoutConfig config) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected I4, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Dimension val = default(Dimension); if (!Dimension.GetDimension(zone.DimensionIndex, ref val)) { Logger.Info("dimension getter failed"); config = null; return false; } if (val.IsMainDimension) { LG_LayerType type = zone.Layer.m_type; switch ((int)type) { case 0: config = MainLayer; return MainLayer != null; case 1: config = SecondaryLayer; return SecondaryLayer != null; case 2: config = ThirdLayer; return ThirdLayer != null; } } else if (!val.DimensionData.IsStaticDimension) { Enumerator<Dimension> enumerator = Builder.CurrentFloor.m_dimensions.GetEnumerator(); while (enumerator.MoveNext()) { Dimension current = enumerator.Current; if (!current.IsMainDimension && !current.DimensionData.IsStaticDimension) { LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(current.DimensionData.LevelLayoutData); if (block != null && ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out var config2)) { Logger.Info("found a dimension + levellayout"); config2.Reset(((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)current.Grid).m_sizeX); DimensionLayer[current.DimensionIndex] = config2; } } } config = DimensionLayer[zone.DimensionIndex]; return config != null; } config = null; return false; } public static GameObject GetRandomPlug(uint seed, int plugHeight, SubComplex subcomplex, bool withGate) { //IL_002d: 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_0065: Unknown result type (might be due to invalid IL or missing references) ComplexResourceSetDataBlock complexResourceSet = ComplexResourceSet; return (GameObject)(plugHeight switch { 0 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_straightPlugsWithGates : complexResourceSet.m_straightPlugsNoGates, subcomplex), 1 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_singleDropPlugsWithGates : complexResourceSet.m_singleDropPlugsNoGates, subcomplex), 2 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_doubleDropPlugsWithGates : complexResourceSet.m_doubleDropPlugsNoGates, subcomplex), _ => null, }); } public static uint GetLayoutIdOfZone(LG_Zone zone) { //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_0036: Expected I4, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) Dimension dimension = zone.Dimension; if (dimension.IsMainDimension) { LG_LayerType type = zone.Layer.m_type; ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition; return (int)type switch { 0 => activeExpedition.LevelLayoutData, 1 => activeExpedition.SecondaryLayout, 2 => activeExpedition.ThirdLayout, _ => throw new NotSupportedException($"LayerType: {type} is not supported!"), }; } return dimension.DimensionData.LevelLayoutData; } } [BepInPlugin("LGTuner", "LGTuner", "1.2.2")] [BepInProcess("GTFO.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class EntryPoint : BasePlugin { public static Dictionary<string, AssetBundle> BundleLookup = new Dictionary<string, AssetBundle>(); public static string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "LGTuner.cfg"); public static ConfigFile config = new ConfigFile(CONFIG_PATH, true); public static ConfigEntry<string> _bundlesToRename; public static ConfigEntry<string> _bundlesToLoadAllFrom; public static List<AssetBundle> BundleLoadAllLookup = new List<AssetBundle>(); public static bool StairsFixed = false; public static bool TechFixed = false; public static bool ServiceFixed = false; public static List<string> CustomMarkerPrefabs = new List<string>(); public Harmony HarmonyInstance { get; private set; } public override void Load() { //IL_000f: 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_002e: Expected O, but got Unknown //IL_002e: Expected O, but got Unknown //IL_0042: 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_0061: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown _bundlesToRename = config.Bind<string>(new ConfigDefinition("General", "Bundles_To_Rename"), "cavetile-compressed,rlc_legacy-compressed,rlc_mining-compressed,rlc_tech-compressed,customgeo_mining_prelude-compressed,customgeo_service_prelude-compressed,customgeo_tech_prelude-compressed,doggygeos-compressed,dogstilepack-compressed,ds_geo_pack_2-compressed,flowgeo-mining-vol2-compressed,flowgeo-service-vol2-compressed,flowgeo-tech-vol2-compressed,geo_64x64_service_floodways_boss_hub_ds_01-compressed,geo_64x64_service_floodways_hub_ds_01-compressed,geo_64x64_tech_data_center_hub_ds_01-compressed,geo_64x64_tech_data_center_i_tile_ds_1-compressed,geo_mining_flow-compressed,geo_service_flow-compressed,geo_tech_flow-compressed,madgeos-gardens-compressed,qt-geos-mining-compressed,qt-geos-service-compressed,qt-geos-tech-compressed,samgeos-compressed,samgeosv2-compressed,dak_geos-compressed,eternal_geos-compressed,collisiongeo-compressed,customgeo-compressed,mccadcustomgeopack-compressed,yoshi moment gaming-compressed,bro pack 69-compressed,wowoowowowowowoowowrru921r-compressed,dv1_dogcustomgeos-compressed,dogcustomplugs-compressed,dogcustomgeos1-compressed,xiaoyao2-compressed,xiaoyao3-compressed,xiaoyao4-compressed,xiaoyao5-compressed,xiaoyao6-compressed,", new ConfigDescription("comma separated list of asset bundle files for lgtuner processing (will be renamed file.fdfd.manifest)", (AcceptableValueBase)null, Array.Empty<object>())); _bundlesToLoadAllFrom = config.Bind<string>(new ConfigDefinition("General", "Bundles_To_Load_All_From"), "somefile1-compressed,somefile2-compressed,somefile3-compressed", new ConfigDescription("comma separated list of asset bundle files that will be fully loaded upon use, if problems with single prefab loading arise", (AcceptableValueBase)null, Array.Empty<object>())); HarmonyInstance = new Harmony("LGTuner"); HarmonyInstance.PatchAll(); ConfigManager.RenameFiles(); ConfigManager.Init(); AssetShardManager.OnSharedAsssetLoaded += Action.op_Implicit((Action)ConfigManager.LoadCustomBundles); LG_Factory.OnFactoryBuildStart += Action.op_Implicit((Action)ConfigManager.LoadData); } } public static class LGExtensions { public static bool IsSame(this LG_GridPosition position, LG_GridPosition other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (position.x == other.x) { return position.z == other.z; } return false; } public static LG_GridPosition ToNormalGrid(this LG_Tile tile, int gridSize) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return tile.m_shape.m_gridPosition.GetNormal(gridSize); } public static LG_GridPosition GetNormal(this LG_GridPosition position, int gridSize) { //IL_003a: 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_0051: 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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) LG_GridPosition result; if (gridSize < 0) { result = default(LG_GridPosition); result.x = position.x + BuilderInfo.GridZeroOffset; result.z = position.z + BuilderInfo.GridZeroOffset; return result; } int num = gridSize / 2; result = default(LG_GridPosition); result.x = position.x - num; result.z = position.z - num; return result; } public static Vector3 GetPositionNormal(this LG_Grid grid, int x, int z, int gridSize) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (gridSize < 0) { return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetPosition(x - BuilderInfo.GridZeroOffset, z - BuilderInfo.GridZeroOffset); } int num = gridSize / 2; return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetPosition(x + num, z + num); } public static int GetGridSize(this Dimension dimension) { return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)dimension.Grid).m_sizeX; } public static bool TryGetDimension(this LG_Floor floor, int dimensionIndex, out Dimension dimension) { if (Enum.IsDefined(typeof(eDimensionIndex), dimensionIndex)) { return floor.GetDimension((eDimensionIndex)dimensionIndex, ref dimension); } dimension = null; return false; } public static bool TryGetDimension(this LG_Floor floor, eDimensionIndex dimensionIndex, out Dimension dimension) { //IL_000a: 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) if (Enum.IsDefined(typeof(eDimensionIndex), dimensionIndex)) { return floor.GetDimension(dimensionIndex, ref dimension); } dimension = null; return false; } } public static class RandomExtensions { public static uint NextUint(this Random random) { int num = random.Next(1073741824); uint num2 = (uint)random.Next(4); return (uint)(num << 2) | num2; } public static float NextFloat(this Random random) { return Mathf.Clamp01((float)random.NextDouble()); } public static int ToSeed(this uint seed) { return (int)seed; } } internal static class Logger { private static readonly ManualLogSource _logger; static Logger() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown _logger = new ManualLogSource("LGTuner"); Logger.Sources.Add((ILogSource)(object)_logger); } private static string Format(object msg) { return msg.ToString(); } public static void Info(object data) { _logger.LogMessage((object)Format(data)); } public static void Verbose(object data) { } public static void Debug(object data) { _logger.LogDebug((object)Format(data)); } public static void Error(object data) { _logger.LogError((object)Format(data)); } } public enum DirectionType { Unknown, Forward, Backward, Left, Right } public enum RotateType { None, Flip, MoveTo_Left, MoveTo_Right, Towards_Random, Towards_Forward, Towards_Backward, Towards_Left, Towards_Right } public struct LG_PlugInfo { public static readonly Quaternion NoRotation = Quaternion.AngleAxis(0f, Vector3.up); public static readonly Quaternion RightRotation = Quaternion.AngleAxis(90f, Vector3.up); public static readonly Quaternion BackwardRotation = Quaternion.AngleAxis(180f, Vector3.up); public static readonly Quaternion LeftRotation = Quaternion.AngleAxis(270f, Vector3.up); public static readonly Vector3 FrontPlugPosition = Vector3.forward * 32f; public static readonly Vector3 BackPlugPosition = Vector3.back * 32f; public static readonly Vector3 LeftPlugPosition = Vector3.left * 32f; public static readonly Vector3 RightPlugPosition = Vector3.right * 32f; public bool IsValid { get; private set; } public DirectionType StartDirection { get; private set; } public int Count { get; private set; } public bool HasFront { get; private set; } public bool HasBack { get; private set; } public bool HasLeft { get; private set; } public bool HasRight { get; private set; } public bool TryGetNewRotation(uint seed, RotateType rotate, out Quaternion rotation) { //IL_0062: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) DirectionType newDirection = GetNewDirection(seed, StartDirection, rotate); if (Count >= 4) { rotation = GetRotationOfDirection(newDirection); return true; } Logger.Info($"You are rotating {Count} side Geomorph, this could lead to level gen crash!"); rotation = GetRotationOfDirection(newDirection); return true; } public bool HasPlug(DirectionType direction) { if (!IsValid) { return false; } if (Count >= 4) { return true; } return direction switch { DirectionType.Forward => HasFront, DirectionType.Backward => HasBack, DirectionType.Left => HasLeft, DirectionType.Right => HasRight, _ => false, }; } public static LG_PlugInfo BuildPlugInfo(GameObject geoObject, Quaternion rotation) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected I4, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)geoObject.GetComponent<LG_Geomorph>() == (Object)null) { return default(LG_PlugInfo); } Il2CppArrayBase<LG_Plug> componentsInChildren = geoObject.GetComponentsInChildren<LG_Plug>(); if (componentsInChildren == null) { return default(LG_PlugInfo); } if (componentsInChildren.Length < 1) { return default(LG_PlugInfo); } LG_PlugInfo result = default(LG_PlugInfo); foreach (LG_Plug item in componentsInChildren) { LG_PlugDir dir = item.m_dir; switch (dir - 2) { case 0: result.HasBack = true; result.Count++; break; case 2: result.HasFront = true; result.Count++; break; case 3: result.HasLeft = true; result.Count++; break; case 1: result.HasRight = true; result.Count++; break; } } result.IsValid = result.Count > 0; float num = Mathf.Round(((Quaternion)(ref rotation)).eulerAngles.y); Logger.Verbose($"angle: {num}"); num = Mathf.Repeat(num, 360f); result.StartDirection = Mathf.RoundToInt(num / 90f) switch { 0 => DirectionType.Forward, 1 => DirectionType.Right, 2 => DirectionType.Backward, 3 => DirectionType.Left, _ => DirectionType.Unknown, }; return result; } public static DirectionType GetNewDirection(uint seed, DirectionType direction, RotateType rotate) { if (direction == DirectionType.Unknown) { return DirectionType.Unknown; } if (rotate == RotateType.Towards_Random) { rotate = new Random(seed.ToSeed()).Next(4) switch { 0 => RotateType.Towards_Forward, 1 => RotateType.Towards_Backward, 2 => RotateType.Towards_Left, 3 => RotateType.Towards_Right, _ => throw new IndexOutOfRangeException("Towards_Random: nextIndex was out of range?!"), }; } return rotate switch { RotateType.None => direction, RotateType.Flip => direction switch { DirectionType.Forward => DirectionType.Backward, DirectionType.Backward => DirectionType.Forward, DirectionType.Left => DirectionType.Right, DirectionType.Right => DirectionType.Left, _ => throw new ArgumentOutOfRangeException("direction"), }, RotateType.MoveTo_Left => direction switch { DirectionType.Forward => DirectionType.Left, DirectionType.Backward => DirectionType.Right, DirectionType.Left => DirectionType.Backward, DirectionType.Right => DirectionType.Forward, _ => throw new ArgumentOutOfRangeException("direction"), }, RotateType.MoveTo_Right => direction switch { DirectionType.Forward => DirectionType.Right, DirectionType.Backward => DirectionType.Left, DirectionType.Left => DirectionType.Forward, DirectionType.Right => DirectionType.Backward, _ => throw new ArgumentOutOfRangeException("direction"), }, RotateType.Towards_Forward => DirectionType.Forward, RotateType.Towards_Backward => DirectionType.Backward, RotateType.Towards_Left => DirectionType.Left, RotateType.Towards_Right => DirectionType.Right, _ => throw new ArgumentOutOfRangeException("direction"), }; } public static Quaternion GetRotationOfDirection(DirectionType direction) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_0032: 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_0045: Unknown result type (might be due to invalid IL or missing references) return (Quaternion)(direction switch { DirectionType.Forward => NoRotation, DirectionType.Backward => BackwardRotation, DirectionType.Left => LeftRotation, DirectionType.Right => RightRotation, _ => throw new ArgumentOutOfRangeException("direction"), }); } } [GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")] [CompilerGenerated] internal static class VersionInfo { public const string RootNamespace = "LGTuner"; public const string Version = "1.0.0"; public const string VersionPrerelease = null; public const string VersionMetadata = "gitc8bce57-dirty-master"; public const string SemVer = "1.0.0+gitc8bce57-dirty-master"; public const string GitRevShort = "c8bce57-dirty"; public const string GitRevLong = "c8bce578aac34cdac66af591417e728397a714ef-dirty"; public const string GitBranch = "master"; public const string GitTag = null; public const bool GitIsDirty = true; } } namespace LGTuner.Utils { internal static class JSON { private static readonly JsonSerializerOptions _setting; static JSON() { _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new JsonStringEnumConverter()); if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized) { _setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); Logger.Info("PartialData Support Found!"); } } public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize(object value, Type type) { return JsonSerializer.Serialize(value, type, _setting); } } public static class MTFOPartialDataUtil { public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; public static JsonConverter PersistentIDConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class"); PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = obj2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); IsLoaded = true; } catch (Exception value2) { Logger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } static MTFOUtil() { GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value2) { Logger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}"); } } } } namespace LGTuner.Manager { public static class ConfigManager { [CompilerGenerated] private static class <>O { public static LiveEditEventHandler <0>__LiveEdit_FileChanged; } private static readonly List<LayoutConfig> _layouts = new List<LayoutConfig>(); private static readonly Dictionary<uint, LayoutConfig> _lookup = new Dictionary<uint, LayoutConfig>(); private static readonly Dictionary<string, LayoutConfig> _fileNameLookup = new Dictionary<string, LayoutConfig>(); public static IEnumerable<LayoutConfig> Layouts => _layouts; public static void LoadData() { List<string> list = new List<string>(); List<uint> list2 = new List<uint>(); list2.Add(RundownManager.ActiveExpedition.Expedition.ComplexResourceData); foreach (MiningMarkerDataBlock allBlock in GameDataBlockBase<MiningMarkerDataBlock>.GetAllBlocks()) { if (allBlock == null || allBlock.CommonData == null) { continue; } Enumerator<MarkerComposition> enumerator2 = allBlock.CommonData.Compositions.GetEnumerator(); while (enumerator2.MoveNext()) { MarkerComposition current2 = enumerator2.Current; if (current2 != null && current2.prefab != null && EntryPoint.BundleLookup.ContainsKey(current2.prefab.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(current2.prefab.ToUpperInvariant())) { Object val = EntryPoint.BundleLookup[current2.prefab.ToUpperInvariant()].LoadAsset(current2.prefab.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(current2.prefab.ToUpperInvariant(), val); } catch { } EntryPoint.CustomMarkerPrefabs.Add(current2.prefab.ToUpperInvariant()); } } } foreach (TechMarkerDataBlock allBlock2 in GameDataBlockBase<TechMarkerDataBlock>.GetAllBlocks()) { if (allBlock2 == null || allBlock2.CommonData == null) { continue; } Enumerator<MarkerComposition> enumerator2 = allBlock2.CommonData.Compositions.GetEnumerator(); while (enumerator2.MoveNext()) { MarkerComposition current4 = enumerator2.Current; if (current4 != null && current4.prefab != null && EntryPoint.BundleLookup.ContainsKey(current4.prefab.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(current4.prefab.ToUpperInvariant())) { Object val2 = EntryPoint.BundleLookup[current4.prefab.ToUpperInvariant()].LoadAsset(current4.prefab.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(current4.prefab.ToUpperInvariant(), val2); } catch { } EntryPoint.CustomMarkerPrefabs.Add(current4.prefab.ToUpperInvariant()); } } } foreach (ServiceMarkerDataBlock allBlock3 in GameDataBlockBase<ServiceMarkerDataBlock>.GetAllBlocks()) { if (allBlock3 == null || allBlock3.CommonData == null) { continue; } Enumerator<MarkerComposition> enumerator2 = allBlock3.CommonData.Compositions.GetEnumerator(); while (enumerator2.MoveNext()) { MarkerComposition current6 = enumerator2.Current; if (current6 != null && current6.prefab != null && EntryPoint.BundleLookup.ContainsKey(current6.prefab.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(current6.prefab.ToUpperInvariant())) { Object val3 = EntryPoint.BundleLookup[current6.prefab.ToUpperInvariant()].LoadAsset(current6.prefab.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(current6.prefab.ToUpperInvariant(), val3); } catch { } EntryPoint.CustomMarkerPrefabs.Add(current6.prefab.ToUpperInvariant()); } } } Enumerator<DimensionInExpeditionData> enumerator5 = RundownManager.ActiveExpedition.DimensionDatas.GetEnumerator(); while (enumerator5.MoveNext()) { DimensionInExpeditionData current7 = enumerator5.Current; if (current7.Enabled && !list2.Contains(GameDataBlockBase<DimensionDataBlock>.GetBlock(current7.DimensionData).DimensionData.DimensionResourceSetID)) { list2.Add(GameDataBlockBase<DimensionDataBlock>.GetBlock(current7.DimensionData).DimensionData.DimensionResourceSetID); } } foreach (uint item in list2) { ComplexResourceSetDataBlock block = GameDataBlockBase<ComplexResourceSetDataBlock>.GetBlock(item); Enumerator<ResourceData> enumerator7 = block.CustomGeomorphs_Challenge_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current8 = enumerator7.Current; if (!list.Contains(current8.Prefab.ToUpperInvariant())) { list.Add(current8.Prefab.ToUpperInvariant()); } } enumerator7 = block.CustomGeomorphs_Exit_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current9 = enumerator7.Current; if (!list.Contains(current9.Prefab.ToUpperInvariant())) { list.Add(current9.Prefab.ToUpperInvariant()); } } enumerator7 = block.CustomGeomorphs_Objective_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current10 = enumerator7.Current; if (!list.Contains(current10.Prefab.ToUpperInvariant())) { list.Add(current10.Prefab.ToUpperInvariant()); } } enumerator7 = block.GeomorphTiles_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current11 = enumerator7.Current; if (!list.Contains(current11.Prefab.ToUpperInvariant())) { list.Add(current11.Prefab.ToUpperInvariant()); } } enumerator7 = block.GeomorphTiles_2x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current12 = enumerator7.Current; if (!list.Contains(current12.Prefab.ToUpperInvariant())) { list.Add(current12.Prefab.ToUpperInvariant()); } } enumerator7 = block.GeomorphTiles_2x2.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current13 = enumerator7.Current; if (!list.Contains(current13.Prefab.ToUpperInvariant())) { list.Add(current13.Prefab.ToUpperInvariant()); } } enumerator7 = block.ElevatorShafts_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current14 = enumerator7.Current; if (!list.Contains(current14.Prefab.ToUpperInvariant())) { list.Add(current14.Prefab.ToUpperInvariant()); } } enumerator7 = block.PlugCaps.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current15 = enumerator7.Current; if (!list.Contains(current15.Prefab.ToUpperInvariant())) { list.Add(current15.Prefab.ToUpperInvariant()); } } enumerator7 = block.DoubleDropPlugsNoGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current16 = enumerator7.Current; if (!list.Contains(current16.Prefab.ToUpperInvariant())) { list.Add(current16.Prefab.ToUpperInvariant()); } } enumerator7 = block.SingleDropPlugsNoGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current17 = enumerator7.Current; if (!list.Contains(current17.Prefab.ToUpperInvariant())) { list.Add(current17.Prefab.ToUpperInvariant()); } } enumerator7 = block.StraightPlugsNoGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current18 = enumerator7.Current; if (!list.Contains(current18.Prefab.ToUpperInvariant())) { list.Add(current18.Prefab.ToUpperInvariant()); } } enumerator7 = block.DoubleDropPlugsWithGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current19 = enumerator7.Current; if (!list.Contains(current19.Prefab.ToUpperInvariant())) { list.Add(current19.Prefab.ToUpperInvariant()); } } enumerator7 = block.SingleDropPlugsWithGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current20 = enumerator7.Current; if (!list.Contains(current20.Prefab.ToUpperInvariant())) { list.Add(current20.Prefab.ToUpperInvariant()); } } enumerator7 = block.StraightPlugsWithGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current21 = enumerator7.Current; if (!list.Contains(current21.Prefab.ToUpperInvariant())) { list.Add(current21.Prefab.ToUpperInvariant()); } } } foreach (string item2 in list) { if (!EntryPoint.BundleLookup.ContainsKey(item2) || AssetShardManager.s_loadedAssetsLookup.ContainsKey(item2)) { continue; } foreach (KeyValuePair<string, AssetBundle> item3 in EntryPoint.BundleLookup) { if (item3.Key == item2 && !EntryPoint.BundleLoadAllLookup.Contains(item3.Value)) { Logger.Info("loading bundle asset prefab " + item2 + " .."); Object val4 = item3.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val4); } catch { } } if (!(item3.Key == item2) || !EntryPoint.BundleLoadAllLookup.Contains(item3.Value)) { continue; } Logger.Info("loading all assets from bundle " + ((Object)item3.Value).name); foreach (string item4 in (Il2CppArrayBase<string>)(object)item3.Value.GetAllAssetNames()) { Object val5 = item3.Value.LoadAsset(item4); try { AssetShardManager.s_loadedAssetsLookup.Add(item4.ToUpperInvariant(), val5); } catch { } } } } } public static void UnloadData() { List<Object> list = new List<Object>(); foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (AssetShardManager.s_loadedAssetsLookup.ContainsKey(item.Key.ToUpperInvariant()) && !EntryPoint.CustomMarkerPrefabs.Contains(item.Key)) { list.Add(AssetShardManager.s_loadedAssetsLookup[item.Key.ToUpperInvariant()]); AssetShardManager.s_loadedAssetsLookup.Remove(item.Key.ToUpperInvariant()); } } foreach (Object item2 in list) { Object.Destroy(item2); } } public static void RenameFiles() { string path = Path.Combine(Paths.BepInExRootPath, "Assets", "AssetBundles"); string path2 = Path.Combine(Paths.ConfigPath, "Assets", "AssetBundles"); string[] array = Directory.GetFiles(path, "*", SearchOption.AllDirectories).ToArray(); string[] array2; if (Directory.Exists(path2)) { array2 = Directory.GetFiles(path2, "'", SearchOption.AllDirectories).ToArray(); foreach (string text in array2) { CollectionExtensions.AddItem<string>((IEnumerable<string>)array, text); } } array2 = array; foreach (string text2 in array2) { string value = text2.Split("\\").ToArray().Last(); if (EntryPoint._bundlesToRename.Value.Contains(value)) { try { Logger.Info($"renaming file {value} to {value}.fdfd.manifest"); File.Move(text2, text2 + ".fdfd.manifest", overwrite: true); } catch { } } } } public static void LoadCustomBundles() { string[] array = Directory.GetFiles(Path.Combine(Paths.BepInExRootPath, "Assets", "AssetBundles"), "*", SearchOption.AllDirectories).ToArray(); foreach (string text in array) { if (!text.Contains(".fdfd.manifest")) { continue; } Logger.Info("loading assetbundle " + text); string value = text.Split("\\").ToArray().Last() .Split(".") .ToArray() .First(); AssetBundle val = AssetBundle.LoadFromFile(text); if (EntryPoint._bundlesToLoadAllFrom.Value.Contains(value)) { Logger.Info($"bundle {((Object)val).name} file {value} marked as load-all-prefabs"); EntryPoint.BundleLoadAllLookup.Add(val); } foreach (string item in (Il2CppArrayBase<string>)(object)val.GetAllAssetNames()) { EntryPoint.BundleLookup.Add(item.ToUpperInvariant(), val); } } } public static void Init() { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown if (!MTFOUtil.HasCustomContent) { return; } string text = Path.Combine(MTFOUtil.CustomPath, "LGTuner"); FileInfo[] files = Directory.CreateDirectory(text).GetFiles(); foreach (FileInfo fileInfo in files) { string extension = fileInfo.Extension; bool flag = extension.Equals(".json", StringComparison.InvariantCultureIgnoreCase); bool flag2 = extension.Equals(".jsonc", StringComparison.InvariantCultureIgnoreCase); if (flag || flag2) { LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(File.ReadAllText(fileInfo.FullName)); if (_lookup.ContainsKey(layoutConfig.LevelLayoutID)) { Logger.Error($"Duplicated ID found!: {fileInfo.Name}, {layoutConfig.LevelLayoutID}"); } else { _layouts.Add(layoutConfig); _lookup.Add(layoutConfig.LevelLayoutID, layoutConfig); _fileNameLookup.Add(fileInfo.Name.ToLowerInvariant(), layoutConfig); } } } LiveEditListener obj = LiveEdit.CreateListener(text, "*.*", true); object obj2 = <>O.<0>__LiveEdit_FileChanged; if (obj2 == null) { LiveEditEventHandler val = LiveEdit_FileChanged; <>O.<0>__LiveEdit_FileChanged = val; obj2 = (object)val; } obj.FileChanged += (LiveEditEventHandler)obj2; object obj3 = <>O.<0>__LiveEdit_FileChanged; if (obj3 == null) { LiveEditEventHandler val2 = LiveEdit_FileChanged; <>O.<0>__LiveEdit_FileChanged = val2; obj3 = (object)val2; } obj.FileCreated += (LiveEditEventHandler)obj3; obj.StartListen(); } private static void LiveEdit_FileChanged(LiveEditEventArgs e) { string key = Path.GetFileName(e.FullPath).ToLowerInvariant(); string extension = Path.GetExtension(e.FullPath); if (!extension.Equals(".json", StringComparison.InvariantCulture) && !extension.Equals(".jsonc", StringComparison.InvariantCulture)) { return; } Logger.Error($"File Edited: '{key}' '{e.FullPath}'"); try { uint oldID = 0u; bool newfile = false; LayoutConfig data = null; if (_fileNameLookup.ContainsKey(key)) { data = _fileNameLookup[key]; } if (data == null) { newfile = true; } if (data != null) { oldID = data.LevelLayoutID; } LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string json) { try { LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(json); if (oldID != 0) { layoutConfig.LevelLayoutID = oldID; } if (oldID == 0) { oldID = layoutConfig.LevelLayoutID; } if (newfile) { if (_fileNameLookup.ContainsKey(key)) { _fileNameLookup.Remove(key); } LayoutConfig layoutConfig2 = null; foreach (LayoutConfig layout in _layouts) { if (layout.LevelLayoutID == layoutConfig.LevelLayoutID) { layoutConfig2 = layout; } } if (layoutConfig2 != null) { _layouts.Remove(layoutConfig2); } if (_lookup.ContainsKey(oldID)) { _lookup.Remove(oldID); } } if (!newfile) { _fileNameLookup.Remove(key); _lookup.Remove(oldID); _layouts.Remove(data); } _layouts.Add(layoutConfig); _lookup.Add(oldID, layoutConfig); _fileNameLookup.Add(key, layoutConfig); } catch (Exception value2) { Logger.Error($"Error while reading or inserting LGTuner Config: {value2}"); } }); } catch (Exception value) { Logger.Error($"Error while reading LGTuner Config: {value}"); } } private static void DumpLevel() { } private static void DumpLayerToConfig() { } public static bool TryGetConfig(uint layoutID, out LayoutConfig config) { return _lookup.TryGetValue(layoutID, out config); } } } namespace LGTuner.Inject { [HarmonyPatch] internal static class Inject_CreateDimension { [HarmonyPatch(typeof(LG_Floor), "CreateAllDimensions")] [HarmonyPrefix] private static bool Dim250(LG_Floor __instance, uint seed, bool skipMainDimension = true) { //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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Invalid comparison between Unknown and I4 //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Invalid comparison between Unknown and I4 //IL_0286: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) int num = 40; if (Builder.LevelGenExpedition.DimensionDatas == null || Builder.LevelGenExpedition.DimensionDatas.Count <= 0) { Dimension.CalculateAllDimensionBounds(); return false; } XXHashSequence val = default(XXHashSequence); ((XXHashSequence)(ref val))..ctor(seed, true); Vector3 up = Vector3.up; int num2 = 0; float num3 = 150f; DimensionDataBlock val3 = default(DimensionDataBlock); for (int i = 0; i < Builder.LevelGenExpedition.DimensionDatas.Count; i++) { DimensionInExpeditionData val2 = Builder.LevelGenExpedition.DimensionDatas[i]; if ((int)val2.DimensionIndex != 22 && val2.TryGetDimensionData(ref val3)) { DimensionData dimensionData = val3.DimensionData; if (val2.Enabled && (!skipMainDimension || (int)val2.DimensionIndex != 0) && !__instance.m_createdDimensionSet.Contains(val2.DimensionIndex)) { num3 += dimensionData.VerticalExtentsDown; Vector3 val4 = up * num3; __instance.CreateDimension(((XXHashSequence)(ref val)).NextSubSeed(), val2.DimensionIndex, false, dimensionData, val4, num, 64f); __instance.m_createdDimensionSet.Add(val2.DimensionIndex); Logger.Info($"created dim {val2.DimensionIndex} pos {val4} .."); num3 += dimensionData.VerticalExtentsUp; num2++; } } } float num4 = 0f; float num5 = 0f; DimensionDataBlock val6 = default(DimensionDataBlock); for (int j = 0; j < Builder.LevelGenExpedition.DimensionDatas.Count; j++) { DimensionInExpeditionData val5 = Builder.LevelGenExpedition.DimensionDatas[j]; if ((int)val5.DimensionIndex == 22 && val5.TryGetDimensionData(ref val6)) { num = 10; if (val6.DimensionData.VerticalExtentsDown > num4) { num4 = val6.DimensionData.VerticalExtentsDown; } if (val6.DimensionData.VerticalExtentsUp > num4) { num5 = num4; } } } int num6 = 0; Vector3 right = Vector3.right; DimensionDataBlock val8 = default(DimensionDataBlock); Bounds val10 = default(Bounds); for (int k = 0; k < ((Il2CppArrayBase<SNet_Slot>)(object)SNet.Slots.PlayerSlots).Length; k++) { num3 += num4; float num7 = 0f; for (int l = 0; l < Builder.LevelGenExpedition.DimensionDatas.Count; l++) { DimensionInExpeditionData val7 = Builder.LevelGenExpedition.DimensionDatas[l]; if ((int)val7.DimensionIndex != 22) { continue; } if (!val7.TryGetDimensionData(ref val8)) { Debug.LogError(Object.op_Implicit("Could not find datablock for arena: datablockID: " + val7.DimensionData)); continue; } eDimensionIndex val9 = (eDimensionIndex)(21 - (num6 + 1)); if (__instance.m_createdDimensionSet.Contains(val9)) { DebugLog.LogPrefixError((Object)(object)__instance, $"Enemy dimension ({val9}) had already been created! If there are dimension enemies in the level, dimensionIndex {17}-{20} needs to be free (one for each player slot)."); continue; } DimensionData dimensionData2 = val8.DimensionData; if (val7.Enabled) { GameObject customGeomorph = GameDataBlockBase<ComplexResourceSetDataBlock>.GetBlock(dimensionData2.DimensionResourceSetID).GetCustomGeomorph(dimensionData2.DimensionGeomorph); if ((Object)(object)customGeomorph == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"The dimension geomorph for ({((GameDataBlockBase<DimensionDataBlock>)(object)val8).persistentID}) {((GameDataBlockBase<DimensionDataBlock>)(object)val8).name} could not be found!"); continue; } float num8 = 32f; LG_Dimension component = customGeomorph.GetComponent<LG_Dimension>(); if ((Object)(object)component != (Object)null && component.TryGetDimensionBounds(ref val10)) { num8 += ((Bounds)(ref val10)).extents.x; } num7 += num8; Vector3 val11 = up * num3 + right * num7; __instance.CreateDimension(((XXHashSequence)(ref val)).NextSubSeed(), val9, true, dimensionData2, val11, 10, 64f); __instance.m_createdDimensionSet.Add(val9); DimensionSlotIndex val12 = default(DimensionSlotIndex); val12.DimensionDataBlockID = 14u; val12.PlayerSlotIndex = (uint)k; DimensionSlotIndex val13 = val12; __instance.m_dimensionArenaMap.Add(val13, __instance.m_dimensions[__instance.m_dimensions.Count - 1]); Logger.Info($"created dim {val9} pos {val11} .."); num2++; num7 += num8; } num6++; } num3 += num5; } Dimension.CalculateAllDimensionBounds(); Logger.Info($"Found ({num2}) unique dimension references in GameData for this expedition and created ({num6}) enemy dimensions."); return false; } [HarmonyPatch(typeof(LG_Floor), "CreateDimension")] [HarmonyPrefix] private static bool Prefix(LG_Floor __instance, uint seed, eDimensionIndex dimensionIndex, bool arenaDimension, ref DimensionData dimensionData, Vector3 position, ref int __result, int gridSize, float cellSize = 64f) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) if (arenaDimension) { return true; } gridSize = 40; _ = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex; if (dimensionData.IsStaticDimension) { return true; } LayoutConfig config = null; LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(dimensionData.LevelLayoutData); ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out config); if (config == null) { return true; } if (config.TileOverrides.Length == 0) { return true; } Logger.Info($"in createdim prefix gridsize {gridSize} .."); cellSize = 64f; GameObject val = null; XXHashSequence val2 = default(XXHashSequence); ((XXHashSequence)(ref val2))..ctor(seed, true); Vector3 val3 = position - new Vector3(cellSize, 0f, cellSize) * (float)gridSize * 0.5f; LG_TileShape val4 = __instance.CreateTileShape((LG_TileShapeType)1, cellSize, ref val3); LG_Grid val5 = CellGridBase<LG_Grid, LG_Tile, LG_Cell>.Create(cellSize, val3); ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)val5).SetupCells(gridSize, gridSize); ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)val5).InititalizeCells(); int count = __instance.m_dimensions.Count; Dimension val6 = new Dimension(val5, dimensionIndex, count, dimensionData, position, arenaDimension); DebugLog.LogPrefix((Object)(object)__instance, $"Created Dimension (Index: {dimensionIndex}, gridSize: {gridSize}, cellSize: {cellSize})."); val = val6.ResourceData.GetCustomGeomorph(dimensionData.DimensionGeomorph); if (block != null && config.TileOverrides[0].X == 0 && config.TileOverrides[0].Z == 0 && !string.IsNullOrEmpty(config.TileOverrides[0].Geomorph)) { if (EntryPoint.BundleLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + config.TileOverrides[0].Geomorph.ToUpperInvariant()); Object val7 = item.Value.LoadAsset(config.TileOverrides[0].Geomorph.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(config.TileOverrides[0].Geomorph.ToUpperInvariant(), val7); } catch { } } if (!(item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info("loading all asset prefabs from bundle " + ((Object)item.Value).name); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val8 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val8); } catch { } } } } Object loadedAsset = AssetAPI.GetLoadedAsset(config.TileOverrides[0].Geomorph); val = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null); Logger.Info($" - dim {dimensionIndex} elevator overriden! {((Object)val).name}"); } if ((Object)(object)val == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> Could not get the Dimension Geomorph prefab for dimension {dimensionIndex}, are you using a resource set in the DimensionDataBlock that contains the Dimension Geomorph prefab under the \"Custom Geomorphs_Objective_1x1\" header?"); __result = count; return false; } LG_FloorTransition val9 = __instance.CreateFloorTransition(((XXHashSequence)(ref val2)).NextSubSeed(), val6, position, Quaternion.identity, val, val6.DimensionData.IsStaticDimension); if ((Object)(object)val9 == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The LG_FloorTransition of dimension {dimensionIndex} was null! Does the dimension prefab have a LG_FloorTransition component on its root?"); __result = count; return false; } LG_Dimension val10 = ((Component)val9).GetComponent<LG_Dimension>(); if ((Object)(object)val10 == (Object)null) { val10 = ((Component)val9).gameObject.AddComponent<LG_Dimension>(); DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The dimension {dimensionIndex} had no {typeof(LG_Dimension).Name} component, so added one automatically!"); } val6.DimensionLevel = val10; if (val9.m_spawnPoints != null && ((Il2CppArrayBase<Transform>)(object)val9.m_spawnPoints).Length != 0) { val10.AddSpawnPoints(val9.m_spawnPoints); } val4.m_gridPosition = new LG_GridPosition(gridSize / 2, gridSize / 2); val4.m_type = val9.m_shapeType; AIG_GeomorphNodeVolume component = ((Component)val9).GetComponent<AIG_GeomorphNodeVolume>(); if ((Object)(object)component == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The Dimension Geomorph for {dimensionIndex} did not have a {typeof(AIG_GeomorphNodeVolume).Name} component on it!"); __result = count; return false; } ((LG_Geomorph)val9).m_nodeVolume = (AIG_NodeVolume)(object)component; ((AIG_NodeVolume)component).ConstructVoxelNodeVolume(); ((LG_Geomorph)val9).ScanChildrenAreas(); val6.m_startTile = LG_Tile.Create(val5, val4); val6.m_startTile.m_geoRoot = (LG_Geomorph)(object)val9; val6.m_startTile.m_geoRoot.m_tile = val6.m_startTile; ((Component)val9).transform.SetParent(((Component)val6.DimensionRootTemp).transform); ((LG_Geomorph)val9).m_tile = val6.m_startTile; val6.m_startTransition = val9; val6.Tiles.Add(val6.m_startTile); __instance.m_dimensions.Add(val6); __instance.m_indexToDimensionMap[dimensionIndex] = val6; __result = count; return false; } } [HarmonyPatch(typeof(LG_SetupFloor), "Build")] internal static class Inject_SetupFloor { [HarmonyPrefix] private static bool Prefix(LG_SetupFloor __instance, ref bool __result) { //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) Enumerator<string, AssetShardManifest> enumerator = AssetShardManager.s_loadedManifests.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<string, AssetShardManifest> current = enumerator.Current; if (current.Key.Contains("Complex_Service") && !EntryPoint.ServiceFixed) { GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Complex/Service/Geomorphs/Maintenance/geo_64x64_service_floodways_hub_SF_01.prefab"); if ((Object)(object)loadedAsset != (Object)null) { foreach (Transform componentsInChild in loadedAsset.GetComponentsInChildren<Transform>()) { if (((Object)componentsInChild).name == "AIGraphSource") { componentsInChild.position = new Vector3(5f, 2f, -16f); } } Logger.Info("navmesh fix on geo_64x64_service_floodways_hub_SF_01.prefab done"); EntryPoint.ServiceFixed = true; } } if (!current.Key.Contains("Complex_Tech") || EntryPoint.TechFixed) { continue; } GameObject loadedAsset2 = AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Complex/Tech/Geomorphs/geo_64x64_tech_lab_HA_05.prefab"); if (!((Object)(object)loadedAsset2 != (Object)null)) { continue; } foreach (LG_PrefabSpawner componentsInChild2 in loadedAsset2.GetComponentsInChildren<LG_PrefabSpawner>()) { if (!((Object)((Component)componentsInChild2).transform).name.Contains("prop_generic_duct_d_2m_tile_001")) { continue; } foreach (Transform componentsInChild3 in componentsInChild2.m_prefab.GetComponentsInChildren<Transform>()) { if (((Object)componentsInChild3).name == "Capsulecollider") { ((Component)componentsInChild3).transform.localScale = new Vector3(0.5f, 1f, 0.5f); } } } Logger.Info("collider fix on geo_64x64_tech_lab_HA_05.prefab done"); EntryPoint.TechFixed = true; } LayoutConfig config = null; Debug.Log(Object.op_Implicit(Deb.LG("LG_SetupFloor.Build", 0f))); GameObject val = null; uint num = 0u; if (Builder.LayerBuildDatas[0].m_zoneBuildDatas != null && Builder.LayerBuildDatas[0].m_zoneBuildDatas.Count > 0) { _ = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex; num = (uint)Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubSeed; } XXHashSeed seed = __instance.m_rnd.Seed; XXHashSequence val2 = default(XXHashSequence); ((XXHashSequence)(ref val2))..ctor(((XXHashSeed)(ref seed)).SubSeed(num), true); ConfigManager.TryGetConfig(RundownManager.ActiveExpedition.LevelLayoutData, out config); if (config == null) { return true; } LG_GridPosition val3 = default(LG_GridPosition); val3.x = 0; val3.z = 0; if (config.TileOverrides.Length == 0) { return true; } if (config.TileOverrides[0].X != 0 || config.TileOverrides[0].Z != 0) { return true; } if (!string.IsNullOrEmpty(config.TileOverrides[0].Geomorph)) { if (EntryPoint.BundleLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + config.TileOverrides[0].Geomorph.ToUpperInvariant()); Object val4 = item.Value.LoadAsset(config.TileOverrides[0].Geomorph.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(config.TileOverrides[0].Geomorph.ToUpperInvariant(), val4); } catch { } } if (!(item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info("loading all assets from bundle " + ((Object)item.Value).name); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val5 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val5); } catch { } } } } Object loadedAsset3 = AssetAPI.GetLoadedAsset(config.TileOverrides[0].Geomorph); val = ((loadedAsset3 != null) ? ((Il2CppObjectBase)loadedAsset3).Cast<GameObject>() : null); if ((Object)(object)val == (Object)null) { Logger.Info("LGTuner failed to override elevator!"); return true; } Logger.Info(" - elevator overriden! " + ((Object)val).name); LG_FloorTransition val6 = GOUtil.SpawnChildAndGetComp<LG_FloorTransition>(val, __instance.m_position, __instance.m_rotation); ((LG_Geomorph)val6).m_geoPrefab = val; ((LG_Geomorph)val6).SetupAreas(((XXHashSequence)(ref val2)).NextSubSeed()); ((LG_Geomorph)val6).SetPlaced(); __instance.m_floor.Setup(((XXHashSequence)(ref val2)).NextSubSeed(), (LG_FloorType)0, Builder.ComplexResourceSetBlock.LevelGenConfig.TransitionDirection, val6); for (int i = 0; i < __instance.m_floor.m_dimensions.Count; i++) { __instance.m_floor.InjectJobs(__instance.m_floor.m_dimensions[i].DimensionIndex); } LG_Factory.InjectJob((LG_FactoryJob)new LG_BuildFloorJob(__instance.m_floor), (BatchName)7); __result = true; return false; } return true; } } [HarmonyPatch(typeof(LG_BuildPlugBaseJob), "SpawnPlug")] internal static class Inject_BuildPlug { private static void Prefix(LG_Plug plug, ref GameObject prefab) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected I4, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) Logger.Info($"found plug for zone: {((LG_ZoneExpander)plug).m_linksFrom.m_zone.LocalIndex}{((Object)((LG_ZoneExpander)plug).m_linksFrom).name}->{((LG_ZoneExpander)plug).m_linksTo.m_zone.LocalIndex}{((Object)((LG_ZoneExpander)plug).m_linksTo).name}"); if (!BuilderInfo.TryGetConfig(((LG_ZoneExpander)plug).m_linksFrom.m_zone, out var config)) { return; } LG_GridPosition normal = ((LG_ZoneExpander)plug).m_linksFrom.m_geomorph.m_tile.m_shape.m_gridPosition.GetNormal(config.GridSize); if (!config.TryGetTileData(normal, out var overrideData)) { return; } ZoneOverrideData zoneData = overrideData.ZoneData; if (zoneData != null && zoneData.OverridePlugs && TryGetPlugPrefab(overrideData.ZoneData.GetNextPlug(), out var prefab2)) { Logger.Info(" - Prefab Replaced by Zone OverridePlugs! " + ((Object)prefab2).name); prefab = prefab2; } LG_PlugDir dir = plug.m_dir; GameObject prefab3; switch (dir - 2) { case 0: if (TryGetPlugPrefab(overrideData.BackwardPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by BackwardPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; case 2: if (TryGetPlugPrefab(overrideData.ForwardPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by ForwardPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; case 3: if (TryGetPlugPrefab(overrideData.LeftPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by LeftPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; case 1: if (TryGetPlugPrefab(overrideData.RightPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by RightPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; } if (overrideData.OverridePlugWithNoGateChance) { Random random = new Random(((LG_ZoneExpander)plug).m_linksFrom.AreaSeed.ToSeed()); bool withGate = ((LG_ZoneExpander)plug).m_isZoneSource || (!(overrideData.PlugWithNoGateChance >= 1f) && (overrideData.PlugWithNoGateChance <= 0f || random.NextFloat() >= overrideData.PlugWithNoGateChance)); int dropHeight = GetDropHeight(plug); GameObject randomPlug = BuilderInfo.GetRandomPlug(random.NextUint(), dropHeight, GetSubComplexOfPlug(plug), withGate); if ((Object)(object)randomPlug == (Object)null) { Logger.Error($"Plug was null! - Height: {dropHeight}"); } else { prefab = randomPlug; } } } private static SubComplex GetSubComplexOfPlug(LG_Plug plug) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) SubComplex result = ((LG_ZoneExpander)plug).m_subComplex; if (((LG_ZoneExpander)plug).m_subComplex != ((LG_ZoneExpander)plug.m_pariedWith).m_subComplex) { result = (SubComplex)8; } return result; } private static bool TryGetPlugPrefab(string prefabPath, out GameObject prefab) { if (string.IsNullOrEmpty(prefabPath)) { prefab = null; return false; } if (EntryPoint.BundleLookup.ContainsKey(prefabPath.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(prefabPath.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == prefabPath.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + prefabPath.ToUpperInvariant()); Object val = item.Value.LoadAsset(prefabPath.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(prefabPath.ToUpperInvariant(), val); } catch { } } if (!(item.Key == prefabPath.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info($"loading all assets from bundle {item.Value}"); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val2 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val2); } catch { } } } } Object loadedAsset = AssetAPI.GetLoadedAsset(prefabPath); prefab = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null); return (Object)(object)prefab != (Object)null; } private static int GetDropHeight(LG_Plug plug) { //IL_0006: 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) return Mathf.RoundToInt(Mathf.Abs(((Component)plug).transform.position.y - ((Component)plug.m_pariedWith).transform.position.y) / BuilderInfo.AltitudeOffset); } } [HarmonyPatch(typeof(LG_BuildPlugJob), "Build")] internal class Inject_BuildPlugJob { [HarmonyWrapSafe] private static bool Prefix(LG_BuildPlugJob __instance) { //IL_0022: 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_0054: 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_007d: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected I4, but got Unknown //IL_01cc: 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_01f5: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; LG_Plug plug = __instance.m_plug; Logger.Info($"buildplugjob plug in complex {((LG_ZoneExpander)plug).m_subComplex} plug status {((LG_ZoneExpander)plug).ExpanderStatus} plug direction {plug.m_dir} .."); if ((int)((LG_ZoneExpander)plug).ExpanderStatus == 1) { return true; } if (((LG_ZoneExpander)plug).m_isZoneSource) { return true; } if (!BuilderInfo.TryGetConfig(((LG_ZoneExpander)plug).m_linksFrom.m_zone, out var config)) { return true; } LG_GridPosition normal = ((LG_ZoneExpander)plug).m_linksFrom.m_geomorph.m_tile.m_shape.m_gridPosition.GetNormal(config.GridSize); if (!config.TryGetTileData(normal, out var overrideData)) { return true; } LG_PlugDir dir = plug.m_dir; GameObject prefab; switch (dir - 2) { case 0: if (TryGetPlugPrefab(overrideData.BackwardPlug, out prefab)) { Logger.Info(" - Prefab Replaced by BackwardPlug setting! " + ((Object)prefab).name); val = prefab; } break; case 2: if (TryGetPlugPrefab(overrideData.ForwardPlug, out prefab)) { Logger.Info(" - Prefab Replaced by ForwardPlug setting! " + ((Object)prefab).name); val = prefab; } break; case 3: if (TryGetPlugPrefab(overrideData.LeftPlug, out prefab)) { Logger.Info(" - Prefab Replaced by LeftPlug setting! " + ((Object)prefab).name); val = prefab; } break; case 1: if (TryGetPlugPrefab(overrideData.RightPlug, out prefab)) { Logger.Info(" - Prefab Replaced by RightPlug setting! " + ((Object)prefab).name); val = prefab; } break; } if ((Object)(object)val != (Object)null) { Logger.Info($"we shall replace a cap going {plug.m_dir}"); Vector3 position = ((Component)plug).transform.position; Quaternion rotation = ((Component)plug).transform.rotation; GameObject val2 = Object.Instantiate<GameObject>(val, position, rotation); val2.transform.SetParent(((Component)plug).transform, true); LG_Factory.FindAndBuildSelectorsAndSpawners(val2, RandomExtensions.NextSubSeed(__instance.m_rnd.Random), false); __instance.ProcessDivider(plug, val2, false, RandomExtensions.NextSubSeed(__instance.m_rnd.Random)); ((LG_ZoneExpander)plug).m_wasProcessed = true; } return true; } private static bool TryGetPlugPrefab(string prefabPath, out GameObject prefab) { if (string.IsNullOrEmpty(prefabPath)) { prefab = null; return false; } if (EntryPoint.BundleLookup.ContainsKey(prefabPath.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(prefabPath.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == prefabPath.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + prefabPath.ToUpperInvariant()); Object val = item.Value.LoadAsset(prefabPath.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(prefabPath.ToUpperInvariant(), val); } catch { } } if (!(item.Key == prefabPath.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info($"loading all assets from bundle {item.Value}"); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val2 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val2); } catch { } } } } prefab = ((Il2CppObjectBase)AssetAPI.GetLoadedAsset(prefabPath)).Cast<GameObject>(); return (Object)(object)prefab != (Object)null; } } [HarmonyPatch(typeof(LG_LevelBuilder), "PlaceRoot")] internal static class Inject_BuildGeomorph { private static LayoutConfig _configContext; private static LayoutConfig _configContext2; private static RotateType _nextRotateType; [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch("BuildFloor")] private static void Post_BuildFloor() { BuilderInfo.OnResourceSetSelected(); } [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch("PlaceRoot")] private static void Pre_PlaceRoot(LG_Tile tile, ref GameObject tilePrefab, ref bool forceAlignToVector, ref Vector3 alignVector, LG_Zone zone) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) _configContext = null; _nextRotateType = RotateType.None; forceAlignToVector = alignVector != Vector3.zero; int gridSize = zone.Dimension.GetGridSize(); LG_GridPosition val = tile.ToNormalGrid(gridSize); Logger.Info($"tile info: {val.x} {val.z} {((Object)tilePrefab).name} for {zone.LocalIndex} : {zone.DimensionIndex}"); if (!BuilderInfo.TryGetConfig(zone, out _configContext)) { return; } if (!_configContext.TryGetTileData(val, out var overrideData)) { overrideData = _configContext.PopulateTileOverrideForZone(zone, val); if (overrideData == null) { return; } } if (!string.IsNullOrEmpty(overrideData.Geomorph)) { if (overrideData.X == 0 && overrideData.Z == 0) { return; } if (EntryPoint.BundleLookup.ContainsKey(overrideData.Geomorph.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(overrideData.Geomorph.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == overrideData.Geomorph.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + overrideData.Geomorph.ToUpperInvariant()); Object val2 = item.Value.LoadAsset(overrideData.Geomorph.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(overrideData.Geomorph.ToUpperInvariant(), val2); } catch { } } if (!(item.Key == overrideData.Geomorph.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info("loading all assets from bundle " + ((Object)item.Value).name); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val3 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val3); } catch { } } } } Object loadedAsset = AssetAPI.GetLoadedAsset(overrideData.Geomorph); GameObject val4 = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null); if ((Object)(object)val4 != (Object)null) { Logger.Info(" - tile overriden! " + ((Object)val4).name); tilePrefab = val4; } } if (overrideData.Rotation != 0) { _nextRotateType = overrideData.Rotation; } } [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch("GetTilePosition")] private static void Post_GetTilePosition(LG_Tile tile, LG_Floor floor, int dimensionIndex, ref Vector3 __result) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (_configContext != null && floor.TryGetDimension(dimensionIndex, out var dimension)) { int gridSize = _configContext.GridSize; LG_GridPosition val = tile.ToNormalGrid(gridSize); if (_configContext.TryGetTileData(val, out var overrideData) && overrideData.OverrideAltitude) { Vector3 positionNormal = dimension.Grid.GetPositionNormal(val.x, val.z, gridSize); positionNormal += new Vector3(0f, (float)overrideData.Altitude * BuilderInfo.AltitudeOffset, 0f); __result = positionNormal; } } } [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch("PlaceRoot")] private static void Post_PlaceRoot(LG_Tile tile, LG_Zone zone, LG_Geomorph __result) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown if (_configContext == null) { return; } if (_nextRotateType != 0) { GameObject gameObject = ((Component)__result).gameObject; LG_PlugInfo lG_PlugInfo = LG_PlugInfo.BuildPlugInfo(gameObject, gameObject.transform.rotation); Logger.Info($" - TRYING ROTATION! PLUG COUNT: {lG_PlugInfo.Count}"); if (lG_PlugInfo.TryGetNewRotation(zone.m_subSeed, _nextRotateType, out var rotation)) { Logger.Info(" - Done!"); gameObject.transform.rotation = rotation; } __result.SetPlaced(); } int gridSize = _configContext.GridSize; LG_GridPosition normalGridPosition = tile.ToNormalGrid(gridSize); if (!_configContext.TryGetTileData(normalGridPosition, out var overrideData)) { return; } if (overrideData.OverrideAreaSeeds) { if (overrideData.AreaSeeds.Length == ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length) { int length = ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length; for (int i = 0; i < length; i++) { uint num = overrideData.AreaSeeds[i]; if (num != 0) { ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas)[i].AreaSeed = num; Logger.Info($" - new area seed: {((Il2CppArrayBase<LG_Area>)(object)__result.m_areas)[i].m_navInfo}, {num}"); } } } else { Logger.Error($" - Area count and AreaSeeds item count mismatched! (CFG: {overrideData.AreaSeeds.Length} != AREA: {((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length}) Area seed will not be applied!"); } } if (!zone.m_settings.HasCustomGeomorphPrefab) { iLG_CustomGeomorphLogic[] array = Il2CppArrayBase<iLG_CustomGeomorphLogic>.op_Implicit(((Component)__result).GetComponentsInChildren<iLG_CustomGeomorphLogic>()); for (int j = 0; j < array.Length; j++) { array[j].SpawnedOnFloor(); LG_Factory.InjectJob((LG_FactoryJob)new LG_CustomGeomorphBuildJob(array[j]), (BatchName)45); LG_Factory.InjectJob((LG_FactoryJob)new LG_CustomGeomorphPostCullingJob(array[j]), (BatchName)64); } } } [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(typeof(LG_ZoneJob_CreateExpandFromData), "Build")] private static void Pre_ZoneJob(LG_ZoneJob_CreateExpandFromData __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (!__instance.m_zone.m_settings.HasCustomGeomorphInstance || (int)__instance.m_mainStatus != 5) { return; } TileOverrideData overrideData = null; if ((Object)(object)Builder.CurrentFloor == (Object)null) { return; } if (BuilderInfo.TryGetConfig(__instance.m_zone, out _configContext2)) { int gridSize = _configContext2.GridSize; LG_GridPosition normalGridPosition = __instance.m_zone.m_settings.CustomGeomorphInstance.GetComponent<LG_Geomorph>().m_tile.ToNormalGrid(gridSize); _configContext2.TryGetTileData(normalGridPosition, out overrideData); } if (overrideData == null || !overrideData.TryForceCustomGeoAreaAssignment) { return; } Logger.Info(" - addcustomgeomorphareas firing for " + ((Object)__instance.m_zone.NavInfo).ToString()); Dictionary<LG_Area, float> dictionary = new Dictionary<LG_Area, float>(); Enumerator<LG_Area> enumerator = __instance.m_zone.m_areas.GetEnumerator(); while (enumerator.MoveNext()) { LG_Area current = enumerator.Current; float num = 1000f; if (current.m_zone.ID == 0 && (Object)(object)current == (Object)(object)current.m_zone.m_areas[0]) { num = 2000f; } if ((Object)(object)current == (Object)(object)current.m_zone.m_sourceExpander.m_linksTo) { num = 1500f; } dictionary.Add(current, num - Vector3.Distance(current.Position, __instance.m_zone.m_sourceExpander.m_linksFrom.Position)); } IOrderedEnumerable<KeyValuePair<LG_Area, float>> orderedEnumerable = dictionary.OrderByDescending((KeyValuePair<LG_Area, float> listdict) => listdict.Value); __instance.m_zone.m_areas.Clear(); foreach (KeyValuePair<LG_Area, float> item in orderedEnumerable) { Logger.Info($" - addcustomgeomorphareas scoredict {((Object)item.Key).name} {item.Value}"); if (!__instance.m_zone.m_areas.Contains(item.Key)) { __instance.m_zone.m_areas.Add(item.Key); } foreach (LG_InternalGate componentsInChild in ((Component)item.Key).gameObject.GetComponentsInChildren<LG_InternalGate>(true)) { if ((Object)(object)((LG_ZoneExpander)componentsInChild).m_linksFrom != (Object)null && !__instance.m_zone.m_areas.Contains(((LG_ZoneExpander)componentsInChild).m_linksFrom)) { Logger.Info(" - addcustomgeomorphareas adding m_linksFrom " + ((Object)((LG_ZoneExpander)componentsInChild).m_linksFrom).name); __instance.m_zone.m_areas.Add(((LG_ZoneExpander)componentsInChild).m_linksFrom); } if ((Object)(object)((LG_ZoneExpander)componentsInChild).m_linksTo != (Object)null && !__instance.m_zone.m_areas.Contains(((LG_ZoneExpander)componentsInChild).m_linksTo)) { Logger.Info(" - addcustomgeomorphareas adding m_linksTo " + ((Object)((LG_ZoneExpander)componentsInChild).m_linksTo).name); __instance.m_zone.m_areas.Add(((LG_ZoneExpander)componentsInChild).m_linksTo); } } } } } [HarmonyPatch(typeof(LG_LoadComplexDataSetResourcesJob), "Build")] internal static class Inject_LoadComplexShard { private static int _waitingShared; private static void Prefix(LG_LoadComplexDataSetResourcesJob __instance) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected I4, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00bb: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_loadingStarted) { return; } if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("StairsFix", out var _) && !EntryPoint.StairsFixed) { Transform transform = ((Component)AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Complex/Dimensions/Desert/Dimension_Desert_Mining_Shaft.prefab").GetComponentsInChildren<LG_Ladder>()[2]).gameObject.transform; transform.position += new Vector3(0f, 0f, -1.5f); Logger.Info("navmesh fix on Dimension_Desert_Mining_Shaft.prefab (StairsFix) done"); EntryPoint.StairsFixed = true; } foreach (Complex item in BuilderInfo.ExtraComplexResourceToLoad) { AssetBundleName val = (AssetBundleName)((int)item switch { 0 => 2, 1 => 4, 2 => 3, _ => 0, }); if ((int)val != 0) { AssetShardManager.LoadAllShardsForBundleAsync(val, Action.op_Implicit((Action)Loaded), 1, (LoadSceneMode)1); _waitingShared++; } } } private static void Loaded() { _waitingShared--; } [HarmonyWrapSafe] private static void Postfix(LG_LoadComplexDataSetResourcesJob __instance, ref bool __result) { if (_waitingShared >= 1) { __result = false; } } } } namespace LGTuner.Configs { public sealed class LayoutConfig { private TileOverrideData[,] _builtTileOverrides = new TileOverrideData[0, 0]; public uint LevelLayoutID { get; set; } public Complex[] ExtraComplexResourceToLoad { get; set; } = Array.Empty<Complex>(); public ZoneOverrideData[] ZoneOverrides { get; set; } = Array.Empty<ZoneOverrideData>(); public TileOverrideData[] TileOverrides { get; set; } = Array.Empty<TileOverrideData>(); [JsonIgnore] public int GridSize { get; private set; } [JsonIgnore] public int GridSizeHalf { get; private set; } public void Reset(int gridSize) { Array.ForEach(ZoneOverrides, delegate(ZoneOverrideData item) { item.Clear(); }); Array.Clear(_builtTileOverrides, 0, _builtTileOverrides.Length); GridSize = gridSize; GridSizeHalf = gridSize / 2; _builtTileOverrides = new TileOverrideData[GridSize, GridSize]; TileOverrideData[] tileOverrides = TileOverrides; foreach (TileOverrideData tileOverrideData in tileOverrides) { if (_builtTileOverrides[tileOverrideData.X + GridSizeHalf, tileOverrideData.Z + GridSizeHalf] == null) { PutOverrideData(tileOverrideData); continue; } Logger.Error($"Duplicate tile data in layout: {LevelLayoutID}, ({tileOverrideData.X}, {tileOverrideData.Z})!"); } } public bool TryGetTileData(LG_GridPosition normalGridPosition, out TileOverrideData overrideData) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) int num = normalGridPosition.x + GridSizeHalf; if (num >= GridSize) { Logger.Error($"TryGetTileData grid x was out of range! {num}:{GridSize}"); overrideData = null; return false; } int num2 = normalGridPosition.z + GridSizeHalf; if (num2 >= GridSize) { Logger.Error($"TryGetTileData grid Z was out of range! {num2}:{GridSize}"); overrideData = null; return false; } overrideData = _builtTileOverrides[num, num2]; return overrideData != null; } public void PutOverrideData(TileOverrideData data) { _builtTileOverrides[data.X + GridSizeHalf, data.Z + GridSizeHalf] = data; } public TileOverrideData PopulateTileOverrideForZone(LG_Zone zone, LG_GridPosition normalGridPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0047: Unknown result type (might be due to invalid IL or missing references) if (!TryGetZoneOverride(zone.LocalIndex, out var data)) { return null; } if (TryGetTileData(normalGridPosition, out var overrideData)) { overrideData.ZoneData = data; TryApplyOverrides(data, overrideData); return overrideData; } TileOverrideData tileOverrideData = new TileOverrideData { ZoneData = data, X = normalGridPosition.x, Z = normalGridPosition.z, OverridePlugWithNoGateChance = data.OverridePlugWithNoGateChance, PlugWithNoGateChance = data.PlugWithNoGateChance }; TryApplyOverrides(data, tileOverrideData); PutOverrideData(tileOverrideData); return tileOverrideData; } private void TryApplyOverrides(ZoneOverrideData zoneOverrideData, TileOverrideData tileOverrideData) { if (zoneOverrideData.OverrideGeomorphs && string.IsNullOrEmpty(tileOverrideData.Geomorph)) { ZoneOverrideData.GeomorphData? nextGeo = zoneOverrideData.GetNextGeo(); if (nextGeo.HasValue) { tileOverrideData.Geomorph = nextGeo.Value.Geomorph; if (tileOverrideData.Rotation == RotateT
LGTuner.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using System.Text.Json.Serialization; using AIGraph; using AssetShards; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Expedition; using GTFO.API; using GTFO.API.Utilities; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using LGTuner.Configs; using LGTuner.Manager; using LGTuner.Utils; using LevelGeneration; using LevelGeneration.Core; using LogUtils; using Microsoft.CodeAnalysis; using SNetwork; using UnityEngine; using UnityEngine.SceneManagement; using XXHashing; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("LGTuner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+gitc8bce57-dirty-master.c8bce578aac34cdac66af591417e728397a714ef")] [assembly: AssemblyProduct("LGTuner")] [assembly: AssemblyTitle("LGTuner")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LGTuner { public static class BuilderInfo { private static readonly List<Complex> _extraComplexResourceToLoad = new List<Complex>(); public static IEnumerable<Complex> ExtraComplexResourceToLoad => _extraComplexResourceToLoad; public static ComplexResourceSetDataBlock ComplexResourceSet { get; private set; } public static int GridSize { get; private set; } public static int GridCenter { get; private set; } public static int GridZeroOffset { get; private set; } public static float AltitudeOffset { get; private set; } public static LayoutConfig MainLayer { get; private set; } public static LayoutConfig SecondaryLayer { get; private set; } public static LayoutConfig ThirdLayer { get; private set; } public static LayoutConfig[] DimensionLayer { get; private set; } = Array.Empty<LayoutConfig>(); internal static void OnResourceSetSelected() { //IL_0156: Unknown result type (might be due to invalid IL or missing references) ComplexResourceSet = Builder.ComplexResourceSetBlock; GridSize = ComplexResourceSet.LevelGenConfig.GridSize; GridCenter = GridSize / 2; GridZeroOffset = -GridCenter; AltitudeOffset = ComplexResourceSet.LevelGenConfig.AltitudeOffset; MainLayer = null; SecondaryLayer = null; ThirdLayer = null; DimensionLayer = new LayoutConfig[Enum.GetValues(typeof(eDimensionIndex)).Length]; _extraComplexResourceToLoad.Clear(); ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition; if (ConfigManager.TryGetConfig(activeExpedition.LevelLayoutData, out var config)) { MainLayer = config; } if (activeExpedition.SecondaryLayerEnabled && ConfigManager.TryGetConfig(activeExpedition.SecondaryLayout, out var config2)) { SecondaryLayer = config2; } if (activeExpedition.ThirdLayerEnabled && ConfigManager.TryGetConfig(activeExpedition.ThirdLayout, out var config3)) { ThirdLayer = config3; } Enumerator<Dimension> enumerator = Builder.CurrentFloor.m_dimensions.GetEnumerator(); while (enumerator.MoveNext()) { Dimension current = enumerator.Current; if (!current.IsMainDimension && !current.DimensionData.IsStaticDimension) { LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(current.DimensionData.LevelLayoutData); if (block != null && ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out var config4)) { Logger.Info("loysimme dimension ja levellayoutin"); config4.Reset(((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)current.Grid).m_sizeX); DimensionLayer[current.DimensionIndex] = config4; } } } MainLayer?.Reset(GridSize); SecondaryLayer?.Reset(GridSize); ThirdLayer?.Reset(GridSize); AddExtraShard(MainLayer); AddExtraShard(SecondaryLayer); AddExtraShard(ThirdLayer); Array.ForEach(DimensionLayer, delegate(LayoutConfig x) { AddExtraShard(x); }); } private static void AddExtraShard(LayoutConfig layerConfig) { //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_0025: Unknown result type (might be due to invalid IL or missing references) if (layerConfig == null) { return; } Complex[] extraComplexResourceToLoad = layerConfig.ExtraComplexResourceToLoad; foreach (Complex item in extraComplexResourceToLoad) { if (!_extraComplexResourceToLoad.Contains(item)) { _extraComplexResourceToLoad.Add(item); } } } public static bool TryGetConfig(LG_Zone zone, out LayoutConfig config) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected I4, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Dimension val = default(Dimension); if (!Dimension.GetDimension(zone.DimensionIndex, ref val)) { Logger.Info("dimension getter failed"); config = null; return false; } if (val.IsMainDimension) { LG_LayerType type = zone.Layer.m_type; switch ((int)type) { case 0: config = MainLayer; return MainLayer != null; case 1: config = SecondaryLayer; return SecondaryLayer != null; case 2: config = ThirdLayer; return ThirdLayer != null; } } else if (!val.DimensionData.IsStaticDimension) { Enumerator<Dimension> enumerator = Builder.CurrentFloor.m_dimensions.GetEnumerator(); while (enumerator.MoveNext()) { Dimension current = enumerator.Current; if (!current.IsMainDimension && !current.DimensionData.IsStaticDimension) { LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(current.DimensionData.LevelLayoutData); if (block != null && ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out var config2)) { Logger.Info("found a dimension + levellayout"); config2.Reset(((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)current.Grid).m_sizeX); DimensionLayer[current.DimensionIndex] = config2; } } } config = DimensionLayer[zone.DimensionIndex]; return config != null; } config = null; return false; } public static GameObject GetRandomPlug(uint seed, int plugHeight, SubComplex subcomplex, bool withGate) { //IL_002d: 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_0065: Unknown result type (might be due to invalid IL or missing references) ComplexResourceSetDataBlock complexResourceSet = ComplexResourceSet; return (GameObject)(plugHeight switch { 0 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_straightPlugsWithGates : complexResourceSet.m_straightPlugsNoGates, subcomplex), 1 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_singleDropPlugsWithGates : complexResourceSet.m_singleDropPlugsNoGates, subcomplex), 2 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_doubleDropPlugsWithGates : complexResourceSet.m_doubleDropPlugsNoGates, subcomplex), _ => null, }); } public static uint GetLayoutIdOfZone(LG_Zone zone) { //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_0036: Expected I4, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) Dimension dimension = zone.Dimension; if (dimension.IsMainDimension) { LG_LayerType type = zone.Layer.m_type; ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition; return (int)type switch { 0 => activeExpedition.LevelLayoutData, 1 => activeExpedition.SecondaryLayout, 2 => activeExpedition.ThirdLayout, _ => throw new NotSupportedException($"LayerType: {type} is not supported!"), }; } return dimension.DimensionData.LevelLayoutData; } } [BepInPlugin("LGTuner", "LGTuner", "1.2.2")] [BepInProcess("GTFO.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class EntryPoint : BasePlugin { public static Dictionary<string, AssetBundle> BundleLookup = new Dictionary<string, AssetBundle>(); public static string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "LGTuner.cfg"); public static ConfigFile config = new ConfigFile(CONFIG_PATH, true); public static ConfigEntry<string> _bundlesToRename; public static ConfigEntry<string> _bundlesToLoadAllFrom; public static List<AssetBundle> BundleLoadAllLookup = new List<AssetBundle>(); public static bool StairsFixed = false; public static bool TechFixed = false; public static bool ServiceFixed = false; public static List<string> CustomMarkerPrefabs = new List<string>(); public Harmony HarmonyInstance { get; private set; } public override void Load() { //IL_000f: 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_002e: Expected O, but got Unknown //IL_002e: Expected O, but got Unknown //IL_0042: 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_0061: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown _bundlesToRename = config.Bind<string>(new ConfigDefinition("General", "Bundles_To_Rename"), "cavetile-compressed,rlc_legacy-compressed,rlc_mining-compressed,rlc_tech-compressed,customgeo_mining_prelude-compressed,customgeo_service_prelude-compressed,customgeo_tech_prelude-compressed,doggygeos-compressed,dogstilepack-compressed,ds_geo_pack_2-compressed,flowgeo-mining-vol2-compressed,flowgeo-service-vol2-compressed,flowgeo-tech-vol2-compressed,geo_64x64_service_floodways_boss_hub_ds_01-compressed,geo_64x64_service_floodways_hub_ds_01-compressed,geo_64x64_tech_data_center_hub_ds_01-compressed,geo_64x64_tech_data_center_i_tile_ds_1-compressed,geo_mining_flow-compressed,geo_service_flow-compressed,geo_tech_flow-compressed,madgeos-gardens-compressed,qt-geos-mining-compressed,qt-geos-service-compressed,qt-geos-tech-compressed,samgeos-compressed,samgeosv2-compressed,dak_geos-compressed,eternal_geos-compressed,collisiongeo-compressed,customgeo-compressed,mccadcustomgeopack-compressed,yoshi moment gaming-compressed,bro pack 69-compressed,wowoowowowowowoowowrru921r-compressed,dv1_dogcustomgeos-compressed,dogcustomplugs-compressed,dogcustomgeos1-compressed,xiaoyao2-compressed,xiaoyao3-compressed,xiaoyao4-compressed,xiaoyao5-compressed,xiaoyao6-compressed", new ConfigDescription("comma separated list of asset bundle files for lgtuner processing (will be renamed file.fdfd.manifest)", (AcceptableValueBase)null, Array.Empty<object>())); _bundlesToLoadAllFrom = config.Bind<string>(new ConfigDefinition("General", "Bundles_To_Load_All_From"), "somefile1-compressed,somefile2-compressed,somefile3-compressed", new ConfigDescription("comma separated list of asset bundle files that will be fully loaded upon use, if problems with single prefab loading arise", (AcceptableValueBase)null, Array.Empty<object>())); HarmonyInstance = new Harmony("LGTuner"); HarmonyInstance.PatchAll(); ConfigManager.RenameFiles(); ConfigManager.Init(); AssetShardManager.OnSharedAsssetLoaded += Action.op_Implicit((Action)ConfigManager.LoadCustomBundles); LG_Factory.OnFactoryBuildStart += Action.op_Implicit((Action)ConfigManager.LoadData); } } public static class LGExtensions { public static bool IsSame(this LG_GridPosition position, LG_GridPosition other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (position.x == other.x) { return position.z == other.z; } return false; } public static LG_GridPosition ToNormalGrid(this LG_Tile tile, int gridSize) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return tile.m_shape.m_gridPosition.GetNormal(gridSize); } public static LG_GridPosition GetNormal(this LG_GridPosition position, int gridSize) { //IL_003a: 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_0051: 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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) LG_GridPosition result; if (gridSize < 0) { result = default(LG_GridPosition); result.x = position.x + BuilderInfo.GridZeroOffset; result.z = position.z + BuilderInfo.GridZeroOffset; return result; } int num = gridSize / 2; result = default(LG_GridPosition); result.x = position.x - num; result.z = position.z - num; return result; } public static Vector3 GetPositionNormal(this LG_Grid grid, int x, int z, int gridSize) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (gridSize < 0) { return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetPosition(x - BuilderInfo.GridZeroOffset, z - BuilderInfo.GridZeroOffset); } int num = gridSize / 2; return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetPosition(x + num, z + num); } public static int GetGridSize(this Dimension dimension) { return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)dimension.Grid).m_sizeX; } public static bool TryGetDimension(this LG_Floor floor, int dimensionIndex, out Dimension dimension) { if (Enum.IsDefined(typeof(eDimensionIndex), dimensionIndex)) { return floor.GetDimension((eDimensionIndex)dimensionIndex, ref dimension); } dimension = null; return false; } public static bool TryGetDimension(this LG_Floor floor, eDimensionIndex dimensionIndex, out Dimension dimension) { //IL_000a: 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) if (Enum.IsDefined(typeof(eDimensionIndex), dimensionIndex)) { return floor.GetDimension(dimensionIndex, ref dimension); } dimension = null; return false; } } public static class RandomExtensions { public static uint NextUint(this Random random) { int num = random.Next(1073741824); uint num2 = (uint)random.Next(4); return (uint)(num << 2) | num2; } public static float NextFloat(this Random random) { return Mathf.Clamp01((float)random.NextDouble()); } public static int ToSeed(this uint seed) { return (int)seed; } } internal static class Logger { private static readonly ManualLogSource _logger; static Logger() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown _logger = new ManualLogSource("LGTuner"); Logger.Sources.Add((ILogSource)(object)_logger); } private static string Format(object msg) { return msg.ToString(); } public static void Info(object data) { _logger.LogMessage((object)Format(data)); } public static void Verbose(object data) { } public static void Debug(object data) { _logger.LogDebug((object)Format(data)); } public static void Error(object data) { _logger.LogError((object)Format(data)); } } public enum DirectionType { Unknown, Forward, Backward, Left, Right } public enum RotateType { None, Flip, MoveTo_Left, MoveTo_Right, Towards_Random, Towards_Forward, Towards_Backward, Towards_Left, Towards_Right } public struct LG_PlugInfo { public static readonly Quaternion NoRotation = Quaternion.AngleAxis(0f, Vector3.up); public static readonly Quaternion RightRotation = Quaternion.AngleAxis(90f, Vector3.up); public static readonly Quaternion BackwardRotation = Quaternion.AngleAxis(180f, Vector3.up); public static readonly Quaternion LeftRotation = Quaternion.AngleAxis(270f, Vector3.up); public static readonly Vector3 FrontPlugPosition = Vector3.forward * 32f; public static readonly Vector3 BackPlugPosition = Vector3.back * 32f; public static readonly Vector3 LeftPlugPosition = Vector3.left * 32f; public static readonly Vector3 RightPlugPosition = Vector3.right * 32f; public bool IsValid { get; private set; } public DirectionType StartDirection { get; private set; } public int Count { get; private set; } public bool HasFront { get; private set; } public bool HasBack { get; private set; } public bool HasLeft { get; private set; } public bool HasRight { get; private set; } public bool TryGetNewRotation(uint seed, RotateType rotate, out Quaternion rotation) { //IL_0062: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) DirectionType newDirection = GetNewDirection(seed, StartDirection, rotate); if (Count >= 4) { rotation = GetRotationOfDirection(newDirection); return true; } Logger.Info($"You are rotating {Count} side Geomorph, this could lead to level gen crash!"); rotation = GetRotationOfDirection(newDirection); return true; } public bool HasPlug(DirectionType direction) { if (!IsValid) { return false; } if (Count >= 4) { return true; } return direction switch { DirectionType.Forward => HasFront, DirectionType.Backward => HasBack, DirectionType.Left => HasLeft, DirectionType.Right => HasRight, _ => false, }; } public static LG_PlugInfo BuildPlugInfo(GameObject geoObject, Quaternion rotation) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected I4, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)geoObject.GetComponent<LG_Geomorph>() == (Object)null) { return default(LG_PlugInfo); } Il2CppArrayBase<LG_Plug> componentsInChildren = geoObject.GetComponentsInChildren<LG_Plug>(); if (componentsInChildren == null) { return default(LG_PlugInfo); } if (componentsInChildren.Length < 1) { return default(LG_PlugInfo); } LG_PlugInfo result = default(LG_PlugInfo); foreach (LG_Plug item in componentsInChildren) { LG_PlugDir dir = item.m_dir; switch (dir - 2) { case 0: result.HasBack = true; result.Count++; break; case 2: result.HasFront = true; result.Count++; break; case 3: result.HasLeft = true; result.Count++; break; case 1: result.HasRight = true; result.Count++; break; } } result.IsValid = result.Count > 0; float num = Mathf.Round(((Quaternion)(ref rotation)).eulerAngles.y); Logger.Verbose($"angle: {num}"); num = Mathf.Repeat(num, 360f); result.StartDirection = Mathf.RoundToInt(num / 90f) switch { 0 => DirectionType.Forward, 1 => DirectionType.Right, 2 => DirectionType.Backward, 3 => DirectionType.Left, _ => DirectionType.Unknown, }; return result; } public static DirectionType GetNewDirection(uint seed, DirectionType direction, RotateType rotate) { if (direction == DirectionType.Unknown) { return DirectionType.Unknown; } if (rotate == RotateType.Towards_Random) { rotate = new Random(seed.ToSeed()).Next(4) switch { 0 => RotateType.Towards_Forward, 1 => RotateType.Towards_Backward, 2 => RotateType.Towards_Left, 3 => RotateType.Towards_Right, _ => throw new IndexOutOfRangeException("Towards_Random: nextIndex was out of range?!"), }; } return rotate switch { RotateType.None => direction, RotateType.Flip => direction switch { DirectionType.Forward => DirectionType.Backward, DirectionType.Backward => DirectionType.Forward, DirectionType.Left => DirectionType.Right, DirectionType.Right => DirectionType.Left, _ => throw new ArgumentOutOfRangeException("direction"), }, RotateType.MoveTo_Left => direction switch { DirectionType.Forward => DirectionType.Left, DirectionType.Backward => DirectionType.Right, DirectionType.Left => DirectionType.Backward, DirectionType.Right => DirectionType.Forward, _ => throw new ArgumentOutOfRangeException("direction"), }, RotateType.MoveTo_Right => direction switch { DirectionType.Forward => DirectionType.Right, DirectionType.Backward => DirectionType.Left, DirectionType.Left => DirectionType.Forward, DirectionType.Right => DirectionType.Backward, _ => throw new ArgumentOutOfRangeException("direction"), }, RotateType.Towards_Forward => DirectionType.Forward, RotateType.Towards_Backward => DirectionType.Backward, RotateType.Towards_Left => DirectionType.Left, RotateType.Towards_Right => DirectionType.Right, _ => throw new ArgumentOutOfRangeException("direction"), }; } public static Quaternion GetRotationOfDirection(DirectionType direction) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_0032: 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_0045: Unknown result type (might be due to invalid IL or missing references) return (Quaternion)(direction switch { DirectionType.Forward => NoRotation, DirectionType.Backward => BackwardRotation, DirectionType.Left => LeftRotation, DirectionType.Right => RightRotation, _ => throw new ArgumentOutOfRangeException("direction"), }); } } [GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")] [CompilerGenerated] internal static class VersionInfo { public const string RootNamespace = "LGTuner"; public const string Version = "1.0.0"; public const string VersionPrerelease = null; public const string VersionMetadata = "gitc8bce57-dirty-master"; public const string SemVer = "1.0.0+gitc8bce57-dirty-master"; public const string GitRevShort = "c8bce57-dirty"; public const string GitRevLong = "c8bce578aac34cdac66af591417e728397a714ef-dirty"; public const string GitBranch = "master"; public const string GitTag = null; public const bool GitIsDirty = true; } } namespace LGTuner.Utils { internal static class JSON { private static readonly JsonSerializerOptions _setting; static JSON() { _setting = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, IncludeFields = false, PropertyNameCaseInsensitive = true, WriteIndented = true, IgnoreReadOnlyProperties = true }; _setting.Converters.Add(new JsonStringEnumConverter()); if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized) { _setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter); Logger.Info("PartialData Support Found!"); } } public static T Deserialize<T>(string json) { return JsonSerializer.Deserialize<T>(json, _setting); } public static object Deserialize(Type type, string json) { return JsonSerializer.Deserialize(json, type, _setting); } public static string Serialize(object value, Type type) { return JsonSerializer.Serialize(value, type, _setting); } } public static class MTFOPartialDataUtil { public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks"; public static JsonConverter PersistentIDConverter { get; private set; } public static bool IsLoaded { get; private set; } public static bool Initialized { get; private set; } public static string PartialDataPath { get; private set; } public static string ConfigPath { get; private set; } static MTFOPartialDataUtil() { PersistentIDConverter = null; IsLoaded = false; Initialized = false; PartialDataPath = string.Empty; ConfigPath = string.Empty; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type[] types = obj.GetTypes(); Type type = types.First((Type t) => t.Name == "PersistentIDConverter"); if ((object)type == null) { throw new Exception("Unable to Find PersistentIDConverter Class"); } Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class"); PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public); PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public); PropertyInfo? property3 = obj2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public); if ((object)property == null) { throw new Exception("Unable to Find Property: Initialized"); } if ((object)property2 == null) { throw new Exception("Unable to Find Property: PartialDataPath"); } if ((object)property3 == null) { throw new Exception("Unable to Find Field: ConfigPath"); } Initialized = (bool)property.GetValue(null); PartialDataPath = (string)property2.GetValue(null); ConfigPath = (string)property3.GetValue(null); PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type); IsLoaded = true; } catch (Exception value2) { Logger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}"); } } } public static class MTFOUtil { public const string PLUGIN_GUID = "com.dak.MTFO"; public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public; public static string GameDataPath { get; private set; } public static string CustomPath { get; private set; } public static bool HasCustomContent { get; private set; } public static bool IsLoaded { get; private set; } static MTFOUtil() { GameDataPath = string.Empty; CustomPath = string.Empty; HasCustomContent = false; IsLoaded = false; if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value)) { return; } try { Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null; if ((object)obj == null) { throw new Exception("Assembly is Missing!"); } Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class"); FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public); FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public); if ((object)field == null) { throw new Exception("Unable to Find Field: GameDataPath"); } if ((object)field2 == null) { throw new Exception("Unable to Find Field: CustomPath"); } if ((object)field3 == null) { throw new Exception("Unable to Find Field: HasCustomContent"); } GameDataPath = (string)field.GetValue(null); CustomPath = (string)field2.GetValue(null); HasCustomContent = (bool)field3.GetValue(null); IsLoaded = true; } catch (Exception value2) { Logger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}"); } } } } namespace LGTuner.Manager { public static class ConfigManager { [CompilerGenerated] private static class <>O { public static LiveEditEventHandler <0>__LiveEdit_FileChanged; } private static readonly List<LayoutConfig> _layouts = new List<LayoutConfig>(); private static readonly Dictionary<uint, LayoutConfig> _lookup = new Dictionary<uint, LayoutConfig>(); private static readonly Dictionary<string, LayoutConfig> _fileNameLookup = new Dictionary<string, LayoutConfig>(); public static IEnumerable<LayoutConfig> Layouts => _layouts; public static void LoadData() { List<string> list = new List<string>(); List<uint> list2 = new List<uint>(); list2.Add(RundownManager.ActiveExpedition.Expedition.ComplexResourceData); foreach (MiningMarkerDataBlock allBlock in GameDataBlockBase<MiningMarkerDataBlock>.GetAllBlocks()) { if (allBlock == null || allBlock.CommonData == null) { continue; } Enumerator<MarkerComposition> enumerator2 = allBlock.CommonData.Compositions.GetEnumerator(); while (enumerator2.MoveNext()) { MarkerComposition current2 = enumerator2.Current; if (current2 != null && current2.prefab != null && EntryPoint.BundleLookup.ContainsKey(current2.prefab.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(current2.prefab.ToUpperInvariant())) { Object val = EntryPoint.BundleLookup[current2.prefab.ToUpperInvariant()].LoadAsset(current2.prefab.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(current2.prefab.ToUpperInvariant(), val); } catch { } EntryPoint.CustomMarkerPrefabs.Add(current2.prefab.ToUpperInvariant()); } } } foreach (TechMarkerDataBlock allBlock2 in GameDataBlockBase<TechMarkerDataBlock>.GetAllBlocks()) { if (allBlock2 == null || allBlock2.CommonData == null) { continue; } Enumerator<MarkerComposition> enumerator2 = allBlock2.CommonData.Compositions.GetEnumerator(); while (enumerator2.MoveNext()) { MarkerComposition current4 = enumerator2.Current; if (current4 != null && current4.prefab != null && EntryPoint.BundleLookup.ContainsKey(current4.prefab.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(current4.prefab.ToUpperInvariant())) { Object val2 = EntryPoint.BundleLookup[current4.prefab.ToUpperInvariant()].LoadAsset(current4.prefab.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(current4.prefab.ToUpperInvariant(), val2); } catch { } EntryPoint.CustomMarkerPrefabs.Add(current4.prefab.ToUpperInvariant()); } } } foreach (ServiceMarkerDataBlock allBlock3 in GameDataBlockBase<ServiceMarkerDataBlock>.GetAllBlocks()) { if (allBlock3 == null || allBlock3.CommonData == null) { continue; } Enumerator<MarkerComposition> enumerator2 = allBlock3.CommonData.Compositions.GetEnumerator(); while (enumerator2.MoveNext()) { MarkerComposition current6 = enumerator2.Current; if (current6 != null && current6.prefab != null && EntryPoint.BundleLookup.ContainsKey(current6.prefab.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(current6.prefab.ToUpperInvariant())) { Object val3 = EntryPoint.BundleLookup[current6.prefab.ToUpperInvariant()].LoadAsset(current6.prefab.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(current6.prefab.ToUpperInvariant(), val3); } catch { } EntryPoint.CustomMarkerPrefabs.Add(current6.prefab.ToUpperInvariant()); } } } Enumerator<DimensionInExpeditionData> enumerator5 = RundownManager.ActiveExpedition.DimensionDatas.GetEnumerator(); while (enumerator5.MoveNext()) { DimensionInExpeditionData current7 = enumerator5.Current; if (current7.Enabled && !list2.Contains(GameDataBlockBase<DimensionDataBlock>.GetBlock(current7.DimensionData).DimensionData.DimensionResourceSetID)) { list2.Add(GameDataBlockBase<DimensionDataBlock>.GetBlock(current7.DimensionData).DimensionData.DimensionResourceSetID); } } foreach (uint item in list2) { ComplexResourceSetDataBlock block = GameDataBlockBase<ComplexResourceSetDataBlock>.GetBlock(item); Enumerator<ResourceData> enumerator7 = block.CustomGeomorphs_Challenge_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current8 = enumerator7.Current; if (!list.Contains(current8.Prefab.ToUpperInvariant())) { list.Add(current8.Prefab.ToUpperInvariant()); } } enumerator7 = block.CustomGeomorphs_Exit_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current9 = enumerator7.Current; if (!list.Contains(current9.Prefab.ToUpperInvariant())) { list.Add(current9.Prefab.ToUpperInvariant()); } } enumerator7 = block.CustomGeomorphs_Objective_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current10 = enumerator7.Current; if (!list.Contains(current10.Prefab.ToUpperInvariant())) { list.Add(current10.Prefab.ToUpperInvariant()); } } enumerator7 = block.GeomorphTiles_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current11 = enumerator7.Current; if (!list.Contains(current11.Prefab.ToUpperInvariant())) { list.Add(current11.Prefab.ToUpperInvariant()); } } enumerator7 = block.GeomorphTiles_2x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current12 = enumerator7.Current; if (!list.Contains(current12.Prefab.ToUpperInvariant())) { list.Add(current12.Prefab.ToUpperInvariant()); } } enumerator7 = block.GeomorphTiles_2x2.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current13 = enumerator7.Current; if (!list.Contains(current13.Prefab.ToUpperInvariant())) { list.Add(current13.Prefab.ToUpperInvariant()); } } enumerator7 = block.ElevatorShafts_1x1.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current14 = enumerator7.Current; if (!list.Contains(current14.Prefab.ToUpperInvariant())) { list.Add(current14.Prefab.ToUpperInvariant()); } } enumerator7 = block.PlugCaps.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current15 = enumerator7.Current; if (!list.Contains(current15.Prefab.ToUpperInvariant())) { list.Add(current15.Prefab.ToUpperInvariant()); } } enumerator7 = block.DoubleDropPlugsNoGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current16 = enumerator7.Current; if (!list.Contains(current16.Prefab.ToUpperInvariant())) { list.Add(current16.Prefab.ToUpperInvariant()); } } enumerator7 = block.SingleDropPlugsNoGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current17 = enumerator7.Current; if (!list.Contains(current17.Prefab.ToUpperInvariant())) { list.Add(current17.Prefab.ToUpperInvariant()); } } enumerator7 = block.StraightPlugsNoGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current18 = enumerator7.Current; if (!list.Contains(current18.Prefab.ToUpperInvariant())) { list.Add(current18.Prefab.ToUpperInvariant()); } } enumerator7 = block.DoubleDropPlugsWithGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current19 = enumerator7.Current; if (!list.Contains(current19.Prefab.ToUpperInvariant())) { list.Add(current19.Prefab.ToUpperInvariant()); } } enumerator7 = block.SingleDropPlugsWithGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current20 = enumerator7.Current; if (!list.Contains(current20.Prefab.ToUpperInvariant())) { list.Add(current20.Prefab.ToUpperInvariant()); } } enumerator7 = block.StraightPlugsWithGates.GetEnumerator(); while (enumerator7.MoveNext()) { ResourceData current21 = enumerator7.Current; if (!list.Contains(current21.Prefab.ToUpperInvariant())) { list.Add(current21.Prefab.ToUpperInvariant()); } } } foreach (string item2 in list) { if (!EntryPoint.BundleLookup.ContainsKey(item2) || AssetShardManager.s_loadedAssetsLookup.ContainsKey(item2)) { continue; } foreach (KeyValuePair<string, AssetBundle> item3 in EntryPoint.BundleLookup) { if (item3.Key == item2 && !EntryPoint.BundleLoadAllLookup.Contains(item3.Value)) { Logger.Info("loading bundle asset prefab " + item2 + " .."); Object val4 = item3.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val4); } catch { } } if (!(item3.Key == item2) || !EntryPoint.BundleLoadAllLookup.Contains(item3.Value)) { continue; } Logger.Info("loading all assets from bundle " + ((Object)item3.Value).name); foreach (string item4 in (Il2CppArrayBase<string>)(object)item3.Value.GetAllAssetNames()) { Object val5 = item3.Value.LoadAsset(item4); try { AssetShardManager.s_loadedAssetsLookup.Add(item4.ToUpperInvariant(), val5); } catch { } } } } } public static void UnloadData() { List<Object> list = new List<Object>(); foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (AssetShardManager.s_loadedAssetsLookup.ContainsKey(item.Key.ToUpperInvariant()) && !EntryPoint.CustomMarkerPrefabs.Contains(item.Key)) { list.Add(AssetShardManager.s_loadedAssetsLookup[item.Key.ToUpperInvariant()]); AssetShardManager.s_loadedAssetsLookup.Remove(item.Key.ToUpperInvariant()); } } foreach (Object item2 in list) { Object.Destroy(item2); } } public static void RenameFiles() { string path = Path.Combine(Paths.BepInExRootPath, "Assets", "AssetBundles"); string path2 = Path.Combine(Paths.ConfigPath, "Assets", "AssetBundles"); string[] array = Directory.GetFiles(path, "*", SearchOption.AllDirectories).ToArray(); string[] array2; if (Directory.Exists(path2)) { array2 = Directory.GetFiles(path2, "'", SearchOption.AllDirectories).ToArray(); foreach (string text in array2) { CollectionExtensions.AddItem<string>((IEnumerable<string>)array, text); } } array2 = array; foreach (string text2 in array2) { string value = text2.Split("\\").ToArray().Last(); if (EntryPoint._bundlesToRename.Value.Contains(value)) { try { Logger.Info($"renaming file {value} to {value}.fdfd.manifest"); File.Move(text2, text2 + ".fdfd.manifest", overwrite: true); } catch { } } } } public static void LoadCustomBundles() { string[] array = Directory.GetFiles(Path.Combine(Paths.BepInExRootPath, "Assets", "AssetBundles"), "*", SearchOption.AllDirectories).ToArray(); foreach (string text in array) { if (!text.Contains(".fdfd.manifest")) { continue; } Logger.Info("loading assetbundle " + text); string value = text.Split("\\").ToArray().Last() .Split(".") .ToArray() .First(); AssetBundle val = AssetBundle.LoadFromFile(text); if (EntryPoint._bundlesToLoadAllFrom.Value.Contains(value)) { Logger.Info($"bundle {((Object)val).name} file {value} marked as load-all-prefabs"); EntryPoint.BundleLoadAllLookup.Add(val); } foreach (string item in (Il2CppArrayBase<string>)(object)val.GetAllAssetNames()) { EntryPoint.BundleLookup.Add(item.ToUpperInvariant(), val); } } } public static void Init() { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown if (!MTFOUtil.HasCustomContent) { return; } string text = Path.Combine(MTFOUtil.CustomPath, "LGTuner"); FileInfo[] files = Directory.CreateDirectory(text).GetFiles(); foreach (FileInfo fileInfo in files) { string extension = fileInfo.Extension; bool flag = extension.Equals(".json", StringComparison.InvariantCultureIgnoreCase); bool flag2 = extension.Equals(".jsonc", StringComparison.InvariantCultureIgnoreCase); if (flag || flag2) { LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(File.ReadAllText(fileInfo.FullName)); if (_lookup.ContainsKey(layoutConfig.LevelLayoutID)) { Logger.Error($"Duplicated ID found!: {fileInfo.Name}, {layoutConfig.LevelLayoutID}"); } else { _layouts.Add(layoutConfig); _lookup.Add(layoutConfig.LevelLayoutID, layoutConfig); _fileNameLookup.Add(fileInfo.Name.ToLowerInvariant(), layoutConfig); } } } LiveEditListener obj = LiveEdit.CreateListener(text, "*.*", true); object obj2 = <>O.<0>__LiveEdit_FileChanged; if (obj2 == null) { LiveEditEventHandler val = LiveEdit_FileChanged; <>O.<0>__LiveEdit_FileChanged = val; obj2 = (object)val; } obj.FileChanged += (LiveEditEventHandler)obj2; object obj3 = <>O.<0>__LiveEdit_FileChanged; if (obj3 == null) { LiveEditEventHandler val2 = LiveEdit_FileChanged; <>O.<0>__LiveEdit_FileChanged = val2; obj3 = (object)val2; } obj.FileCreated += (LiveEditEventHandler)obj3; obj.StartListen(); } private static void LiveEdit_FileChanged(LiveEditEventArgs e) { string key = Path.GetFileName(e.FullPath).ToLowerInvariant(); string extension = Path.GetExtension(e.FullPath); if (!extension.Equals(".json", StringComparison.InvariantCulture) && !extension.Equals(".jsonc", StringComparison.InvariantCulture)) { return; } Logger.Error($"File Edited: '{key}' '{e.FullPath}'"); try { uint oldID = 0u; bool newfile = false; LayoutConfig data = null; if (_fileNameLookup.ContainsKey(key)) { data = _fileNameLookup[key]; } if (data == null) { newfile = true; } if (data != null) { oldID = data.LevelLayoutID; } LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string json) { try { LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(json); if (oldID != 0) { layoutConfig.LevelLayoutID = oldID; } if (oldID == 0) { oldID = layoutConfig.LevelLayoutID; } if (newfile) { if (_fileNameLookup.ContainsKey(key)) { _fileNameLookup.Remove(key); } LayoutConfig layoutConfig2 = null; foreach (LayoutConfig layout in _layouts) { if (layout.LevelLayoutID == layoutConfig.LevelLayoutID) { layoutConfig2 = layout; } } if (layoutConfig2 != null) { _layouts.Remove(layoutConfig2); } if (_lookup.ContainsKey(oldID)) { _lookup.Remove(oldID); } } if (!newfile) { _fileNameLookup.Remove(key); _lookup.Remove(oldID); _layouts.Remove(data); } _layouts.Add(layoutConfig); _lookup.Add(oldID, layoutConfig); _fileNameLookup.Add(key, layoutConfig); } catch (Exception value2) { Logger.Error($"Error while reading or inserting LGTuner Config: {value2}"); } }); } catch (Exception value) { Logger.Error($"Error while reading LGTuner Config: {value}"); } } private static void DumpLevel() { } private static void DumpLayerToConfig() { } public static bool TryGetConfig(uint layoutID, out LayoutConfig config) { return _lookup.TryGetValue(layoutID, out config); } } } namespace LGTuner.Inject { [HarmonyPatch] internal static class Inject_CreateDimension { [HarmonyPatch(typeof(LG_Floor), "CreateAllDimensions")] [HarmonyPrefix] private static bool Dim250(LG_Floor __instance, uint seed, bool skipMainDimension = true) { //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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Invalid comparison between Unknown and I4 //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Invalid comparison between Unknown and I4 //IL_0286: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) int num = 40; if (Builder.LevelGenExpedition.DimensionDatas == null || Builder.LevelGenExpedition.DimensionDatas.Count <= 0) { Dimension.CalculateAllDimensionBounds(); return false; } XXHashSequence val = default(XXHashSequence); ((XXHashSequence)(ref val))..ctor(seed, true); Vector3 up = Vector3.up; int num2 = 0; float num3 = 150f; DimensionDataBlock val3 = default(DimensionDataBlock); for (int i = 0; i < Builder.LevelGenExpedition.DimensionDatas.Count; i++) { DimensionInExpeditionData val2 = Builder.LevelGenExpedition.DimensionDatas[i]; if ((int)val2.DimensionIndex != 22 && val2.TryGetDimensionData(ref val3)) { DimensionData dimensionData = val3.DimensionData; if (val2.Enabled && (!skipMainDimension || (int)val2.DimensionIndex != 0) && !__instance.m_createdDimensionSet.Contains(val2.DimensionIndex)) { num3 += dimensionData.VerticalExtentsDown; Vector3 val4 = up * num3; __instance.CreateDimension(((XXHashSequence)(ref val)).NextSubSeed(), val2.DimensionIndex, false, dimensionData, val4, num, 64f); __instance.m_createdDimensionSet.Add(val2.DimensionIndex); Logger.Info($"created dim {val2.DimensionIndex} pos {val4} .."); num3 += dimensionData.VerticalExtentsUp; num2++; } } } float num4 = 0f; float num5 = 0f; DimensionDataBlock val6 = default(DimensionDataBlock); for (int j = 0; j < Builder.LevelGenExpedition.DimensionDatas.Count; j++) { DimensionInExpeditionData val5 = Builder.LevelGenExpedition.DimensionDatas[j]; if ((int)val5.DimensionIndex == 22 && val5.TryGetDimensionData(ref val6)) { num = 10; if (val6.DimensionData.VerticalExtentsDown > num4) { num4 = val6.DimensionData.VerticalExtentsDown; } if (val6.DimensionData.VerticalExtentsUp > num4) { num5 = num4; } } } int num6 = 0; Vector3 right = Vector3.right; DimensionDataBlock val8 = default(DimensionDataBlock); Bounds val10 = default(Bounds); for (int k = 0; k < ((Il2CppArrayBase<SNet_Slot>)(object)SNet.Slots.PlayerSlots).Length; k++) { num3 += num4; float num7 = 0f; for (int l = 0; l < Builder.LevelGenExpedition.DimensionDatas.Count; l++) { DimensionInExpeditionData val7 = Builder.LevelGenExpedition.DimensionDatas[l]; if ((int)val7.DimensionIndex != 22) { continue; } if (!val7.TryGetDimensionData(ref val8)) { Debug.LogError(Object.op_Implicit("Could not find datablock for arena: datablockID: " + val7.DimensionData)); continue; } eDimensionIndex val9 = (eDimensionIndex)(21 - (num6 + 1)); if (__instance.m_createdDimensionSet.Contains(val9)) { DebugLog.LogPrefixError((Object)(object)__instance, $"Enemy dimension ({val9}) had already been created! If there are dimension enemies in the level, dimensionIndex {17}-{20} needs to be free (one for each player slot)."); continue; } DimensionData dimensionData2 = val8.DimensionData; if (val7.Enabled) { GameObject customGeomorph = GameDataBlockBase<ComplexResourceSetDataBlock>.GetBlock(dimensionData2.DimensionResourceSetID).GetCustomGeomorph(dimensionData2.DimensionGeomorph); if ((Object)(object)customGeomorph == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"The dimension geomorph for ({((GameDataBlockBase<DimensionDataBlock>)(object)val8).persistentID}) {((GameDataBlockBase<DimensionDataBlock>)(object)val8).name} could not be found!"); continue; } float num8 = 32f; LG_Dimension component = customGeomorph.GetComponent<LG_Dimension>(); if ((Object)(object)component != (Object)null && component.TryGetDimensionBounds(ref val10)) { num8 += ((Bounds)(ref val10)).extents.x; } num7 += num8; Vector3 val11 = up * num3 + right * num7; __instance.CreateDimension(((XXHashSequence)(ref val)).NextSubSeed(), val9, true, dimensionData2, val11, 10, 64f); __instance.m_createdDimensionSet.Add(val9); DimensionSlotIndex val12 = default(DimensionSlotIndex); val12.DimensionDataBlockID = 14u; val12.PlayerSlotIndex = (uint)k; DimensionSlotIndex val13 = val12; __instance.m_dimensionArenaMap.Add(val13, __instance.m_dimensions[__instance.m_dimensions.Count - 1]); Logger.Info($"created dim {val9} pos {val11} .."); num2++; num7 += num8; } num6++; } num3 += num5; } Dimension.CalculateAllDimensionBounds(); Logger.Info($"Found ({num2}) unique dimension references in GameData for this expedition and created ({num6}) enemy dimensions."); return false; } [HarmonyPatch(typeof(LG_Floor), "CreateDimension")] [HarmonyPrefix] private static bool Prefix(LG_Floor __instance, uint seed, eDimensionIndex dimensionIndex, bool arenaDimension, ref DimensionData dimensionData, Vector3 position, ref int __result, int gridSize, float cellSize = 64f) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) if (arenaDimension) { return true; } gridSize = 40; _ = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex; if (dimensionData.IsStaticDimension) { return true; } LayoutConfig config = null; LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(dimensionData.LevelLayoutData); ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out config); if (config == null) { return true; } if (config.TileOverrides.Length == 0) { return true; } Logger.Info($"in createdim prefix gridsize {gridSize} .."); cellSize = 64f; GameObject val = null; XXHashSequence val2 = default(XXHashSequence); ((XXHashSequence)(ref val2))..ctor(seed, true); Vector3 val3 = position - new Vector3(cellSize, 0f, cellSize) * (float)gridSize * 0.5f; LG_TileShape val4 = __instance.CreateTileShape((LG_TileShapeType)1, cellSize, ref val3); LG_Grid val5 = CellGridBase<LG_Grid, LG_Tile, LG_Cell>.Create(cellSize, val3); ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)val5).SetupCells(gridSize, gridSize); ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)val5).InititalizeCells(); int count = __instance.m_dimensions.Count; Dimension val6 = new Dimension(val5, dimensionIndex, count, dimensionData, position, arenaDimension); DebugLog.LogPrefix((Object)(object)__instance, $"Created Dimension (Index: {dimensionIndex}, gridSize: {gridSize}, cellSize: {cellSize})."); val = val6.ResourceData.GetCustomGeomorph(dimensionData.DimensionGeomorph); if (block != null && config.TileOverrides[0].X == 0 && config.TileOverrides[0].Z == 0 && !string.IsNullOrEmpty(config.TileOverrides[0].Geomorph)) { if (EntryPoint.BundleLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + config.TileOverrides[0].Geomorph.ToUpperInvariant()); Object val7 = item.Value.LoadAsset(config.TileOverrides[0].Geomorph.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(config.TileOverrides[0].Geomorph.ToUpperInvariant(), val7); } catch { } } if (!(item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info("loading all asset prefabs from bundle " + ((Object)item.Value).name); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val8 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val8); } catch { } } } } Object loadedAsset = AssetAPI.GetLoadedAsset(config.TileOverrides[0].Geomorph); val = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null); Logger.Info($" - dim {dimensionIndex} elevator overriden! {((Object)val).name}"); } if ((Object)(object)val == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> Could not get the Dimension Geomorph prefab for dimension {dimensionIndex}, are you using a resource set in the DimensionDataBlock that contains the Dimension Geomorph prefab under the \"Custom Geomorphs_Objective_1x1\" header?"); __result = count; return false; } LG_FloorTransition val9 = __instance.CreateFloorTransition(((XXHashSequence)(ref val2)).NextSubSeed(), val6, position, Quaternion.identity, val, val6.DimensionData.IsStaticDimension); if ((Object)(object)val9 == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The LG_FloorTransition of dimension {dimensionIndex} was null! Does the dimension prefab have a LG_FloorTransition component on its root?"); __result = count; return false; } LG_Dimension val10 = ((Component)val9).GetComponent<LG_Dimension>(); if ((Object)(object)val10 == (Object)null) { val10 = ((Component)val9).gameObject.AddComponent<LG_Dimension>(); DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The dimension {dimensionIndex} had no {typeof(LG_Dimension).Name} component, so added one automatically!"); } val6.DimensionLevel = val10; if (val9.m_spawnPoints != null && ((Il2CppArrayBase<Transform>)(object)val9.m_spawnPoints).Length != 0) { val10.AddSpawnPoints(val9.m_spawnPoints); } val4.m_gridPosition = new LG_GridPosition(gridSize / 2, gridSize / 2); val4.m_type = val9.m_shapeType; AIG_GeomorphNodeVolume component = ((Component)val9).GetComponent<AIG_GeomorphNodeVolume>(); if ((Object)(object)component == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The Dimension Geomorph for {dimensionIndex} did not have a {typeof(AIG_GeomorphNodeVolume).Name} component on it!"); __result = count; return false; } ((LG_Geomorph)val9).m_nodeVolume = (AIG_NodeVolume)(object)component; ((AIG_NodeVolume)component).ConstructVoxelNodeVolume(); ((LG_Geomorph)val9).ScanChildrenAreas(); val6.m_startTile = LG_Tile.Create(val5, val4); val6.m_startTile.m_geoRoot = (LG_Geomorph)(object)val9; val6.m_startTile.m_geoRoot.m_tile = val6.m_startTile; ((Component)val9).transform.SetParent(((Component)val6.DimensionRootTemp).transform); ((LG_Geomorph)val9).m_tile = val6.m_startTile; val6.m_startTransition = val9; val6.Tiles.Add(val6.m_startTile); __instance.m_dimensions.Add(val6); __instance.m_indexToDimensionMap[dimensionIndex] = val6; __result = count; return false; } } [HarmonyPatch(typeof(LG_SetupFloor), "Build")] internal static class Inject_SetupFloor { [HarmonyPrefix] private static bool Prefix(LG_SetupFloor __instance, ref bool __result) { //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) Enumerator<string, AssetShardManifest> enumerator = AssetShardManager.s_loadedManifests.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<string, AssetShardManifest> current = enumerator.Current; if (current.Key.Contains("Complex_Service") && !EntryPoint.ServiceFixed) { GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Complex/Service/Geomorphs/Maintenance/geo_64x64_service_floodways_hub_SF_01.prefab"); if ((Object)(object)loadedAsset != (Object)null) { foreach (Transform componentsInChild in loadedAsset.GetComponentsInChildren<Transform>()) { if (((Object)componentsInChild).name == "AIGraphSource") { componentsInChild.position = new Vector3(5f, 2f, -16f); } } Logger.Info("navmesh fix on geo_64x64_service_floodways_hub_SF_01.prefab done"); EntryPoint.ServiceFixed = true; } } if (!current.Key.Contains("Complex_Tech") || EntryPoint.TechFixed) { continue; } GameObject loadedAsset2 = AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Complex/Tech/Geomorphs/geo_64x64_tech_lab_HA_05.prefab"); if (!((Object)(object)loadedAsset2 != (Object)null)) { continue; } foreach (LG_PrefabSpawner componentsInChild2 in loadedAsset2.GetComponentsInChildren<LG_PrefabSpawner>()) { if (!((Object)((Component)componentsInChild2).transform).name.Contains("prop_generic_duct_d_2m_tile_001")) { continue; } foreach (Transform componentsInChild3 in componentsInChild2.m_prefab.GetComponentsInChildren<Transform>()) { if (((Object)componentsInChild3).name == "Capsulecollider") { ((Component)componentsInChild3).transform.localScale = new Vector3(0.5f, 1f, 0.5f); } } } Logger.Info("collider fix on geo_64x64_tech_lab_HA_05.prefab done"); EntryPoint.TechFixed = true; } LayoutConfig config = null; Debug.Log(Object.op_Implicit(Deb.LG("LG_SetupFloor.Build", 0f))); GameObject val = null; uint num = 0u; if (Builder.LayerBuildDatas[0].m_zoneBuildDatas != null && Builder.LayerBuildDatas[0].m_zoneBuildDatas.Count > 0) { _ = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex; num = (uint)Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubSeed; } XXHashSeed seed = __instance.m_rnd.Seed; XXHashSequence val2 = default(XXHashSequence); ((XXHashSequence)(ref val2))..ctor(((XXHashSeed)(ref seed)).SubSeed(num), true); ConfigManager.TryGetConfig(RundownManager.ActiveExpedition.LevelLayoutData, out config); if (config == null) { return true; } LG_GridPosition val3 = default(LG_GridPosition); val3.x = 0; val3.z = 0; if (config.TileOverrides.Length == 0) { return true; } if (config.TileOverrides[0].X != 0 || config.TileOverrides[0].Z != 0) { return true; } if (!string.IsNullOrEmpty(config.TileOverrides[0].Geomorph)) { if (EntryPoint.BundleLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(config.TileOverrides[0].Geomorph.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + config.TileOverrides[0].Geomorph.ToUpperInvariant()); Object val4 = item.Value.LoadAsset(config.TileOverrides[0].Geomorph.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(config.TileOverrides[0].Geomorph.ToUpperInvariant(), val4); } catch { } } if (!(item.Key == config.TileOverrides[0].Geomorph.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info("loading all assets from bundle " + ((Object)item.Value).name); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val5 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val5); } catch { } } } } Object loadedAsset3 = AssetAPI.GetLoadedAsset(config.TileOverrides[0].Geomorph); val = ((loadedAsset3 != null) ? ((Il2CppObjectBase)loadedAsset3).Cast<GameObject>() : null); if ((Object)(object)val == (Object)null) { Logger.Info("LGTuner failed to override elevator!"); return true; } Logger.Info(" - elevator overriden! " + ((Object)val).name); LG_FloorTransition val6 = GOUtil.SpawnChildAndGetComp<LG_FloorTransition>(val, __instance.m_position, __instance.m_rotation); ((LG_Geomorph)val6).m_geoPrefab = val; ((LG_Geomorph)val6).SetupAreas(((XXHashSequence)(ref val2)).NextSubSeed()); ((LG_Geomorph)val6).SetPlaced(); __instance.m_floor.Setup(((XXHashSequence)(ref val2)).NextSubSeed(), (LG_FloorType)0, Builder.ComplexResourceSetBlock.LevelGenConfig.TransitionDirection, val6); for (int i = 0; i < __instance.m_floor.m_dimensions.Count; i++) { __instance.m_floor.InjectJobs(__instance.m_floor.m_dimensions[i].DimensionIndex); } LG_Factory.InjectJob((LG_FactoryJob)new LG_BuildFloorJob(__instance.m_floor), (BatchName)7); __result = true; return false; } return true; } } [HarmonyPatch(typeof(LG_BuildPlugBaseJob), "SpawnPlug")] internal static class Inject_BuildPlug { private static void Prefix(LG_Plug plug, ref GameObject prefab) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected I4, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) Logger.Info($"found plug for zone: {((LG_ZoneExpander)plug).m_linksFrom.m_zone.LocalIndex}{((Object)((LG_ZoneExpander)plug).m_linksFrom).name}->{((LG_ZoneExpander)plug).m_linksTo.m_zone.LocalIndex}{((Object)((LG_ZoneExpander)plug).m_linksTo).name}"); if (!BuilderInfo.TryGetConfig(((LG_ZoneExpander)plug).m_linksFrom.m_zone, out var config)) { return; } LG_GridPosition normal = ((LG_ZoneExpander)plug).m_linksFrom.m_geomorph.m_tile.m_shape.m_gridPosition.GetNormal(config.GridSize); if (!config.TryGetTileData(normal, out var overrideData)) { return; } ZoneOverrideData zoneData = overrideData.ZoneData; if (zoneData != null && zoneData.OverridePlugs && TryGetPlugPrefab(overrideData.ZoneData.GetNextPlug(), out var prefab2)) { Logger.Info(" - Prefab Replaced by Zone OverridePlugs! " + ((Object)prefab2).name); prefab = prefab2; } LG_PlugDir dir = plug.m_dir; GameObject prefab3; switch (dir - 2) { case 0: if (TryGetPlugPrefab(overrideData.BackwardPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by BackwardPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; case 2: if (TryGetPlugPrefab(overrideData.ForwardPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by ForwardPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; case 3: if (TryGetPlugPrefab(overrideData.LeftPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by LeftPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; case 1: if (TryGetPlugPrefab(overrideData.RightPlug, out prefab3)) { Logger.Info(" - Prefab Replaced by RightPlug setting! " + ((Object)prefab3).name); prefab = prefab3; return; } break; } if (overrideData.OverridePlugWithNoGateChance) { Random random = new Random(((LG_ZoneExpander)plug).m_linksFrom.AreaSeed.ToSeed()); bool withGate = ((LG_ZoneExpander)plug).m_isZoneSource || (!(overrideData.PlugWithNoGateChance >= 1f) && (overrideData.PlugWithNoGateChance <= 0f || random.NextFloat() >= overrideData.PlugWithNoGateChance)); int dropHeight = GetDropHeight(plug); GameObject randomPlug = BuilderInfo.GetRandomPlug(random.NextUint(), dropHeight, GetSubComplexOfPlug(plug), withGate); if ((Object)(object)randomPlug == (Object)null) { Logger.Error($"Plug was null! - Height: {dropHeight}"); } else { prefab = randomPlug; } } } private static SubComplex GetSubComplexOfPlug(LG_Plug plug) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) SubComplex result = ((LG_ZoneExpander)plug).m_subComplex; if (((LG_ZoneExpander)plug).m_subComplex != ((LG_ZoneExpander)plug.m_pariedWith).m_subComplex) { result = (SubComplex)8; } return result; } private static bool TryGetPlugPrefab(string prefabPath, out GameObject prefab) { if (string.IsNullOrEmpty(prefabPath)) { prefab = null; return false; } if (EntryPoint.BundleLookup.ContainsKey(prefabPath.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(prefabPath.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == prefabPath.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + prefabPath.ToUpperInvariant()); Object val = item.Value.LoadAsset(prefabPath.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(prefabPath.ToUpperInvariant(), val); } catch { } } if (!(item.Key == prefabPath.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info($"loading all assets from bundle {item.Value}"); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val2 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val2); } catch { } } } } Object loadedAsset = AssetAPI.GetLoadedAsset(prefabPath); prefab = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null); return (Object)(object)prefab != (Object)null; } private static int GetDropHeight(LG_Plug plug) { //IL_0006: 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) return Mathf.RoundToInt(Mathf.Abs(((Component)plug).transform.position.y - ((Component)plug.m_pariedWith).transform.position.y) / BuilderInfo.AltitudeOffset); } } [HarmonyPatch(typeof(LG_BuildPlugJob), "Build")] internal class Inject_BuildPlugJob { [HarmonyWrapSafe] private static bool Prefix(LG_BuildPlugJob __instance) { //IL_0022: 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_0054: 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_007d: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected I4, but got Unknown //IL_01cc: 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_01f5: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; LG_Plug plug = __instance.m_plug; Logger.Info($"buildplugjob plug in complex {((LG_ZoneExpander)plug).m_subComplex} plug status {((LG_ZoneExpander)plug).ExpanderStatus} plug direction {plug.m_dir} .."); if ((int)((LG_ZoneExpander)plug).ExpanderStatus == 1) { return true; } if (((LG_ZoneExpander)plug).m_isZoneSource) { return true; } if (!BuilderInfo.TryGetConfig(((LG_ZoneExpander)plug).m_linksFrom.m_zone, out var config)) { return true; } LG_GridPosition normal = ((LG_ZoneExpander)plug).m_linksFrom.m_geomorph.m_tile.m_shape.m_gridPosition.GetNormal(config.GridSize); if (!config.TryGetTileData(normal, out var overrideData)) { return true; } LG_PlugDir dir = plug.m_dir; GameObject prefab; switch (dir - 2) { case 0: if (TryGetPlugPrefab(overrideData.BackwardPlug, out prefab)) { Logger.Info(" - Prefab Replaced by BackwardPlug setting! " + ((Object)prefab).name); val = prefab; } break; case 2: if (TryGetPlugPrefab(overrideData.ForwardPlug, out prefab)) { Logger.Info(" - Prefab Replaced by ForwardPlug setting! " + ((Object)prefab).name); val = prefab; } break; case 3: if (TryGetPlugPrefab(overrideData.LeftPlug, out prefab)) { Logger.Info(" - Prefab Replaced by LeftPlug setting! " + ((Object)prefab).name); val = prefab; } break; case 1: if (TryGetPlugPrefab(overrideData.RightPlug, out prefab)) { Logger.Info(" - Prefab Replaced by RightPlug setting! " + ((Object)prefab).name); val = prefab; } break; } if ((Object)(object)val != (Object)null) { Logger.Info($"we shall replace a cap going {plug.m_dir}"); Vector3 position = ((Component)plug).transform.position; Quaternion rotation = ((Component)plug).transform.rotation; GameObject val2 = Object.Instantiate<GameObject>(val, position, rotation); val2.transform.SetParent(((Component)plug).transform, true); LG_Factory.FindAndBuildSelectorsAndSpawners(val2, RandomExtensions.NextSubSeed(__instance.m_rnd.Random), false); __instance.ProcessDivider(plug, val2, false, RandomExtensions.NextSubSeed(__instance.m_rnd.Random)); ((LG_ZoneExpander)plug).m_wasProcessed = true; } return true; } private static bool TryGetPlugPrefab(string prefabPath, out GameObject prefab) { if (string.IsNullOrEmpty(prefabPath)) { prefab = null; return false; } if (EntryPoint.BundleLookup.ContainsKey(prefabPath.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(prefabPath.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == prefabPath.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + prefabPath.ToUpperInvariant()); Object val = item.Value.LoadAsset(prefabPath.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(prefabPath.ToUpperInvariant(), val); } catch { } } if (!(item.Key == prefabPath.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info($"loading all assets from bundle {item.Value}"); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val2 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val2); } catch { } } } } prefab = ((Il2CppObjectBase)AssetAPI.GetLoadedAsset(prefabPath)).Cast<GameObject>(); return (Object)(object)prefab != (Object)null; } } [HarmonyPatch(typeof(LG_LevelBuilder), "PlaceRoot")] internal static class Inject_BuildGeomorph { private static LayoutConfig _configContext; private static LayoutConfig _configContext2; private static RotateType _nextRotateType; [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch("BuildFloor")] private static void Post_BuildFloor() { BuilderInfo.OnResourceSetSelected(); } [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch("PlaceRoot")] private static void Pre_PlaceRoot(LG_Tile tile, ref GameObject tilePrefab, ref bool forceAlignToVector, ref Vector3 alignVector, LG_Zone zone) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) _configContext = null; _nextRotateType = RotateType.None; forceAlignToVector = alignVector != Vector3.zero; int gridSize = zone.Dimension.GetGridSize(); LG_GridPosition val = tile.ToNormalGrid(gridSize); Logger.Info($"tile info: {val.x} {val.z} {((Object)tilePrefab).name} for {zone.LocalIndex} : {zone.DimensionIndex}"); if (!BuilderInfo.TryGetConfig(zone, out _configContext)) { return; } if (!_configContext.TryGetTileData(val, out var overrideData)) { overrideData = _configContext.PopulateTileOverrideForZone(zone, val); if (overrideData == null) { return; } } if (!string.IsNullOrEmpty(overrideData.Geomorph)) { if (overrideData.X == 0 && overrideData.Z == 0) { return; } if (EntryPoint.BundleLookup.ContainsKey(overrideData.Geomorph.ToUpperInvariant()) && !AssetShardManager.s_loadedAssetsLookup.ContainsKey(overrideData.Geomorph.ToUpperInvariant())) { foreach (KeyValuePair<string, AssetBundle> item in EntryPoint.BundleLookup) { if (item.Key == overrideData.Geomorph.ToUpperInvariant() && !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { Logger.Info("loading bundle asset prefab " + overrideData.Geomorph.ToUpperInvariant()); Object val2 = item.Value.LoadAsset(overrideData.Geomorph.ToUpperInvariant()); try { AssetShardManager.s_loadedAssetsLookup.Add(overrideData.Geomorph.ToUpperInvariant(), val2); } catch { } } if (!(item.Key == overrideData.Geomorph.ToUpperInvariant()) || !EntryPoint.BundleLoadAllLookup.Contains(item.Value)) { continue; } Logger.Info("loading all assets from bundle " + ((Object)item.Value).name); foreach (string item2 in (Il2CppArrayBase<string>)(object)item.Value.GetAllAssetNames()) { Object val3 = item.Value.LoadAsset(item2); try { AssetShardManager.s_loadedAssetsLookup.Add(item2.ToUpperInvariant(), val3); } catch { } } } } Object loadedAsset = AssetAPI.GetLoadedAsset(overrideData.Geomorph); GameObject val4 = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null); if ((Object)(object)val4 != (Object)null) { Logger.Info(" - tile overriden! " + ((Object)val4).name); tilePrefab = val4; } } if (overrideData.Rotation != 0) { _nextRotateType = overrideData.Rotation; } } [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch("GetTilePosition")] private static void Post_GetTilePosition(LG_Tile tile, LG_Floor floor, int dimensionIndex, ref Vector3 __result) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (_configContext != null && floor.TryGetDimension(dimensionIndex, out var dimension)) { int gridSize = _configContext.GridSize; LG_GridPosition val = tile.ToNormalGrid(gridSize); if (_configContext.TryGetTileData(val, out var overrideData) && overrideData.OverrideAltitude) { Vector3 positionNormal = dimension.Grid.GetPositionNormal(val.x, val.z, gridSize); positionNormal += new Vector3(0f, (float)overrideData.Altitude * BuilderInfo.AltitudeOffset, 0f); __result = positionNormal; } } } [HarmonyPostfix] [HarmonyWrapSafe] [HarmonyPatch("PlaceRoot")] private static void Post_PlaceRoot(LG_Tile tile, LG_Zone zone, LG_Geomorph __result) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown if (_configContext == null) { return; } if (_nextRotateType != 0) { GameObject gameObject = ((Component)__result).gameObject; LG_PlugInfo lG_PlugInfo = LG_PlugInfo.BuildPlugInfo(gameObject, gameObject.transform.rotation); Logger.Info($" - TRYING ROTATION! PLUG COUNT: {lG_PlugInfo.Count}"); if (lG_PlugInfo.TryGetNewRotation(zone.m_subSeed, _nextRotateType, out var rotation)) { Logger.Info(" - Done!"); gameObject.transform.rotation = rotation; } __result.SetPlaced(); } int gridSize = _configContext.GridSize; LG_GridPosition normalGridPosition = tile.ToNormalGrid(gridSize); if (!_configContext.TryGetTileData(normalGridPosition, out var overrideData)) { return; } if (overrideData.OverrideAreaSeeds) { if (overrideData.AreaSeeds.Length == ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length) { int length = ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length; for (int i = 0; i < length; i++) { uint num = overrideData.AreaSeeds[i]; if (num != 0) { ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas)[i].AreaSeed = num; Logger.Info($" - new area seed: {((Il2CppArrayBase<LG_Area>)(object)__result.m_areas)[i].m_navInfo}, {num}"); } } } else { Logger.Error($" - Area count and AreaSeeds item count mismatched! (CFG: {overrideData.AreaSeeds.Length} != AREA: {((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length}) Area seed will not be applied!"); } } if (!zone.m_settings.HasCustomGeomorphPrefab) { iLG_CustomGeomorphLogic[] array = Il2CppArrayBase<iLG_CustomGeomorphLogic>.op_Implicit(((Component)__result).GetComponentsInChildren<iLG_CustomGeomorphLogic>()); for (int j = 0; j < array.Length; j++) { array[j].SpawnedOnFloor(); LG_Factory.InjectJob((LG_FactoryJob)new LG_CustomGeomorphBuildJob(array[j]), (BatchName)45); LG_Factory.InjectJob((LG_FactoryJob)new LG_CustomGeomorphPostCullingJob(array[j]), (BatchName)64); } } } [HarmonyPrefix] [HarmonyWrapSafe] [HarmonyPatch(typeof(LG_ZoneJob_CreateExpandFromData), "Build")] private static void Pre_ZoneJob(LG_ZoneJob_CreateExpandFromData __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (!__instance.m_zone.m_settings.HasCustomGeomorphInstance || (int)__instance.m_mainStatus != 5) { return; } TileOverrideData overrideData = null; if ((Object)(object)Builder.CurrentFloor == (Object)null) { return; } if (BuilderInfo.TryGetConfig(__instance.m_zone, out _configContext2)) { int gridSize = _configContext2.GridSize; LG_GridPosition normalGridPosition = __instance.m_zone.m_settings.CustomGeomorphInstance.GetComponent<LG_Geomorph>().m_tile.ToNormalGrid(gridSize); _configContext2.TryGetTileData(normalGridPosition, out overrideData); } if (overrideData == null || !overrideData.TryForceCustomGeoAreaAssignment) { return; } Logger.Info(" - addcustomgeomorphareas firing for " + ((Object)__instance.m_zone.NavInfo).ToString()); Dictionary<LG_Area, float> dictionary = new Dictionary<LG_Area, float>(); Enumerator<LG_Area> enumerator = __instance.m_zone.m_areas.GetEnumerator(); while (enumerator.MoveNext()) { LG_Area current = enumerator.Current; float num = 1000f; if (current.m_zone.ID == 0 && (Object)(object)current == (Object)(object)current.m_zone.m_areas[0]) { num = 2000f; } if ((Object)(object)current == (Object)(object)current.m_zone.m_sourceExpander.m_linksTo) { num = 1500f; } dictionary.Add(current, num - Vector3.Distance(current.Position, __instance.m_zone.m_sourceExpander.m_linksFrom.Position)); } IOrderedEnumerable<KeyValuePair<LG_Area, float>> orderedEnumerable = dictionary.OrderByDescending((KeyValuePair<LG_Area, float> listdict) => listdict.Value); __instance.m_zone.m_areas.Clear(); foreach (KeyValuePair<LG_Area, float> item in orderedEnumerable) { Logger.Info($" - addcustomgeomorphareas scoredict {((Object)item.Key).name} {item.Value}"); if (!__instance.m_zone.m_areas.Contains(item.Key)) { __instance.m_zone.m_areas.Add(item.Key); } foreach (LG_InternalGate componentsInChild in ((Component)item.Key).gameObject.GetComponentsInChildren<LG_InternalGate>(true)) { if ((Object)(object)((LG_ZoneExpander)componentsInChild).m_linksFrom != (Object)null && !__instance.m_zone.m_areas.Contains(((LG_ZoneExpander)componentsInChild).m_linksFrom)) { Logger.Info(" - addcustomgeomorphareas adding m_linksFrom " + ((Object)((LG_ZoneExpander)componentsInChild).m_linksFrom).name); __instance.m_zone.m_areas.Add(((LG_ZoneExpander)componentsInChild).m_linksFrom); } if ((Object)(object)((LG_ZoneExpander)componentsInChild).m_linksTo != (Object)null && !__instance.m_zone.m_areas.Contains(((LG_ZoneExpander)componentsInChild).m_linksTo)) { Logger.Info(" - addcustomgeomorphareas adding m_linksTo " + ((Object)((LG_ZoneExpander)componentsInChild).m_linksTo).name); __instance.m_zone.m_areas.Add(((LG_ZoneExpander)componentsInChild).m_linksTo); } } } } } [HarmonyPatch(typeof(LG_LoadComplexDataSetResourcesJob), "Build")] internal static class Inject_LoadComplexShard { private static int _waitingShared; private static void Prefix(LG_LoadComplexDataSetResourcesJob __instance) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected I4, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00bb: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_loadingStarted) { return; } if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("StairsFix", out var _) && !EntryPoint.StairsFixed) { Transform transform = ((Component)AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Complex/Dimensions/Desert/Dimension_Desert_Mining_Shaft.prefab").GetComponentsInChildren<LG_Ladder>()[2]).gameObject.transform; transform.position += new Vector3(0f, 0f, -1.5f); Logger.Info("navmesh fix on Dimension_Desert_Mining_Shaft.prefab (StairsFix) done"); EntryPoint.StairsFixed = true; } foreach (Complex item in BuilderInfo.ExtraComplexResourceToLoad) { AssetBundleName val = (AssetBundleName)((int)item switch { 0 => 2, 1 => 4, 2 => 3, _ => 0, }); if ((int)val != 0) { AssetShardManager.LoadAllShardsForBundleAsync(val, Action.op_Implicit((Action)Loaded), 1, (LoadSceneMode)1); _waitingShared++; } } } private static void Loaded() { _waitingShared--; } [HarmonyWrapSafe] private static void Postfix(LG_LoadComplexDataSetResourcesJob __instance, ref bool __result) { if (_waitingShared >= 1) { __result = false; } } } } namespace LGTuner.Configs { public sealed class LayoutConfig { private TileOverrideData[,] _builtTileOverrides = new TileOverrideData[0, 0]; public uint LevelLayoutID { get; set; } public Complex[] ExtraComplexResourceToLoad { get; set; } = Array.Empty<Complex>(); public ZoneOverrideData[] ZoneOverrides { get; set; } = Array.Empty<ZoneOverrideData>(); public TileOverrideData[] TileOverrides { get; set; } = Array.Empty<TileOverrideData>(); [JsonIgnore] public int GridSize { get; private set; } [JsonIgnore] public int GridSizeHalf { get; private set; } public void Reset(int gridSize) { Array.ForEach(ZoneOverrides, delegate(ZoneOverrideData item) { item.Clear(); }); Array.Clear(_builtTileOverrides, 0, _builtTileOverrides.Length); GridSize = gridSize; GridSizeHalf = gridSize / 2; _builtTileOverrides = new TileOverrideData[GridSize, GridSize]; TileOverrideData[] tileOverrides = TileOverrides; foreach (TileOverrideData tileOverrideData in tileOverrides) { if (_builtTileOverrides[tileOverrideData.X + GridSizeHalf, tileOverrideData.Z + GridSizeHalf] == null) { PutOverrideData(tileOverrideData); continue; } Logger.Error($"Duplicate tile data in layout: {LevelLayoutID}, ({tileOverrideData.X}, {tileOverrideData.Z})!"); } } public bool TryGetTileData(LG_GridPosition normalGridPosition, out TileOverrideData overrideData) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) int num = normalGridPosition.x + GridSizeHalf; if (num >= GridSize) { Logger.Error($"TryGetTileData grid x was out of range! {num}:{GridSize}"); overrideData = null; return false; } int num2 = normalGridPosition.z + GridSizeHalf; if (num2 >= GridSize) { Logger.Error($"TryGetTileData grid Z was out of range! {num2}:{GridSize}"); overrideData = null; return false; } overrideData = _builtTileOverrides[num, num2]; return overrideData != null; } public void PutOverrideData(TileOverrideData data) { _builtTileOverrides[data.X + GridSizeHalf, data.Z + GridSizeHalf] = data; } public TileOverrideData PopulateTileOverrideForZone(LG_Zone zone, LG_GridPosition normalGridPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0047: Unknown result type (might be due to invalid IL or missing references) if (!TryGetZoneOverride(zone.LocalIndex, out var data)) { return null; } if (TryGetTileData(normalGridPosition, out var overrideData)) { overrideData.ZoneData = data; TryApplyOverrides(data, overrideData); return overrideData; } TileOverrideData tileOverrideData = new TileOverrideData { ZoneData = data, X = normalGridPosition.x, Z = normalGridPosition.z, OverridePlugWithNoGateChance = data.OverridePlugWithNoGateChance, PlugWithNoGateChance = data.PlugWithNoGateChance }; TryApplyOverrides(data, tileOverrideData); PutOverrideData(tileOverrideData); return tileOverrideData; } private void TryApplyOverrides(ZoneOverrideData zoneOverrideData, TileOverrideData tileOverrideData) { if (zoneOverrideData.OverrideGeomorphs && string.IsNullOrEmpty(tileOverrideData.Geomorph)) { ZoneOverrideData.GeomorphData? nextGeo = zoneOverrideData.GetNextGeo(); if (nextGeo.HasValue) { tileOverrideData.Geomorph = nextGeo.Value.Geomorph; if (tileOverrideData.Rotation == RotateTy