using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using HarmonyLib; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Managing; using Il2CppFishNet.Managing.Object; using Il2CppFishNet.Object; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1MAPI.Building.Components; using S1MAPI.Building.Config; using S1MAPI.Building.Interior; using S1MAPI.Building.Structural; using S1MAPI.Core; using S1MAPI.Extensions; using S1MAPI.Gltf.Data; using S1MAPI.Gltf.Processing; using S1MAPI.ProceduralMesh; using S1MAPI.ProceduralMesh.Generators.Primitives; using S1MAPI.S1; using S1MAPI.Utils; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("S1MAPI Contributors")] [assembly: AssemblyConfiguration("Il2cpp")] [assembly: AssemblyDescription("A mapping and construction library for Schedule 1 mods, providing procedural mesh generation, building construction, and GLTF loading while remaining update-resilient.")] [assembly: AssemblyFileVersion("2.0.1.0")] [assembly: AssemblyInformationalVersion("2.0.1+25b579ddb004b9fbebb610d0a78d6e051d310d52")] [assembly: AssemblyProduct("S1MAPI_Il2cpp")] [assembly: AssemblyTitle("S1MAPI_Il2cpp")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ifBars/S1MAPI")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 S1MAPI.Utils { internal static class Constants { public static class Layers { public const string DEFAULT = "Default"; public const string IGNORE_RAYCAST = "Ignore Raycast"; } public static class Tags { public const string UNTAGGED = "Untagged"; } public static class Mesh { public const int MaxVerticesPerMesh = 65535; public const float VertexWeldThreshold = 0.001f; public const int DefaultCylinderSegments = 12; public const int DefaultSphereSubdivisions = 8; public const int DefaultCapsuleSubdivisions = 6; } public static class Materials { public const float DefaultTransparencyAlpha = 0.5f; public const float WindowGlassAlpha = 0.35f; public const float GlassAlpha = 0.3f; public const string TreadWoodName = "wood brown"; public const string RiserWoodName = "wood_beige"; public const string StringerTreadWoodName = "mansion_brownwood_mat"; public const string StringerBeamWoodName = "wood brown"; } public static class Resources { public const float DefaultPixelsPerUnit = 100f; } public static class Spatial { public const float DefaultGridSize = 0.5f; public const float DefaultMaxStepHeight = 0.2f; public const float DefaultStepDepth = 0.3f; public const float FoundationPadding = 0.1f; public const string StairsFolderName = "Stairs"; public const string FoundationFolderName = "Foundation"; } public static class Window { public const float DefaultDividerWidth = 0.15f; public const float MaxPaneWidth = 2f; public const float MinPaneWidth = 0.3f; public const float MinGap = 0.15f; public const float SideMargin = 0.5f; public const float VerticalMargin = 1.2f; public const float MinDoorSideWidth = 1f; public const float FrameDepth = 0.05f; public const float FrameWidth = 0.1f; public const float SegmentThreshold = 0.01f; public const float MaxDoorStripWidth = 0.5f; public const float MinDoorStripWidth = 0.3f; public const float DoorStripMargin = 0.4f; public const string FrameNamePrefix = "Frame"; public const string GlassNameSubstring = "Glass"; } public static class Roof { public const float DeepParapetHeight = 0.6f; public const float DeepCapHeight = 0.25f; public const float DeepCapOverhang = 0.15f; public const float ShallowParapetHeight = 0.3f; public const float ShallowCapHeight = 0.15f; public const float ShallowCapOverhang = 0.05f; public const float ParapetDepthPadding = 0.1f; public const float DefaultRidgeHeight = 2f; public const float DefaultOverhang = 0.3f; public const float DefaultBaseSlabHeight = 0.15f; public const string RoofSlopeMaterialName = "mansion_roof_mat"; public const float DefaultRoofColorR = 0.45f; public const float DefaultRoofColorG = 0.35f; public const float DefaultRoofColorB = 0.3f; } public static class NavMesh { public const float MinRampWidth = 3f; public const float RampErosionBuffer = 1f; public const float RampColliderThickness = 0.1f; } public static class InteriorNav { public const float MaxGridCellSize = 0.5f; public const float WallMargin = 0.15f; public const float ChaseRepathInterval = 0.2f; public const float WaypointArrivalThreshold = 0.3f; public const float DestinationArrivalThreshold = 0.5f; public const float DoorwayApproachThreshold = 4f; public const float StairApproachThreshold = 1.5f; public const float PhaseTransitionThreshold = 0.15f; public const float StairMaxEntryDistance = 3f; public const float ExteriorAngleCorrectionThreshold = 1f; public const float ExitStuckTimeout = 3f; public const float ExitStuckDisplacementSq = 0.25f; public const float RotationSpeed = 360f; } public static class InteriorWall { public const float MinWallLength = 0.5f; public const float SegmentThreshold = 0.01f; } public static class Terrain { public const float DefaultClearingPadding = 2f; public static readonly string[] DefaultVegetationKeywords = new string[6] { "Rock", "Boulder", "Shrub", "Bush", "Tree rustle", "Foliage" }; public static readonly string[] DefaultProtectedKeywords = new string[3] { "Road", "Sidewalk", "Wedge" }; public const float DefaultFlattenPadding = 0.5f; public const float DefaultBlendDistance = 3f; } public static class Gltf { public const uint GlbMagic = 1179937895u; public const uint ChunkTypeJson = 1313821514u; public const uint ChunkTypeBin = 5130562u; public const int SupportedVersion = 2; public const string DefaultModelName = "GltfModel"; } public const string LIBRARY_NAME = "S1MAPI"; public const string LIBRARY_VERSION = "2.0.1"; public const string LIBRARY_AUTHOR = "Bars"; public const string MIN_UNITY_VERSION = "2019.4"; public const string RECOMMENDED_UNITY_VERSION = "2022.3.62f2"; } internal static class DebugLog { private static bool _debugEnabled = true; public static bool DebugEnabled { get { return _debugEnabled; } set { _debugEnabled = value; } } public static void Info(string message) { if (_debugEnabled) { Debug.Log(Object.op_Implicit("[S1MAPI] " + message)); } } public static void Warning(string message) { if (_debugEnabled) { Debug.LogWarning(Object.op_Implicit("[S1MAPI] " + message)); } } public static void Error(string message) { Debug.LogError(Object.op_Implicit("[S1MAPI] " + message)); } public static void Exception(Exception ex) { CrossException.LogException(ex); } public static void InfoFormat(string format, params object[] args) { if (_debugEnabled) { Info(string.Format(format, args)); } } public static void WarningFormat(string format, params object[] args) { if (_debugEnabled) { Warning(string.Format(format, args)); } } public static void ErrorFormat(string format, params object[] args) { Error(string.Format(format, args)); } } public static class EmbeddedResourceLoader { public static byte[]? LoadBytes(string resourceName, Assembly? assembly = null) { if (string.IsNullOrEmpty(resourceName)) { DebugLog.Error("Resource name cannot be null or empty"); return null; } Assembly assembly2 = assembly ?? Assembly.GetCallingAssembly(); try { using Stream stream = assembly2.GetManifestResourceStream(resourceName); if (stream == null) { DebugLog.Warning("Embedded resource not found: " + resourceName); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); DebugLog.Info($"Loaded {array.Length} bytes from embedded resource: {resourceName}"); return array; } catch (Exception ex) { DebugLog.Error("Failed to load embedded resource: " + resourceName); DebugLog.Exception(ex); return null; } } public static Texture2D? LoadTexture(string resourceName, Assembly? assembly = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown byte[] array = LoadBytes(resourceName, assembly); if (array == null) { return null; } Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, Il2CppStructArray.op_Implicit(array))) { DebugLog.Error("Failed to load image data from resource: " + resourceName); Object.Destroy((Object)(object)val); return null; } ((Object)val).name = "MAPI_" + Path.GetFileNameWithoutExtension(resourceName); DebugLog.Info($"Loaded texture: {((Object)val).name} ({((Texture)val).width}x{((Texture)val).height})"); return val; } public static Sprite? LoadSprite(string resourceName, Assembly? assembly = null, float pixelsPerUnit = 100f) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadTexture(resourceName, assembly); if ((Object)(object)val == (Object)null) { return null; } Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), pixelsPerUnit); ((Object)val2).name = "MAPI_" + Path.GetFileNameWithoutExtension(resourceName) + "_Sprite"; DebugLog.Info("Created sprite from texture: " + ((Object)val2).name); return val2; } public static bool ResourceExists(string resourceName, Assembly? assembly = null) { if (string.IsNullOrEmpty(resourceName)) { return false; } Assembly assembly2 = assembly ?? Assembly.GetCallingAssembly(); using Stream stream = assembly2.GetManifestResourceStream(resourceName); return stream != null; } public static string[] ListResources(Assembly? assembly = null) { Assembly assembly2 = assembly ?? Assembly.GetCallingAssembly(); return assembly2.GetManifestResourceNames(); } } internal static class Il2CppListExtensions { public static IEnumerable AsEnumerable(this List list) { return list ?? new List(); } public static List ToIl2CppList(this IEnumerable source) { List val = new List(); foreach (T item in source) { val.Add(item); } return val; } public static List ToCSharpList(this List il2CppList) { if (il2CppList == null) { return new List(); } List list = new List(); T[] collection = Il2CppArrayBase.op_Implicit(il2CppList.ToArray()); list.AddRange(collection); return list; } public static IEnumerable AsEnumerable(this List list) { if (list == null) { return new List(); } return ((IEnumerable)list._items).Take(list._size); } } internal static class CrossType { public static Type Of() { return Il2CppType.Of(); } public static Type ToRuntimeType(Type systemType) { return Il2CppType.From(systemType); } public static bool Is(object obj, out T result) where T : Object { Object val = (Object)((obj is Object) ? obj : null); if (val != null) { Type val2 = Il2CppType.Of(); Type il2CppType = val.GetIl2CppType(); if (val2.IsAssignableFrom(il2CppType)) { result = ((Il2CppObjectBase)val).TryCast(); return result != null; } } result = default(T); return false; } } internal static class CrossException { public static void LogException(Exception ex) { Debug.LogError(Object.op_Implicit($"[Exception] {ex.GetType().Name}: {ex.Message}\n{ex.StackTrace}")); } public static void LogException(string message, Exception ex) { Debug.LogError(Object.op_Implicit($"[Exception] {message}: {ex.GetType().Name}: {ex.Message}\n{ex.StackTrace}")); } } public static class MaterialPresets { internal static Shader? _defaultShader; public static Shader DefaultShader { get { if ((Object)(object)_defaultShader == (Object)null) { _defaultShader = Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)_defaultShader == (Object)null) { DebugLog.Warning("URP Lit shader not found, trying Standard shader"); _defaultShader = Shader.Find("Standard"); } if ((Object)(object)_defaultShader == (Object)null) { DebugLog.Warning("Standard shader not found, falling back to Internal-Colored"); _defaultShader = Shader.Find("Hidden/Internal-Colored"); } } return _defaultShader; } set { _defaultShader = value; } } public static Material FromTextureName(string textureName, Color? color = null) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) Texture val = Resources.Load(textureName); if ((Object)(object)val == (Object)null) { Texture2D[] array = Il2CppArrayBase.op_Implicit(Resources.FindObjectsOfTypeAll()); Texture2D[] array2 = array; foreach (Texture2D val2 in array2) { if (((Object)val2).name.Equals(textureName, StringComparison.OrdinalIgnoreCase)) { val = (Texture)(object)val2; break; } } } if ((Object)(object)val == (Object)null) { DebugLog.Warning("Could not find texture '" + textureName + "' in Resources or Memory."); return Opaque((Color)(((??)color) ?? Color.white)); } Material val3 = new Material(DefaultShader); ((Object)val3).name = "MAPI_Texture_" + ((Object)val).name; if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", val); } if (val3.HasProperty("_BaseMap")) { val3.SetTexture("_BaseMap", val); } if (color.HasValue) { val3.color = color.Value; if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", color.Value); } } ApplyStandardProperties(val3); return val3; } public static Material? FindExistingMaterial(string materialName) { Material val = Resources.Load(materialName); if ((Object)(object)val != (Object)null) { return val; } Material[] array = Il2CppArrayBase.op_Implicit(Resources.FindObjectsOfTypeAll()); Material[] array2 = array; foreach (Material val2 in array2) { if (((Object)val2).name.Equals(materialName, StringComparison.OrdinalIgnoreCase) || ((Object)val2).name.Contains(materialName)) { return val2; } } return null; } public unsafe static Material Opaque(Color color, Shader? shader = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0039: Expected O, but got Unknown Shader val = shader ?? DefaultShader; Material val2 = new Material(val) { name = "MAPI_Opaque_" + ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString(), color = color }; ApplyStandardProperties(val2); if (val2.HasProperty("_Mode")) { val2.SetFloat("_Mode", 0f); } if (val2.HasProperty("_SrcBlend")) { val2.SetInt("_SrcBlend", 1); } if (val2.HasProperty("_DstBlend")) { val2.SetInt("_DstBlend", 0); } if (val2.HasProperty("_ZWrite")) { val2.SetInt("_ZWrite", 1); } val2.DisableKeyword("_ALPHATEST_ON"); val2.DisableKeyword("_ALPHABLEND_ON"); val2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val2.renderQueue = -1; return val2; } public unsafe static Material Transparent(Color color, float alpha = 0.5f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0062: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown Material val = new Material(DefaultShader) { name = $"MAPI_Transparent_{((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString()}_{alpha}", color = new Color(color.r, color.g, color.b, alpha) }; ApplyStandardProperties(val); if (val.HasProperty("_Mode")) { val.SetFloat("_Mode", 3f); } if (val.HasProperty("_SrcBlend")) { val.SetInt("_SrcBlend", 1); } if (val.HasProperty("_DstBlend")) { val.SetInt("_DstBlend", 10); } if (val.HasProperty("_ZWrite")) { val.SetInt("_ZWrite", 0); } val.DisableKeyword("_ALPHATEST_ON"); val.DisableKeyword("_ALPHABLEND_ON"); val.EnableKeyword("_ALPHAPREMULTIPLY_ON"); val.renderQueue = 3000; return val; } public unsafe static Material Glass(Color color, float alpha = 0.3f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Material val = Transparent(color, alpha); ((Object)val).name = $"MAPI_Glass_{((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString()}_{alpha}"; if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.95f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } return val; } public static Material ClearGlass(float alpha = 0.3f, Color? tint = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Color color = (Color)(((??)tint) ?? new Color(0.95f, 0.97f, 1f)); Material val = Transparent(color, alpha); ((Object)val).name = $"MAPI_ClearGlass_a{alpha}"; if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 1f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } return val; } public unsafe static Material Metal(Color color, float metallic = 0.8f, float smoothness = 0.9f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Material val = Opaque(color); ((Object)val).name = "MAPI_Metal_" + ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString(); if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } return val; } public unsafe static Material Emissive(Color color, float intensity = 1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Material val = Opaque(color); ((Object)val).name = "MAPI_Emissive_" + ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString(); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", color * intensity); val.EnableKeyword("_EMISSION"); } return val; } public unsafe static Material CreateFromShader(Shader shader, Color color) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005a: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)shader == (Object)null) { DebugLog.Error("Cannot create material from null shader"); return Opaque(color); } Material val = new Material(shader) { name = "MAPI_" + ((Object)shader).name + "_" + ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString(), color = color }; ApplyStandardProperties(val); return val; } public static void ApplyStandardProperties(Material material) { if ((Object)(object)material == (Object)null) { DebugLog.Warning("Cannot apply properties to null material"); return; } material.enableInstancing = true; if (material.HasProperty("_Glossiness")) { material.SetFloat("_Glossiness", 0.5f); } } } } namespace S1MAPI.S1 { public static class Materials { private static Material? _woodMediumBrown; private static Material? _graniteDullSalmonLighter; private static Material? _brickBrickColored; private static Material? _metalDarkGrey; private static Material? _concreteLightGrey; private static Material? _laundromatGlass; private static Material? _woodCrate; private static Material? _docksGround; private static Material? _concreteDocksRamps; private static Material? _concreteClothingStoreGreen; private static Material? _concreteClothingStoreDarkGreen; private static Material? _straightRoad10m; private static Material? _straightRoad10mNoLines; private static Material? _straightRoad10mDesert; private static Material? _fabricWhite; private static Material? _fabricRed; private static Material? _fabricGreen; private static Material? _fabricDenim; private static Material? _fabricBrown; private static Material? _fabricBlue; private static Material? _fabricBlack; private static Material? _industrialBuildingAUpperWalls; private static Material? _industrialBuildingATopWalls; private static Material? _industrialBuildingARoof; private static Material? _industrialBuildingALowerWalls; private static Material? _industrialBuildingAFoundation; private static Material? _industrialBuildingRollerdoor; private static Material? _metalWarehouseGreen; private static Material? _metalWarehouseTrimGreen; private static Material? _metalMediumGrey; private static Material? _metalVeryDarkGrey; private static Material? _metalLightGrey; private static Material? _metalWhite; private static Material? _woodPlanksMediumBrown; private static Material? _woodPlanksLightBrown; private static Material? _woodPlanksWhite; private static Material? _tilesDarkGrey; private static Material? _smallTileDirtyWhite; private static Material? _concreteParkingLot; private static Material? _windowGlass; private static Material? _chainlinkFenceMetal; private static Material? _industrialMetalDoor; private static Material? _industrialMetalDoorRed; private static Material? _industrialMetalDoorGreen; private static Material? _industrialMetalDoorBlue; private static Material? _industrialMetalDoorYellow; private static Material? _industrialMetalDoorGrey; private static Material? _docksWarehouseMezzanine; private static Material? _docksWarehouseFence; private static Material? _dockswallMain; private static Material? _straightRoad10x4; private static Material? _straightRoad10x4NoLines; private static Material? _straightRoad10x4Sidewalk; private static Material? _industrialBuildingAPillar; private static Material? _industrialBuildingAMiddleTrim; private static Material? _industrialBuildingASmallRoof; public static Material WoodMediumBrown { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_woodMediumBrown == (Object)null) { _woodMediumBrown = MaterialPresets.FindExistingMaterial("wood_mediumbrown"); if ((Object)(object)_woodMediumBrown == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'wood_mediumbrown'. Using fallback."); _woodMediumBrown = MaterialPresets.Opaque(new Color(0.4f, 0.25f, 0.1f)); } } return _woodMediumBrown; } } public static Material GraniteDullSalmonLighter { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_graniteDullSalmonLighter == (Object)null) { _graniteDullSalmonLighter = MaterialPresets.FindExistingMaterial("granite dull salmon lighter"); if ((Object)(object)_graniteDullSalmonLighter == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'granite dull salmon lighter'. Using fallback."); _graniteDullSalmonLighter = MaterialPresets.Opaque(new Color(0.8f, 0.55f, 0.5f)); } } return _graniteDullSalmonLighter; } } public static Material ConcreteLightGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_concreteLightGrey == (Object)null) { _concreteLightGrey = MaterialPresets.FindExistingMaterial("concrete light grey"); if ((Object)(object)_concreteLightGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'concrete light grey'. Using fallback."); _concreteLightGrey = MaterialPresets.Opaque(new Color(0.75f, 0.75f, 0.75f)); } } return _concreteLightGrey; } } public static Material BrickWallRed { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_brickBrickColored == (Object)null) { _brickBrickColored = MaterialPresets.FindExistingMaterial("brick brick colored"); if ((Object)(object)_brickBrickColored == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'brick brick colored'. Using fallback."); _brickBrickColored = MaterialPresets.Opaque(new Color(0.6f, 0.3f, 0.2f)); } } return _brickBrickColored; } } public static Material MetalDarkGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalDarkGrey == (Object)null) { _metalDarkGrey = MaterialPresets.FindExistingMaterial("metal_darkgrey_mat"); if ((Object)(object)_metalDarkGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal_darkgrey_mat'. Using fallback."); _metalDarkGrey = MaterialPresets.Opaque(new Color(0.2f, 0.2f, 0.2f)); } } return _metalDarkGrey; } } public static Material LaundromatGlass { get { if ((Object)(object)_laundromatGlass == (Object)null) { _laundromatGlass = MaterialPresets.FindExistingMaterial("laundromat glass mat"); if ((Object)(object)_laundromatGlass == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'laundromat glass mat'. Using fallback."); _laundromatGlass = MaterialPresets.ClearGlass(); } } return _laundromatGlass; } } public static Material WoodCrate { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_woodCrate == (Object)null) { _woodCrate = MaterialPresets.FindExistingMaterial("wood crate mat"); if ((Object)(object)_woodCrate == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'wood crate mat'. Using fallback."); _woodCrate = MaterialPresets.Opaque(new Color(0.5f, 0.35f, 0.2f)); } } return _woodCrate; } } public static Material WoodPlanksMediumBrown { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_woodPlanksMediumBrown == (Object)null) { _woodPlanksMediumBrown = MaterialPresets.FindExistingMaterial("wood planks medium brown mat"); if ((Object)(object)_woodPlanksMediumBrown == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'wood planks medium brown mat'. Using fallback."); _woodPlanksMediumBrown = MaterialPresets.Opaque(new Color(0.45f, 0.3f, 0.15f)); } } return _woodPlanksMediumBrown; } } public static Material WoodPlanksLightBrown { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_woodPlanksLightBrown == (Object)null) { _woodPlanksLightBrown = MaterialPresets.FindExistingMaterial("wood planks light brown mat"); if ((Object)(object)_woodPlanksLightBrown == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'wood planks light brown mat'. Using fallback."); _woodPlanksLightBrown = MaterialPresets.Opaque(new Color(0.55f, 0.4f, 0.25f)); } } return _woodPlanksLightBrown; } } public static Material WoodPlanksWhite { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_woodPlanksWhite == (Object)null) { _woodPlanksWhite = MaterialPresets.FindExistingMaterial("wood planks white"); if ((Object)(object)_woodPlanksWhite == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'wood planks white'. Using fallback."); _woodPlanksWhite = MaterialPresets.Opaque(new Color(0.9f, 0.9f, 0.9f)); } } return _woodPlanksWhite; } } public static Material DocksGround { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_docksGround == (Object)null) { _docksGround = MaterialPresets.FindExistingMaterial("docks ground"); if ((Object)(object)_docksGround == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'docks ground'. Using fallback."); _docksGround = MaterialPresets.Opaque(new Color(0.35f, 0.35f, 0.3f)); } } return _docksGround; } } public static Material ConcreteDocksRamps { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_concreteDocksRamps == (Object)null) { _concreteDocksRamps = MaterialPresets.FindExistingMaterial("concrete_docks_ramps"); if ((Object)(object)_concreteDocksRamps == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'concrete_docks_ramps'. Using fallback."); _concreteDocksRamps = MaterialPresets.Opaque(new Color(0.5f, 0.5f, 0.5f)); } } return _concreteDocksRamps; } } public static Material DocksWarehouseMezzanine { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_docksWarehouseMezzanine == (Object)null) { _docksWarehouseMezzanine = MaterialPresets.FindExistingMaterial("docks warehouse mezzanine mat"); if ((Object)(object)_docksWarehouseMezzanine == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'docks warehouse mezzanine mat'. Using fallback."); _docksWarehouseMezzanine = MaterialPresets.Opaque(new Color(0.4f, 0.4f, 0.35f)); } } return _docksWarehouseMezzanine; } } public static Material DocksWarehouseFence { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_docksWarehouseFence == (Object)null) { _docksWarehouseFence = MaterialPresets.FindExistingMaterial("docks warehouse fence mat"); if ((Object)(object)_docksWarehouseFence == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'docks warehouse fence mat'. Using fallback."); _docksWarehouseFence = MaterialPresets.Opaque(new Color(0.3f, 0.3f, 0.25f)); } } return _docksWarehouseFence; } } public static Material DockswallMain { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_dockswallMain == (Object)null) { _dockswallMain = MaterialPresets.FindExistingMaterial("dockswall_Main mat"); if ((Object)(object)_dockswallMain == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'dockswall_Main mat'. Using fallback."); _dockswallMain = MaterialPresets.Opaque(new Color(0.45f, 0.45f, 0.4f)); } } return _dockswallMain; } } public static Material FabricWhite { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricWhite == (Object)null) { _fabricWhite = MaterialPresets.FindExistingMaterial("fabric white"); if ((Object)(object)_fabricWhite == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric white'. Using fallback."); _fabricWhite = MaterialPresets.Opaque(new Color(0.95f, 0.95f, 0.95f)); } } return _fabricWhite; } } public static Material FabricRed { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricRed == (Object)null) { _fabricRed = MaterialPresets.FindExistingMaterial("fabric red"); if ((Object)(object)_fabricRed == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric red'. Using fallback."); _fabricRed = MaterialPresets.Opaque(new Color(0.7f, 0.2f, 0.2f)); } } return _fabricRed; } } public static Material FabricGreen { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricGreen == (Object)null) { _fabricGreen = MaterialPresets.FindExistingMaterial("fabric green"); if ((Object)(object)_fabricGreen == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric green'. Using fallback."); _fabricGreen = MaterialPresets.Opaque(new Color(0.2f, 0.5f, 0.3f)); } } return _fabricGreen; } } public static Material FabricDenim { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricDenim == (Object)null) { _fabricDenim = MaterialPresets.FindExistingMaterial("fabric denim"); if ((Object)(object)_fabricDenim == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric denim'. Using fallback."); _fabricDenim = MaterialPresets.Opaque(new Color(0.25f, 0.35f, 0.55f)); } } return _fabricDenim; } } public static Material FabricBrown { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricBrown == (Object)null) { _fabricBrown = MaterialPresets.FindExistingMaterial("fabric brown"); if ((Object)(object)_fabricBrown == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric brown'. Using fallback."); _fabricBrown = MaterialPresets.Opaque(new Color(0.4f, 0.25f, 0.15f)); } } return _fabricBrown; } } public static Material FabricBlue { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricBlue == (Object)null) { _fabricBlue = MaterialPresets.FindExistingMaterial("fabric blue"); if ((Object)(object)_fabricBlue == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric blue'. Using fallback."); _fabricBlue = MaterialPresets.Opaque(new Color(0.2f, 0.3f, 0.6f)); } } return _fabricBlue; } } public static Material FabricBlack { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fabricBlack == (Object)null) { _fabricBlack = MaterialPresets.FindExistingMaterial("fabric black"); if ((Object)(object)_fabricBlack == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'fabric black'. Using fallback."); _fabricBlack = MaterialPresets.Opaque(new Color(0.15f, 0.15f, 0.15f)); } } return _fabricBlack; } } public static Material IndustrialBuildingAUpperWalls { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingAUpperWalls == (Object)null) { _industrialBuildingAUpperWalls = MaterialPresets.FindExistingMaterial("industrialbuildingA_UpperWalls mat"); if ((Object)(object)_industrialBuildingAUpperWalls == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_UpperWalls mat'. Using fallback."); _industrialBuildingAUpperWalls = MaterialPresets.Opaque(new Color(0.6f, 0.6f, 0.55f)); } } return _industrialBuildingAUpperWalls; } } public static Material IndustrialBuildingATopWalls { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingATopWalls == (Object)null) { _industrialBuildingATopWalls = MaterialPresets.FindExistingMaterial("industrialbuildingA_TopWalls mat"); if ((Object)(object)_industrialBuildingATopWalls == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_TopWalls mat'. Using fallback."); _industrialBuildingATopWalls = MaterialPresets.Opaque(new Color(0.55f, 0.55f, 0.5f)); } } return _industrialBuildingATopWalls; } } public static Material IndustrialBuildingARoof { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingARoof == (Object)null) { _industrialBuildingARoof = MaterialPresets.FindExistingMaterial("industrialbuildingA_Roof mat"); if ((Object)(object)_industrialBuildingARoof == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_Roof mat'. Using fallback."); _industrialBuildingARoof = MaterialPresets.Opaque(new Color(0.25f, 0.25f, 0.25f)); } } return _industrialBuildingARoof; } } public static Material IndustrialBuildingASmallRoof { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingASmallRoof == (Object)null) { _industrialBuildingASmallRoof = MaterialPresets.FindExistingMaterial("industrialbuildingA_SmallRoof mat"); if ((Object)(object)_industrialBuildingASmallRoof == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_SmallRoof mat'. Using fallback."); _industrialBuildingASmallRoof = MaterialPresets.Opaque(new Color(0.3f, 0.3f, 0.3f)); } } return _industrialBuildingASmallRoof; } } public static Material IndustrialBuildingALowerWalls { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingALowerWalls == (Object)null) { _industrialBuildingALowerWalls = MaterialPresets.FindExistingMaterial("industrialbuildingA_LowerWalls mat"); if ((Object)(object)_industrialBuildingALowerWalls == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_LowerWalls mat'. Using fallback."); _industrialBuildingALowerWalls = MaterialPresets.Opaque(new Color(0.5f, 0.5f, 0.45f)); } } return _industrialBuildingALowerWalls; } } public static Material IndustrialBuildingAFoundation { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingAFoundation == (Object)null) { _industrialBuildingAFoundation = MaterialPresets.FindExistingMaterial("industrialbuildingA_Foundation mat"); if ((Object)(object)_industrialBuildingAFoundation == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_Foundation mat'. Using fallback."); _industrialBuildingAFoundation = MaterialPresets.Opaque(new Color(0.35f, 0.35f, 0.35f)); } } return _industrialBuildingAFoundation; } } public static Material IndustrialBuildingAPillar { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingAPillar == (Object)null) { _industrialBuildingAPillar = MaterialPresets.FindExistingMaterial("industrialbuildingA_Pillar mat"); if ((Object)(object)_industrialBuildingAPillar == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_Pillar mat'. Using fallback."); _industrialBuildingAPillar = MaterialPresets.Opaque(new Color(0.45f, 0.45f, 0.4f)); } } return _industrialBuildingAPillar; } } public static Material IndustrialBuildingAMiddleTrim { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingAMiddleTrim == (Object)null) { _industrialBuildingAMiddleTrim = MaterialPresets.FindExistingMaterial("industrialbuildingA_MiddleTrim mat"); if ((Object)(object)_industrialBuildingAMiddleTrim == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuildingA_MiddleTrim mat'. Using fallback."); _industrialBuildingAMiddleTrim = MaterialPresets.Opaque(new Color(0.4f, 0.4f, 0.35f)); } } return _industrialBuildingAMiddleTrim; } } public static Material IndustrialBuildingRollerdoor { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialBuildingRollerdoor == (Object)null) { _industrialBuildingRollerdoor = MaterialPresets.FindExistingMaterial("industrialbuilding rollerdoor mat"); if ((Object)(object)_industrialBuildingRollerdoor == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrialbuilding rollerdoor mat'. Using fallback."); _industrialBuildingRollerdoor = MaterialPresets.Opaque(new Color(0.3f, 0.3f, 0.35f)); } } return _industrialBuildingRollerdoor; } } public static Material ConcreteClothingStoreGreen { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_concreteClothingStoreGreen == (Object)null) { _concreteClothingStoreGreen = MaterialPresets.FindExistingMaterial("concrete clothing store green"); if ((Object)(object)_concreteClothingStoreGreen == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'concrete clothing store green'. Using fallback."); _concreteClothingStoreGreen = MaterialPresets.Opaque(new Color(0.6f, 0.65f, 0.6f)); } } return _concreteClothingStoreGreen; } } public static Material ConcreteClothingStoreDarkGreen { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_concreteClothingStoreDarkGreen == (Object)null) { _concreteClothingStoreDarkGreen = MaterialPresets.FindExistingMaterial("concrete clothing store dark green"); if ((Object)(object)_concreteClothingStoreDarkGreen == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'concrete clothing store dark green'. Using fallback."); _concreteClothingStoreDarkGreen = MaterialPresets.Opaque(new Color(0.4f, 0.45f, 0.4f)); } } return _concreteClothingStoreDarkGreen; } } public static Material StraightRoad10m { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_straightRoad10m == (Object)null) { _straightRoad10m = MaterialPresets.FindExistingMaterial("straight road 10m mat"); if ((Object)(object)_straightRoad10m == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'straight road 10m mat'. Using fallback."); _straightRoad10m = MaterialPresets.Opaque(new Color(0.25f, 0.25f, 0.25f)); } } return _straightRoad10m; } } public static Material StraightRoad10mNoLines { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_straightRoad10mNoLines == (Object)null) { _straightRoad10mNoLines = MaterialPresets.FindExistingMaterial("straight road 10m mat nolines"); if ((Object)(object)_straightRoad10mNoLines == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'straight road 10m mat nolines'. Using fallback."); _straightRoad10mNoLines = MaterialPresets.Opaque(new Color(0.25f, 0.25f, 0.25f)); } } return _straightRoad10mNoLines; } } public static Material StraightRoad10mDesert { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_straightRoad10mDesert == (Object)null) { _straightRoad10mDesert = MaterialPresets.FindExistingMaterial("straight road 10m mat desert"); if ((Object)(object)_straightRoad10mDesert == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'straight road 10m mat desert'. Using fallback."); _straightRoad10mDesert = MaterialPresets.Opaque(new Color(0.55f, 0.5f, 0.4f)); } } return _straightRoad10mDesert; } } public static Material StraightRoad10x4 { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_straightRoad10x4 == (Object)null) { _straightRoad10x4 = MaterialPresets.FindExistingMaterial("straight road 10x4 mat"); if ((Object)(object)_straightRoad10x4 == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'straight road 10x4 mat'. Using fallback."); _straightRoad10x4 = MaterialPresets.Opaque(new Color(0.25f, 0.25f, 0.25f)); } } return _straightRoad10x4; } } public static Material StraightRoad10x4NoLines { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_straightRoad10x4NoLines == (Object)null) { _straightRoad10x4NoLines = MaterialPresets.FindExistingMaterial("straight road 10x4 mat nolines"); if ((Object)(object)_straightRoad10x4NoLines == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'straight road 10x4 mat nolines'. Using fallback."); _straightRoad10x4NoLines = MaterialPresets.Opaque(new Color(0.25f, 0.25f, 0.25f)); } } return _straightRoad10x4NoLines; } } public static Material StraightRoad10x4Sidewalk { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_straightRoad10x4Sidewalk == (Object)null) { _straightRoad10x4Sidewalk = MaterialPresets.FindExistingMaterial("straight road 10x4 sidewalk mat"); if ((Object)(object)_straightRoad10x4Sidewalk == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'straight road 10x4 sidewalk mat'. Using fallback."); _straightRoad10x4Sidewalk = MaterialPresets.Opaque(new Color(0.7f, 0.7f, 0.7f)); } } return _straightRoad10x4Sidewalk; } } public static Material MetalWarehouseGreen { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalWarehouseGreen == (Object)null) { _metalWarehouseGreen = MaterialPresets.FindExistingMaterial("metal warehouse green mat"); if ((Object)(object)_metalWarehouseGreen == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal warehouse green mat'. Using fallback."); _metalWarehouseGreen = MaterialPresets.Opaque(new Color(0.25f, 0.4f, 0.3f)); } } return _metalWarehouseGreen; } } public static Material MetalWarehouseTrimGreen { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalWarehouseTrimGreen == (Object)null) { _metalWarehouseTrimGreen = MaterialPresets.FindExistingMaterial("metal warehouse trim green mat"); if ((Object)(object)_metalWarehouseTrimGreen == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal warehouse trim green mat'. Using fallback."); _metalWarehouseTrimGreen = MaterialPresets.Opaque(new Color(0.2f, 0.35f, 0.25f)); } } return _metalWarehouseTrimGreen; } } public static Material MetalMediumGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalMediumGrey == (Object)null) { _metalMediumGrey = MaterialPresets.FindExistingMaterial("metal_mediumgrey_mat"); if ((Object)(object)_metalMediumGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal_mediumgrey_mat'. Using fallback."); _metalMediumGrey = MaterialPresets.Opaque(new Color(0.45f, 0.45f, 0.45f)); } } return _metalMediumGrey; } } public static Material MetalVeryDarkGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalVeryDarkGrey == (Object)null) { _metalVeryDarkGrey = MaterialPresets.FindExistingMaterial("metal_verydarkgrey_mat"); if ((Object)(object)_metalVeryDarkGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal_verydarkgrey_mat'. Using fallback."); _metalVeryDarkGrey = MaterialPresets.Opaque(new Color(0.15f, 0.15f, 0.15f)); } } return _metalVeryDarkGrey; } } public static Material MetalLightGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalLightGrey == (Object)null) { _metalLightGrey = MaterialPresets.FindExistingMaterial("metal_lightgrey_mat"); if ((Object)(object)_metalLightGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal_lightgrey_mat'. Using fallback."); _metalLightGrey = MaterialPresets.Opaque(new Color(0.65f, 0.65f, 0.65f)); } } return _metalLightGrey; } } public static Material MetalWhite { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_metalWhite == (Object)null) { _metalWhite = MaterialPresets.FindExistingMaterial("metal white"); if ((Object)(object)_metalWhite == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'metal white'. Using fallback."); _metalWhite = MaterialPresets.Opaque(new Color(0.9f, 0.9f, 0.9f)); } } return _metalWhite; } } public static Material IndustrialMetalDoor { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialMetalDoor == (Object)null) { _industrialMetalDoor = MaterialPresets.FindExistingMaterial("industrial metal door mat"); if ((Object)(object)_industrialMetalDoor == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrial metal door mat'. Using fallback."); _industrialMetalDoor = MaterialPresets.Opaque(new Color(0.35f, 0.35f, 0.4f)); } } return _industrialMetalDoor; } } public static Material IndustrialMetalDoorRed { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialMetalDoorRed == (Object)null) { _industrialMetalDoorRed = MaterialPresets.FindExistingMaterial("industrial metal door red mat"); if ((Object)(object)_industrialMetalDoorRed == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrial metal door red mat'. Using fallback."); _industrialMetalDoorRed = MaterialPresets.Opaque(new Color(0.5f, 0.2f, 0.2f)); } } return _industrialMetalDoorRed; } } public static Material IndustrialMetalDoorGreen { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialMetalDoorGreen == (Object)null) { _industrialMetalDoorGreen = MaterialPresets.FindExistingMaterial("industrial metal door green mat"); if ((Object)(object)_industrialMetalDoorGreen == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrial metal door green mat'. Using fallback."); _industrialMetalDoorGreen = MaterialPresets.Opaque(new Color(0.2f, 0.4f, 0.3f)); } } return _industrialMetalDoorGreen; } } public static Material IndustrialMetalDoorBlue { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialMetalDoorBlue == (Object)null) { _industrialMetalDoorBlue = MaterialPresets.FindExistingMaterial("industrial metal door blue mat"); if ((Object)(object)_industrialMetalDoorBlue == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrial metal door blue mat'. Using fallback."); _industrialMetalDoorBlue = MaterialPresets.Opaque(new Color(0.2f, 0.25f, 0.5f)); } } return _industrialMetalDoorBlue; } } public static Material IndustrialMetalDoorYellow { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialMetalDoorYellow == (Object)null) { _industrialMetalDoorYellow = MaterialPresets.FindExistingMaterial("industrial metal door yellow mat"); if ((Object)(object)_industrialMetalDoorYellow == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrial metal door yellow mat'. Using fallback."); _industrialMetalDoorYellow = MaterialPresets.Opaque(new Color(0.7f, 0.7f, 0.2f)); } } return _industrialMetalDoorYellow; } } public static Material IndustrialMetalDoorGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_industrialMetalDoorGrey == (Object)null) { _industrialMetalDoorGrey = MaterialPresets.FindExistingMaterial("industrial metal door grey mat"); if ((Object)(object)_industrialMetalDoorGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'industrial metal door grey mat'. Using fallback."); _industrialMetalDoorGrey = MaterialPresets.Opaque(new Color(0.4f, 0.4f, 0.4f)); } } return _industrialMetalDoorGrey; } } public static Material ChainlinkFenceMetal { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_chainlinkFenceMetal == (Object)null) { _chainlinkFenceMetal = MaterialPresets.FindExistingMaterial("chainlinkfence metal mat"); if ((Object)(object)_chainlinkFenceMetal == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'chainlinkfence metal mat'. Using fallback."); _chainlinkFenceMetal = MaterialPresets.Opaque(new Color(0.5f, 0.5f, 0.5f)); } } return _chainlinkFenceMetal; } } public static Material TilesDarkGrey { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_tilesDarkGrey == (Object)null) { _tilesDarkGrey = MaterialPresets.FindExistingMaterial("tiles_darkgrey"); if ((Object)(object)_tilesDarkGrey == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'tiles_darkgrey'. Using fallback."); _tilesDarkGrey = MaterialPresets.Opaque(new Color(0.3f, 0.3f, 0.3f)); } } return _tilesDarkGrey; } } public static Material SmallTileDirtyWhite { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_smallTileDirtyWhite == (Object)null) { _smallTileDirtyWhite = MaterialPresets.FindExistingMaterial("small tile dirty white"); if ((Object)(object)_smallTileDirtyWhite == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'small tile dirty white'. Using fallback."); _smallTileDirtyWhite = MaterialPresets.Opaque(new Color(0.8f, 0.8f, 0.75f)); } } return _smallTileDirtyWhite; } } public static Material ConcreteParkingLot { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_concreteParkingLot == (Object)null) { _concreteParkingLot = MaterialPresets.FindExistingMaterial("concrete_parking_lot"); if ((Object)(object)_concreteParkingLot == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'concrete_parking_lot'. Using fallback."); _concreteParkingLot = MaterialPresets.Opaque(new Color(0.45f, 0.45f, 0.4f)); } } return _concreteParkingLot; } } public static Material WindowGlass { get { if ((Object)(object)_windowGlass == (Object)null) { _windowGlass = MaterialPresets.FindExistingMaterial("window_glass_material"); if ((Object)(object)_windowGlass == (Object)null) { DebugLog.Warning("[S1.Materials] Could not find 'window_glass_material'. Using fallback."); _windowGlass = MaterialPresets.ClearGlass(); } } return _windowGlass; } } public static Material? Find(string name) { return MaterialPresets.FindExistingMaterial(name); } } public static class Meshes { public static readonly MeshRef Door = new MeshRef("SM_Door"); public static readonly MeshRef DoorDouble = new MeshRef("SM_DoorDouble"); public static readonly MeshRef DoorFrame = new MeshRef("SM_Door_Frame"); public static readonly MeshRef DoorDoubleFrame = new MeshRef("SM_DoubleDoor_Frame"); public static readonly MeshRef GarageDoor = new MeshRef("SM_GarageDoor"); public static readonly MeshRef GarageDoorFrame = new MeshRef("SM_GarageDoor_Frame"); public static readonly MeshRef GarageDoorButton = new MeshRef("SM_GarageDoor_Button"); public static readonly MeshRef Chair = new MeshRef("Chair"); public static readonly MeshRef Armchair = new MeshRef("Armchair"); public static readonly MeshRef Bench = new MeshRef("Bench"); public static readonly MeshRef CoffeeTable = new MeshRef("CoffeeTable"); public static readonly MeshRef Desk = new MeshRef("Desk"); public static readonly MeshRef Bed = new MeshRef("Bed"); public static readonly MeshRef BedsideDrawer = new MeshRef("Bedside_Drawer"); public static readonly MeshRef Fridge = new MeshRef("Fridge"); public static readonly MeshRef OfficeTable = new MeshRef("Office_table"); public static readonly MeshRef Safe = new MeshRef("Safe"); public static readonly MeshRef Frontdesk = new MeshRef("Frontdesk"); public static readonly MeshRef DeskPedestal = new MeshRef("Desk"); public static readonly MeshRef Box = new MeshRef("Box"); public static readonly MeshRef Barrel = new MeshRef("Barrel"); public static readonly MeshRef PlantBox = new MeshRef("PlantBox"); public static readonly MeshRef Planter = new MeshRef("Planter"); public static readonly MeshRef Bin = new MeshRef("Bin"); public static readonly MeshRef Dumpster = new MeshRef("Dumpster"); public static readonly MeshRef DumpsterCover = new MeshRef("Dumpster_Cover"); public static readonly MeshRef Cabinet = new MeshRef("Cabinet1"); public static readonly MeshRef Drawer = new MeshRef("Drawer"); public static readonly MeshRef LockerShelf = new MeshRef("Locker_Shelf"); public static readonly MeshRef Vase = new MeshRef("SM_Prop_Vase_02"); public static readonly MeshRef Plant = new MeshRef("SM_Prop_Plant_02"); public static readonly MeshRef NoSmokingSign = new MeshRef("Nonsmoking sign"); public static readonly MeshRef Cigarette = new MeshRef("SM_Prop_Cigarette_Long_01"); public static readonly MeshRef SmokePipe = new MeshRef("SM_Prop_SmokePipe_01"); public static readonly MeshRef Syringe = new MeshRef("SM_Prop_Syringe_02"); public static readonly MeshRef Beaker = new MeshRef("Beaker"); public static readonly MeshRef Bottle = new MeshRef("Bottle"); public static readonly MeshRef Cup = new MeshRef("Cup"); public static readonly MeshRef Mug = new MeshRef("Mug"); public static readonly MeshRef Basketball = new MeshRef("Basketball"); public static readonly MeshRef Computer = new MeshRef("Computer"); public static readonly MeshRef Keyboard = new MeshRef("Keyboard"); public static readonly MeshRef Mouse = new MeshRef("Mouse"); public static readonly MeshRef Screen = new MeshRef("Screen"); public static readonly MeshRef Clock = new MeshRef("Clock"); public static readonly MeshRef Hammer = new MeshRef("Hammer"); public static readonly MeshRef Magazine = new MeshRef("Magazine"); public static readonly MeshRef Notepad = new MeshRef("Notepad"); public static readonly MeshRef LabTankSmall = new MeshRef("SM_Prop_Lab_Tank_01"); public static readonly MeshRef LabTankLarge = new MeshRef("SM_Prop_Lab_Tank_03"); public static readonly MeshRef BarrierPlastic = new MeshRef("SM_Prop_Barrier_Plastic_01"); public static readonly MeshRef SecurityCamera = new MeshRef("SM_Prop_Security_Camera_01"); public static readonly MeshRef PowerBoxes = new MeshRef("SM_Prop_PowerBoxes_01"); public static readonly MeshRef RubberMat = new MeshRef("SM_Prop_RubberMat_01"); public static readonly MeshRef Barricade = new MeshRef("Barricade"); public static readonly MeshRef Barrier = new MeshRef("Barrier"); public static readonly MeshRef Bollard = new MeshRef("Bollard"); public static readonly MeshRef Generator = new MeshRef("SM_Prop_Generator_01_Convex"); public static readonly MeshRef Cauldron = new MeshRef("Cauldron"); public static readonly MeshRef Conveyor = new MeshRef("Conveyor"); public static readonly MeshRef Extractor = new MeshRef("Extractor"); public static readonly MeshRef Mixer = new MeshRef("Mixer"); public static readonly MeshRef Fusebox = new MeshRef("Fusebox2"); public static readonly MeshRef Alarm = new MeshRef("Alarm"); public static readonly MeshRef Intercom = new MeshRef("Intercom"); public static readonly MeshRef Lightswitch = new MeshRef("Lightswitch"); public static readonly MeshRef Mailbox = new MeshRef("Mailbox1"); public static readonly MeshRef GarbageBag = new MeshRef("Garbage bag"); public static readonly MeshRef Arcade = new MeshRef("Arcade"); public static readonly MeshRef Billboard = new MeshRef("Billboard"); public static readonly MeshRef BusStop = new MeshRef("Bus stop (2024112815191238)"); public static readonly MeshRef PayPhone = new MeshRef("PayPhone_low"); public static readonly MeshRef PalletRack = new MeshRef("Pallet rack (20241127234446952)"); public static readonly MeshRef OutdoorFence = new MeshRef("2m outdoor fence (202532147291)"); public static readonly MeshRef Fence = new MeshRef("Fence"); public static readonly MeshRef Hoop = new MeshRef("Hoop"); public static readonly MeshRef Pillar = new MeshRef("SM_Pillar"); public static readonly MeshRef Ladder = new MeshRef("SM_Ladder"); public static readonly MeshRef WallSmall = new MeshRef("SM_SmallWall"); public static readonly MeshRef WallMedium = new MeshRef("SM_MediumWall"); public static readonly MeshRef WallLarge = new MeshRef("SM_LargelWall"); public static readonly MeshRef WallSide = new MeshRef("SM_SideWall"); public static readonly MeshRef WindowSmall = new MeshRef("SM_SmallWindow"); public static readonly MeshRef ACUnit = new MeshRef("SM_AC_Unit"); public static readonly MeshRef AC = new MeshRef("SM_AC"); public static readonly MeshRef ACInteriorUnit = new MeshRef("AC_Interior_Unit"); public static readonly MeshRef ACPipeLong = new MeshRef("AC_Pipe_Long"); public static readonly MeshRef ACPipeMedium = new MeshRef("AC_Pipe_Medium"); public static readonly MeshRef ACPipeSideRight = new MeshRef("AC_Pipe_Side_Right"); public static readonly MeshRef ACPipeSideLeft = new MeshRef("AC_Pipe_Side_left"); public static readonly MeshRef Revolver = new MeshRef("Revolver"); public static readonly MeshRef Machete = new MeshRef("Machete"); public static readonly MeshRef FryingPan = new MeshRef("FryingPan"); public static readonly MeshRef M1911 = new MeshRef("M1911"); public static readonly MeshRef BaseballBat = new MeshRef("BaseballBat"); public static readonly MeshRef BrutDugLoop = new MeshRef("brutdugloop"); public static readonly MeshRef ChateauLaPeePee = new MeshRef("chateaulapeepee"); public static readonly MeshRef GoldBar = new MeshRef("goldbar"); public static readonly MeshRef Jukebox = new MeshRef("jukebox"); public static readonly MeshRef MetalSign = new MeshRef("metalsign"); public static readonly MeshRef OldManJimmys = new MeshRef("oldmanjimmys"); public static readonly MeshRef Paintings = new MeshRef("paintings"); public static readonly MeshRef Toilet = new MeshRef("toilet"); public static readonly MeshRef WallClock = new MeshRef("wallclock"); public static readonly MeshRef WoodenSign = new MeshRef("woodensign"); public static MeshRef Custom(string meshName) { return new MeshRef(meshName); } } public static class Prefabs { public static readonly PrefabRef SlidingDoors = new PrefabRef("Dealership Sliding Doors"); public static readonly PrefabRef SlidingGlassDoor = new PrefabRef("Sliding Glass Door"); public static readonly PrefabRef MetalGlassDoor = new PrefabRef("Basic Metal Glass Door"); public static readonly PrefabRef ClassicalWoodenDoor = new PrefabRef("Classical Wooden door"); public static readonly PrefabRef IndustrialMetalDoorPeephole = new PrefabRef("Industrial Metal Door Peephole"); public static readonly PrefabRef IndustrialMetalDoor = new PrefabRef("Industrial Metal Door"); public static readonly PrefabRef BaseDoor = new PrefabRef("BaseDoor"); public static readonly PrefabRef CashRegister = new PrefabRef("CashRegister"); public static readonly PrefabRef ATM = new PrefabRef("ATM"); public static readonly PrefabRef CigaretteBox = new PrefabRef("CigaretteBox_Trash"); public static readonly PrefabRef CigaretteLit = new PrefabRef("Cigarette_Lit"); public static readonly PrefabRef Cigarette = new PrefabRef("Cigarette_Trash"); public static readonly PrefabRef CigaretteUsed = new PrefabRef("Cigarette_Used_Trash"); public static readonly PrefabRef Beaker = new PrefabRef("Beaker"); public static readonly PrefabRef StirringRod = new PrefabRef("StirringRod"); public static readonly PrefabRef MeasuringJug = new PrefabRef("MeasuringJug"); public static readonly PrefabRef Hammer = new PrefabRef("Hammer"); public static readonly PrefabRef BaseballBat = new PrefabRef("BaseballBat_"); public static readonly PrefabRef FryingPan = new PrefabRef("FryingPan_"); public static readonly PrefabRef M1911 = new PrefabRef("M1911_"); public static readonly PrefabRef Machete = new PrefabRef("Machete_"); public static readonly PrefabRef Revolver = new PrefabRef("Revolver_"); public static readonly PrefabRef M1911Magazine = new PrefabRef("Magazine_"); public static readonly PrefabRef RevolverCylinder = new PrefabRef("RevolverCylinder_"); public static readonly PrefabRef Skateboard = new PrefabRef("Skateboard"); public static readonly PrefabRef CheapSkateboard = new PrefabRef("CheapSkateboard"); public static readonly PrefabRef CruiserSkateboard = new PrefabRef("Cruiser"); public static readonly PrefabRef GoldenSkateboard = new PrefabRef("GoldSkateboard"); public static readonly PrefabRef LightweightSkateboard = new PrefabRef("LightweightSkateboard"); public static readonly PrefabRef AntiqueWallLamp = new PrefabRef("AntiqueWallLamp_Built"); public static readonly PrefabRef FloorLamp = new PrefabRef("FloorLamp"); public static readonly PrefabRef FullSpectrumLight = new PrefabRef("FullSpectrumLight_Built"); public static readonly PrefabRef HalogenLight = new PrefabRef("HalogenLight"); public static readonly PrefabRef LEDLight = new PrefabRef("LEDLight"); public static readonly PrefabRef ModernWallLamp = new PrefabRef("ModernWallLamp_Built"); public static readonly PrefabRef MetalShelf = new PrefabRef("Metal Shelf"); public static readonly PrefabRef WoodenCrate = new PrefabRef("Wooden Crate"); public static readonly PrefabRef CoffeeTable = new PrefabRef("CoffeeTable_Built"); public static readonly PrefabRef MetalSquareTable = new PrefabRef("MetalSquareTable"); public static readonly PrefabRef WoodSquareTable = new PrefabRef("WoodSquareTable"); public static readonly PrefabRef SingleBed = new PrefabRef("SingleBed"); public static readonly PrefabRef FloorRack = new PrefabRef("FloorRack"); public static readonly PrefabRef GrandfatherClock = new PrefabRef("GrandfatherClock_Built"); public static readonly PrefabRef TV = new PrefabRef("TV_Built"); public static readonly PrefabRef Television = new PrefabRef("tv"); public static readonly PrefabRef Safe = new PrefabRef("Safe"); public static readonly PrefabRef SmallSafe = new PrefabRef("Small Safe"); public static readonly PrefabRef Dumpster = new PrefabRef("Dumpster_Built"); public static readonly PrefabRef TrashCan = new PrefabRef("TrashCan_Built"); public static readonly PrefabRef SmallTrashCan = new PrefabRef("SmallTrashCan_Built"); public static readonly PrefabRef WallMountedShelf = new PrefabRef("WallMountedShelf_Built"); public static readonly PrefabRef DisplayCabinet = new PrefabRef("DisplayCabinet_Built"); public static readonly PrefabRef FilingCabinet = new PrefabRef("FilingCabinet_Built"); public static readonly PrefabRef SafeBuilt = new PrefabRef("Safe_Built"); public static readonly PrefabRef PasscodePanel = new PrefabRef("Passcode Panel (Functional)"); public static readonly PrefabRef ModularSwitch = new PrefabRef("ModularSwitch"); public static readonly PrefabRef BrickPress = new PrefabRef("BrickPress"); public static readonly PrefabRef Cauldron = new PrefabRef("Cauldron_Built"); public static readonly PrefabRef ChemistryStation = new PrefabRef("ChemistryStation_Built"); public static readonly PrefabRef DryingRack = new PrefabRef("DryingRack_Built"); public static readonly PrefabRef LabOven = new PrefabRef("LabOven_Built"); public static readonly PrefabRef LaunderingStation = new PrefabRef("LaunderingStation_Built"); public static readonly PrefabRef MixingStation = new PrefabRef("MixingStation_Built"); public static readonly PrefabRef MixingStationMk2 = new PrefabRef("MixingStationMk2_Built"); public static readonly PrefabRef PackagingStation = new PrefabRef("PackagingStation"); public static readonly PrefabRef PackagingStationMk2 = new PrefabRef("PackagingStation_Mk2"); public static readonly PrefabRef FluorescentLight = new PrefabRef("Fluorescent Light"); public static PrefabRef Custom(string prefabName) { return new PrefabRef(prefabName); } } } namespace S1MAPI.Gltf { public sealed class GltfImporter { private const uint GLB_MAGIC = 1179937895u; private const uint CHUNK_TYPE_JSON = 1313821514u; private const uint CHUNK_TYPE_BIN = 5130562u; private readonly GltfImportOptions _options; private string? _basePath; public GltfImporter() { _options = new GltfImportOptions(); } public GltfImporter(GltfImportOptions options) { _options = options ?? new GltfImportOptions(); } public GltfImporter SetName(string name) { _options.RootName = name; return this; } public GltfImporter SetShader(Shader shader) { _options.Shader = shader; return this; } public GltfImporter SetScale(float scale) { _options.ScaleFactor = scale; return this; } public GltfImporter ImportAnimations(bool import) { _options.ImportAnimations = import; return this; } public GltfImporter ImportSkins(bool import) { _options.ImportSkins = import; return this; } public GltfImporter ImportBlendShapes(bool import) { _options.ImportBlendShapes = import; return this; } public GltfImporter ImportCameras(bool import) { _options.ImportCameras = import; return this; } public GltfImporter ReadableMeshes(bool readable) { _options.ReadableMeshes = readable; return this; } public GltfImporter GenerateNormals(bool generate) { _options.GenerateMissingNormals = generate; return this; } public GltfImporter GenerateTangents(bool generate) { _options.GenerateMissingTangents = generate; return this; } public GltfImporter SetEmissionIntensity(float intensity) { _options.EmissionIntensity = intensity; return this; } public GameObject? Load(byte[] data) { if (data == null || data.Length < 4) { DebugLog.Error("Invalid GLTF data: null or too short"); return null; } uint num = BitConverter.ToUInt32(data, 0); if (num == 1179937895) { return LoadGlb(data); } string json = Encoding.UTF8.GetString(data); return LoadGltfJson(json, null); } public GameObject? LoadGlb(byte[] glbBytes) { if (glbBytes == null || glbBytes.Length < 12) { DebugLog.Error("Invalid GLB data: too short"); return null; } if (!ParseGlbChunks(glbBytes, out GltfRoot root, out byte[] binaryChunk)) { return null; } if (root == null) { DebugLog.Error("Failed to parse GLB root"); return null; } GltfBufferResolver resolver = new GltfBufferResolver(null, binaryChunk); return ImportModel(root, resolver); } public GameObject? LoadFromFile(string filePath) { if (string.IsNullOrEmpty(filePath)) { DebugLog.Error("Invalid file path: null or empty"); return null; } try { if (!File.Exists(filePath)) { DebugLog.Error("File not found: " + filePath); return null; } byte[] data = File.ReadAllBytes(filePath); _basePath = Path.GetDirectoryName(filePath); if (_options.RootName == "GltfModel") { _options.RootName = Path.GetFileNameWithoutExtension(filePath); } return Load(data); } catch (Exception ex) { DebugLog.Error("Failed to load file '" + filePath + "': " + ex.Message); return null; } } public GameObject? LoadGltfJson(string json, string? basePath) { if (string.IsNullOrEmpty(json)) { DebugLog.Error("Invalid GLTF JSON: null or empty"); return null; } GltfRoot gltfRoot; try { gltfRoot = JsonConvert.DeserializeObject(json); } catch (Exception ex) { DebugLog.Error("Failed to parse GLTF JSON: " + ex.Message); return null; } if (gltfRoot == null) { DebugLog.Error("Deserialized GLTF root is null"); return null; } string basePath2 = basePath ?? _basePath; GltfBufferResolver resolver = new GltfBufferResolver(basePath2); return ImportModel(gltfRoot, resolver); } private bool ParseGlbChunks(byte[] glbBytes, out GltfRoot? root, out byte[]? binaryChunk) { root = null; binaryChunk = null; using MemoryStream memoryStream = new MemoryStream(glbBytes); using BinaryReader binaryReader = new BinaryReader(memoryStream); uint num = binaryReader.ReadUInt32(); if (num != 1179937895) { DebugLog.Error($"Invalid GLB magic: 0x{num:X8}"); return false; } uint num2 = binaryReader.ReadUInt32(); if (num2 != 2) { DebugLog.Warning($"GLB version is {num2}, expected 2. Loading may fail."); } uint num3 = binaryReader.ReadUInt32(); if (num3 != glbBytes.Length) { DebugLog.Warning($"GLB length mismatch: header says {num3}, actual {glbBytes.Length}"); } while (memoryStream.Position < memoryStream.Length && memoryStream.Position + 8 <= memoryStream.Length) { uint num4 = binaryReader.ReadUInt32(); uint num5 = binaryReader.ReadUInt32(); if (memoryStream.Position + num4 > memoryStream.Length) { DebugLog.Error("GLB chunk extends beyond file"); return false; } byte[] array = binaryReader.ReadBytes((int)num4); switch (num5) { case 1313821514u: { string text = Encoding.UTF8.GetString(array); try { root = JsonConvert.DeserializeObject(text); } catch (Exception ex) { DebugLog.Error("Failed to parse GLB JSON chunk: " + ex.Message); return false; } break; } case 5130562u: binaryChunk = array; break; } } if (root == null) { DebugLog.Error("GLB file missing JSON chunk"); return false; } return true; } private GameObject? ImportModel(GltfRoot root, GltfBufferResolver resolver) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!resolver.ResolveBuffers(root)) { DebugLog.Error("Failed to resolve GLTF buffers"); return null; } GltfLoadContext gltfLoadContext = new GltfLoadContext(root, resolver, _options); List list = ProcessTextures(gltfLoadContext); List list2 = GltfMaterialProcessor.ProcessMaterials(gltfLoadContext); List list3 = ProcessMeshes(gltfLoadContext); GameObject val = new GameObject(_options.RootName); if (Math.Abs(_options.ScaleFactor - 1f) > 0.0001f) { val.transform.localScale = Vector3.one * _options.ScaleFactor; } ProcessNodes(gltfLoadContext, val, list3, list2); if (_options.ImportAnimations) { List list4 = GltfAnimationProcessor.ProcessAnimations(gltfLoadContext); if (list4.Count > 0) { Animation val2 = val.AddComponent(); foreach (AnimationClip item in list4) { val2.AddClip(item, ((Object)item).name); } if (list4.Count > 0) { val2.clip = list4[0]; } } } DebugLog.Info($"Imported GLTF model '{_options.RootName}': {list3.Count} meshes, {list2.Count} materials, {list.Count} textures, {gltfLoadContext.Animations.Count} animations"); return val; } private List ProcessTextures(GltfLoadContext context) { GltfRoot root = context.Root; List list = new List(); if (root.textures == null) { return list; } foreach (GltfTexture texture in root.textures) { Texture2D val = null; if (texture.source.HasValue && root.images != null && texture.source.Value < root.images.Count) { GltfImage gltfImage = root.images[texture.source.Value]; val = LoadImage(context, gltfImage); if ((Object)(object)val != (Object)null) { ((Object)val).name = texture.name ?? gltfImage.name ?? $"texture_{list.Count}"; if (texture.sampler.HasValue && root.samplers != null && texture.sampler.Value < root.samplers.Count) { ApplySampler(val, root.samplers[texture.sampler.Value]); } } } list.Add(val); context.RegisterTexture(val); } return list; } private Texture2D? LoadImage(GltfLoadContext context, GltfImage image) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown byte[] array = null; if (image.bufferView.HasValue) { array = context.BufferResolver.GetBufferViewData(context.Root, image.bufferView.Value); } else if (!string.IsNullOrEmpty(image.uri) && image.uri.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) { int num = image.uri.IndexOf(','); if (num > 0 && image.uri.Substring(0, num).Contains(";base64")) { try { array = Convert.FromBase64String(image.uri.Substring(num + 1)); } catch { DebugLog.Warning("Failed to decode base64 image data"); } } } if (array == null || array.Length == 0) { return null; } Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, Il2CppStructArray.op_Implicit(array))) { return val; } Object.Destroy((Object)(object)val); return null; } private void ApplySampler(Texture2D tex, GltfSampler sampler) { //IL_001d: 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_0088: Unknown result type (might be due to invalid IL or missing references) if (sampler.wrapS.HasValue) { ((Texture)tex).wrapModeU = GetWrapMode(sampler.wrapS.Value); } if (sampler.wrapT.HasValue) { ((Texture)tex).wrapModeV = GetWrapMode(sampler.wrapT.Value); } if (sampler.minFilter.HasValue || sampler.magFilter.HasValue) { ((Texture)tex).filterMode = GetFilterMode(sampler.minFilter.GetValueOrDefault(), sampler.magFilter.GetValueOrDefault()); } } private static TextureWrapMode GetWrapMode(int mode) { //IL_002b: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } TextureWrapMode result = (TextureWrapMode)(mode switch { 33071 => 1, 33648 => 2, 10497 => 0, _ => 0, }); if (1 == 0) { } return result; } private static FilterMode GetFilterMode(int min, int mag) { //IL_001a: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (min == 9728 || mag == 9728) { return (FilterMode)0; } if (min >= 9984) { return (FilterMode)2; } return (FilterMode)1; } private List ProcessMeshes(GltfLoadContext context) { GltfRoot root = context.Root; byte[] binaryBuffer = root.buffers?[0]?.Data; List list = GltfMeshProcessor.ProcessMeshes(root, binaryBuffer); foreach (GltfMeshResult item in list) { if ((Object)(object)item?.mesh != (Object)null) { context.RegisterMesh(item.mesh); } } return list; } private void ProcessNodes(GltfLoadContext context, GameObject root, List meshResults, List materials) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown GltfRoot root2 = context.Root; if (root2.nodes == null) { return; } Dictionary dictionary = new Dictionary(); for (int i = 0; i < root2.nodes.Count; i++) { GltfNode gltfNode = root2.nodes[i]; GameObject val = new GameObject(gltfNode.name ?? $"node_{i}"); dictionary[i] = val.transform; context.RegisterNodeTransform(i, val.transform); ApplyNodeTransform(val.transform, gltfNode); if (gltfNode.mesh.HasValue && gltfNode.mesh.Value < meshResults.Count) { AttachMesh(val, meshResults[gltfNode.mesh.Value], materials, context); } if (_options.ImportCameras && gltfNode.camera.HasValue && root2.cameras != null && gltfNode.camera.Value < root2.cameras.Count) { AttachCamera(val, root2.cameras[gltfNode.camera.Value]); } } for (int j = 0; j < root2.nodes.Count; j++) { GltfNode gltfNode2 = root2.nodes[j]; Transform val2 = dictionary[j]; if (gltfNode2.children == null) { continue; } foreach (int child in gltfNode2.children) { if (dictionary.TryGetValue(child, out var value) && (Object)(object)value != (Object)null) { value.SetParent(val2, false); } } } foreach (Transform value2 in dictionary.Values) { if ((Object)(object)value2.parent == (Object)null) { value2.SetParent(root.transform, false); } } } private void ApplyNodeTransform(Transform transform, GltfNode node) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) if (node.matrix != null && node.matrix.Length == 16) { Matrix4x4 val = default(Matrix4x4); for (int i = 0; i < 4; i++) { int num = i * 4; ((Matrix4x4)(ref val)).SetColumn(i, new Vector4(node.matrix[num], node.matrix[num + 1], node.matrix[num + 2], node.matrix[num + 3])); } Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3)); Quaternion rotation = ((Matrix4x4)(ref val)).rotation; Vector3 lossyScale = ((Matrix4x4)(ref val)).lossyScale; transform.localPosition = new Vector3(0f - val2.x, val2.y, val2.z); transform.localRotation = new Quaternion(rotation.x, 0f - rotation.y, 0f - rotation.z, rotation.w); transform.localScale = lossyScale; } else { if (node.translation != null && node.translation.Length >= 3) { transform.localPosition = new Vector3(0f - node.translation[0], node.translation[1], node.translation[2]); } if (node.rotation != null && node.rotation.Length >= 4) { transform.localRotation = new Quaternion(node.rotation[0], 0f - node.rotation[1], 0f - node.rotation[2], node.rotation[3]); } if (node.scale != null && node.scale.Length >= 3) { transform.localScale = new Vector3(node.scale[0], node.scale[1], node.scale[2]); } } } private void AttachMesh(GameObject go, GltfMeshResult meshResult, List materials, GltfLoadContext context) { if ((Object)(object)meshResult?.mesh == (Object)null) { return; } MeshFilter val = go.AddComponent(); val.mesh = meshResult.mesh; MeshRenderer val2 = go.AddComponent(); Material[] array = (Material[])(object)new Material[meshResult.mesh.subMeshCount]; Material val3 = null; for (int i = 0; i < meshResult.mesh.subMeshCount; i++) { int num = ((i < meshResult.materialIndices.Length) ? meshResult.materialIndices[i] : (-1)); if (num >= 0 && num < materials.Count) { array[i] = materials[num]; } else if ((Object)(object)val3 == (Object)null) { val3 = GltfMaterialProcessor.CreateDefaultMaterial(context); } else { array[i] = val3; } } ((Renderer)val2).materials = Il2CppReferenceArray.op_Implicit(array); } private void AttachCamera(GameObject go, GltfCamera gltfCamera) { Camera val = go.AddComponent(); if (gltfCamera.type == "perspective" && gltfCamera.perspective != null) { val.orthographic = false; val.fieldOfView = gltfCamera.perspective.yfov * 57.29578f; val.nearClipPlane = gltfCamera.perspective.znear; if (gltfCamera.perspective.zfar.HasValue) { val.farClipPlane = gltfCamera.perspective.zfar.Value; } if (gltfCamera.perspective.aspectRatio.HasValue) { val.aspect = gltfCamera.perspective.aspectRatio.Value; } } else if (gltfCamera.type == "orthographic" && gltfCamera.orthographic != null) { val.orthographic = true; val.orthographicSize = gltfCamera.orthographic.ymag; val.nearClipPlane = gltfCamera.orthographic.znear; val.farClipPlane = gltfCamera.orthographic.zfar; } } } public static class GltfLoader { public static GameObject? Load(byte[] data, Shader? shader = null) { GltfImporter gltfImporter = new GltfImporter(); if ((Object)(object)shader != (Object)null) { gltfImporter.SetShader(shader); } return gltfImporter.Load(data); } public static GameObject? LoadGlb(byte[] glbBytes, Shader? shader = null) { GltfImporter gltfImporter = new GltfImporter(); if ((Object)(object)shader != (Object)null) { gltfImporter.SetShader(shader); } return gltfImporter.LoadGlb(glbBytes); } public static GameObject? LoadFromFile(string filePath, Shader? shader = null) { GltfImporter gltfImporter = new GltfImporter(); if ((Object)(object)shader != (Object)null) { gltfImporter.SetShader(shader); } return gltfImporter.LoadFromFile(filePath); } public static GameObject? LoadFromJson(string json, string basePath, Shader? shader = null) { GltfImporter gltfImporter = new GltfImporter(); if ((Object)(object)shader != (Object)null) { gltfImporter.SetShader(shader); } return gltfImporter.LoadGltfJson(json, basePath); } } } namespace S1MAPI.Gltf.Processing { internal static class GltfAnimationProcessor { public static List ProcessAnimations(GltfLoadContext context) { List list = new List(); GltfRoot root = context.Root; if (root.animations == null || !context.Options.ImportAnimations) { return list; } for (int i = 0; i < root.animations.Count; i++) { GltfAnimation gltfAnim = root.animations[i]; AnimationClip val = CreateAnimationClip(context, gltfAnim, i); if ((Object)(object)val != (Object)null) { list.Add(val); context.RegisterAnimation(val); } } return list; } private static AnimationClip? CreateAnimationClip(GltfLoadContext context, GltfAnimation gltfAnim, int index) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (gltfAnim.channels == null || gltfAnim.samplers == null) { return null; } AnimationClip val = new AnimationClip(); ((Object)val).name = gltfAnim.name ?? $"animation_{index}"; val.legacy = true; foreach (GltfAnimationChannel channel in gltfAnim.channels) { GltfAnimationChannelTarget? target = channel.target; if (target == null || !target.node.HasValue || channel.target.path == null) { continue; } int sampler = channel.sampler; if (sampler < 0 || sampler >= gltfAnim.samplers.Count) { continue; } GltfAnimationSampler gltfAnimationSampler = gltfAnim.samplers[sampler]; int value = channel.target.node.Value; string path = channel.target.path; string nodePath = GetNodePath(context, value); if (string.IsNullOrEmpty(nodePath)) { continue; } float[] array = ReadFloatArray(context, gltfAnimationSampler.input); if (array != null && array.Length != 0) { switch (path) { case "translation": ApplyTranslationAnimation(context, val, gltfAnimationSampler, array, nodePath); break; case "rotation": ApplyRotationAnimation(context, val, gltfAnimationSampler, array, nodePath); break; case "scale": ApplyScaleAnimation(context, val, gltfAnimationSampler, array, nodePath); break; case "weights": ApplyMorphTargetAnimation(context, val, gltfAnimationSampler, array, nodePath, value); break; } } } val.EnsureQuaternionContinuity(); return val; } private static void ApplyTranslationAnimation(GltfLoadContext context, AnimationClip clip, GltfAnimationSampler sampler, float[] times, string nodePath) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = ReadVector3Array(context, sampler.output); if (array == null || array.Length == 0) { return; } bool flag = sampler.interpolation == "CUBICSPLINE"; int num = times.Length; AnimationCurve val = new AnimationCurve(); AnimationCurve val2 = new AnimationCurve(); AnimationCurve val3 = new AnimationCurve(); for (int i = 0; i < num; i++) { float num2 = times[i]; Vector3 val4; if (flag) { int num3 = i * 3 + 1; val4 = ((num3 < array.Length) ? array[num3] : Vector3.zero); } else { int num4 = Math.Min(i, array.Length - 1); val4 = array[num4]; } val.AddKey(num2, 0f - val4.x); val2.AddKey(num2, val4.y); val3.AddKey(num2, val4.z); } clip.SetCurve(nodePath, Il2CppType.Of(), "localPosition.x", val); clip.SetCurve(nodePath, Il2CppType.Of(), "localPosition.y", val2); clip.SetCurve(nodePath, Il2CppType.Of(), "localPosition.z", val3); } private static void ApplyRotationAnimation(GltfLoadContext context, AnimationClip clip, GltfAnimationSampler sampler, float[] times, string nodePath) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Vector4[] array = ReadVector4Array(context, sampler.output); if (array == null || array.Length == 0) { return; } bool flag = sampler.interpolation == "CUBICSPLINE"; int num = times.Length; AnimationCurve val = new AnimationCurve(); AnimationCurve val2 = new AnimationCurve(); AnimationCurve val3 = new AnimationCurve(); AnimationCurve val4 = new AnimationCurve(); for (int i = 0; i < num; i++) { float num2 = times[i]; Vector4 val5; if (flag) { int num3 = i * 3 + 1; val5 = ((num3 < array.Length) ? array[num3] : Vector4.zero); } else { int num4 = Math.Min(i, array.Length - 1); val5 = array[num4]; } val.AddKey(num2, val5.x); val2.AddKey(num2, 0f - val5.y); val3.AddKey(num2, 0f - val5.z); val4.AddKey(num2, val5.w); } clip.SetCurve(nodePath, Il2CppType.Of(), "localRotation.x", val); clip.SetCurve(nodePath, Il2CppType.Of(), "localRotation.y", val2); clip.SetCurve(nodePath, Il2CppType.Of(), "localRotation.z", val3); clip.SetCurve(nodePath, Il2CppType.Of(), "localRotation.w", val4); } private static void ApplyScaleAnimation(GltfLoadContext context, AnimationClip clip, GltfAnimationSampler sampler, float[] times, string nodePath) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = ReadVector3Array(context, sampler.output); if (array == null || array.Length == 0) { return; } bool flag = sampler.interpolation == "CUBICSPLINE"; int num = times.Length; AnimationCurve val = new AnimationCurve(); AnimationCurve val2 = new AnimationCurve(); AnimationCurve val3 = new AnimationCurve(); for (int i = 0; i < num; i++) { float num2 = times[i]; Vector3 val4; if (flag) { int num3 = i * 3 + 1; val4 = ((num3 < array.Length) ? array[num3] : Vector3.one); } else { int num4 = Math.Min(i, array.Length - 1); val4 = array[num4]; } val.AddKey(num2, val4.x); val2.AddKey(num2, val4.y); val3.AddKey(num2, val4.z); } clip.SetCurve(nodePath, Il2CppType.Of(), "localScale.x", val); clip.SetCurve(nodePath, Il2CppType.Of(), "localScale.y", val2); clip.SetCurve(nodePath, Il2CppType.Of(), "localScale.z", val3); } private static void ApplyMorphTargetAnimation(GltfLoadContext context, AnimationClip clip, GltfAnimationSampler sampler, float[] times, string nodePath, int nodeIndex) { //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown if (!context.Options.ImportBlendShapes) { return; } float[] array = ReadFloatArray(context, sampler.output); if (array == null || array.Length == 0) { return; } GltfRoot root = context.Root; if (root.nodes == null || nodeIndex < 0 || nodeIndex >= root.nodes.Count) { return; } GltfNode gltfNode = root.nodes[nodeIndex]; if (!gltfNode.mesh.HasValue || root.meshes == null || gltfNode.mesh.Value >= root.meshes.Count) { return; } GltfMesh gltfMesh = root.meshes[gltfNode.mesh.Value]; int num = 0; if (gltfMesh.primitives != null && gltfMesh.primitives.Count > 0 && gltfMesh.primitives[0].targets != null) { num = gltfMesh.primitives[0].targets.Count; } if (num == 0) { return; } bool flag = sampler.interpolation == "CUBICSPLINE"; int num2 = times.Length; int num3 = (flag ? (num * 3) : num); AnimationCurve[] array2 = (AnimationCurve[])(object)new AnimationCurve[num]; for (int i = 0; i < num; i++) { array2[i] = new AnimationCurve(); } for (int j = 0; j < num2; j++) { float num4 = times[j]; for (int k = 0; k < num; k++) { int num5 = ((!flag) ? (j * num + k) : (j * num3 + num + k)); float num6 = ((num5 < array.Length) ? (array[num5] * 100f) : 0f); array2[k].AddKey(num4, num6); } } for (int l = 0; l < num; l++) { string text = $"blendShape.{l}"; clip.SetCurve(nodePath, Il2CppType.Of(), text, array2[l]); } } private static string? GetNodePath(GltfLoadContext context, int nodeIndex) { Transform nodeTransform = context.GetNodeTransform(nodeIndex); if ((Object)(object)nodeTransform == (Object)null) { return null; } List list = new List(); Transform val = nodeTransform; while ((Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)null) { list.Insert(0, ((Object)val).name); val = val.parent; if (((Object)val).name == context.Options.RootName) { break; } } return string.Join("/", list); } private static float[]? ReadFloatArray(GltfLoadContext context, int accessorIndex) { GltfAccessor accessor = context.GetAccessor(accessorIndex); if (accessor == null) { return null; } byte[] accessorData = context.GetAccessorData(accessorIndex); if (accessorData == null) { return null; } int num = context.GetBufferView(accessor.bufferView.GetValueOrDefault())?.byteStride ?? 4; int count = accessor.count; float[] array = new float[count]; for (int i = 0; i < count; i++) { int num2 = accessor.byteOffset + i * num; if (num2 + 4 <= accessorData.Length) { array[i] = BitConverter.ToSingle(accessorData, num2); } } return array; } private static Vector3[]? ReadVector3Array(GltfLoadContext context, int accessorIndex) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) GltfAccessor accessor = context.GetAccessor(accessorIndex); if (accessor == null) { return null; } byte[] accessorData = context.GetAccessorData(accessorIndex); if (accessorData == null) { return null; } int num = context.GetBufferView(accessor.bufferView.GetValueOrDefault())?.byteStride ?? 12; int count = accessor.count; Vector3[] array = (Vector3[])(object)new Vector3[count]; for (int i = 0; i < count; i++) { int num2 = accessor.byteOffset + i * num; if (num2 + 12 <= accessorData.Length) { float num3 = BitConverter.ToSingle(accessorData, num2); float num4 = BitConverter.ToSingle(accessorData, num2 + 4); float num5 = BitConverter.ToSingle(accessorData, num2 + 8); array[i] = new Vector3(num3, num4, num5); } } return array; } private static Vector4[]? ReadVector4Array(GltfLoadContext context, int accessorIndex) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) GltfAccessor accessor = context.GetAccessor(accessorIndex); if (accessor == null) { return null; } byte[] accessorData = context.GetAccessorData(accessorIndex); if (accessorData == null) { return null; } int num = context.GetBufferView(accessor.bufferView.GetValueOrDefault())?.byteStride ?? 16; int count = accessor.count; Vector4[] array = (Vector4[])(object)new Vector4[count]; for (int i = 0; i < count; i++) { int num2 = accessor.byteOffset + i * num; if (num2 + 16 <= accessorData.Length) { float num3 = BitConverter.ToSingle(accessorData, num2); float num4 = BitConverter.ToSingle(accessorData, num2 + 4); float num5 = BitConverter.ToSingle(accessorData, num2 + 8); float num6 = BitConverter.ToSingle(accessorData, num2 + 12); array[i] = new Vector4(num3, num4, num5, num6); } } return array; } } internal sealed class GltfBufferResolver { private readonly string? _basePath; private readonly byte[]? _glbBinaryChunk; public GltfBufferResolver(byte[] glbBinaryChunk) { _glbBinaryChunk = glbBinaryChunk; _basePath = null; } public GltfBufferResolver(string? basePath) { _basePath = basePath; _glbBinaryChunk = null; } public GltfBufferResolver(string? basePath, byte[]? glbBinaryChunk) { _basePath = basePath; _glbBinaryChunk = glbBinaryChunk; } public bool ResolveBuffers(GltfRoot gltf) { if (gltf.buffers == null || gltf.buffers.Count == 0) { return true; } for (int i = 0; i < gltf.buffers.Count; i++) { GltfBuffer gltfBuffer = gltf.buffers[i]; if (gltfBuffer.Data == null) { byte[] array = ResolveBuffer(gltfBuffer, i); if (array == null) { DebugLog.Error($"Failed to resolve buffer {i}"); return false; } gltfBuffer.Data = array; } } return true; } public byte[]? ResolveBuffer(GltfBuffer buffer, int bufferIndex) { if (string.IsNullOrEmpty(buffer.uri)) { if (bufferIndex == 0 && _glbBinaryChunk != null) { return _glbBinaryChunk; } DebugLog.Error($"Buffer {bufferIndex} has no URI and no GLB binary chunk available"); return null; } if (IsDataUri(buffer.uri)) { return DecodeDataUri(buffer.uri); } return LoadExternalFile(buffer.uri); } public byte[]? GetBufferViewData(GltfRoot gltf, int bufferViewIndex) { if (gltf.bufferViews == null || bufferViewIndex < 0 || bufferViewIndex >= gltf.bufferViews.Count) { return null; } GltfBufferView gltfBufferView = gltf.bufferViews[bufferViewIndex]; if (gltf.buffers == null || gltfBufferView.buffer < 0 || gltfBufferView.buffer >= gltf.buffers.Count) { return null; } GltfBuffer gltfBuffer = gltf.buffers[gltfBufferView.buffer]; if (gltfBuffer.Data == null) { DebugLog.Error($"Buffer {gltfBufferView.buffer} not resolved"); return null; } int byteOffset = gltfBufferView.byteOffset; int byteLength = gltfBufferView.byteLength; if (byteOffset + byteLength > gltfBuffer.Data.Length) { DebugLog.Error($"Buffer view {bufferViewIndex} exceeds buffer bounds"); return null; } byte[] array = new byte[byteLength]; Array.Copy(gltfBuffer.Data, byteOffset, array, 0, byteLength); return array; } private static bool IsDataUri(string uri) { return uri?.StartsWith("data:", StringComparison.OrdinalIgnoreCase) ?? false; } private static byte[]? DecodeDataUri(string uri) { int num = uri.IndexOf(','); if (num < 0) { DebugLog.Error("Invalid data URI: missing comma separator"); return null; } string text = uri.Substring(0, num); string text2 = uri.Substring(num + 1); bool flag = text.Contains(";base64"); try { if (flag) { return Convert.FromBase64String(text2); } string s = Uri.UnescapeDataString(text2); return Encoding.UTF8.GetBytes(s); } catch (Exception ex) { DebugLog.Error("Failed to decode data URI: " + ex.Message); return null; } } private byte[]? LoadExternalFile(string uri) { if (string.IsNullOrEmpty(_basePath)) { DebugLog.Error("Cannot load external file '" + uri + "': no base path specified"); return null; } try { string path = Uri.UnescapeDataString(uri); string path2 = Path.Combine(_basePath, path); path2 = Path.GetFullPath(path2); string fullPath = Path.GetFullPath(_basePath); if (!path2.StartsWith(fullPath, StringComparison.OrdinalIgnoreCase)) { DebugLog.Error("Security: external file '" + uri + "' resolves outside base directory"); return null; } if (!File.Exists(path2)) { DebugLog.Error("External file not found: " + path2); return null; } return File.ReadAllBytes(path2); } catch (Exception ex) { DebugLog.Error("Failed to load external file '" + uri + "': " + ex.Message); return null; } } } internal static class GltfMaterialProcessor { private static class UrpProperty { public const string BaseMap = "_BaseMap"; public const string BumpMap = "_BumpMap"; public const string MetallicGlossMap = "_MetallicGlossMap"; public const string OcclusionMap = "_OcclusionMap"; public const string EmissionMap = "_EmissionMap"; public const string BaseColor = "_BaseColor"; public const string EmissionColor = "_EmissionColor"; public const string Metallic = "_Metallic"; public const string Smoothness = "_Smoothness"; public const string BumpScale = "_BumpScale"; public const string OcclusionStrength = "_OcclusionStrength"; public const string Surface = "_Surface"; public const string Blend = "_Blend"; public const string AlphaClip = "_AlphaClip"; public const string Cutoff = "_Cutoff"; public const string Cull = "_Cull"; public const string SrcBlend = "_SrcBlend"; public const string DstBlend = "_DstBlend"; public const string ZWrite = "_ZWrite"; } private static class UrpShaderName { public const string Lit = "Universal Render Pipeline/Lit"; public const string SimpleLit = "Universal Render Pipeline/Simple Lit"; public const string Unlit = "Universal Render Pipeline/Unlit"; } public static List ProcessMaterials(GltfLoadContext context) { List list = new List(); GltfRoot root = context.Root; if (root.materials == null) { return list; } Shader shader = GetShader(context); if ((Object)(object)shader == (Object)null) { DebugLog.Error("Failed to find URP Lit shader for materials"); return list; } for (int i = 0; i < root.materials.Count; i++) { GltfMaterial gltfMat = root.materials[i]; Material val = CreateMaterial(context, gltfMat, shader, i); list.Add(val); context.RegisterMaterial(val); } return list; } public static Material? CreateDefaultMaterial(GltfLoadContext context) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) Shader shader = GetShader(context); if ((Object)(object)shader == (Object)null) { DebugLog.Error("Failed to find URP shader for default material"); return null; } Material val = new Material(shader); ((Object)val).name = "DefaultGltfMaterial"; SetBaseColor(val, new Color(0.8f, 0.8f, 0.8f, 1f)); SetMetallicSmoothness(val, 0f, 0.5f); context.RegisterMaterial(val); return val; } private static Shader? GetShader(GltfLoadContext context) { if ((Object)(object)context.Options.Shader != (Object)null) { return context.Options.Shader; } Shader val = Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)val != (Object)null) { return val; } val = Shader.Find("Universal Render Pipeline/Simple Lit"); if ((Object)(object)val != (Object)null) { DebugLog.Warning("URP Lit shader not found, using Simple Lit"); return val; } val = Shader.Find("Standard"); if ((Object)(object)val != (Object)null) { DebugLog.Warning("URP shaders not found, falling back to Standard (may not render correctly)"); } return val; } private static Material CreateMaterial(GltfLoadContext context, GltfMaterial gltfMat, Shader shader, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader); ((Object)val).name = gltfMat.name ?? $"material_{index}"; if (gltfMat.pbrMetallicRoughness != null) { ApplyPbrMetallicRoughness(context, val, gltfMat.pbrMetallicRoughness); } else { SetBaseColor(val, Color.white); SetMetallicSmoothness(val, 0f, 0.5f); } if (gltfMat.normalTexture != null) { ApplyNormalTexture(context, val, gltfMat.normalTexture); } if (gltfMat.occlusionTexture != null) { ApplyOcclusionTexture(context, val, gltfMat.occlusionTexture); } if (gltfMat.emissiveTexture != null || gltfMat.emissiveFactor != null) { ApplyEmission(context, val, gltfMat); } ApplyAlphaMode(val, gltfMat); if (gltfMat.doubleSided == true) { val.SetFloat("_Cull", 0f); } return val; } private static void ApplyPbrMetallicRoughness(GltfLoadContext context, Material mat, GltfPbrMetallicRoughness pbr) { //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_0050: Unknown result type (might be due to invalid IL or missing references) Color white = Color.white; if (pbr.baseColorFactor != null && pbr.baseColorFactor.Length >= 4) { ((Color)(ref white))..ctor(pbr.baseColorFactor[0], pbr.baseColorFactor[1], pbr.baseColorFactor[2], pbr.baseColorFactor[3]); } SetBaseColor(mat, white); if (pbr.baseColorTexture != null) { Texture2D texture = GetTexture(context, pbr.baseColorTexture.index); if ((Object)(object)texture != (Object)null) { mat.SetTexture("_BaseMap", (Texture)(object)texture); } } float num = pbr.metallicFactor ?? 1f; float num2 = pbr.roughnessFactor ?? 1f; float smoothness = 1f - num2; SetMetallicSmoothness(mat, num, smoothness); if (pbr.metallicRoughnessTexture != null) { Texture2D texture2 = GetTexture(context, pbr.metallicRoughnessTexture.index); if ((Object)(object)texture2 != (Object)null) { Texture2D val = GltfMaterialTextureConverter.CreateMetallicSmoothness(texture2, num, num2); context.RegisterTexture(val); mat.SetTexture("_MetallicGlossMap", (Texture)(object)val); mat.EnableKeyword("_METALLICSPECGLOSSMAP"); SetMetallicSmoothness(mat, 1f, 1f); } } } private static void SetBaseColor(Material mat, Color color) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (mat.HasProperty("_BaseColor")) { mat.SetColor("_BaseColor", color); } else if (mat.HasProperty("_Color")) { mat.SetColor("_Color", color); } } private static void SetMetallicSmoothness(Material mat, float metallic, float smoothness) { if (mat.HasProperty("_Metallic")) { mat.SetFloat("_Metallic", metallic); } else if (mat.HasProperty("_Metallic")) { mat.SetFloat("_Metallic", metallic); } if (mat.HasProperty("_Smoothness")) { mat.SetFloat("_Smoothness", smoothness); } else if (mat.HasProperty("_Glossiness")) { mat.SetFloat("_Glossiness", smoothness); } } private static void ApplyNormalTexture(GltfLoadContext context, Material mat, GltfNormalTextureInfo normalInfo) { Texture2D texture = GetTexture(context, normalInfo.index); if ((Object)(object)texture != (Object)null) { Texture2D val = GltfMaterialTextureConverter.CreateLinearCopy(texture, "Normal"); context.RegisterTexture(val); mat.SetTexture("_BumpMap", (Texture)(object)val); mat.EnableKeyword("_NORMALMAP"); if (normalInfo.scale.HasValue) { mat.SetFloat("_BumpScale", normalInfo.scale.Value); } } } private static void ApplyOcclusionTexture(GltfLoadContext context, Material mat, GltfOcclusionTextureInfo occlusionInfo) { Texture2D texture = GetTexture(context, occlusionInfo.index); if ((Object)(object)texture != (Object)null) { Texture2D val = GltfMaterialTextureConverter.CreateLinearCopy(texture, "Occlusion"); context.RegisterTexture(val); mat.SetTexture("_OcclusionMap", (Texture)(object)val); mat.EnableKeyword("_OCCLUSIONMAP"); if (occlusionInfo.strength.HasValue) { mat.SetFloat("_OcclusionStrength", occlusionInfo.strength.Value); } } } private static void ApplyEmission(GltfLoadContext context, Material mat, GltfMaterial gltfMat) { //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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) Color val = Color.black; float num = context.Options.EmissionIntensity; if (gltfMat.extensions != null && gltfMat.extensions.ContainsKey("KHR_materials_emissive_strength")) { try { object obj = gltfMat.extensions["KHR_materials_emissive_strength"]; if (obj is Dictionary dictionary && dictionary.ContainsKey("emissiveStrength")) { if (dictionary["emissiveStrength"] is float num2) { num *= num2; } else if (dictionary["emissiveStrength"] is double num3) { num *= (float)num3; } } } catch { } } if (gltfMat.emissiveFactor != null && gltfMat.emissiveFactor.Length >= 3) { ((Color)(ref val))..ctor(gltfMat.emissiveFactor[0] * num, gltfMat.emissiveFactor[1] * num, gltfMat.emissiveFactor[2] * num, 1f); } if (gltfMat.emissiveTexture != null) { Texture2D texture = GetTexture(context, gltfMat.emissiveTexture.index); if ((Object)(object)texture != (Object)null) { mat.SetTexture("_EmissionMap", (Texture)(object)texture); mat.EnableKeyword("_EMISSION"); if (gltfMat.emissiveFactor == null) { val = Color.white * num; } } } if (val != Color.black) { mat.SetColor("_EmissionColor", val); mat.EnableKeyword("_EMISSION"); mat.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)2; } } private static void ApplyAlphaMode(Material mat, GltfMaterial gltfMat) { switch (gltfMat.alphaMode ?? "OPAQUE") { case "OPAQUE": SetUrpOpaqueMode(mat); break; case "MASK": SetUrpCutoutMode(mat, gltfMat.alphaCutoff ?? 0.5f); break; case "BLEND": SetUrpTransparentMode(mat); break; default: SetUrpOpaqueMode(mat); break; } } private static void SetUrpOpaqueMode(Material mat) { mat.SetFloat("_Surface", 0f); mat.SetFloat("_AlphaClip", 0f); mat.SetFloat("_SrcBlend", 1f); mat.SetFloat("_DstBlend", 0f); mat.SetFloat("_ZWrite", 1f); mat.DisableKeyword("_ALPHATEST_ON"); mat.DisableKeyword("_ALPHABLEND_ON"); mat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); mat.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); mat.renderQueue = 2000; } private static void SetUrpCutoutMode(Material mat, float cutoff) { mat.SetFloat("_Surface", 0f); mat.SetFloat("_AlphaClip", 1f); mat.SetFloat("_Cutoff", cutoff); mat.SetFloat("_SrcBlend", 1f); mat.SetFloat("_DstBlend", 0f); mat.SetFloat("_ZWrite", 1f); mat.EnableKeyword("_ALPHATEST_ON"); mat.DisableKeyword("_ALPHABLEND_ON"); mat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); mat.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); mat.renderQueue = 2450; } private static void SetUrpTransparentMode(Material mat) { mat.SetFloat("_Surface", 1f); mat.SetFloat("_Blend", 0f); mat.SetFloat("_AlphaClip", 0f); mat.SetFloat("_SrcBlend", 5f); mat.SetFloat("_DstBlend", 10f); mat.SetFloat("_ZWrite", 0f); mat.DisableKeyword("_ALPHATEST_ON"); mat.EnableKeyword("_ALPHABLEND_ON"); mat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); mat.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); mat.renderQueue = 3000; } private static Texture2D? GetTexture(GltfLoadContext context, int textureIndex) { IReadOnlyList textures = context.Textures; if (textures == null || textureIndex < 0 || textureIndex >= textures.Count) { return null; } return textures[textureIndex]; } } internal static class GltfMaterialTextureConverter { public static Texture2D CreateLinearCopy(Texture2D source, string suffix) { Color32[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)source.GetPixels32()); Texture2D val = CreateLinearTexture(source, suffix); val.SetPixels32(Il2CppStructArray.op_Implicit(array)); val.Apply(true, true); return val; } public static Texture2D CreateMetallicSmoothness(Texture2D source, float metallicFactor, float roughnessFactor) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Color32[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)source.GetPixels32()); float num = Mathf.Clamp01(metallicFactor); float num2 = Mathf.Clamp01(roughnessFactor); for (int i = 0; i < array.Length; i++) { Color32 val = array[i]; byte b = ToByte((float)(int)val.b / 255f * num); byte b2 = ToByte(1f - (float)(int)val.g / 255f * num2); array[i] = new Color32(b, (byte)0, (byte)0, b2); } Texture2D val2 = CreateLinearTexture(source, "MetallicSmoothness"); val2.SetPixels32(Il2CppStructArray.op_Implicit(array)); val2.Apply(true, true); return val2; } private static Texture2D CreateLinearTexture(Texture2D source, string suffix) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown return new Texture2D(((Texture)source).width, ((Texture)source).height, (TextureFormat)4, true, true) { name = ((Object)source).name + "_" + suffix, filterMode = ((Texture)source).filterMode, anisoLevel = ((Texture)source).anisoLevel, wrapModeU = ((Texture)source).wrapModeU, wrapModeV = ((Texture)source).wrapModeV }; } private static byte ToByte(float value) { return (byte)Mathf.RoundToInt(Mathf.Clamp01(value) * 255f); } } internal class GltfMeshResult { public Mesh mesh = null; public int[] materialIndices = null; } internal static class GltfMeshProcessor { public static List ProcessMeshes(GltfRoot gltf, byte[]? binaryBuffer) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown List list = new List(); if (gltf.meshes == null) { return list; } foreach (GltfMesh mesh in gltf.meshes) { Mesh val = new Mesh(); ((Object)val).name = mesh.name ?? "gltf_mesh"; val.indexFormat = (IndexFormat)1; List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); List list6 = new List(); List list7 = new List(); List list8 = new List(); int num = 0; if (mesh.primitives != null) { foreach (GltfPrimitive primitive in mesh.primitives) { if (primitive.attributes == null) { continue; } int num2 = 0; if (primitive.attributes.TryGetValue("POSITION", out var value)) { Vector3[] array = ReadVector3Array(gltf, binaryBuffer, value, convertCoordinate: true); num2 = array.Length; list2.AddRange(array); } if (primitive.attributes.TryGetValue("NORMAL", out var value2)) { list3.AddRange(ReadVector3Array(gltf, binaryBuffer, value2, convertCoordinate: true)); } if (primitive.attributes.TryGetValue("TEXCOORD_0", out var value3)) { Vector2[] array2 = ReadVector2Array(gltf, binaryBuffer, value3, flipY: false); FlipUVs(array2); list4.AddRange(array2); } if (primitive.attributes.TryGetValue("TANGENT", out var value4)) { list5.AddRange(ReadVector4Array(gltf, binaryBuffer, value4, convertCoordinate: true)); } if (primitive.attributes.TryGetValue("JOINTS_0", out var value5) && primitive.attributes.TryGetValue("WEIGHTS_0", out var value6)) { list6.AddRange(ReadBoneWeights(gltf, binaryBuffer, value5, value6)); } if (primitive.indices.HasValue) { int[] array3 = ReadIntArray(gltf, binaryBuffer, primitive.indices.Value); FlipTriangles(array3); if (num > 0) { for (int i = 0; i < array3.Length; i++) { array3[i] += num; } } list7.Add(array3); } else { DebugLog.Warning("Non-indexed primitive in mesh '" + ((Object)val).name + "'. Skipping."); list7.Add(new int[0]); } list8.Add(primitive.material ?? (-1)); num += num2; } } val.SetVertices(list2.ToIl2CppList()); if (list3.Count > 0) { val.SetNormals(list3.ToIl2CppList()); } if (list4.Count > 0) { val.SetUVs(0, list4.ToIl2CppList()); } if (list5.Count > 0) { val.SetTangents(list5.ToIl2CppList()); } if (list6.Count > 0) { val.boneWeights = Il2CppStructArray.op_Implicit(list6.ToArray()); } val.subMeshCount = list7.Count; for (int j = 0; j < list7.Count; j++) { val.SetTriangles(Il2CppStructArray.op_Implicit(list7[j]), j); } val.RecalculateBounds(); list.Add(new GltfMeshResult { mesh = val, materialIndices = list8.ToArray() }); } return list; } private static void FlipUVs(Vector2[] uvs) { for (int i = 0; i < uvs.Length; i++) { uvs[i].y = 1f - uvs[i].y; } } private static void FlipTriangles(int[] indices) { for (int i = 0; i < indices.Length; i += 3) { int num = indices[i]; indices[i] = indices[i + 2]; indices[i + 2] = num; } } private static Vector3[] ReadVector3Array(GltfRoot gltf, byte[]? buffer, int accessorIndex, bool convertCoordinate) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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) if (gltf.accessors == null || accessorIndex >= gltf.accessors.Count) { return (Vector3[])(object)new Vector3[0]; } GltfAccessor gltfAccessor = gltf.accessors[accessorIndex]; if (!gltfAccessor.bufferView.HasValue || gltf.bufferViews == null || buffer == null) { return (Vector3[])(object)new Vector3[gltfAccessor.count]; } GltfBufferView gltfBufferView = gltf.bufferViews[gltfAccessor.bufferView.Value]; int count = gltfAccessor.count; int num = gltfBufferView.byteOffset + gltfAccessor.byteOffset; int num2 = gltfBufferView.byteStride ?? 12; Vector3[] array = (Vector3[])(object)new Vector3[count]; for (int i = 0; i < count; i++) { int num3 = num + i * num2; float num4 = BitConverter.ToSingle(buffer, num3); float num5 = BitConverter.ToSingle(buffer, num3 + 4); float num6 = BitConverter.ToSingle(buffer, num3 + 8); if (convertCoordinate) { array[i] = new Vector3(0f - num4, num5, num6); } else { array[i] = new Vector3(num4, num5, num6); } } return array; } private static Vector2[] ReadVector2Array(GltfRoot gltf, byte[]? buffer, int accessorIndex, bool flipY) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (gltf.accessors == null || accessorIndex >= gltf.accessors.Count) { return (Vector2[])(object)new Vector2[0]; } GltfAccessor gltfAccessor = gltf.accessors[accessorIndex]; if (!gltfAccessor.bufferView.HasValue || gltf.bufferViews == null || buffer == null) { return (Vector2[])(object)new Vector2[gltfAccessor.count]; } GltfBufferView gltfBufferView = gltf.bufferViews[gltfAccessor.bufferView.Value]; int count = gltfAccessor.count; int num = gltfBufferView.byteOffset + gltfAccessor.byteOffset; int num2 = gltfBufferView.byteStride ?? 8; Vector2[] array = (Vector2[])(object)new Vector2[count]; for (int i = 0; i < count; i++) { int num3 = num + i * num2; float num4 = BitConverter.ToSingle(buffer, num3); float num5 = BitConverter.ToSingle(buffer, num3 + 4); array[i] = new Vector2(num4, num5); } return array; } private static Vector4[] ReadVector4Array(GltfRoot gltf, byte[]? buffer, int accessorIndex, bool convertCoordinate) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if (gltf.accessors == null || accessorIndex >= gltf.accessors.Count) { return (Vector4[])(object)new Vector4[0]; } GltfAccessor gltfAccessor = gltf.accessors[accessorIndex]; if (!gltfAccessor.bufferView.HasValue || gltf.bufferViews == null || buffer == null) { return (Vector4[])(object)new Vector4[gltfAccessor.count]; } GltfBufferView gltfBufferView = gltf.bufferViews[gltfAccessor.bufferView.Value]; int count = gltfAccessor.count; int num = gltfBufferView.byteOffset + gltfAccessor.byteOffset; int num2 = gltfBufferView.byteStride ?? 16; Vector4[] array = (Vector4[])(object)new Vector4[count]; for (int i = 0; i < count; i++) { int num3 = num + i * num2; float num4 = BitConverter.ToSingle(buffer, num3); float num5 = BitConverter.ToSingle(buffer, num3 + 4); float num6 = BitConverter.ToSingle(buffer, num3 + 8); float num7 = BitConverter.ToSingle(buffer, num3 + 12); if (convertCoordinate) { array[i] = new Vector4(0f - num4, num5, num6, num7); } else { array[i] = new Vector4(num4, num5, num6, num7); } } return array; } private static int[] ReadIntArray(GltfRoot gltf, byte[]? buffer, int accessorIndex) { if (gltf.accessors == null || accessorIndex >= gltf.accessors.Count) { return new int[0]; } GltfAccessor gltfAccessor = gltf.accessors[accessorIndex]; if (!gltfAccessor.bufferView.HasValue || gltf.bufferViews == null || buffer == null) { return new int[gltfAccessor.count]; } GltfBufferView gltfBufferView = gltf.bufferViews[gltfAccessor.bufferView.Value]; int count = gltfAccessor.count; int num = gltfBufferView.byteOffset + gltfAccessor.byteOffset; int[] array = new int[count]; int num2 = gltfBufferView.byteStride ?? GetComponentSize(gltfAccessor.componentType); for (int i = 0; i < count; i++) { int num3 = num + i * num2; switch (gltfAccessor.componentType) { case 5121: array[i] = buffer[num3]; continue; case 5123: array[i] = BitConverter.ToUInt16(buffer, num3); continue; case 5125: array[i] = (int)BitConverter.ToUInt32(buffer, num3); continue; } DebugLog.Warning($"Unsupported component type for indices: {gltfAccessor.componentType}"); } return array; } private static BoneWeight[] ReadBoneWeights(GltfRoot gltf, byte[]? buffer, int jointsIndex, int weightsIndex) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) if (gltf.accessors == null || gltf.bufferViews == null || buffer == null) { return (BoneWeight[])(object)new BoneWeight[0]; } GltfAccessor gltfAccessor = gltf.accessors[jointsIndex]; GltfAccessor gltfAccessor2 = gltf.accessors[weightsIndex]; if (!gltfAccessor.bufferView.HasValue || !gltfAccessor2.bufferView.HasValue) { return (BoneWeight[])(object)new BoneWeight[gltfAccessor.count]; } int count = gltfAccessor.count; BoneWeight[] array = (BoneWeight[])(object)new BoneWeight[count]; int num = gltf.bufferViews[gltfAccessor.bufferView.Value].byteOffset + gltfAccessor.byteOffset; int num2 = gltf.bufferViews[gltfAccessor2.bufferView.Value].byteOffset + gltfAccessor2.byteOffset; for (int i = 0; i < count; i++) { BoneWeight val = default(BoneWeight); int num3 = num + i * ((gltfAccessor.componentType == 5123) ? 8 : 4); if (gltfAccessor.componentType == 5123) { ((BoneWeight)(ref val)).boneIndex0 = BitConverter.ToUInt16(buffer, num3); ((BoneWeight)(ref val)).boneIndex1 = BitConverter.ToUInt16(buffer, num3 + 2); ((BoneWeight)(ref val)).boneIndex2 = BitConverter.ToUInt16(buffer, num3 + 4); ((BoneWeight)(ref val)).boneIndex3 = BitConverter.ToUInt16(buffer, num3 + 6); } else { ((BoneWeight)(ref val)).boneIndex0 = buffer[num3]; ((BoneWeight)(ref val)).boneIndex1 = buffer[num3 + 1]; ((BoneWeight)(ref val)).boneIndex2 = buffer[num3 + 2]; ((BoneWeight)(ref val)).boneIndex3 = buffer[num3 + 3]; } int num4 = num2 + i * 16; ((BoneWeight)(ref val)).weight0 = BitConverter.ToSingle(buffer, num4); ((BoneWeight)(ref val)).weight1 = BitConverter.ToSingle(buffer, num4 + 4); ((BoneWeight)(ref val)).weight2 = BitConverter.ToSingle(buffer, num4 + 8); ((BoneWeight)(ref val)).weight3 = BitConverter.ToSingle(buffer, num4 + 12); array[i] = val; } return array; } private static int GetComponentSize(int componentType) { return componentType switch { 5120 => 1, 5121 => 1, 5122 => 2, 5123 => 2, 5125 => 4, 5126 => 4, _ => 1, }; } } internal static class GltfNodeProcessor { public static List ProcessNodes(GltfRoot gltf, GameObject root, List meshes, List textures, Shader shader) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Expected O, but got Unknown //IL_03fc: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Dictionary dictionary = new Dictionary(); if (gltf.nodes == null) { return list; } for (int i = 0; i < gltf.nodes.Count; i++) { GltfNode gltfNode = gltf.nodes[i]; GameObject val = new GameObject(gltfNode.name ?? $"node_{i}"); dictionary[i] = val.transform; list.Add(val.transform); if (gltfNode.matrix != null && gltfNode.matrix.Length == 16) { Matrix4x4 val2 = default(Matrix4x4); for (int j = 0; j < 4; j++) { int num = j * 4; ((Matrix4x4)(ref val2)).SetColumn(j, new Vector4(gltfNode.matrix[num], gltfNode.matrix[num + 1], gltfNode.matrix[num + 2], gltfNode.matrix[num + 3])); } Vector3 val3 = Vector4.op_Implicit(((Matrix4x4)(ref val2)).GetColumn(3)); Quaternion rotation = ((Matrix4x4)(ref val2)).rotation; Vector3 lossyScale = ((Matrix4x4)(ref val2)).lossyScale; val.transform.localPosition = new Vector3(0f - val3.x, val3.y, val3.z); val.transform.localRotation = new Quaternion(rotation.x, 0f - rotation.y, 0f - rotation.z, rotation.w); val.transform.localScale = lossyScale; } else { if (gltfNode.translation != null) { val.transform.localPosition = new Vector3(0f - gltfNode.translation[0], gltfNode.translation[1], gltfNode.translation[2]); } if (gltfNode.rotation != null) { val.transform.localRotation = new Quaternion(gltfNode.rotation[0], 0f - gltfNode.rotation[1], 0f - gltfNode.rotation[2], gltfNode.rotation[3]); } if (gltfNode.scale != null) { val.transform.localScale = new Vector3(gltfNode.scale[0], gltfNode.scale[1], gltfNode.scale[2]); } } if (!gltfNode.mesh.HasValue || gltfNode.mesh.Value >= meshes.Count) { continue; } GltfMeshResult gltfMeshResult = meshes[gltfNode.mesh.Value]; MeshFilter val4 = val.AddComponent(); val4.mesh = gltfMeshResult.mesh; MeshRenderer val5 = val.AddComponent(); Material[] array = (Material[])(object)new Material[gltfMeshResult.mesh.subMeshCount]; Shader val6 = shader ?? Shader.Find("Standard"); for (int k = 0; k < gltfMeshResult.mesh.subMeshCount; k++) { Material val7 = new Material(val6); int num2 = ((k < gltfMeshResult.materialIndices.Length) ? gltfMeshResult.materialIndices[k] : (-1)); if (num2 >= 0 && gltf.materials != null && num2 < gltf.materials.Count) { GltfMaterial gltfMaterial = gltf.materials[num2]; ((Object)val7).name = gltfMaterial.name ?? $"material_{num2}"; if (gltfMaterial.pbrMetallicRoughness != null) { GltfPbrMetallicRoughness pbrMetallicRoughness = gltfMaterial.pbrMetallicRoughness; if (pbrMetallicRoughness.baseColorFactor != null && pbrMetallicRoughness.baseColorFactor.Length == 4) { val7.color = new Color(pbrMetallicRoughness.baseColorFactor[0], pbrMetallicRoughness.baseColorFactor[1], pbrMetallicRoughness.baseColorFactor[2], pbrMetallicRoughness.baseColorFactor[3]); } if (pbrMetallicRoughness.baseColorTexture != null && textures != null) { int index = pbrMetallicRoughness.baseColorTexture.index; if (index >= 0 && index < textures.Count) { val7.mainTexture = (Texture)(object)textures[index]; } } if (((Object)val6).name == "Standard") { if (pbrMetallicRoughness.metallicFactor.HasValue) { val7.SetFloat("_Metallic", pbrMetallicRoughness.metallicFactor.Value); } if (pbrMetallicRoughness.roughnessFactor.HasValue) { val7.SetFloat("_Glossiness", 1f - pbrMetallicRoughness.roughnessFactor.Value); } } } } else { ((Object)val7).name = "DefaultMaterial"; } array[k] = val7; } ((Renderer)val5).materials = Il2CppReferenceArray.op_Implicit(array); } for (int l = 0; l < gltf.nodes.Count; l++) { GltfNode gltfNode2 = gltf.nodes[l]; Transform val8 = dictionary[l]; if (gltfNode2.children == null) { continue; } foreach (int child in gltfNode2.children) { if (dictionary.TryGetValue(child, out var value) && (Object)(object)value != (Object)null) { value.SetParent(val8, false); } } } foreach (Transform item in list) { if ((Object)(object)item.parent == (Object)null) { item.SetParent(root.transform, false); } } return list; } } internal static class GltfTextureProcessor { public static List ProcessTextures(GltfRoot gltf, byte[]? binaryBuffer) { List list = new List(); if (gltf.textures == null) { return list; } foreach (GltfTexture texture in gltf.textures) { if (texture.source.HasValue && gltf.images != null && texture.source.Value < gltf.images.Count) { GltfImage gltfImage = gltf.images[texture.source.Value]; Texture2D val = LoadImage(gltf, gltfImage, binaryBuffer); if ((Object)(object)val != (Object)null) { ((Object)val).name = texture.name ?? gltfImage.name ?? $"texture_{list.Count}"; if (texture.sampler.HasValue && gltf.samplers != null && texture.sampler.Value < gltf.samplers.Count) { ApplySampler(val, gltf.samplers[texture.sampler.Value]); } list.Add(val); } else { list.Add(null); DebugLog.Warning($"Failed to load texture index {list.Count - 1}"); } } else { list.Add(null); } } return list; } private static Texture2D? LoadImage(GltfRoot gltf, GltfImage image, byte[]? binaryBuffer) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown if (image.bufferView.HasValue && gltf.bufferViews != null && image.bufferView.Value < gltf.bufferViews.Count) { GltfBufferView gltfBufferView = gltf.bufferViews[image.bufferView.Value]; if (gltfBufferView.buffer == 0 && binaryBuffer != null) { int byteOffset = gltfBufferView.byteOffset; int byteLength = gltfBufferView.byteLength; if (byteOffset + byteLength <= binaryBuffer.Length) { byte[] array = new byte[byteLength]; Array.Copy(binaryBuffer, byteOffset, array, 0, byteLength); Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, Il2CppStructArray.op_Implicit(array))) { return val; } } } } return null; } private static void ApplySampler(Texture2D tex, GltfSampler sampler) { //IL_001c: 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_0084: Unknown result type (might be due to invalid IL or missing references) if (sampler.wrapS.HasValue) { ((Texture)tex).wrapModeU = GetWrapMode(sampler.wrapS.Value); } if (sampler.wrapT.HasValue) { ((Texture)tex).wrapModeV = GetWrapMode(sampler.wrapT.Value); } if (sampler.minFilter.HasValue || sampler.magFilter.HasValue) { ((Texture)tex).filterMode = GetFilterMode(sampler.minFilter.GetValueOrDefault(), sampler.magFilter.GetValueOrDefault()); } } private static TextureWrapMode GetWrapMode(int mode) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) return (TextureWrapMode)(mode switch { 33071 => 1, 33648 => 2, 10497 => 0, _ => 0, }); } private static FilterMode GetFilterMode(int min, int mag) { //IL_001d: 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_0020: Unknown result type (might be due to invalid IL or missing references) if (min == 9728 || mag == 9728) { return (FilterMode)0; } return (FilterMode)1; } } } namespace S1MAPI.Gltf.Data { [Serializable] internal sealed class GltfRoot { public GltfAsset? asset; public List? scenes; public List? nodes; public List? meshes; public List? buffers; public List? bufferViews; public List? accessors; public List? textures; public List? images; public List? samplers; public List? materials; public List? skins; public List? animations; public List? cameras; public int scene; public List? extensionsUsed; public List? extensionsRequired; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfAsset { public string? version; public string? minVersion; public string? generator; public string? copyright; } [Serializable] internal sealed class GltfScene { public string? name; public List? nodes; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfNode { public string? name; public int? mesh; public int? skin; public int? camera; public float[]? weights; public List? children; public float[]? matrix; public float[]? translation; public float[]? rotation; public float[]? scale; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfMesh { public string? name; public List? primitives; public float[]? weights; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfPrimitive { public Dictionary? attributes; public int? indices; public int? material; public int mode = 4; public List>? targets; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfBuffer { public int byteLength; public string? uri; public string? name; [NonSerialized] public byte[]? Data; } [Serializable] internal sealed class GltfBufferView { public int buffer; public int byteOffset; public int byteLength; public int? byteStride; public int? target; public string? name; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfAccessor { public int? bufferView; public int byteOffset; public int componentType; public int count; public string? type; public bool? normalized; public float[]? min; public float[]? max; public GltfAccessorSparse? sparse; public string? name; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfAccessorSparse { public int count; public GltfAccessorSparseIndices? indices; public GltfAccessorSparseValues? values; } [Serializable] internal sealed class GltfAccessorSparseIndices { public int bufferView; public int byteOffset; public int componentType; } [Serializable] internal sealed class GltfAccessorSparseValues { public int bufferView; public int byteOffset; } [Serializable] internal sealed class GltfMaterial { public string? name; public GltfPbrMetallicRoughness? pbrMetallicRoughness; public GltfNormalTextureInfo? normalTexture; public GltfOcclusionTextureInfo? occlusionTexture; public GltfTextureInfo? emissiveTexture; public float[]? emissiveFactor; public string? alphaMode; public float? alphaCutoff; public bool? doubleSided; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfPbrMetallicRoughness { public float[]? baseColorFactor; public GltfTextureInfo? baseColorTexture; public float? metallicFactor; public float? roughnessFactor; public GltfTextureInfo? metallicRoughnessTexture; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfTextureInfo { public int index; public int? texCoord; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfNormalTextureInfo { public int index; public int? texCoord; public float? scale; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfOcclusionTextureInfo { public int index; public int? texCoord; public float? strength; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfTexture { public int? sampler; public int? source; public string? name; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfImage { public string? uri; public string? mimeType; public int? bufferView; public string? name; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfSampler { public int? magFilter; public int? minFilter; public int? wrapS; public int? wrapT; public string? name; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfSkin { public string? name; public int? inverseBindMatrices; public int? skeleton; public List? joints; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfAnimation { public string? name; public List? channels; public List? samplers; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfAnimationChannel { public int sampler; public GltfAnimationChannelTarget? target; } [Serializable] internal sealed class GltfAnimationChannelTarget { public int? node; public string? path; } [Serializable] internal sealed class GltfAnimationSampler { public int input; public string? interpolation; public int output; } [Serializable] internal sealed class GltfCamera { public string? name; public string? type; public GltfCameraPerspective? perspective; public GltfCameraOrthographic? orthographic; public Dictionary? extensions; public object? extras; } [Serializable] internal sealed class GltfCameraPerspective { public float? aspectRatio; public float yfov; public float znear; public float? zfar; } [Serializable] internal sealed class GltfCameraOrthographic { public float xmag; public float ymag; public float znear; public float zfar; } internal static class GltfComponentType { public const int Byte = 5120; public const int UnsignedByte = 5121; public const int Short = 5122; public const int UnsignedShort = 5123; public const int UnsignedInt = 5125; public const int Float = 5126; public static int GetSize(int componentType) { if (1 == 0) { } int result = componentType switch { 5120 => 1, 5121 => 1, 5122 => 2, 5123 => 2, 5125 => 4, 5126 => 4, _ => 1, }; if (1 == 0) { } return result; } } internal static class GltfAccessorType { public const string Scalar = "SCALAR"; public const string Vec2 = "VEC2"; public const string Vec3 = "VEC3"; public const string Vec4 = "VEC4"; public const string Mat2 = "MAT2"; public const string Mat3 = "MAT3"; public const string Mat4 = "MAT4"; public static int GetComponentCount(string type) { if (1 == 0) { } int result = type switch { "SCALAR" => 1, "VEC2" => 2, "VEC3" => 3, "VEC4" => 4, "MAT2" => 4, "MAT3" => 9, "MAT4" => 16, _ => 1, }; if (1 == 0) { } return result; } } internal static class GltfPrimitiveMode { public const int Points = 0; public const int Lines = 1; public const int LineLoop = 2; public const int LineStrip = 3; public const int Triangles = 4; public const int TriangleStrip = 5; public const int TriangleFan = 6; } internal static class GltfAlphaMode { public const string Opaque = "OPAQUE"; public const string Mask = "MASK"; public const string Blend = "BLEND"; } internal static class GltfTextureFilter { public const int Nearest = 9728; public const int Linear = 9729; public const int NearestMipmapNearest = 9984; public const int LinearMipmapNearest = 9985; public const int NearestMipmapLinear = 9986; public const int LinearMipmapLinear = 9987; } internal static class GltfTextureWrap { public const int ClampToEdge = 33071; public const int MirroredRepeat = 33648; public const int Repeat = 10497; } internal static class GltfInterpolation { public const string Linear = "LINEAR"; public const string Step = "STEP"; public const string CubicSpline = "CUBICSPLINE"; } internal static class GltfAnimationPath { public const string Translation = "translation"; public const string Rotation = "rotation"; public const string Scale = "scale"; public const string Weights = "weights"; } internal sealed class GltfLoadContext { private readonly GltfRoot _root; private readonly GltfBufferResolver _bufferResolver; private readonly GltfImportOptions _options; private List _meshes; private List _materials; private List _textures; private List _animations; private Dictionary _nodeTransforms; public GltfRoot Root => _root; public GltfBufferResolver BufferResolver => _bufferResolver; public GltfImportOptions Options => _options; public IReadOnlyList Meshes => _meshes; public IReadOnlyList Materials => _materials; public IReadOnlyList Textures => _textures; public IReadOnlyList Animations => _animations; public IReadOnlyDictionary NodeTransforms => _nodeTransforms; public GltfLoadContext(GltfRoot root, GltfBufferResolver bufferResolver, GltfImportOptions? options = null) { _root = root; _bufferResolver = bufferResolver; _options = options ?? new GltfImportOptions(); _meshes = new List(); _materials = new List(); _textures = new List(); _animations = new List(); _nodeTransforms = new Dictionary(); } public void RegisterMesh(Mesh mesh) { if (!((Object)(object)mesh == (Object)null)) { _meshes.Add(mesh); } } public void RegisterMaterial(Material material) { if (!((Object)(object)material == (Object)null)) { _materials.Add(material); } } public void RegisterTexture(Texture2D? texture) { if ((Object)(object)texture == (Object)null) { _textures.Add(null); } else { _textures.Add(texture); } } public void RegisterAnimation(AnimationClip clip) { if (!((Object)(object)clip == (Object)null)) { _animations.Add(clip); } } public void RegisterNodeTransform(int nodeIndex, Transform transform) { _nodeTransforms[nodeIndex] = transform; } public Transform? GetNodeTransform(int nodeIndex) { Transform value; return _nodeTransforms.TryGetValue(nodeIndex, out value) ? value : null; } public byte[]? GetAccessorData(int accessorIndex) { if (_root.accessors == null || accessorIndex < 0 || accessorIndex >= _root.accessors.Count) { return null; } GltfAccessor gltfAccessor = _root.accessors[accessorIndex]; if (gltfAccessor.type == null) { return null; } if (!gltfAccessor.bufferView.HasValue) { int size = GltfComponentType.GetSize(gltfAccessor.componentType); int componentCount = GltfAccessorType.GetComponentCount(gltfAccessor.type); return new byte[gltfAccessor.count * size * componentCount]; } return _bufferResolver.GetBufferViewData(_root, gltfAccessor.bufferView.Value); } public GltfAccessor? GetAccessor(int accessorIndex) { if (_root.accessors == null || accessorIndex < 0 || accessorIndex >= _root.accessors.Count) { return null; } return _root.accessors[accessorIndex]; } public GltfBufferView? GetBufferView(int bufferViewIndex) { if (_root.bufferViews == null || bufferViewIndex < 0 || bufferViewIndex >= _root.bufferViews.Count) { return null; } return _root.bufferViews[bufferViewIndex]; } } public sealed class GltfImportOptions { public Shader? Shader { get; set; } public bool ImportAnimations { get; set; } = true; public bool ImportSkins { get; set; } = true; public bool ImportBlendShapes { get; set; } = true; public bool ImportCameras { get; set; } = false; public bool GenerateMissingNormals { get; set; } = true; public bool GenerateMissingTangents { get; set; } = true; public bool ReadableMeshes { get; set; } = false; public float ScaleFactor { get; set; } = 1f; public string RootName { get; set; } = "GltfModel"; public float EmissionIntensity { get; set; } = 1f; } } namespace S1MAPI.Building { public sealed class BuildingBuilder { private readonly struct StairSpec { public readonly WallSide Wall; public readonly float FoundationHeight; public readonly float Width; public readonly float LateralOffset; public readonly float MaxStepHeight; public readonly float StepDepth; public readonly StairStyle Style; public readonly bool FlushWithFloor; public StairSpec(WallSide wall, float foundationHeight, float width, float lateralOffset, float maxStepHeight, float stepDepth, StairStyle style, bool flushWithFloor) { Wall = wall; FoundationHeight = foundationHeight; Width = width; LateralOffset = lateralOffset; MaxStepHeight = maxStepHeight; StepDepth = stepDepth; Style = style; FlushWithFloor = flushWithFloor; } } private readonly string _name; private readonly GameObject _root; private BuildingConfig _config; private Vector3 _roomSize; private readonly BuildingPartRegistry _registry; private WallBuilder? _wallBuilder; private FurnitureBuilder? _furnitureBuilder; private LightingBuilder? _lightingBuilder; private DecorBuilder? _decorBuilder; private RoofBuilder? _roofBuilder; private PrefabPlacer? _prefabPlacer; private InteriorWallBuilder? _interiorWallBuilder; private int _interiorWallLayer = -1; private IReadOnlyList? _interiorDoorwaysCache; private float _foundationHeight; private float _foundationExpandX; private float _foundationExpandZ; private readonly List _stairs = new List(); private WallOpening? _northOpening; private WallOpening? _southOpening; private WallOpening? _eastOpening; private WallOpening? _westOpening; public IReadOnlyList InteriorDoorways => _interiorWallBuilder?.Doorways ?? _interiorDoorwaysCache ?? Array.Empty(); public GameObject Root => _root; public Vector3 RoomSize => _roomSize; public BuildingConfig Config => _config; public BuildingPartRegistry Registry => _registry; public float GridCellSize => BuildingUtilities.ComputeGridCellSize(_roomSize.x, _roomSize.z); public BuildingBuilder(string name) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) _name = name; _root = new GameObject(name); _registry = new BuildingPartRegistry(); _config = BuildingConfig.Default; _roomSize = _config.Size; } public BuildingBuilder WithConfig(BuildingConfig config) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) _config = config; _roomSize = config.Size; InvalidateBuilders(); return this; } public BuildingBuilder WithPalette(BuildingPalette palette) { _config.Palette = palette; InvalidateBuilders(); return this; } public BuildingBuilder DefineRoom(float width, float height, float depth) { //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) _config.Width = width; _config.Height = height; _config.Depth = depth; _roomSize = new Vector3(width, height, depth); InvalidateBuilders(); return this; } public BuildingBuilder AddFloor(Color? color = null, Material? material = null) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (color.HasValue) { _config.Palette.FloorColor = color.Value; } if ((Object)(object)material != (Object)null) { _config.Palette.FloorMaterial = material; } GameObject go = GetDecorBuilder().AddFloor(_config.FloorThickness); _registry.Register(BuildingPart.Floor, go); return this; } public BuildingBuilder AddCeiling(Color? color = null, Material? material = null) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (color.HasValue) { _config.Palette.CeilingColor = color.Value; } if ((Object)(object)material != (Object)null) { _config.Palette.CeilingMaterial = material; } GameObject go = GetDecorBuilder().AddCeiling(_config.CeilingThickness); _registry.Register(BuildingPart.Ceiling, go); return this; } public BuildingBuilder AddWalls(bool northDoor = false, bool southDoor = false, bool eastDoor = false, bool westDoor = false, bool northWindow = false, bool southWindow = false, bool eastWindow = false, bool westWindow = false, bool northDoorWindows = false, bool southDoorWindows = false, bool eastDoorWindows = false, bool westDoorWindows = false, Color? color = null, Material? material = null) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) BuildingPalette buildingPalette = _config.Palette; if (color.HasValue || (Object)(object)material != (Object)null) { buildingPalette = buildingPalette.Clone(); if (color.HasValue) { buildingPalette.WallColor = color.Value; } if ((Object)(object)material != (Object)null) { buildingPalette.WallMaterial = material; } } _northOpening = ((!northDoor) ? (northWindow ? WallOpening.Window() : null) : (northDoorWindows ? WallOpening.DoorWithWindows() : WallOpening.Door())); _southOpening = ((!southDoor) ? (southWindow ? WallOpening.Window() : null) : (southDoorWindows ? WallOpening.DoorWithWindows() : WallOpening.Door())); _eastOpening = ((!eastDoor) ? (eastWindow ? WallOpening.Window() : null) : (eastDoorWindows ? WallOpening.DoorWithWindows() : WallOpening.Door())); _westOpening = ((!westDoor) ? (westWindow ? WallOpening.Window() : null) : (westDoorWindows ? WallOpening.DoorWithWindows() : WallOpening.Door())); WallBuilder wallBuilder = GetWallBuilder(buildingPalette); GameObject wallsContainer = wallBuilder.BuildWalls(_northOpening, _southOpening, _eastOpening, _westOpening); RegisterWallChildren(wallsContainer); return this; } public BuildingBuilder AddWalls(WallOpening? north = null, WallOpening? south = null, WallOpening? east = null, WallOpening? west = null) { _northOpening = north; _southOpening = south; _eastOpening = east; _westOpening = west; GameObject wallsContainer = GetWallBuilder().BuildWalls(north, south, east, west); RegisterWallChildren(wallsContainer); return this; } public BuildingBuilder AddWalls(WallOpening? north, WallOpening? south, WallOpening? east, WallOpening? west, IReadOnlyDictionary wallAppearances) { _northOpening = north; _southOpening = south; _eastOpening = east; _westOpening = west; GameObject wallsContainer = GetWallBuilder().BuildWalls(north, south, east, west, wallAppearances); RegisterWallChildren(wallsContainer); return this; } public BuildingBuilder WithInteriorWallLayer(int layer) { if (_interiorWallBuilder != null) { throw new InvalidOperationException("[BuildingBuilder.WithInteriorWallLayer] Must be called before AddInteriorWall."); } _interiorWallLayer = layer; return this; } public BuildingBuilder AddInteriorWall(InteriorWallAxis axis, float position, float from, float to, WallOpening? opening = null, Color? color = null, Material? material = null) { InteriorWallDefinition def = new InteriorWallDefinition(axis, position, from, to, opening, color, material); GameObject val = GetInteriorWallBuilder().BuildInteriorWall(def); if ((Object)(object)val != (Object)null) { _registry.Register(BuildingPart.InteriorWalls, val); } return this; } public BuildingBuilder AddInteriorWall(InteriorWallAxis axis, float position, WallOpening? opening = null, Color? color = null, Material? material = null) { float to = ((axis == InteriorWallAxis.X) ? _roomSize.x : _roomSize.z); return AddInteriorWall(axis, position, 0f, to, opening, color, material); } public NavigationBuilder CreateNavigationBuilder() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) List list = new List(); TryAddExteriorDoor(WallSide.North, _northOpening, list); TryAddExteriorDoor(WallSide.South, _southOpening, list); TryAddExteriorDoor(WallSide.East, _eastOpening, list); TryAddExteriorDoor(WallSide.West, _westOpening, list); Vector3 center = default(Vector3); foreach (DoorwayInfo interiorDoorway in InteriorDoorways) { Vector3 inwardNormal = (interiorDoorway.FacesAlongZ ? Vector3.forward : Vector3.right); ((Vector3)(ref center))..ctor(interiorDoorway.Center.x, 0f, interiorDoorway.Center.z); list.Add(new NavDoorwayInfo(center, interiorDoorway.Width, interiorDoorway.Height, inwardNormal, interiorDoorway.WallThickness, null, isInterior: true)); } bool flag = false; for (int i = 0; i < list.Count; i++) { if (!list[i].IsInterior) { flag = true; break; } } if (!flag) { throw new InvalidOperationException("[BuildingBuilder.CreateNavigationBuilder] No exterior doorways found. NavigationBuilder requires at least one exterior door (AddWalls with a door opening)."); } return new NavigationBuilder(_root.transform, _roomSize, list, _config.WallThickness, _foundationHeight); } public BuildingBuilder FlattenTerrain(float padding = 0.5f, bool clearDetails = true, float blendDistance = 3f) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) float targetWorldY = _root.transform.position.y - _foundationHeight; Vector3 roomSize = default(Vector3); ((Vector3)(ref roomSize))..ctor(_roomSize.x + _foundationExpandX * 2f, _roomSize.y, _roomSize.z + _foundationExpandZ * 2f); TerrainFlattener.FlattenUnder(_root, roomSize, targetWorldY, padding, clearDetails, blendDistance); return this; } public BuildingBuilder AddRoofTrim(float height = 0.3f, Material? material = null) { GameObject go = GetDecorBuilder().AddRoofTrim(height, material); _registry.Register(BuildingPart.Trim, go); return this; } public BuildingBuilder AddSecondaryRoofTrim(float height = 0.15f, Material? material = null) { GameObject go = GetDecorBuilder().AddSecondaryRoofTrim(height, material); _registry.Register(BuildingPart.Accent, go); return this; } public BuildingBuilder AddParapetRoof(ParapetPreset preset = ParapetPreset.Deep, float? parapetHeight = null, float? parapetDepth = null, float? capHeight = null, float? capOverhang = null, Color? parapetColor = null, Material? parapetMaterial = null, Color? capColor = null, Material? capMaterial = null) { GameObject go = GetRoofBuilder().AddParapetRoof(preset, parapetHeight, parapetDepth, capHeight, capOverhang, parapetColor, parapetMaterial, capColor, capMaterial); _registry.Register(BuildingPart.Roof, go); return this; } public BuildingBuilder AddHipRoof(float ridgeHeight = 2f, float overhang = 0.3f, bool? ridgeAlongX = null, Color? roofColor = null, Material? roofMaterial = null, float baseSlabHeight = 0.15f) { GameObject go = GetRoofBuilder().AddHipRoof(ridgeHeight, overhang, ridgeAlongX, roofColor, roofMaterial, baseSlabHeight); _registry.Register(BuildingPart.Roof, go); return this; } public BuildingBuilder AddCornerPillars(float width = 0.4f, Material? material = null) { GameObject go = GetDecorBuilder().AddCornerPillars(width, material); _registry.Register(BuildingPart.Pillars, go); return this; } public BuildingBuilder AddCornerTrim(float width = 0.3f, float depth = 0.1f, Material? material = null) { GameObject go = GetDecorBuilder().AddCornerTrim(width, depth, material); _registry.Register(BuildingPart.Trim, go); return this; } public BuildingBuilder AddFoundation(float height = 2f, float expandX = 0f, float expandZ = 0f, Color? color = null, Material? material = null) { _foundationHeight = height; _foundationExpandX = expandX; _foundationExpandZ = expandZ; GameObject go = GetDecorBuilder().AddFoundation(height, expandX, expandZ, color, material); _registry.Register(BuildingPart.Foundation, go); return this; } public BuildingBuilder AddStairs(WallSide wall, float foundationHeight = 2f, float maxStepHeight = 0.2f, float width = 2.5f, float stepDepth = 0.3f, Color? color = null, Material? material = null, StairStyle style = StairStyle.Solid, bool flushWithFloor = false, float gap = 0f) { float doorOffset = GetDoorOffset(wall); _stairs.Add(new StairSpec(wall, foundationHeight, width, doorOffset, maxStepHeight, stepDepth, style, flushWithFloor)); GameObject go = GetDecorBuilder().AddStairs(wall, foundationHeight, maxStepHeight, width, stepDepth, color, material, style, flushWithFloor, gap, doorOffset); _registry.Register(BuildingPart.Stairs, go); return this; } public BuildingBuilder AddDoorFrames(Material? material = null) { GameObject go = GetDecorBuilder().AddDoorFrames(_northOpening, _southOpening, _eastOpening, _westOpening, material); _registry.Register(BuildingPart.Trim, go); return this; } public BuildingBuilder AddInteriorDoorFrames(Material? material = null) { if (_interiorWallBuilder != null && _interiorWallBuilder.Doorways.Count > 0) { GameObject go = GetDecorBuilder().AddInteriorDoorFrames(_interiorWallBuilder.Doorways, 0.12f, 0.04f, material); _registry.Register(BuildingPart.Trim, go); } return this; } public BuildingBuilder AddBaseMolding(float height = 0.3f, float depth = 0.1f, Material? material = null, IEnumerable? skipWalls = null) { GameObject go = GetDecorBuilder().AddBaseMolding(height, depth, material, _northOpening, _southOpening, _eastOpening, _westOpening, skipWalls); _registry.Register(BuildingPart.Trim, go); return this; } public BuildingBuilder AddLights(float? intensity = null, Color? color = null) { GetLightingBuilder().AddCeilingLights(intensity, color); return this; } public BuildingBuilder AddAmbientLighting(float intensity = 0.3f) { GetLightingBuilder().AddAmbientLighting(intensity); return this; } public BuildingBuilder AddFurniture(FurnitureType type, string position, Color? color = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) var (position2, rotation) = ParseSemanticPosition(position, GetOptimalMargin(type)); GetFurnitureBuilder().Create(type, position2, rotation, color); return this; } public BuildingBuilder AddFurniture(FurnitureType type, Vector3 position, Quaternion rotation, Color? color = null) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) GetFurnitureBuilder().Create(type, position, rotation, color); return this; } public BuildingBuilder AddPrefab(PrefabRef prefab, Vector3 position, Quaternion rotation, Action? onCreated = null) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) GameObject val = GetPrefabPlacer().Place(prefab, position, rotation); if ((Object)(object)val != (Object)null) { onCreated?.Invoke(val); } return this; } public BuildingBuilder AddSlidingDoors(Vector3 position, Quaternion rotation, string openingHours = "6AM-6PM", Action? onCreated = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) GetPrefabPlacer().PlaceSlidingDoors(position, rotation, openingHours, Materials.MetalDarkGrey, onCreated); return this; } public GameObject Build() { DebugLog.Info($"[BuildingBuilder] Built '{_name}' ({_roomSize.x}x{_roomSize.y}x{_roomSize.z}m)"); return _root; } public GameObject Build(Action postBuild) { GameObject val = Build(); postBuild?.Invoke(val); return val; } private void InvalidateBuilders() { if (_interiorWallBuilder != null && _interiorWallBuilder.Doorways.Count > 0) { _interiorDoorwaysCache = _interiorWallBuilder.Doorways; } _wallBuilder = null; _furnitureBuilder = null; _lightingBuilder = null; _decorBuilder = null; _roofBuilder = null; _interiorWallBuilder = null; } private WallBuilder GetWallBuilder(BuildingPalette? palette = null) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return _wallBuilder ?? (_wallBuilder = new WallBuilder(_root.transform, _roomSize, _config.WallThickness, palette ?? _config.Palette)); } private FurnitureBuilder GetFurnitureBuilder() { if (_furnitureBuilder == null) { GameObject val = BuildingUtilities.CreateFolder("Furniture", _root.transform); _furnitureBuilder = new FurnitureBuilder(val.transform, _config.Palette); } return _furnitureBuilder; } private LightingBuilder GetLightingBuilder() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return _lightingBuilder ?? (_lightingBuilder = new LightingBuilder(_root.transform, _roomSize, _config.Palette)); } private DecorBuilder GetDecorBuilder() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return _decorBuilder ?? (_decorBuilder = new DecorBuilder(_root.transform, _roomSize, _config.Palette)); } private RoofBuilder GetRoofBuilder() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return _roofBuilder ?? (_roofBuilder = new RoofBuilder(_root.transform, _roomSize, _config.WallThickness, _config.Palette)); } private InteriorWallBuilder GetInteriorWallBuilder() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return _interiorWallBuilder ?? (_interiorWallBuilder = new InteriorWallBuilder(_root.transform, _roomSize, _config.WallThickness, _config.Palette, _interiorWallLayer)); } private PrefabPlacer GetPrefabPlacer() { return _prefabPlacer ?? (_prefabPlacer = new PrefabPlacer(_root.transform)); } private float GetDoorOffset(WallSide wall) { if (1 == 0) { } WallOpening wallOpening = wall switch { WallSide.North => _northOpening, WallSide.South => _southOpening, WallSide.East => _eastOpening, WallSide.West => _westOpening, _ => null, }; if (1 == 0) { } return wallOpening?.Offset ?? 0f; } private void RegisterWallChildren(GameObject wallsContainer) { for (int i = 0; i < wallsContainer.transform.childCount; i++) { Transform child = wallsContainer.transform.GetChild(i); WallSide? wallSide = ParseWallSide(((Object)child).name); if ((Object)(object)((Component)child).GetComponent() != (Object)null) { if (wallSide.HasValue) { _registry.Register(wallSide.Value, ((Component)child).gameObject); } else { _registry.Register(BuildingPart.ExteriorWalls, ((Component)child).gameObject); } continue; } for (int j = 0; j < child.childCount; j++) { Transform child2 = child.GetChild(j); string name = ((Object)child2).name; if (!name.StartsWith("Frame") && !name.Contains("Glass")) { if (wallSide.HasValue) { _registry.Register(wallSide.Value, ((Component)child2).gameObject); } else { _registry.Register(BuildingPart.ExteriorWalls, ((Component)child2).gameObject); } } } } } private static WallSide? ParseWallSide(string name) { if (name.StartsWith("North")) { return WallSide.North; } if (name.StartsWith("South")) { return WallSide.South; } if (name.StartsWith("East")) { return WallSide.East; } if (name.StartsWith("West")) { return WallSide.West; } return null; } private void TryAddExteriorDoor(WallSide wall, WallOpening? opening, List list) { //IL_0063: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) if (opening != null && opening.Type == WallOpeningType.Door) { if (1 == 0) { } Vector3 val = (Vector3)(wall switch { WallSide.North => new Vector3(_roomSize.x / 2f + opening.Offset, 0f, _roomSize.z), WallSide.South => new Vector3(_roomSize.x / 2f + opening.Offset, 0f, 0f), WallSide.East => new Vector3(_roomSize.x, 0f, _roomSize.z / 2f + opening.Offset), WallSide.West => new Vector3(0f, 0f, _roomSize.z / 2f + opening.Offset), _ => Vector3.zero, }); if (1 == 0) { } Vector3 val2 = val; if (1 == 0) { } val = (Vector3)(wall switch { WallSide.North => Vector3.back, WallSide.South => Vector3.forward, WallSide.East => Vector3.left, WallSide.West => Vector3.right, _ => Vector3.zero, }); if (1 == 0) { } Vector3 inwardNormal = val; Vector3? stairBasePosition = ComputeStairBasePosition(wall, val2, inwardNormal); list.Add(new NavDoorwayInfo(val2, opening.Width, opening.Height, inwardNormal, _config.WallThickness, stairBasePosition)); } } private Vector3? ComputeStairBasePosition(WallSide wall, Vector3 doorCenter, Vector3 inwardNormal) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (_foundationHeight <= 0f) { return null; } foreach (StairSpec stair in _stairs) { if (stair.Wall != wall) { continue; } int num = Mathf.Max(2, Mathf.CeilToInt(stair.FoundationHeight / stair.MaxStepHeight)); int num2 = ((stair.Style == StairStyle.ClosedRiser || stair.FlushWithFloor) ? num : (num - 1)); bool flag = wall == WallSide.North || wall == WallSide.South; float num3 = 0.1f + (flag ? _foundationExpandZ : _foundationExpandX); float num4 = (float)num2 * stair.StepDepth + stair.StepDepth / 2f + num3; Vector3 val = -inwardNormal; Vector3 val2 = doorCenter + val * num4; return new Vector3(val2.x, 0f - stair.FoundationHeight, val2.z); } return null; } private float GetOptimalMargin(FurnitureType type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = 0.15f; Vector3 footprint = FurnitureBuilder.GetFootprint(type); return Mathf.Max(footprint.x, footprint.z) / 2f + num; } private (Vector3 position, Quaternion rotation) ParseSemanticPosition(string position, float margin) { //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) float num = _roomSize.x / 2f; float num2 = _roomSize.z / 2f; float num3 = margin * 2.2f; string text = position.ToLowerInvariant(); if (1 == 0) { } (Vector3, Quaternion) result = text switch { "center" => (new Vector3(num, 0f, num2), Quaternion.identity), "north" => (new Vector3(num, 0f, _roomSize.z - margin), Quaternion.Euler(0f, 180f, 0f)), "south" => (new Vector3(num, 0f, margin), Quaternion.identity), "east" => (new Vector3(_roomSize.x - margin, 0f, num2), Quaternion.Euler(0f, -90f, 0f)), "west" => (new Vector3(margin, 0f, num2), Quaternion.Euler(0f, 90f, 0f)), "northeast" => (new Vector3(_roomSize.x - num3, 0f, _roomSize.z - num3), Quaternion.Euler(0f, -135f, 0f)), "northwest" => (new Vector3(num3, 0f, _roomSize.z - num3), Quaternion.Euler(0f, 135f, 0f)), "southeast" => (new Vector3(_roomSize.x - num3, 0f, num3), Quaternion.Euler(0f, -45f, 0f)), "southwest" => (new Vector3(num3, 0f, num3), Quaternion.Euler(0f, 45f, 0f)), _ => (new Vector3(num, 0f, num2), Quaternion.identity), }; if (1 == 0) { } return result; } } public sealed class BuildingPartRegistry { private readonly Dictionary> _parts = new Dictionary>(); private readonly Dictionary> _wallsByDirection = new Dictionary>(); internal void Register(BuildingPart part, GameObject go) { if (!_parts.TryGetValue(part, out List value)) { value = new List(); _parts[part] = value; } value.Add(go); } internal void Register(WallSide side, GameObject go) { if (!_wallsByDirection.TryGetValue(side, out List value)) { value = new List(); _wallsByDirection[side] = value; } value.Add(go); Register(BuildingPart.ExteriorWalls, go); } public Renderer[] GetRenderers(BuildingPart part) { if (!_parts.TryGetValue(part, out List value)) { return Array.Empty(); } List list = new List(); for (int i = 0; i < value.Count; i++) { if ((Object)(object)value[i] != (Object)null) { list.AddRange((IEnumerable)value[i].GetComponentsInChildren()); } } return list.ToArray(); } public Renderer[] GetRenderers(WallSide side) { if (!_wallsByDirection.TryGetValue(side, out List value)) { return Array.Empty(); } List list = new List(); for (int i = 0; i < value.Count; i++) { if ((Object)(object)value[i] != (Object)null) { list.AddRange((IEnumerable)value[i].GetComponentsInChildren()); } } return list.ToArray(); } public GameObject[] GetParts(BuildingPart part) { if (!_parts.TryGetValue(part, out List value)) { return Array.Empty(); } List list = new List(value.Count); for (int i = 0; i < value.Count; i++) { if ((Object)(object)value[i] != (Object)null) { list.Add(value[i]); } } return list.ToArray(); } public GameObject[] GetParts(WallSide side) { if (!_wallsByDirection.TryGetValue(side, out List value)) { return Array.Empty(); } List list = new List(value.Count); for (int i = 0; i < value.Count; i++) { if ((Object)(object)value[i] != (Object)null) { list.Add(value[i]); } } return list.ToArray(); } public void SetMaterial(BuildingPart part, Material material) { Renderer[] renderers = GetRenderers(part); for (int i = 0; i < renderers.Length; i++) { renderers[i].material = material; } } public void SetMaterial(WallSide side, Material material) { Renderer[] renderers = GetRenderers(side); for (int i = 0; i < renderers.Length; i++) { renderers[i].material = material; } } public void SetMaterial(BuildingPart part, Material material, int submeshIndex) { Renderer[] renderers = GetRenderers(part); SetSubmeshMaterial(renderers, material, submeshIndex); } public void SetMaterial(WallSide side, Material material, int submeshIndex) { Renderer[] renderers = GetRenderers(side); SetSubmeshMaterial(renderers, material, submeshIndex); } public void SetExteriorWallMaterial(Material material) { SetMaterial(BuildingPart.ExteriorWalls, material, 0); } public void SetInteriorFaceMaterial(Material material) { SetMaterial(BuildingPart.ExteriorWalls, material, 1); } private static void SetSubmeshMaterial(Renderer[] renderers, Material material, int submeshIndex) { for (int i = 0; i < renderers.Length; i++) { Material[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)renderers[i].materials); if (submeshIndex >= 0 && submeshIndex < array.Length) { array[submeshIndex] = material; renderers[i].materials = Il2CppReferenceArray.op_Implicit(array); } } } } public static class BuildingUtilities { public static void AddNavMeshObstacle(GameObject gameObject, bool carving = true, bool carveOnlyStationary = false) { if ((Object)(object)gameObject == (Object)null) { DebugLog.Warning("Cannot add NavMeshObstacle to null GameObject"); return; } NavMeshObstacle orAddComponent = gameObject.GetOrAddComponent(); orAddComponent.carving = carving; orAddComponent.carveOnlyStationary = carveOnlyStationary; DebugLog.Info("Added NavMeshObstacle to: " + ((Object)gameObject).name); } public static void AddNavMeshObstacles(GameObject[] gameObjects, bool carving = true) { if (gameObjects != null) { foreach (GameObject gameObject in gameObjects) { AddNavMeshObstacle(gameObject, carving); } } } public static void RemoveColliders(GameObject gameObject, bool includeChildren = false) { if ((Object)(object)gameObject == (Object)null) { return; } if (includeChildren) { Collider[] array = Il2CppArrayBase.op_Implicit(gameObject.GetComponentsInChildren()); Collider[] array2 = array; foreach (Collider val in array2) { Object.Destroy((Object)(object)val); } } else { Collider component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } } public static void SetupCollider(GameObject gameObject) { if (!((Object)(object)gameObject == (Object)null)) { string text = ((Object)gameObject).name.ToLower(); if (text.Contains("fallback") || text.Contains("decorative") || text.Contains("rug") || text.Contains("mat")) { RemoveColliders(gameObject); } } } public static void ApplyOcclusionSettings(GameObject gameObject, bool allowOcclusion) { if (!((Object)(object)gameObject == (Object)null)) { Renderer[] array = Il2CppArrayBase.op_Implicit(gameObject.GetComponentsInChildren()); Renderer[] array2 = array; foreach (Renderer val in array2) { val.allowOcclusionWhenDynamic = allowOcclusion; } DebugLog.Info($"Set occlusion to {allowOcclusion} for {array.Length} renderers in {((Object)gameObject).name}"); } } public static float ComputeGridCellSize(float roomX, float roomZ) { float num = 0.5f; int num2 = Mathf.Max(1, Mathf.CeilToInt(roomX / num)); int num3 = Mathf.Max(1, Mathf.CeilToInt(roomZ / num)); return Mathf.Min(roomX / (float)num2, roomZ / (float)num3); } internal static bool IsLivingEntity(Transform t, HashSet livingRoots, HashSet staticRoots) { int instanceID = ((Object)t.root).GetInstanceID(); if (livingRoots.Contains(instanceID)) { return true; } if (staticRoots.Contains(instanceID)) { return false; } Transform root = t.root; bool flag = (Object)(object)((Component)root).GetComponentInChildren() != (Object)null || (Object)(object)((Component)root).GetComponentInChildren() != (Object)null; (flag ? livingRoots : staticRoots).Add(instanceID); return flag; } public static GameObject CreateFolder(string name, Transform? parent = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(name); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent); val.transform.Reset(); } return val; } } internal sealed class InteriorNavigator : MonoBehaviour { internal InteriorNavigatorCore? _core; private void Update() { _core?.Update(); } private void OnDestroy() { _core?.Cleanup(); _core = null; } } internal sealed class InteriorNavigatorCore { private enum NPCNavState { Approaching, Entering, Inside, Exiting, LeavingDoorway } private sealed class TrackedNPC { public Component NpcComponent; public NPCNavState State; public NavDoorwayInfo TargetDoorway; public Vector3 DoorwayExteriorWorld; public Vector3 DoorwayThresholdWorld; public Vector3 DoorwayInteriorWorld; public List? Path; public int PathIndex; public Vector3 TargetLocal; public Transform? ChaseTarget; public float ChaseRepathTimer; public float Speed; public Action? OnArrival; public float LerpProgress; public float LerpDuration; public Vector3 LerpStart; public Vector3 LerpEnd; public bool Arrived; public Vector3? PendingExteriorDestination; public Vector3? SavedChasePosition; public float RepathTimer; public float StuckTimer; public Vector3 StuckStartPos; public Vector3 LastChaseTargetLocal; public float ApproachStartTime; public bool IsStairLerp; public Vector3 LastValidPos; public object? MovementRef; public NavMeshAgent? Agent; public Collider? NpcCollider; } private readonly struct MemberAccessor { private readonly FieldInfo? _field; private readonly PropertyInfo? _prop; public bool IsValid => _field != null || _prop != null; public MemberAccessor(Type type, string name, BindingFlags flags) { _prop = type.GetProperty(name, flags); _field = ((_prop == null) ? type.GetField(name, flags) : null); } public object? GetValue(object target) { return (_field != null) ? _field.GetValue(target) : _prop?.GetValue(target); } public void SetValue(object target, object? value) { if (_field != null) { _field.SetValue(target, value); } else { _prop?.SetValue(target, value); } } } private readonly InteriorPathGrid _grid; private readonly IReadOnlyList _doorways; private readonly Transform _buildingRoot; private readonly Vector3 _roomSize; private readonly float _foundationHeight; private readonly Dictionary _tracked = new Dictionary(); private readonly List _removeQueue = new List(); private float _doorwayScanTimer; private float _approachLogTimer; private static readonly Collider[] _scanBuffer = (Collider[])(object)new Collider[32]; private static readonly HashSet _globallyManaged = new HashSet(); private static readonly List _activeBuildings = new List(); private static bool _patchApplied; private static bool _reflectionResolved; private static Type? _npcMovementType; private static MemberAccessor _agentAccessor; private static MethodInfo? _setAgentEnabled; private static MemberAccessor _walkSpeedAccessor; private static MemberAccessor _runSpeedAccessor; private static MemberAccessor _speedScaleAccessor; private static MemberAccessor _moveSpeedMultAccessor; private static MemberAccessor _hasDestinationAccessor; private static MethodInfo? _originalSetDestination; private static Harmony? _harmony; private static MemberAccessor _movementNpcAccessor; private static MemberAccessor _npcBehaviourAccessor; private static MemberAccessor _activeBehaviourAccessor; private static Type? _combatBehaviourType; internal InteriorPathGrid PathGrid => _grid; public InteriorNavigatorCore(InteriorPathGrid grid, IReadOnlyList doorways, Transform buildingRoot, Vector3 roomSize, float foundationHeight) { //IL_0034: 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) _grid = grid; _doorways = doorways; _buildingRoot = buildingRoot; _roomSize = roomSize; _foundationHeight = foundationHeight; ResolveReflection(); _activeBuildings.Add(this); ApplyPatchIfNeeded(); } private static void ResolveReflection() { if (_reflectionResolved) { return; } _reflectionResolved = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { _npcMovementType = assembly.GetType("Il2CppScheduleOne.NPCs.NPCMovement"); if (_npcMovementType != null) { break; } } if (_npcMovementType == null) { DebugLog.Warning("[InteriorNavigator] NPCMovement type not found."); return; } _agentAccessor = new MemberAccessor(_npcMovementType, "Agent", BindingFlags.Instance | BindingFlags.Public); _setAgentEnabled = _npcMovementType.GetMethod("SetAgentEnabled", BindingFlags.Instance | BindingFlags.Public); _walkSpeedAccessor = new MemberAccessor(_npcMovementType, "WalkSpeed", BindingFlags.Instance | BindingFlags.Public); _runSpeedAccessor = new MemberAccessor(_npcMovementType, "RunSpeed", BindingFlags.Instance | BindingFlags.Public); _speedScaleAccessor = new MemberAccessor(_npcMovementType, "MovementSpeedScale", BindingFlags.Instance | BindingFlags.Public); _moveSpeedMultAccessor = new MemberAccessor(_npcMovementType, "MoveSpeedMultiplier", BindingFlags.Instance | BindingFlags.Public); _hasDestinationAccessor = new MemberAccessor(_npcMovementType, "HasDestination", BindingFlags.Instance | BindingFlags.Public); _movementNpcAccessor = new MemberAccessor(_npcMovementType, "npc", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Type type = null; Type type2 = null; Assembly[] assemblies2 = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies2) { if ((object)type == null) { type = assembly2.GetType("Il2CppScheduleOne.NPCs.NPC"); } if ((object)type2 == null) { type2 = assembly2.GetType("Il2CppScheduleOne.NPCs.Behaviour.NPCBehaviour"); } if ((object)_combatBehaviourType == null) { _combatBehaviourType = assembly2.GetType("Il2CppScheduleOne.Combat.CombatBehaviour"); } if (type != null && type2 != null && _combatBehaviourType != null) { break; } } if (type != null) { _npcBehaviourAccessor = new MemberAccessor(type, "Behaviour", BindingFlags.Instance | BindingFlags.Public); } if (type2 != null) { _activeBehaviourAccessor = new MemberAccessor(type2, "activeBehaviour", BindingFlags.Instance | BindingFlags.Public); } } private static void ApplyPatchIfNeeded() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown if (_patchApplied || _npcMovementType == null) { return; } _patchApplied = true; MethodInfo methodInfo = null; MethodInfo[] methods = _npcMovementType.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (!(methodInfo2.Name != "SetDestination")) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length == 4 && parameters[0].ParameterType == typeof(Vector3)) { methodInfo = methodInfo2; break; } } } if (methodInfo == null) { DebugLog.Warning("[InteriorNavigator] Could not find SetDestination to patch."); return; } _originalSetDestination = methodInfo; _harmony = new Harmony("com.s1mapi.interiornavigator"); MethodInfo method = typeof(InteriorNavigatorCore).GetMethod("SetDestinationPrefix", BindingFlags.Static | BindingFlags.NonPublic); _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo method2 = _npcMovementType.GetMethod("UpdateDestination", BindingFlags.Instance | BindingFlags.NonPublic); if (method2 != null) { MethodInfo method3 = typeof(InteriorNavigatorCore).GetMethod("UpdateDestinationPrefix", BindingFlags.Static | BindingFlags.NonPublic); _harmony.Patch((MethodBase)method2, new HarmonyMethod(method3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); DebugLog.Info("[InteriorNavigator] Patched UpdateDestination."); } else { DebugLog.Warning("[InteriorNavigator] Could not find UpdateDestination to patch."); } DebugLog.Info("[InteriorNavigator] Patched NPCMovement.SetDestination for auto-interception."); } private static bool SetDestinationPrefix(object __instance, Vector3 pos) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0403: 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) //IL_03c0: 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_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) Component val = (Component)((__instance is Component) ? __instance : null); if ((Object)(object)val == (Object)null) { return true; } for (int i = 0; i < _activeBuildings.Count; i++) { InteriorNavigatorCore interiorNavigatorCore = _activeBuildings[i]; if (interiorNavigatorCore == null || (Object)(object)interiorNavigatorCore._buildingRoot == (Object)null) { continue; } Vector3 val2 = interiorNavigatorCore._buildingRoot.InverseTransformPoint(pos); if (!interiorNavigatorCore.IsInsideBuilding(val2) && (!IsNPCInCombat(val) || !interiorNavigatorCore.IsInsideBuilding(val2, 3f) || !interiorNavigatorCore.IsPlayerInside())) { continue; } val2.x = Mathf.Clamp(val2.x, 0f, interiorNavigatorCore._roomSize.x); val2.z = Mathf.Clamp(val2.z, 0f, interiorNavigatorCore._roomSize.z); Transform val3 = (IsNPCInCombat(val) ? DetectChaseTarget(pos) : null); if (interiorNavigatorCore._tracked.TryGetValue(val, out TrackedNPC value)) { value.TargetLocal = val2; value.OnArrival = null; if ((Object)(object)val3 != (Object)null) { value.ChaseTarget = val3; value.LastChaseTargetLocal = val2; } else { value.ChaseTarget = null; } if (value.State == NPCNavState.Inside) { interiorNavigatorCore.ComputePathToTarget(value); } if (value.State == NPCNavState.Approaching && (Object)(object)value.Agent != (Object)null && ((Behaviour)value.Agent).enabled && value.Agent.isOnNavMesh) { value.Agent.SetDestination(value.DoorwayExteriorWorld); } return false; } DebugLog.Info($"[InteriorNavigator] Tracking new NPC {((Object)val).name} targeting local ({val2.x:F1}, {val2.z:F1})"); TrackedNPC trackedNPC = interiorNavigatorCore.CreateTrackedNPC(val); trackedNPC.TargetLocal = val2; trackedNPC.ChaseTarget = val3; trackedNPC.ChaseRepathTimer = 0f; trackedNPC.OnArrival = null; interiorNavigatorCore.ComputeDoorwayPoints(trackedNPC, trackedNPC.TargetDoorway = interiorNavigatorCore.FindNearestExteriorDoorway(interiorNavigatorCore._buildingRoot.InverseTransformPoint(val.transform.position))); trackedNPC.State = NPCNavState.Approaching; trackedNPC.ApproachStartTime = Time.time; if ((Object)(object)trackedNPC.Agent != (Object)null && ((Behaviour)trackedNPC.Agent).enabled && trackedNPC.Agent.isOnNavMesh) { trackedNPC.Agent.SetDestination(trackedNPC.DoorwayExteriorWorld); } interiorNavigatorCore._tracked[val] = trackedNPC; _globallyManaged.Add(val); return false; } if (_globallyManaged.Contains(val)) { for (int j = 0; j < _activeBuildings.Count; j++) { InteriorNavigatorCore interiorNavigatorCore2 = _activeBuildings[j]; if (interiorNavigatorCore2 == null || !interiorNavigatorCore2._tracked.TryGetValue(val, out TrackedNPC value2)) { continue; } if (value2.State == NPCNavState.Approaching) { Vector3 localPos = interiorNavigatorCore2._buildingRoot.InverseTransformPoint(pos); if (!interiorNavigatorCore2.IsInsideBuilding(localPos, 5f)) { _globallyManaged.Remove(val); interiorNavigatorCore2._tracked.Remove(val); return true; } return false; } value2.PendingExteriorDestination = pos; interiorNavigatorCore2.RecallNPC(val); return false; } } return true; } private static bool UpdateDestinationPrefix(object __instance) { Component val = (Component)((__instance is Component) ? __instance : null); if ((Object)(object)val != (Object)null && _globallyManaged.Contains(val)) { return false; } return true; } private static bool IsNPCInCombat(Component movement) { if (_combatBehaviourType == null || !_movementNpcAccessor.IsValid || !_npcBehaviourAccessor.IsValid || !_activeBehaviourAccessor.IsValid) { return false; } try { object value = _movementNpcAccessor.GetValue(movement); if (value == null) { return false; } object value2 = _npcBehaviourAccessor.GetValue(value); if (value2 == null) { return false; } object value3 = _activeBehaviourAccessor.GetValue(value2); if (value3 == null) { return false; } return _combatBehaviourType.IsInstanceOfType(value3); } catch { return false; } } private static Transform? DetectChaseTarget(Vector3 destination) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) foreach (Camera item in (Il2CppArrayBase)(object)Camera.allCameras) { Vector3 position = ((Component)item).transform.position; float num = destination.x - position.x; float num2 = destination.z - position.z; float num3 = num * num + num2 * num2; if (num3 < 9f) { return ((Component)item).transform; } } return null; } public void SendNPCToPosition(Component npc, Vector3 localTarget, Action? onArrival) { //IL_0017: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (_tracked.TryGetValue(npc, out TrackedNPC value)) { value.TargetLocal = localTarget; value.OnArrival = onArrival; value.Arrived = false; value.ChaseTarget = null; if (value.State == NPCNavState.Inside) { ComputePathToTarget(value); } return; } if (_globallyManaged.Contains(npc)) { DebugLog.Warning("[InteriorNavigator] NPC is already managed by another building."); return; } TrackedNPC trackedNPC = CreateTrackedNPC(npc); trackedNPC.TargetLocal = localTarget; trackedNPC.OnArrival = onArrival; trackedNPC.ChaseTarget = null; Vector3 position = npc.transform.position; NavDoorwayInfo navDoorwayInfo = null; for (int i = 0; i < _doorways.Count; i++) { NavDoorwayInfo navDoorwayInfo2 = _doorways[i]; if (!navDoorwayInfo2.IsInterior) { Vector3 b; float num; if (navDoorwayInfo2.StairBasePosition.HasValue) { b = _buildingRoot.TransformPoint(navDoorwayInfo2.StairBasePosition.Value); num = 1.5f; } else { b = _buildingRoot.TransformPoint(navDoorwayInfo2.Center); num = 4f; } if (HorizontalDistance(position, b) < num) { navDoorwayInfo = navDoorwayInfo2; break; } } } _tracked[npc] = trackedNPC; _globallyManaged.Add(npc); if (navDoorwayInfo != null) { trackedNPC.TargetDoorway = navDoorwayInfo; ComputeDoorwayPoints(trackedNPC, navDoorwayInfo); BeginDoorwayEntry(npc, trackedNPC); } else { BeginApproach(trackedNPC); SendAgentToDoorway(trackedNPC); } DebugLog.Info($"[InteriorNavigator] Sending NPC to local ({localTarget.x:F1}, {localTarget.z:F1})"); } public void SendNPCToChase(Component npc, Transform target) { if (_globallyManaged.Contains(npc)) { DebugLog.Warning("[InteriorNavigator] NPC is already managed by a building."); } else { SendNPCToChaseInternal(npc, target); } } private void SendNPCToChaseInternal(Component npc, Transform target) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) Vector3 targetLocal = _buildingRoot.InverseTransformPoint(target.position); TrackedNPC trackedNPC = CreateTrackedNPC(npc); trackedNPC.TargetLocal = targetLocal; trackedNPC.ChaseTarget = target; trackedNPC.ChaseRepathTimer = 0f; trackedNPC.OnArrival = null; BeginApproach(trackedNPC); SendAgentToDoorway(trackedNPC); _tracked[npc] = trackedNPC; _globallyManaged.Add(npc); DebugLog.Info("[InteriorNavigator] NPC chasing player — continuous tracking enabled."); } private static void SendAgentToDoorway(TrackedNPC data) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)data.Agent != (Object)null && ((Behaviour)data.Agent).enabled && data.Agent.isOnNavMesh) { data.Agent.SetDestination(data.DoorwayExteriorWorld); } } public void RecallNPC(Component npc) { if (_tracked.TryGetValue(npc, out TrackedNPC value)) { if (value.State == NPCNavState.Approaching) { ReleaseNPC(npc, value, warpToExterior: false); } else if (value.State != NPCNavState.Exiting && value.State != NPCNavState.LeavingDoorway) { BeginExit(npc, value); } } } public bool IsTracking(Component npc) { return _tracked.ContainsKey(npc); } public void VisualizeGrid(bool show) { if (show) { _grid.Visualize(); } else { _grid.DestroyVisualization(); } } public void DiagnoseCell(int gx, int gz) { _grid.DiagnoseCell(gx, gz); } public void ReleaseAllNPCs() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair item in _tracked) { if ((Object)(object)item.Key == (Object)null) { continue; } TrackedNPC value = item.Value; if (value.State != NPCNavState.Approaching) { if (value.DoorwayExteriorWorld != Vector3.zero) { item.Key.transform.position = value.DoorwayExteriorWorld; } if ((Object)(object)value.NpcCollider != (Object)null) { value.NpcCollider.enabled = true; } EnableAgent(value); } if (value.MovementRef != null && _hasDestinationAccessor.IsValid) { try { _hasDestinationAccessor.SetValue(value.MovementRef, true); } catch (Exception ex) { DebugLog.Warning("[InteriorNavigator] RestoreHasDestination failed: " + ex.Message); } } _globallyManaged.Remove(item.Key); } _tracked.Clear(); } public void Update() { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) _doorwayScanTimer -= Time.deltaTime; if (_doorwayScanTimer <= 0f) { _doorwayScanTimer = 0.5f; ScanForNearbyNPCs(); } if (_tracked.Count == 0) { return; } _removeQueue.Clear(); foreach (KeyValuePair item in _tracked) { Component npc = item.Key; TrackedNPC data = item.Value; if ((Object)(object)npc == (Object)null) { _removeQueue.Add(npc); continue; } if (data.State != NPCNavState.Approaching && (Object)(object)data.Agent != (Object)null && ((Behaviour)data.Agent).enabled) { ((Behaviour)data.Agent).enabled = false; npc.transform.position = data.LastValidPos; } switch (data.State) { case NPCNavState.Approaching: UpdateApproaching(npc, data); break; case NPCNavState.Entering: UpdateLerp(npc, data, delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) float num2 = Vector3.Distance(npc.transform.position, data.DoorwayInteriorWorld); if (num2 > 0.15f) { data.IsStairLerp = false; data.Speed = GetNPCSpeed(data); data.LerpStart = npc.transform.position; data.LerpEnd = data.DoorwayInteriorWorld; float num3 = Vector3.Distance(data.LerpStart, data.LerpEnd); data.LerpDuration = Mathf.Max(num3 / Mathf.Max(data.Speed, 1f), 0.1f); data.LerpProgress = 0f; } else { data.State = NPCNavState.Inside; ComputePathToTarget(data); } }); break; case NPCNavState.Inside: UpdateInside(npc, data); break; case NPCNavState.Exiting: { Vector3 position = npc.transform.position; if (data.StuckTimer == 0f) { data.StuckStartPos = position; } data.StuckTimer += Time.deltaTime; float num = (position.x - data.StuckStartPos.x) * (position.x - data.StuckStartPos.x) + (position.z - data.StuckStartPos.z) * (position.z - data.StuckStartPos.z); if (num > 0.25f) { data.StuckTimer = 0f; } else if (data.StuckTimer > 3f) { DebugLog.Warning("[InteriorNavigator] NPC stuck during exit, forcing doorway leave."); BeginDoorwayLeave(npc, data); break; } UpdatePathFollow(npc, data, delegate { BeginDoorwayLeave(npc, data); }); break; } case NPCNavState.LeavingDoorway: UpdateLerp(npc, data, delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //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) float num2 = Vector3.Distance(npc.transform.position, data.DoorwayExteriorWorld); if (num2 > 0.15f) { data.IsStairLerp = data.TargetDoorway.StairBasePosition.HasValue; data.Speed = GetNPCSpeed(data); data.LerpStart = npc.transform.position; data.LerpEnd = data.DoorwayExteriorWorld; float num3 = Vector3.Distance(data.LerpStart, data.LerpEnd); data.LerpDuration = Mathf.Max(num3 / Mathf.Max(data.Speed, 1f), 0.1f); data.LerpProgress = 0f; } else { ReleaseNPC(npc, data, warpToExterior: false); } }); break; } if (data.State != NPCNavState.Approaching) { data.LastValidPos = npc.transform.position; } } foreach (Component item2 in _removeQueue) { _globallyManaged.Remove(item2); _tracked.Remove(item2); } } private void ScanForNearbyNPCs() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) if (_npcMovementType == null) { return; } Transform val = FindPlayerInside(); if ((Object)(object)val == (Object)null) { return; } Vector3 targetLocal = _buildingRoot.InverseTransformPoint(val.position); float num = 4f; for (int i = 0; i < _doorways.Count; i++) { NavDoorwayInfo navDoorwayInfo = _doorways[i]; if (navDoorwayInfo.IsInterior) { continue; } Vector3 center = navDoorwayInfo.Center; center.y = (navDoorwayInfo.StairBasePosition.HasValue ? navDoorwayInfo.StairBasePosition.Value.y : (0f - _foundationHeight)); Vector3 val2 = _buildingRoot.TransformPoint(center); int num2 = Physics.OverlapSphereNonAlloc(val2, num, Il2CppReferenceArray.op_Implicit(_scanBuffer), -1, (QueryTriggerInteraction)2); for (int j = 0; j < num2; j++) { if (!((Object)(object)_scanBuffer[j] == (Object)null)) { Component val3 = FindComponentInParent((Component)(object)_scanBuffer[j], _npcMovementType); if (!((Object)(object)val3 == (Object)null) && !_globallyManaged.Contains(val3) && !_tracked.ContainsKey(val3)) { DebugLog.Info("[InteriorNavigator] Auto-detected NPC " + ((Object)val3).name + " near doorway, registering..."); TrackedNPC trackedNPC = CreateTrackedNPC(val3); trackedNPC.TargetLocal = targetLocal; trackedNPC.ChaseTarget = val; trackedNPC.ChaseRepathTimer = 0f; trackedNPC.OnArrival = null; trackedNPC.TargetDoorway = navDoorwayInfo; ComputeDoorwayPoints(trackedNPC, navDoorwayInfo); _tracked[val3] = trackedNPC; _globallyManaged.Add(val3); BeginDoorwayEntry(val3, trackedNPC); } } } } } private void BeginApproach(TrackedNPC data) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001e: 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) Vector3 localPos = _buildingRoot.InverseTransformPoint(data.NpcComponent.transform.position); ComputeDoorwayPoints(data, data.TargetDoorway = FindNearestExteriorDoorway(localPos)); data.State = NPCNavState.Approaching; data.ApproachStartTime = Time.time; DebugLog.Info($"[InteriorNavigator] NPC approaching doorway at {data.DoorwayExteriorWorld}"); } private void UpdateApproaching(Component npc, TrackedNPC data) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = npc.transform.position; float num = (data.TargetDoorway.StairBasePosition.HasValue ? 1.5f : 4f); float num2 = HorizontalDistance(position, data.DoorwayExteriorWorld); if (num2 < num) { DebugLog.Info($"[InteriorNavigator] NPC reached doorway (distXZ={num2:F2}), entering..."); BeginDoorwayEntry(npc, data); return; } for (int i = 0; i < _doorways.Count; i++) { NavDoorwayInfo navDoorwayInfo = _doorways[i]; if (!navDoorwayInfo.IsInterior && navDoorwayInfo != data.TargetDoorway) { Vector3 b = _buildingRoot.TransformPoint(navDoorwayInfo.Center); float num3 = HorizontalDistance(position, b); if (num3 < num) { DebugLog.Info($"[InteriorNavigator] NPC near alternate doorway (dist={num3:F2}), switching..."); data.TargetDoorway = navDoorwayInfo; ComputeDoorwayPoints(data, navDoorwayInfo); BeginDoorwayEntry(npc, data); return; } } } float num4 = Time.time - data.ApproachStartTime; if (num4 > 12f) { Vector3 localPos = _buildingRoot.InverseTransformPoint(position); ComputeDoorwayPoints(data, data.TargetDoorway = FindNearestExteriorDoorway(localPos)); float num5 = HorizontalDistance(position, data.DoorwayExteriorWorld); if (num5 < 12f) { DebugLog.Warning($"[InteriorNavigator] Approach timeout ({num4:F0}s), forcing entry (dist={num5:F1}m)..."); BeginDoorwayEntry(npc, data); return; } } if ((Object)(object)data.Agent == (Object)null) { return; } bool pathPending = data.Agent.pathPending; bool hasPath = data.Agent.hasPath; float remainingDistance = data.Agent.remainingDistance; bool flag = !float.IsInfinity(remainingDistance) && !float.IsNaN(remainingDistance); float num6 = (data.TargetDoorway.StairBasePosition.HasValue ? 3f : 8f); if (!pathPending && flag && remainingDistance < 0.5f && num2 < num6) { DebugLog.Info($"[InteriorNavigator] Agent path done near doorway (distXZ={num2:F2}), entering..."); BeginDoorwayEntry(npc, data); return; } if (!pathPending && !hasPath && ((Behaviour)data.Agent).enabled && data.Agent.isOnNavMesh) { data.Agent.SetDestination(data.DoorwayExteriorWorld); } _approachLogTimer -= Time.deltaTime; if (_approachLogTimer <= 0f) { _approachLogTimer = 3f; DebugLog.Info($"[InteriorNavigator] Approach: distXZ={num2:F2}, elapsed={num4:F0}s, hasPath={hasPath}, remaining={remainingDistance:F2}"); } } private static float HorizontalDistance(Vector3 a, Vector3 b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) float num = a.x - b.x; float num2 = a.z - b.z; return Mathf.Sqrt(num * num + num2 * num2); } private void BeginDoorwayEntry(Component npc, TrackedNPC data) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0130: Unknown result type (might be due to invalid IL or missing references) data.LastValidPos = npc.transform.position; if ((Object)(object)data.Agent != (Object)null) { data.Agent.isStopped = true; data.Agent.ResetPath(); } DisableAgent(data); if ((Object)(object)data.NpcCollider != (Object)null) { data.NpcCollider.enabled = false; } ClearHasDestination(data); data.Speed = GetNPCSpeed(data); data.LerpStart = npc.transform.position; if (data.TargetDoorway.StairBasePosition.HasValue) { float num = Vector3.Distance(npc.transform.position, data.DoorwayThresholdWorld); bool flag = num > 0.15f; data.LerpEnd = (flag ? data.DoorwayThresholdWorld : data.DoorwayInteriorWorld); data.IsStairLerp = flag; } else { float num2 = Vector3.Distance(npc.transform.position, data.DoorwayExteriorWorld); data.LerpEnd = ((num2 > 1f) ? data.DoorwayExteriorWorld : data.DoorwayInteriorWorld); data.IsStairLerp = false; } float num3 = Vector3.Distance(data.LerpStart, data.LerpEnd); data.LerpDuration = Mathf.Max(num3 / Mathf.Max(data.Speed, 1f), 0.1f); data.LerpProgress = 0f; data.State = NPCNavState.Entering; } private void BeginDoorwayLeave(Component npc, TrackedNPC data) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0043: 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_004f: Unknown result type (might be due to invalid IL or missing references) data.Speed = GetNPCSpeed(data); data.LerpStart = npc.transform.position; data.LerpEnd = (data.TargetDoorway.StairBasePosition.HasValue ? data.DoorwayThresholdWorld : data.DoorwayExteriorWorld); float num = Vector3.Distance(data.LerpStart, data.LerpEnd); data.LerpDuration = Mathf.Max(num / Mathf.Max(data.Speed, 1f), 0.1f); data.LerpProgress = 0f; data.IsStairLerp = false; data.State = NPCNavState.LeavingDoorway; } private void UpdateLerp(Component npc, TrackedNPC data, Action onComplete) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_00bd: Unknown result type (might be due to invalid IL or missing references) data.LerpProgress += Time.deltaTime / data.LerpDuration; float num = Mathf.Clamp01(data.LerpProgress); float num2 = num * num * (3f - 2f * num); Vector3 val = Vector3.Lerp(data.LerpStart, data.LerpEnd, num2); if (data.IsStairLerp) { float num3 = data.LerpEnd.x - data.LerpStart.x; float num4 = data.LerpEnd.z - data.LerpStart.z; float num5 = num3 * num3 + num4 * num4; if (num5 > 0.001f) { float num6 = (val.x - data.LerpStart.x) * num3 + (val.z - data.LerpStart.z) * num4; float num7 = Mathf.Clamp01(num6 / num5); val.y = Mathf.Lerp(data.LerpStart.y, data.LerpEnd.y, num7); } } npc.transform.position = val; RotateToward(npc.transform, data.LerpEnd - data.LerpStart); if (num >= 1f) { npc.transform.position = data.LerpEnd; onComplete(); } } private void UpdateInside(Component npc, TrackedNPC data) { //IL_0014: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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) Vector3 position = npc.transform.position; if (data.ChaseTarget != null) { if ((Object)(object)data.ChaseTarget == (Object)null) { BeginExit(npc, data); return; } Vector3 val = _buildingRoot.InverseTransformPoint(data.ChaseTarget.position); if (!IsInsideBuilding(val)) { BeginExit(npc, data); return; } float num = Vector3.Distance(position, data.ChaseTarget.position); if (num < 0.5f) { RotateToward(npc.transform, data.ChaseTarget.position - position); data.Path = null; data.ChaseRepathTimer = 0.2f; return; } data.ChaseRepathTimer -= Time.deltaTime; if (data.ChaseRepathTimer <= 0f) { data.ChaseRepathTimer = 0.2f; float num2 = (val.x - data.LastChaseTargetLocal.x) * (val.x - data.LastChaseTargetLocal.x) + (val.z - data.LastChaseTargetLocal.z) * (val.z - data.LastChaseTargetLocal.z); float num3 = _grid.CellSize * 2f; if (num2 > num3 * num3 || data.Path == null) { data.TargetLocal = val; data.LastChaseTargetLocal = val; ComputePathToTarget(data); } } } if (!data.Arrived) { data.RepathTimer -= Time.deltaTime; if (data.RepathTimer <= 0f) { data.RepathTimer = 0.5f; if (data.Path == null || data.PathIndex >= data.Path.Count) { ComputePathToTarget(data); if (data.Path != null) { DebugLog.Info($"[InteriorNavigator] Fallback re-path found {data.Path.Count} waypoints, speed={data.Speed:F1}"); } } } } if (data.Path != null && data.PathIndex < data.Path.Count) { if (data.StuckTimer == 0f) { data.StuckStartPos = position; } data.StuckTimer += Time.deltaTime; float num4 = (position.x - data.StuckStartPos.x) * (position.x - data.StuckStartPos.x) + (position.z - data.StuckStartPos.z) * (position.z - data.StuckStartPos.z); if (num4 > 0.25f) { data.StuckTimer = 0f; } else if (data.StuckTimer > 2f) { data.StuckTimer = 0f; Vector3 val2 = data.Path[data.PathIndex]; DebugLog.Warning($"[InteriorNavigator] NPC stuck (displaced {Mathf.Sqrt(num4):F2}m in 2s). speed={data.Speed:F1}, pathIdx={data.PathIndex}/{data.Path.Count}, npcWorld=({position.x:F1},{position.y:F1},{position.z:F1}), waypoint=({val2.x:F1},{val2.y:F1},{val2.z:F1})"); ComputePathToTarget(data); } } UpdatePathFollow(npc, data, delegate { if ((Object)(object)data.ChaseTarget == (Object)null) { data.Arrived = true; data.OnArrival?.Invoke(); data.OnArrival = null; } }); } private void BeginExit(Component npc, TrackedNPC data) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) Vector3 val = _buildingRoot.InverseTransformPoint(npc.transform.position); ComputeDoorwayPoints(data, data.TargetDoorway = FindNearestExteriorDoorway(val)); if ((Object)(object)data.ChaseTarget != (Object)null) { try { data.SavedChasePosition = data.ChaseTarget.position; } catch { } } data.ChaseTarget = null; data.Path = _grid.FindPath(val, _buildingRoot.InverseTransformPoint(data.DoorwayInteriorWorld)); data.PathIndex = 0; data.StuckTimer = 0f; if (data.Path == null) { DebugLog.Warning("[InteriorNavigator] Exit pathfind failed, forcing doorway leave."); BeginDoorwayLeave(npc, data); } else { data.State = NPCNavState.Exiting; } } private void UpdatePathFollow(Component npc, TrackedNPC data, Action onComplete) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) if (data.Path == null || data.PathIndex >= data.Path.Count) { onComplete(); return; } data.Speed = GetNPCSpeed(data); if (data.Speed < 0.1f) { DebugLog.Warning($"[InteriorNavigator] NPC speed near zero ({data.Speed:F3}), forcing minimum."); data.Speed = 1.8f; } Vector3 val = data.Path[data.PathIndex]; Vector3 position = npc.transform.position; float y = (val.y = _buildingRoot.TransformPoint(Vector3.zero).y); Vector3 val2 = Vector3.MoveTowards(position, val, data.Speed * Time.deltaTime); val2.y = y; npc.transform.position = val2; RotateToward(npc.transform, val - position); float num = (val2.x - val.x) * (val2.x - val.x) + (val2.z - val.z) * (val2.z - val.z); float num2 = ((data.PathIndex == data.Path.Count - 1) ? 0.5f : 0.3f); if (!(num < num2 * num2)) { return; } data.PathIndex++; while (data.PathIndex < data.Path.Count - 1) { Vector3 val3 = data.Path[data.PathIndex]; val3.y = y; float num3 = (val2.x - val3.x) * (val2.x - val3.x) + (val2.z - val3.z) * (val2.z - val3.z); if (num3 < num2 * num2) { data.PathIndex++; continue; } break; } } private void ComputePathToTarget(TrackedNPC data) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0024: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) Vector3 startLocal = _buildingRoot.InverseTransformPoint(data.NpcComponent.transform.position); data.Path = _grid.FindPath(startLocal, data.TargetLocal); data.PathIndex = 0; if (data.Path == null) { DebugLog.Warning("[InteriorNavigator] No path found to target " + $"({data.TargetLocal.x:F1}, {data.TargetLocal.z:F1})"); } else if (data.Path.Count > 1) { Vector3 val = data.Path[0]; Vector3 position = data.NpcComponent.transform.position; float num = (position.x - val.x) * (position.x - val.x) + (position.z - val.z) * (position.z - val.z); if (num < _grid.CellSize * _grid.CellSize) { data.PathIndex = 1; } } } private static Component? FindComponent(Component target, Type type) { return target.GetComponent(Il2CppType.From(type)); } private static Component? FindComponentInChildren(Component target, Type type) { return target.GetComponentInChildren(Il2CppType.From(type)); } private static Component? FindComponentInParent(Component target, Type type) { return target.GetComponentInParent(Il2CppType.From(type)); } private void RotateToward(Transform t, Vector3 direction) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) direction.y = 0f; if (!(((Vector3)(ref direction)).sqrMagnitude < 0.001f)) { Quaternion val = Quaternion.LookRotation(((Vector3)(ref direction)).normalized, Vector3.up); t.rotation = Quaternion.RotateTowards(t.rotation, val, 360f * Time.deltaTime); } } private NavDoorwayInfo FindNearestExteriorDoorway(Vector3 localPos) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) NavDoorwayInfo result = null; float num = float.MaxValue; foreach (NavDoorwayInfo doorway in _doorways) { if (!doorway.IsInterior) { float num2 = Vector3.Distance(localPos, doorway.Center); if (num2 < num) { num = num2; result = doorway; } } } return result; } private void ComputeDoorwayPoints(TrackedNPC data, NavDoorwayInfo door) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0094: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) Vector3 val; if (door.StairBasePosition.HasValue) { val = door.StairBasePosition.Value; } else { float num = door.WallThickness / 2f + 2.5f; val = door.Center - door.InwardNormal * num; val.y = 0f - _foundationHeight; } Vector3 doorwayExteriorWorld = _buildingRoot.TransformPoint(val); float num2 = door.WallThickness / 2f + 0.3f; Vector3 val2 = door.Center - door.InwardNormal * num2; val2.y = (door.StairBasePosition.HasValue ? 0f : val.y); float num3 = door.WallThickness / 2f + 0.3f; Vector3 val3 = door.Center + door.InwardNormal * num3; val3.y = 0f; data.DoorwayExteriorWorld = doorwayExteriorWorld; data.DoorwayThresholdWorld = _buildingRoot.TransformPoint(val2); data.DoorwayInteriorWorld = _buildingRoot.TransformPoint(val3); } private bool IsInsideBuilding(Vector3 localPos, float margin = 0f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) return localPos.x >= 0f - margin && localPos.x <= _roomSize.x + margin && localPos.z >= 0f - margin && localPos.z <= _roomSize.z + margin; } private bool IsPlayerInside() { return (Object)(object)FindPlayerInside() != (Object)null; } private Transform? FindPlayerInside() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) foreach (Camera item in (Il2CppArrayBase)(object)Camera.allCameras) { Vector3 localPos = _buildingRoot.InverseTransformPoint(((Component)item).transform.position); if (IsInsideBuilding(localPos, 1f)) { return ((Component)item).transform; } } return null; } private TrackedNPC CreateTrackedNPC(Component npc) { TrackedNPC trackedNPC = new TrackedNPC { NpcComponent = npc }; if (_npcMovementType != null) { Component val = FindComponent(npc, _npcMovementType); if ((Object)(object)val == (Object)null) { val = FindComponentInChildren(npc, _npcMovementType); } if ((Object)(object)val == (Object)null) { val = FindComponentInParent(npc, _npcMovementType); } if ((Object)(object)val != (Object)null) { trackedNPC.MovementRef = val; if (_agentAccessor.IsValid) { ref NavMeshAgent? agent = ref trackedNPC.Agent; object? value = _agentAccessor.GetValue(val); agent = (NavMeshAgent?)((value is NavMeshAgent) ? value : null); } } } trackedNPC.NpcCollider = (Collider?)(object)npc.GetComponentInChildren(); trackedNPC.Speed = GetNPCSpeed(trackedNPC); return trackedNPC; } private float GetNPCSpeed(TrackedNPC data) { if (data.MovementRef == null) { return 3.5f; } float num = 1.8f; float num2 = 7f; float num3 = 0f; float num4 = 1f; try { if (_walkSpeedAccessor.IsValid && _walkSpeedAccessor.GetValue(data.MovementRef) is float num5) { num = num5; } if (_runSpeedAccessor.IsValid && _runSpeedAccessor.GetValue(data.MovementRef) is float num6) { num2 = num6; } if (_speedScaleAccessor.IsValid && _speedScaleAccessor.GetValue(data.MovementRef) is float num7) { num3 = num7; } if (_moveSpeedMultAccessor.IsValid && _moveSpeedMultAccessor.GetValue(data.MovementRef) is float num8) { num4 = num8; } } catch (Exception ex) { DebugLog.Warning("[InteriorNavigator] Failed to read NPC speed via reflection: " + ex.Message); } return Mathf.Lerp(num, num2, num3) * num4; } private void ReleaseNPC(Component npc, TrackedNPC data, bool warpToExterior) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) if (warpToExterior && data.DoorwayExteriorWorld != Vector3.zero) { npc.transform.position = data.DoorwayExteriorWorld; } if ((Object)(object)data.NpcCollider != (Object)null) { data.NpcCollider.enabled = true; } EnableAgent(data); if (data.MovementRef != null && _hasDestinationAccessor.IsValid) { try { _hasDestinationAccessor.SetValue(data.MovementRef, true); } catch (Exception ex) { DebugLog.Warning("[InteriorNavigator] RestoreHasDestination failed: " + ex.Message); } } _globallyManaged.Remove(npc); _removeQueue.Add(npc); Vector3? val = data.PendingExteriorDestination ?? data.SavedChasePosition; if (val.HasValue && data.MovementRef != null && _originalSetDestination != null) { try { _originalSetDestination.Invoke(data.MovementRef, new object[4] { val.Value, null, 1f, 1f }); DebugLog.Info($"[InteriorNavigator] NPC released, resuming navigation to ({val.Value.x:F1}, {val.Value.z:F1})"); return; } catch (Exception ex2) { DebugLog.Warning("[InteriorNavigator] Failed to set resume destination: " + ex2.Message); return; } } DebugLog.Info("[InteriorNavigator] NPC released from building (no resume destination)."); } private void DisableAgent(TrackedNPC data) { if (data.MovementRef != null && _setAgentEnabled != null) { try { _setAgentEnabled.Invoke(data.MovementRef, new object[1] { false }); } catch (Exception ex) { DebugLog.Warning("[InteriorNavigator] DisableAgent failed: " + ex.Message); } } } private void ClearHasDestination(TrackedNPC data) { if (data.MovementRef != null && _hasDestinationAccessor.IsValid) { try { _hasDestinationAccessor.SetValue(data.MovementRef, false); } catch (Exception ex) { DebugLog.Warning("[InteriorNavigator] ClearHasDestination failed: " + ex.Message); } } } private void EnableAgent(TrackedNPC data) { if (data.MovementRef != null && _setAgentEnabled != null) { try { _setAgentEnabled.Invoke(data.MovementRef, new object[1] { true }); } catch (Exception ex) { DebugLog.Warning("[InteriorNavigator] EnableAgent failed: " + ex.Message); } } } public void Cleanup() { _activeBuildings.Remove(this); ReleaseAllNPCs(); if (_activeBuildings.Count == 0 && _harmony != null) { _harmony.UnpatchSelf(); _harmony = null; _patchApplied = false; DebugLog.Info("[InteriorNavigator] Unpatched NPCMovement.SetDestination (no active buildings)."); } } } internal sealed class InteriorPathGrid { private sealed class DuplicateKeyComparer : IComparer { public int Compare(float x, float y) { int num = x.CompareTo(y); return (num == 0) ? 1 : num; } } private readonly float _cellSize; private readonly int _gridWidth; private readonly int _gridDepth; private readonly bool[] _walkable; private readonly Transform _buildingRoot; private readonly Vector3 _roomSize; private readonly IReadOnlyList _doorways; private static readonly int[] DirectionX = new int[8] { 0, 1, 1, 1, 0, -1, -1, -1 }; private static readonly int[] DirectionZ = new int[8] { 1, 1, 0, -1, -1, -1, 0, 1 }; private static readonly float[] MoveCost = new float[8] { 1f, 1.414f, 1f, 1.414f, 1f, 1.414f, 1f, 1.414f }; private GameObject? _vizRoot; public float CellSize => _cellSize; public InteriorPathGrid(Transform buildingRoot, Vector3 roomSize, IReadOnlyList doorways) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) _buildingRoot = buildingRoot; _roomSize = roomSize; _doorways = doorways; _cellSize = BuildingUtilities.ComputeGridCellSize(roomSize.x, roomSize.z); _gridWidth = Mathf.CeilToInt(roomSize.x / _cellSize); _gridDepth = Mathf.CeilToInt(roomSize.z / _cellSize); _walkable = new bool[_gridWidth * _gridDepth]; GenerateGrid(); } public void Regenerate() { GenerateGrid(); } public List? FindPath(Vector3 startLocal, Vector3 endLocal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) int num = LocalToGridX(startLocal.x); int num2 = LocalToGridZ(startLocal.z); int num3 = LocalToGridX(endLocal.x); int num4 = LocalToGridZ(endLocal.z); num = Mathf.Clamp(num, 0, _gridWidth - 1); num2 = Mathf.Clamp(num2, 0, _gridDepth - 1); num3 = Mathf.Clamp(num3, 0, _gridWidth - 1); num4 = Mathf.Clamp(num4, 0, _gridDepth - 1); if (!IsWalkableCell(num, num2)) { FindNearestWalkableCell(ref num, ref num2); } if (!IsWalkableCell(num3, num4)) { FindNearestWalkableCell(ref num3, ref num4); } if (!IsWalkableCell(num, num2) || !IsWalkableCell(num3, num4)) { return null; } List list = AStar(num, num2, num3, num4); if (list == null) { return null; } List list2 = new List(list.Count); foreach (Vector2Int item in list) { Vector2Int current = item; Vector3 val = GridToLocal(((Vector2Int)(ref current)).x, ((Vector2Int)(ref current)).y); list2.Add(_buildingRoot.TransformPoint(val)); } SmoothPath(list2); return list2; } public bool IsWalkable(Vector3 localPos) { //IL_0001: 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) int gx = Mathf.FloorToInt(localPos.x / _cellSize); int gz = Mathf.FloorToInt(localPos.z / _cellSize); return IsWalkableCell(gx, gz); } public Vector3 NearestWalkableCell(Vector3 localPos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) int gx = LocalToGridX(localPos.x); int gz = LocalToGridZ(localPos.z); FindNearestWalkableCell(ref gx, ref gz); return GridToLocal(gx, gz); } private void GenerateGrid() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) float num = 0.15f; for (int i = 0; i < _walkable.Length; i++) { _walkable[i] = true; } for (int j = 0; j < _gridWidth; j++) { for (int k = 0; k < _gridDepth; k++) { Vector3 val = GridToLocal(j, k); if (val.x < num || val.x > _roomSize.x - num || val.z < num || val.z > _roomSize.z - num) { _walkable[k * _gridWidth + j] = false; } } } MarkInteriorWalls(num); MarkPhysicsObstacles(); MarkDoorwayOpenings(); int num2 = 0; for (int l = 0; l < _walkable.Length; l++) { if (_walkable[l]) { num2++; } } DebugLog.Info($"[InteriorPathGrid] Generated {_gridWidth}x{_gridDepth} grid ({num2}/{_walkable.Length} walkable), cellSize={_cellSize:F2}m"); } private void MarkInteriorWalls(float margin) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) foreach (NavDoorwayInfo doorway in _doorways) { if (!doorway.IsInterior) { continue; } Vector3 inwardNormal = doorway.InwardNormal; bool flag = Mathf.Abs(inwardNormal.z) > Mathf.Abs(inwardNormal.x); float num = (flag ? doorway.Center.z : doorway.Center.x); float num2 = (flag ? doorway.Center.x : doorway.Center.z); float num3 = doorway.Width / 2f; for (int i = 0; i < _gridWidth; i++) { for (int j = 0; j < _gridDepth; j++) { Vector3 val = GridToLocal(i, j); float num4 = (flag ? Mathf.Abs(val.z - num) : Mathf.Abs(val.x - num)); if (!(num4 > margin)) { float num5 = (flag ? val.x : val.z); if (!(Mathf.Abs(num5 - num2) < num3 + 0.1f)) { _walkable[j * _gridWidth + i] = false; } } } } } } private void MarkDoorwayOpenings() { //IL_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0096: Unknown result type (might be due to invalid IL or missing references) foreach (NavDoorwayInfo doorway in _doorways) { Vector3 center = doorway.Center; float num = doorway.Width / 2f; Vector3 inwardNormal = doorway.InwardNormal; bool flag = Mathf.Abs(inwardNormal.z) > Mathf.Abs(inwardNormal.x); for (int i = 0; i < _gridWidth; i++) { for (int j = 0; j < _gridDepth; j++) { Vector3 val = GridToLocal(i, j); float num2; float num3; if (flag) { num2 = Mathf.Abs(val.z - center.z); num3 = Mathf.Abs(val.x - center.x); } else { num2 = Mathf.Abs(val.x - center.x); num3 = Mathf.Abs(val.z - center.z); } if (num2 < doorway.WallThickness / 2f + _cellSize && num3 < num + _cellSize) { _walkable[j * _gridWidth + i] = true; } } } } } private void MarkPhysicsObstacles() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) float num = 0.5f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(_cellSize / 2f * 0.8f, num, _cellSize / 2f * 0.8f); Quaternion rotation = _buildingRoot.rotation; HashSet hashSet = new HashSet(); CollectStructuralColliders(_buildingRoot, hashSet); HashSet livingRoots = new HashSet(); HashSet staticRoots = new HashSet(); Vector3 val3 = default(Vector3); for (int i = 0; i < _gridWidth; i++) { for (int j = 0; j < _gridDepth; j++) { if (!_walkable[j * _gridWidth + i]) { continue; } Vector3 val2 = GridToLocal(i, j); ((Vector3)(ref val3))..ctor(val2.x, num, val2.z); Vector3 val4 = _buildingRoot.TransformPoint(val3); Collider[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)Physics.OverlapBox(val4, val, rotation)); Collider[] array2 = array; foreach (Collider val5 in array2) { if (!val5.isTrigger && !hashSet.Contains(val5) && !BuildingUtilities.IsLivingEntity(((Component)val5).transform, livingRoots, staticRoots)) { Transform buildingRoot = _buildingRoot; Bounds bounds = val5.bounds; Vector3 val6 = buildingRoot.InverseTransformPoint(((Bounds)(ref bounds)).center); if (!(val6.x < -0.5f) && !(val6.x > _roomSize.x + 0.5f) && !(val6.z < -0.5f) && !(val6.z > _roomSize.z + 0.5f)) { _walkable[j * _gridWidth + i] = false; break; } } } } } } private static void CollectStructuralColliders(Transform root, HashSet excluded) { string[] array = new string[12] { "Floor", "Ceiling", "Walls", "ExteriorWalls", "InteriorWalls", "Foundation", "Stairs", "Roof", "Parapet", "Molding", "WindowFrames", "DoorFrames" }; string[] array2 = array; foreach (string text in array2) { Transform val = root.Find(text); if ((Object)(object)val == (Object)null) { continue; } foreach (Collider componentsInChild in ((Component)val).GetComponentsInChildren()) { excluded.Add(componentsInChild); } } Collider component = ((Component)root).GetComponent(); if ((Object)(object)component != (Object)null) { excluded.Add(component); } } private List? AStar(int sx, int sz, int ex, int ez) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (sx == ex && sz == ez) { return new List { new Vector2Int(sx, sz) }; } int num = _gridWidth * _gridDepth; float[] array = new float[num]; float[] array2 = new float[num]; int[] array3 = new int[num]; bool[] array4 = new bool[num]; for (int i = 0; i < num; i++) { array[i] = float.MaxValue; array2[i] = float.MaxValue; array3[i] = -1; } int num2 = sz * _gridWidth + sx; int num3 = ez * _gridWidth + ex; array[num2] = 0f; array2[num2] = Heuristic(sx, sz, ex, ez); SortedList sortedList = new SortedList(new DuplicateKeyComparer()); sortedList.Add(array2[num2], num2); while (sortedList.Count > 0) { int num4 = sortedList.Values[0]; sortedList.RemoveAt(0); if (num4 == num3) { return ReconstructPath(array3, num4); } if (array4[num4]) { continue; } array4[num4] = true; int num5 = num4 % _gridWidth; int num6 = num4 / _gridWidth; for (int j = 0; j < 8; j++) { int num7 = num5 + DirectionX[j]; int num8 = num6 + DirectionZ[j]; if (num7 < 0 || num7 >= _gridWidth || num8 < 0 || num8 >= _gridDepth) { continue; } int num9 = num8 * _gridWidth + num7; if (array4[num9] || !_walkable[num9]) { continue; } if (j % 2 == 1) { int num10 = num6 * _gridWidth + num7; int num11 = num8 * _gridWidth + num5; if (!_walkable[num10] || !_walkable[num11]) { continue; } } float num12 = array[num4] + MoveCost[j]; if (num12 < array[num9]) { array3[num9] = num4; array[num9] = num12; array2[num9] = num12 + Heuristic(num7, num8, ex, ez); sortedList.Add(array2[num9], num9); } } } return null; } private float Heuristic(int ax, int az, int bx, int bz) { float num = ax - bx; float num2 = az - bz; return Mathf.Sqrt(num * num + num2 * num2); } private List ReconstructPath(int[] cameFrom, int current) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); while (current != -1) { int num = current % _gridWidth; int num2 = current / _gridWidth; list.Add(new Vector2Int(num, num2)); current = cameFrom[current]; } list.Reverse(); return list; } private void SmoothPath(List worldPath) { //IL_002b: 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) if (worldPath.Count <= 2) { return; } for (int i = 0; i < worldPath.Count - 2; i++) { int num = i + 1; for (int num2 = worldPath.Count - 1; num2 > i + 1; num2--) { if (HasLineOfSight(worldPath[i], worldPath[num2])) { num = num2; break; } } if (num > i + 1) { worldPath.RemoveRange(i + 1, num - i - 1); } } } private bool HasLineOfSight(Vector3 worldA, Vector3 worldB) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _buildingRoot.InverseTransformPoint(worldA); Vector3 val2 = _buildingRoot.InverseTransformPoint(worldB); int num = LocalToGridX(val.x); int num2 = LocalToGridZ(val.z); int num3 = LocalToGridX(val2.x); int num4 = LocalToGridZ(val2.z); int num5 = Mathf.Abs(num3 - num); int num6 = Mathf.Abs(num4 - num2); int num7 = ((num < num3) ? 1 : (-1)); int num8 = ((num2 < num4) ? 1 : (-1)); int num9 = num5 - num6; int num10 = num; int num11 = num2; while (true) { if (!IsWalkableCell(num10, num11)) { return false; } if (num10 == num3 && num11 == num4) { break; } int num12 = 2 * num9; if (num12 > -num6) { num9 -= num6; num10 += num7; } if (num12 < num5) { num9 += num5; num11 += num8; } } return true; } private int LocalToGridX(float localX) { return Mathf.Clamp(Mathf.FloorToInt(localX / _cellSize), 0, _gridWidth - 1); } private int LocalToGridZ(float localZ) { return Mathf.Clamp(Mathf.FloorToInt(localZ / _cellSize), 0, _gridDepth - 1); } private Vector3 GridToLocal(int gx, int gz) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) return new Vector3(((float)gx + 0.5f) * _cellSize, 0f, ((float)gz + 0.5f) * _cellSize); } private bool IsWalkableCell(int gx, int gz) { if (gx < 0 || gx >= _gridWidth || gz < 0 || gz >= _gridDepth) { return false; } return _walkable[gz * _gridWidth + gx]; } private void FindNearestWalkableCell(ref int gx, ref int gz) { int num = gx; int num2 = gz; float num3 = float.MaxValue; int num4 = Mathf.Max(_gridWidth, _gridDepth); for (int i = 1; i <= num4; i++) { bool flag = false; for (int j = -i; j <= i; j++) { for (int k = -i; k <= i; k++) { if (Mathf.Abs(j) != i && Mathf.Abs(k) != i) { continue; } int num5 = gx + j; int num6 = gz + k; if (IsWalkableCell(num5, num6)) { float num7 = j * j + k * k; if (num7 < num3) { num3 = num7; num = num5; num2 = num6; flag = true; } } } } if (flag) { break; } } gx = num; gz = num2; } public void Visualize() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003b: 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_0070: 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_00db: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) DestroyVisualization(); _vizRoot = new GameObject("[S1MAPI] PathGrid Visualizer"); _vizRoot.transform.SetParent(_buildingRoot, false); _vizRoot.transform.localPosition = Vector3.zero; _vizRoot.transform.localRotation = Quaternion.identity; Material val = CreateFlatMaterial(new Color(0f, 1f, 0f, 0.35f)); Material val2 = CreateFlatMaterial(new Color(1f, 0f, 0f, 0.35f)); float num = 0.05f; float num2 = _cellSize - num * 2f; for (int i = 0; i < _gridWidth; i++) { for (int j = 0; j < _gridDepth; j++) { bool flag = _walkable[j * _gridWidth + i]; Vector3 localPosition = GridToLocal(i, j); localPosition.y = 0.02f; GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val3).name = $"Cell_{i}_{j}"; val3.transform.SetParent(_vizRoot.transform, false); val3.transform.localPosition = localPosition; val3.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); val3.transform.localScale = new Vector3(num2, num2, 1f); Collider component = val3.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val3.GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Renderer)component2).sharedMaterial = (flag ? val : val2); } } } DebugLog.Info($"[InteriorPathGrid] Visualization created: {_gridWidth}x{_gridDepth} cells"); } public void DestroyVisualization() { if ((Object)(object)_vizRoot != (Object)null) { Object.Destroy((Object)(object)_vizRoot); _vizRoot = null; } } public void DiagnoseCell(int gx, int gz) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) if (gx < 0 || gx >= _gridWidth || gz < 0 || gz >= _gridDepth) { DebugLog.Warning($"[PathGrid] Cell ({gx},{gz}) is out of bounds (grid is {_gridWidth}x{_gridDepth})"); return; } bool flag = _walkable[gz * _gridWidth + gx]; Vector3 val = GridToLocal(gx, gz); Vector3 val2 = _buildingRoot.TransformPoint(val); DebugLog.Info($"[PathGrid] Cell ({gx},{gz}): local=({val.x:F2},{val.z:F2}), world=({val2.x:F2},{val2.y:F2},{val2.z:F2}), walkable={flag}"); if (flag) { return; } float num = 0.15f; if (val.x < num || val.x > _roomSize.x - num || val.z < num || val.z > _roomSize.z - num) { DebugLog.Info($" -> Blocked by EXTERIOR WALL margin (margin={num:F2}, roomSize=({_roomSize.x:F2},{_roomSize.z:F2}))"); } foreach (NavDoorwayInfo doorway in _doorways) { if (!doorway.IsInterior) { continue; } Vector3 inwardNormal = doorway.InwardNormal; bool flag2 = Mathf.Abs(inwardNormal.z) > Mathf.Abs(inwardNormal.x); float num2 = (flag2 ? doorway.Center.z : doorway.Center.x); float num3 = (flag2 ? Mathf.Abs(val.z - num2) : Mathf.Abs(val.x - num2)); if (num3 <= num) { float num4 = (flag2 ? val.x : val.z); float num5 = (flag2 ? doorway.Center.x : doorway.Center.z); if (Mathf.Abs(num4 - num5) >= doorway.Width / 2f + 0.1f) { DebugLog.Info($" -> Blocked by INTERIOR WALL at {(flag2 ? "Z" : "X")}={num2:F2} (perpDist={num3:F2})"); } } } float num6 = 0.5f; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(_cellSize / 2f * 0.8f, num6, _cellSize / 2f * 0.8f); Vector3 val4 = _buildingRoot.TransformPoint(new Vector3(val.x, num6, val.z)); Collider[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)Physics.OverlapBox(val4, val3, _buildingRoot.rotation)); HashSet hashSet = new HashSet(); CollectStructuralColliders(_buildingRoot, hashSet); Collider[] array2 = array; foreach (Collider val5 in array2) { if (!val5.isTrigger) { bool value = hashSet.Contains(val5); Transform buildingRoot = _buildingRoot; Bounds bounds = val5.bounds; Vector3 val6 = buildingRoot.InverseTransformPoint(((Bounds)(ref bounds)).center); bool value2 = val6.x >= -0.5f && val6.x <= _roomSize.x + 0.5f && val6.z >= -0.5f && val6.z <= _roomSize.z + 0.5f; string transformPath = GetTransformPath(((Component)val5).transform); DebugLog.Info($" -> Collider: \"{transformPath}\" (excluded={value}, insideFootprint={value2}, localPos=({val6.x:F2},{val6.y:F2},{val6.z:F2}), type={((object)val5).GetType().Name})"); } } } private static string GetTransformPath(Transform t) { string text = ((Object)t).name; Transform parent = t.parent; int num = 0; while ((Object)(object)parent != (Object)null && num < 5) { text = ((Object)parent).name + "/" + text; parent = parent.parent; num++; } return text; } private static Material CreateFlatMaterial(Color color) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("UI/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } Material val2 = new Material(val); val2.color = color; return val2; } } public sealed class NavDoorwayInfo { public Vector3 Center { get; } public float Width { get; } public float Height { get; } public Vector3 InwardNormal { get; } public float WallThickness { get; } public Vector3? StairBasePosition { get; } public bool IsInterior { get; } public NavDoorwayInfo(Vector3 center, float width, float height, Vector3 inwardNormal, float wallThickness, Vector3? stairBasePosition = null, bool isInterior = false) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Center = center; Width = width; Height = height; InwardNormal = inwardNormal; WallThickness = wallThickness; StairBasePosition = stairBasePosition; IsInterior = isInterior; } } public sealed class NavigationBuilder { private readonly Transform _buildingRoot; private readonly Vector3 _roomSize; private readonly IReadOnlyList _doorways; private readonly float _foundationHeight; private readonly float _wallThickness; private readonly List _rampObjects = new List(); private readonly List _carvingObstacles = new List(); private InteriorNavigatorCore? _navCore; private InteriorNavigator? _navShell; private bool _isBuilt; public bool IsBuilt => _isBuilt; public float CellSize => _navCore?.PathGrid?.CellSize ?? 0.5f; public NavigationBuilder(Transform buildingRoot, Vector3 roomSize, IReadOnlyList doorways, float wallThickness, float foundationHeight = 0f) { //IL_0026: 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) _buildingRoot = buildingRoot; _roomSize = roomSize; _doorways = doorways; _wallThickness = wallThickness; _foundationHeight = foundationHeight; } public void Build() { //IL_0031: 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) if (_isBuilt) { DebugLog.Warning("[NavigationBuilder] NavMesh already built. Call Rebuild() to refresh."); return; } CreateStairRamps(); PlaceFootprintCarvingObstacle(); InteriorPathGrid grid = new InteriorPathGrid(_buildingRoot, _roomSize, _doorways); _navCore = new InteriorNavigatorCore(grid, _doorways, _buildingRoot, _roomSize, _foundationHeight); if (!ClassInjector.IsTypeRegisteredInIl2Cpp()) { ClassInjector.RegisterTypeInIl2Cpp(); } _navShell = ((Component)_buildingRoot).gameObject.AddComponent(); _navShell._core = _navCore; _isBuilt = true; } public void Rebuild() { Remove(); Build(); } public bool IsNPCInside(Component npc) { return _navCore != null && _navCore.IsTracking(npc); } public void SendNPCToPosition(Component npc, Vector3 localTarget, Action? onArrival = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) _navCore?.SendNPCToPosition(npc, localTarget, onArrival); } public void RecallNPC(Component npc) { _navCore?.RecallNPC(npc); } public Vector3 WorldToLocal(Vector3 worldPosition) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return _buildingRoot.InverseTransformPoint(worldPosition); } public Vector3 LocalToWorld(Vector3 localPosition) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return _buildingRoot.TransformPoint(localPosition); } public void VisualizePathGrid(bool show = true) { _navCore?.VisualizeGrid(show); } public void DiagnoseCell(int gridX, int gridZ) { _navCore?.DiagnoseCell(gridX, gridZ); } public void Remove() { if (!_isBuilt) { return; } if (_navCore != null) { _navCore.ReleaseAllNPCs(); _navCore.Cleanup(); _navCore = null; } if ((Object)(object)_navShell != (Object)null) { _navShell._core = null; Object.Destroy((Object)(object)_navShell); _navShell = null; } foreach (GameObject carvingObstacle in _carvingObstacles) { Object.Destroy((Object)(object)carvingObstacle); } _carvingObstacles.Clear(); foreach (GameObject rampObject in _rampObjects) { Object.Destroy((Object)(object)rampObject); } _rampObjects.Clear(); _isBuilt = false; DebugLog.Info("[NavigationBuilder] Removed NavMesh data."); } public bool IsWalkable(Vector3 localPos) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) return _navCore?.PathGrid?.IsWalkable(localPos) == true; } public Vector3 NearestWalkableCell(Vector3 localPos) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) return _navCore?.PathGrid?.NearestWalkableCell(localPos) ?? localPos; } private void PlaceFootprintCarvingObstacle() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_016a: Unknown result type (might be due to invalid IL or missing references) float num = _roomSize.y + 4f; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f, num / 2f, _roomSize.z / 2f); GameObject val = new GameObject("NavMeshFootprintCarve"); val.transform.SetParent(_buildingRoot); val.transform.localPosition = localPosition; val.transform.localRotation = Quaternion.identity; NavMeshObstacle val2 = val.AddComponent(); val2.shape = (NavMeshObstacleShape)1; val2.carving = true; val2.carveOnlyStationary = true; val2.size = new Vector3(_roomSize.x, num, _roomSize.z); val2.center = Vector3.zero; _carvingObstacles.Add(val); DebugLog.Info($"[NavigationBuilder] Footprint carve: size=({_roomSize.x:F1}, {num:F1}, {_roomSize.z:F1}), worldCenter={val.transform.position}"); } private void CreateStairRamps() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); foreach (NavDoorwayInfo doorway in _doorways) { if (doorway.StairBasePosition.HasValue) { Vector3 center = doorway.Center; Vector3 value = doorway.StairBasePosition.Value; ((Vector3)(ref val))..ctor(value.x - center.x, 0f, value.z - center.z); float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Abs(value.y); float num2 = Mathf.Sqrt(magnitude * magnitude + num * num); float num3 = Mathf.Atan2(num, magnitude) * 57.29578f; Vector3 localPosition = (center + value) / 2f; Vector3 normalized = ((Vector3)(ref val)).normalized; GameObject val2 = new GameObject("NavMeshRamp"); val2.transform.SetParent(_buildingRoot); val2.transform.localPosition = localPosition; Quaternion val3 = Quaternion.LookRotation(normalized, Vector3.up); val2.transform.localRotation = val3 * Quaternion.AngleAxis(num3, Vector3.right); float num4 = Mathf.Max(doorway.Width, 3f) + 1f; BoxCollider val4 = val2.AddComponent(); val4.center = Vector3.zero; val4.size = new Vector3(num4, 0.1f, num2); _rampObjects.Add(val2); Vector3 value2 = _buildingRoot.TransformPoint(center); Vector3 value3 = _buildingRoot.TransformPoint(value); DebugLog.Info($"[NavigationBuilder] Ramp: worldPos={val2.transform.position}, top={value2}, bottom={value3}, width={num4:F2}, length={num2:F2}, angle={num3:F1}°"); } } } } } namespace S1MAPI.Building.Structural { public sealed class DecorBuilder { private readonly Transform _parent; private readonly Vector3 _roomSize; private readonly BuildingPalette _palette; private float _foundationClearanceX; private float _foundationClearanceZ; public DecorBuilder(Transform parent, Vector3 roomSize, BuildingPalette palette) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) _parent = parent; _roomSize = roomSize; _palette = palette; } public GameObject AddRoofTrim(float height = 0.3f, Material? material = null) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00bc: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) float num = 0.2f; float num2 = num + 0.1f; GameObject val = BuildingUtilities.CreateFolder("RoofTrim", _parent); Color trimColor = _palette.TrimColor; float num3 = _roomSize.y - height / 2f; GameObject obj = PrimitiveBuilder.CreateBox("NorthTrim", new Vector3(_roomSize.x / 2f, num3, _roomSize.z), new Vector3(_roomSize.x + num2, height, num2), trimColor, val.transform); GameObject obj2 = PrimitiveBuilder.CreateBox("SouthTrim", new Vector3(_roomSize.x / 2f, num3, 0f), new Vector3(_roomSize.x + num2, height, num2), trimColor, val.transform); GameObject obj3 = PrimitiveBuilder.CreateBox("EastTrim", new Vector3(_roomSize.x, num3, _roomSize.z / 2f), new Vector3(num2, height, _roomSize.z - num2), trimColor, val.transform); GameObject obj4 = PrimitiveBuilder.CreateBox("WestTrim", new Vector3(0f, num3, _roomSize.z / 2f), new Vector3(num2, height, _roomSize.z - num2), trimColor, val.transform); Material val2 = material ?? _palette.TrimMaterial; if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); ApplyMaterial(obj2, val2); ApplyMaterial(obj3, val2); ApplyMaterial(obj4, val2); } return val; } public GameObject AddSecondaryRoofTrim(float height = 0.15f, Material? material = null) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00bc: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) float num = 0.2f; float num2 = num + 0.1f; GameObject val = BuildingUtilities.CreateFolder("SecondaryRoofTrim", _parent); Color accentColor = _palette.AccentColor; float num3 = _roomSize.y + height / 2f; GameObject obj = PrimitiveBuilder.CreateBox("NorthTrim", new Vector3(_roomSize.x / 2f, num3, _roomSize.z), new Vector3(_roomSize.x + num2, height, num2), accentColor, val.transform); GameObject obj2 = PrimitiveBuilder.CreateBox("SouthTrim", new Vector3(_roomSize.x / 2f, num3, 0f), new Vector3(_roomSize.x + num2, height, num2), accentColor, val.transform); GameObject obj3 = PrimitiveBuilder.CreateBox("EastTrim", new Vector3(_roomSize.x, num3, _roomSize.z / 2f), new Vector3(num2, height, _roomSize.z - num2), accentColor, val.transform); GameObject obj4 = PrimitiveBuilder.CreateBox("WestTrim", new Vector3(0f, num3, _roomSize.z / 2f), new Vector3(num2, height, _roomSize.z - num2), accentColor, val.transform); Material val2 = material ?? _palette.AccentMaterial ?? _palette.TrimMaterial; if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); ApplyMaterial(obj2, val2); ApplyMaterial(obj3, val2); ApplyMaterial(obj4, val2); } return val; } public GameObject AddCornerPillars(float width = 0.4f, Material? material = null) { //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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("CornerPillars", _parent); Color pillarColor = _palette.PillarColor; float y = _roomSize.y; float num = width / 2f; GameObject obj = PrimitiveBuilder.CreateBox("Pillar_NE", new Vector3(_roomSize.x + num - 0.1f, y / 2f, _roomSize.z + num - 0.1f), new Vector3(width, y, width), pillarColor, val.transform); GameObject obj2 = PrimitiveBuilder.CreateBox("Pillar_NW", new Vector3(0f - num + 0.1f, y / 2f, _roomSize.z + num - 0.1f), new Vector3(width, y, width), pillarColor, val.transform); GameObject obj3 = PrimitiveBuilder.CreateBox("Pillar_SE", new Vector3(_roomSize.x + num - 0.1f, y / 2f, 0f - num + 0.1f), new Vector3(width, y, width), pillarColor, val.transform); GameObject obj4 = PrimitiveBuilder.CreateBox("Pillar_SW", new Vector3(0f - num + 0.1f, y / 2f, 0f - num + 0.1f), new Vector3(width, y, width), pillarColor, val.transform); Material val2 = material ?? _palette.PillarMaterial; if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); ApplyMaterial(obj2, val2); ApplyMaterial(obj3, val2); ApplyMaterial(obj4, val2); } return val; } public GameObject AddCornerTrim(float width = 0.3f, float depth = 0.1f, Material? material = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) float num = 0.2f; float num2 = num + depth; float y = _roomSize.y; GameObject val = BuildingUtilities.CreateFolder("CornerTrim", _parent); Color trimColor = _palette.TrimColor; GameObject obj = PrimitiveBuilder.CreateBox("CornerTrim_NE_N", new Vector3(_roomSize.x, y / 2f, _roomSize.z), new Vector3(width, y, num2), trimColor, val.transform); GameObject obj2 = PrimitiveBuilder.CreateBox("CornerTrim_NE_E", new Vector3(_roomSize.x, y / 2f, _roomSize.z), new Vector3(num2, y, width), trimColor, val.transform); GameObject obj3 = PrimitiveBuilder.CreateBox("CornerTrim_NW_N", new Vector3(0f, y / 2f, _roomSize.z), new Vector3(width, y, num2), trimColor, val.transform); GameObject obj4 = PrimitiveBuilder.CreateBox("CornerTrim_NW_W", new Vector3(0f, y / 2f, _roomSize.z), new Vector3(num2, y, width), trimColor, val.transform); GameObject obj5 = PrimitiveBuilder.CreateBox("CornerTrim_SE_S", new Vector3(_roomSize.x, y / 2f, 0f), new Vector3(width, y, num2), trimColor, val.transform); GameObject obj6 = PrimitiveBuilder.CreateBox("CornerTrim_SE_E", new Vector3(_roomSize.x, y / 2f, 0f), new Vector3(num2, y, width), trimColor, val.transform); GameObject obj7 = PrimitiveBuilder.CreateBox("CornerTrim_SW_S", new Vector3(0f, y / 2f, 0f), new Vector3(width, y, num2), trimColor, val.transform); GameObject obj8 = PrimitiveBuilder.CreateBox("CornerTrim_SW_W", new Vector3(0f, y / 2f, 0f), new Vector3(num2, y, width), trimColor, val.transform); Material val2 = material ?? _palette.TrimMaterial; if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); ApplyMaterial(obj2, val2); ApplyMaterial(obj3, val2); ApplyMaterial(obj4, val2); ApplyMaterial(obj5, val2); ApplyMaterial(obj6, val2); ApplyMaterial(obj7, val2); ApplyMaterial(obj8, val2); } return val; } public GameObject AddFoundation(float height = 2f, float expandX = 0f, float expandZ = 0f, Color? color = null, Material? material = null) { //IL_0026: 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_002b: 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_00d0: 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) Color color2 = (Color)(((??)color) ?? new Color(0.4f, 0.4f, 0.4f)); GameObject val = BuildingUtilities.CreateFolder("Foundation", _parent); float num = 0.1f; float num2 = -0.001f; _foundationClearanceX = num + expandX; _foundationClearanceZ = num + expandZ; float num3 = _roomSize.x + num * 2f + expandX * 2f; float num4 = _roomSize.z + num * 2f + expandZ * 2f; GameObject obj = PrimitiveBuilder.CreateBox("FoundationBlock", new Vector3(_roomSize.x / 2f, (0f - height) / 2f + num2, _roomSize.z / 2f), new Vector3(num3, height, num4), color2, val.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj, material); } return val; } public GameObject AddStairs(WallSide wall, float foundationHeight, float maxStepHeight = 0.2f, float width = 2.5f, float stepDepth = 0.3f, Color? color = null, Material? material = null, StairStyle style = StairStyle.Solid, bool flushWithFloor = false, float gap = 0f, float lateralOffset = 0f) { if (1 == 0) { } GameObject result = (GameObject)(style switch { StairStyle.ClosedRiser => AddClosedRiserStairs(wall, foundationHeight, gap, lateralOffset), StairStyle.OpenStringer => AddOpenStringerStairs(wall, foundationHeight, gap, lateralOffset), _ => AddSolidStairs(wall, foundationHeight, maxStepHeight, width, stepDepth, color, material, flushWithFloor, lateralOffset), }); if (1 == 0) { } return result; } public GameObject AddDoorFrames(WallOpening? northOpening = null, WallOpening? southOpening = null, WallOpening? eastOpening = null, WallOpening? westOpening = null, Material? material = null) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("DoorFrames", _parent); float num = 0.2f; float num2 = 0.12f; float num3 = 0.1f; float trimDepth = num + num3; Color trimColor = _palette.TrimColor; Material material2 = material ?? _palette.TrimMaterial; if (northOpening != null && northOpening.Type == WallOpeningType.Door) { InsetDoorWallSegments("NorthWall", num2, isVertical: false); CreateDoorFrame("DoorFrame_North", new Vector3(_roomSize.x / 2f, _roomSize.y / 2f, _roomSize.z), _roomSize.y, northOpening, isVertical: false, num2, trimDepth, trimColor, material2, val); } if (southOpening != null && southOpening.Type == WallOpeningType.Door) { InsetDoorWallSegments("SouthWall", num2, isVertical: false); CreateDoorFrame("DoorFrame_South", new Vector3(_roomSize.x / 2f, _roomSize.y / 2f, 0f), _roomSize.y, southOpening, isVertical: false, num2, trimDepth, trimColor, material2, val); } if (eastOpening != null && eastOpening.Type == WallOpeningType.Door) { InsetDoorWallSegments("EastWall", num2, isVertical: true); CreateDoorFrame("DoorFrame_East", new Vector3(_roomSize.x, _roomSize.y / 2f, _roomSize.z / 2f), _roomSize.y, eastOpening, isVertical: true, num2, trimDepth, trimColor, material2, val); } if (westOpening != null && westOpening.Type == WallOpeningType.Door) { InsetDoorWallSegments("WestWall", num2, isVertical: true); CreateDoorFrame("DoorFrame_West", new Vector3(0f, _roomSize.y / 2f, _roomSize.z / 2f), _roomSize.y, westOpening, isVertical: true, num2, trimDepth, trimColor, material2, val); } return val; } public GameObject AddInteriorDoorFrames(IReadOnlyList doorways, float frameWidth = 0.12f, float frameProtrusion = 0.04f, Material? material = null) { //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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("InteriorDoorFrames", _parent); Color trimColor = _palette.TrimColor; Material material2 = material ?? _palette.TrimMaterial; Vector3 wallCenter = default(Vector3); for (int i = 0; i < doorways.Count; i++) { DoorwayInfo doorwayInfo = doorways[i]; float trimDepth = doorwayInfo.WallThickness + frameProtrusion; bool isVertical = !doorwayInfo.FacesAlongZ; if ((Object)(object)doorwayInfo.WallContainer != (Object)null) { InsetDoorWallSegments(doorwayInfo.WallContainer.transform, ((Object)doorwayInfo.WallContainer).name, frameWidth, isVertical); } ((Vector3)(ref wallCenter))..ctor(doorwayInfo.Center.x, _roomSize.y / 2f, doorwayInfo.Center.z); CreateDoorFrame($"InteriorDoorFrame_{i}", wallCenter, _roomSize.y, doorwayInfo.Width, doorwayInfo.Height, 0f, isVertical, frameWidth, trimDepth, trimColor, material2, val); } return val; } public GameObject AddBaseMolding(float height = 0.3f, float depth = 0.1f, Material? material = null, WallOpening? northOpening = null, WallOpening? southOpening = null, WallOpening? eastOpening = null, WallOpening? westOpening = null, IEnumerable? skipWalls = null) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) float num = _roomSize.x / 2f; float num2 = _roomSize.z / 2f; float num3 = 0.2f; float num4 = num3 + depth; GameObject val = BuildingUtilities.CreateFolder("BaseMolding", _parent); Color trimColor = _palette.TrimColor; Material material2 = material ?? _palette.TrimMaterial; HashSet hashSet = ((skipWalls != null) ? new HashSet(skipWalls) : null); if (hashSet == null || !hashSet.Contains(WallSide.North)) { CreateMoldingSegments("BaseMolding_North", new Vector3(num, height / 2f, _roomSize.z), new Vector3(_roomSize.x + num4, height, num4), _roomSize.x + num4, isZAxis: false, northOpening, height, trimColor, material2, val); } if (hashSet == null || !hashSet.Contains(WallSide.South)) { CreateMoldingSegments("BaseMolding_South", new Vector3(num, height / 2f, 0f), new Vector3(_roomSize.x + num4, height, num4), _roomSize.x + num4, isZAxis: false, southOpening, height, trimColor, material2, val); } if (hashSet == null || !hashSet.Contains(WallSide.East)) { CreateMoldingSegments("BaseMolding_East", new Vector3(_roomSize.x, height / 2f, num2), new Vector3(num4, height, _roomSize.z - num4), _roomSize.z - num4, isZAxis: true, eastOpening, height, trimColor, material2, val); } if (hashSet == null || !hashSet.Contains(WallSide.West)) { CreateMoldingSegments("BaseMolding_West", new Vector3(0f, height / 2f, num2), new Vector3(num4, height, _roomSize.z - num4), _roomSize.z - num4, isZAxis: true, westOpening, height, trimColor, material2, val); } return val; } public GameObject AddFloor(float thickness = 0.1f) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrimitiveBuilder.CreateBox("Floor", new Vector3(_roomSize.x / 2f, (0f - thickness) / 2f, _roomSize.z / 2f), new Vector3(_roomSize.x, thickness, _roomSize.z), _palette.FloorColor, _parent); if ((Object)(object)_palette.FloorMaterial != (Object)null) { ApplyMaterial(val, _palette.FloorMaterial); } return val; } public GameObject AddCeiling(float thickness = 0.1f) { //IL_003b: 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_0062: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrimitiveBuilder.CreateBox("Ceiling", new Vector3(_roomSize.x / 2f, _roomSize.y - thickness / 2f, _roomSize.z / 2f), new Vector3(_roomSize.x, thickness, _roomSize.z), _palette.CeilingColor, _parent); if ((Object)(object)_palette.CeilingMaterial != (Object)null) { ApplyMaterial(val, _palette.CeilingMaterial); } return val; } private GameObject AddSolidStairs(WallSide wall, float foundationHeight, float maxStepHeight, float width, float stepDepth, Color? color, Material? material, bool flushWithFloor = false, float lateralOffset = 0f) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Stairs", _parent); Color color2 = (Color)(((??)color) ?? _palette.FloorColor); int num = Mathf.Max(2, Mathf.CeilToInt(foundationHeight / maxStepHeight)); float num2 = foundationHeight / (float)num; int num3 = (flushWithFloor ? num : (num - 1)); float num4 = ((_foundationClearanceX > 0f) ? _foundationClearanceX : 0.1f); float num5 = ((_foundationClearanceZ > 0f) ? _foundationClearanceZ : 0.1f); Vector3 localPosition = default(Vector3); Vector3 size = default(Vector3); for (int i = 0; i < num3; i++) { float num6 = (float)(i + 1) * num2; float num7 = 0f - foundationHeight + num6 / 2f; float num8 = ((wall == WallSide.North || wall == WallSide.South) ? num5 : num4); float num9 = (float)(num3 - 1 - i) * stepDepth + stepDepth / 2f + num8; switch (wall) { case WallSide.North: ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f + lateralOffset, num7, _roomSize.z + num9); ((Vector3)(ref size))..ctor(width, num6, stepDepth); break; case WallSide.South: ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f + lateralOffset, num7, 0f - num9); ((Vector3)(ref size))..ctor(width, num6, stepDepth); break; case WallSide.East: ((Vector3)(ref localPosition))..ctor(_roomSize.x + num9, num7, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size))..ctor(stepDepth, num6, width); break; case WallSide.West: ((Vector3)(ref localPosition))..ctor(0f - num9, num7, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size))..ctor(stepDepth, num6, width); break; default: continue; } GameObject obj = PrimitiveBuilder.CreateBox($"Step{i + 1}", localPosition, size, color2, val.transform); Material val2 = material ?? _palette.FloorMaterial; if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); } } return val; } private GameObject AddClosedRiserStairs(WallSide wall, float foundationHeight, float gap, float lateralOffset = 0f) { //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Stairs_ClosedRiser", _parent); Material val2 = MaterialPresets.FindExistingMaterial("wood brown"); Material val3 = MaterialPresets.FindExistingMaterial("wood_beige"); Color color = default(Color); ((Color)(ref color))..ctor(0.85f, 0.8f, 0.72f); Color color2 = default(Color); ((Color)(ref color2))..ctor(0.45f, 0.35f, 0.25f); float num = 2.5f; float num2 = 0.3f; float num3 = 0.05f; int num4 = Mathf.Max(2, Mathf.CeilToInt(foundationHeight / 0.2f)); float num5 = foundationHeight / (float)num4; int num6 = num4; float num7 = ((_foundationClearanceX > 0f) ? _foundationClearanceX : 0.1f); float num8 = ((_foundationClearanceZ > 0f) ? _foundationClearanceZ : 0.1f); Vector3 localPosition = default(Vector3); Vector3 size = default(Vector3); Vector3 localPosition2 = default(Vector3); Vector3 size2 = default(Vector3); for (int i = 0; i < num6; i++) { float num9 = (float)(i + 1) * num5; float num10 = 0f - foundationHeight + num9 / 2f - gap; float num11 = ((wall == WallSide.North || wall == WallSide.South) ? num8 : num7); float num12 = (float)(num6 - 1 - i) * num2 + num2 / 2f + num11; float num13 = 0f - foundationHeight + num9 + num3 / 2f - gap; float num14 = 0.04f; float num15 = 0.06f; switch (wall) { case WallSide.North: ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f + lateralOffset, num10, _roomSize.z + num12); ((Vector3)(ref size))..ctor(num, num9, num2); ((Vector3)(ref localPosition2))..ctor(_roomSize.x / 2f + lateralOffset, num13, _roomSize.z + num12); ((Vector3)(ref size2))..ctor(num + num15, num3, num2 + num14); break; case WallSide.South: ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f + lateralOffset, num10, 0f - num12); ((Vector3)(ref size))..ctor(num, num9, num2); ((Vector3)(ref localPosition2))..ctor(_roomSize.x / 2f + lateralOffset, num13, 0f - num12); ((Vector3)(ref size2))..ctor(num + num15, num3, num2 + num14); break; case WallSide.East: ((Vector3)(ref localPosition))..ctor(_roomSize.x + num12, num10, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size))..ctor(num2, num9, num); ((Vector3)(ref localPosition2))..ctor(_roomSize.x + num12, num13, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size2))..ctor(num2 + num14, num3, num + num15); break; case WallSide.West: ((Vector3)(ref localPosition))..ctor(0f - num12, num10, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size))..ctor(num2, num9, num); ((Vector3)(ref localPosition2))..ctor(0f - num12, num13, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size2))..ctor(num2 + num14, num3, num + num15); break; default: continue; } GameObject obj = PrimitiveBuilder.CreateBox($"Riser{i + 1}", localPosition, size, color, val.transform); if ((Object)(object)val3 != (Object)null) { ApplyMaterial(obj, val3); } GameObject obj2 = PrimitiveBuilder.CreateBox($"Tread{i + 1}", localPosition2, size2, color2, val.transform); if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj2, val2); } } DebugLog.Info($"[DecorBuilder] ClosedRiser stairs: {num6} steps, gap={gap:F2}, treadMat={((val2 != null) ? ((Object)val2).name : null) ?? "fallback"}, riserMat={((val3 != null) ? ((Object)val3).name : null) ?? "fallback"}"); return val; } private GameObject AddOpenStringerStairs(WallSide wall, float foundationHeight, float gap, float lateralOffset = 0f) { //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Stairs_OpenStringer", _parent); Material val2 = MaterialPresets.FindExistingMaterial("mansion_brownwood_mat"); Color color = default(Color); ((Color)(ref color))..ctor(0.55f, 0.45f, 0.35f); Material val3 = MaterialPresets.FindExistingMaterial("wood brown"); float num = 3f; float num2 = 0.3f; float num3 = 0.07f; float num4 = 0.25f; float num5 = 0.25f; int num6 = Mathf.Max(2, Mathf.CeilToInt(foundationHeight / 0.2f)); float num7 = foundationHeight / (float)num6; int num8 = num6 - 1; float num9 = ((_foundationClearanceX > 0f) ? _foundationClearanceX : 0.1f); float num10 = ((_foundationClearanceZ > 0f) ? _foundationClearanceZ : 0.1f); float num11 = ((wall == WallSide.North || wall == WallSide.South) ? num10 : num9); float num12 = 0.2f; Vector3 localPosition = default(Vector3); Vector3 size = default(Vector3); for (int i = 0; i < num8; i++) { float num13 = 0f - foundationHeight + (float)(i + 1) * num7 - gap; float num14 = num13 + num3 / 2f; float num15 = (float)(num8 - 1 - i) * num2 + num2 / 2f + num11; switch (wall) { case WallSide.North: ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f + lateralOffset, num14, _roomSize.z + num15); ((Vector3)(ref size))..ctor(num + num12, num3, num2 + 0.04f); break; case WallSide.South: ((Vector3)(ref localPosition))..ctor(_roomSize.x / 2f + lateralOffset, num14, 0f - num15); ((Vector3)(ref size))..ctor(num + num12, num3, num2 + 0.04f); break; case WallSide.East: ((Vector3)(ref localPosition))..ctor(_roomSize.x + num15, num14, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size))..ctor(num2 + 0.04f, num3, num + num12); break; case WallSide.West: ((Vector3)(ref localPosition))..ctor(0f - num15, num14, _roomSize.z / 2f + lateralOffset); ((Vector3)(ref size))..ctor(num2 + 0.04f, num3, num + num12); break; default: continue; } GameObject obj = PrimitiveBuilder.CreateBox($"Tread{i + 1}", localPosition, size, color, val.transform); if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); } } float num16 = 0.3f; float num17 = 0f - foundationHeight - gap; float num18 = 0f - gap + num7; float num19 = 0f - num5; float num20 = (float)(num8 - 1) * num2 + num2 / 2f + num11; float num21 = num20 - num19; float num22 = num18 - num17; float num23 = Mathf.Atan2(num22, num21); float num24 = num23 * 57.29578f; float num25 = Mathf.Sqrt(num22 * num22 + num21 * num21); float num26 = num7 * 3f; float num27 = num25 + num16 - num26; float num28 = Mathf.Cos(num23); float num29 = Mathf.Sin(num23); float num30 = num19 + num26 * num28; float num31 = num18 - num26 * num29; float num32 = num20 + num16 * num28; float num33 = num17 - num16 * num29; float num34 = (num30 + num32) / 2f; float num35 = (num31 + num33) / 2f; float num36 = num / 2f - num4; Vector3 size2 = default(Vector3); Vector3 localPosition2 = default(Vector3); for (int j = 0; j < 2; j++) { float num37 = ((j == 0) ? (0f - num36) : num36); ((Vector3)(ref size2))..ctor(num4, num27, num5); Quaternion val4; switch (wall) { case WallSide.North: ((Vector3)(ref localPosition2))..ctor(_roomSize.x / 2f + lateralOffset + num37, num35, _roomSize.z + num34); val4 = Quaternion.Euler(num24 + 90f, 0f, 0f); break; case WallSide.South: ((Vector3)(ref localPosition2))..ctor(_roomSize.x / 2f + lateralOffset + num37, num35, 0f - num34); val4 = Quaternion.Euler(0f - num24 - 90f, 0f, 0f); break; case WallSide.East: ((Vector3)(ref localPosition2))..ctor(_roomSize.x + num34, num35, _roomSize.z / 2f + lateralOffset + num37); ((Vector3)(ref size2))..ctor(num5, num27, num4); val4 = Quaternion.Euler(0f, 0f, 0f - num24 - 90f); break; case WallSide.West: ((Vector3)(ref localPosition2))..ctor(0f - num34, num35, _roomSize.z / 2f + lateralOffset + num37); ((Vector3)(ref size2))..ctor(num5, num27, num4); val4 = Quaternion.Euler(0f, 0f, num24 + 90f); break; default: continue; } GameObject val5 = PrimitiveBuilder.CreateBox($"Stringer{j + 1}", localPosition2, size2, color, val.transform); val5.transform.rotation = _parent.rotation * val4; if ((Object)(object)val3 != (Object)null) { ApplyMaterial(val5, val3); } else if ((Object)(object)val2 != (Object)null) { ApplyMaterial(val5, val2); } } DebugLog.Info($"[DecorBuilder] OpenStringer stairs: {num8} treads + 2 stringers, gap={gap:F2}, treadMat={((val2 != null) ? ((Object)val2).name : null) ?? "fallback"}, beamMat={((val3 != null) ? ((Object)val3).name : null) ?? "fallback"}"); return val; } private void CreateMoldingSegments(string name, Vector3 center, Vector3 size, float wallLength, bool isZAxis, WallOpening? opening, float moldingHeight, Color color, Material? material, GameObject container) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (opening == null || opening.Type != WallOpeningType.Door || !(opening.BottomOffset < moldingHeight)) { GameObject obj = PrimitiveBuilder.CreateBox(name, center, size, color, container.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj, material); } return; } float offset = opening.Offset; float num = (wallLength - opening.Width) / 2f + offset; float num2 = (wallLength - opening.Width) / 2f - offset; if (isZAxis) { if (num > 0f) { Vector3 size2 = default(Vector3); ((Vector3)(ref size2))..ctor(size.x, size.y, num); Vector3 localPosition = center + Vector3.back * (wallLength / 2f - num / 2f); GameObject obj2 = PrimitiveBuilder.CreateBox(name + "_L", localPosition, size2, color, container.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj2, material); } } if (num2 > 0f) { Vector3 size3 = default(Vector3); ((Vector3)(ref size3))..ctor(size.x, size.y, num2); Vector3 localPosition2 = center + Vector3.forward * (wallLength / 2f - num2 / 2f); GameObject obj3 = PrimitiveBuilder.CreateBox(name + "_R", localPosition2, size3, color, container.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj3, material); } } return; } if (num > 0f) { Vector3 size4 = default(Vector3); ((Vector3)(ref size4))..ctor(num, size.y, size.z); Vector3 localPosition3 = center + Vector3.left * (wallLength / 2f - num / 2f); GameObject obj4 = PrimitiveBuilder.CreateBox(name + "_L", localPosition3, size4, color, container.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj4, material); } } if (num2 > 0f) { Vector3 size5 = default(Vector3); ((Vector3)(ref size5))..ctor(num2, size.y, size.z); Vector3 localPosition4 = center + Vector3.right * (wallLength / 2f - num2 / 2f); GameObject obj5 = PrimitiveBuilder.CreateBox(name + "_R", localPosition4, size5, color, container.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj5, material); } } } private void InsetDoorWallSegments(string wallName, float inset, bool isVertical) { Transform val = _parent.Find("Walls/" + wallName); if (!((Object)(object)val == (Object)null)) { InsetDoorWallSegments(val, wallName, inset, isVertical); } } private static void InsetDoorWallSegments(Transform wallContainer, string childPrefix, float inset, bool isVertical) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) Transform val = wallContainer.Find(childPrefix + "_Left"); Transform val2 = wallContainer.Find(childPrefix + "_Right"); Transform val3 = wallContainer.Find(childPrefix + "_Top"); if ((Object)(object)val != (Object)null) { Vector3 localScale = val.localScale; Vector3 localPosition = val.localPosition; if (isVertical) { localScale.z -= inset; localPosition.z -= inset / 2f; } else { localScale.x -= inset; localPosition.x -= inset / 2f; } val.localScale = localScale; val.localPosition = localPosition; } if ((Object)(object)val2 != (Object)null) { Vector3 localScale2 = val2.localScale; Vector3 localPosition2 = val2.localPosition; if (isVertical) { localScale2.z -= inset; localPosition2.z += inset / 2f; } else { localScale2.x -= inset; localPosition2.x += inset / 2f; } val2.localScale = localScale2; val2.localPosition = localPosition2; } if ((Object)(object)val3 != (Object)null) { Vector3 localScale3 = val3.localScale; Vector3 localPosition3 = val3.localPosition; localScale3.y -= inset; localPosition3.y += inset / 2f; if (isVertical) { localScale3.z += 2f * inset; } else { localScale3.x += 2f * inset; } val3.localScale = localScale3; val3.localPosition = localPosition3; } } private void CreateDoorFrame(string name, Vector3 wallCenter, float wallHeight, WallOpening opening, bool isVertical, float frameWidth, float trimDepth, Color color, Material? material, GameObject container) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) CreateDoorFrame(name, wallCenter, wallHeight, opening.Width, opening.Height, opening.Offset, isVertical, frameWidth, trimDepth, color, material, container); } private void CreateDoorFrame(string name, Vector3 wallCenter, float wallHeight, float doorWidth, float doorHeight, float doorOffset, bool isVertical, float frameWidth, float trimDepth, Color color, Material? material, GameObject container) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (isVertical ? new Vector3(0f, 0f, doorOffset) : new Vector3(doorOffset, 0f, 0f)); Vector3 val2 = wallCenter + val; float num = (0f - (wallHeight - doorHeight)) / 2f; float num2 = doorWidth / 2f + frameWidth / 2f; Vector3 size = (isVertical ? new Vector3(trimDepth, doorHeight, frameWidth) : new Vector3(frameWidth, doorHeight, trimDepth)); Vector3 localPosition = val2 + (isVertical ? new Vector3(0f, num, 0f - num2) : new Vector3(0f - num2, num, 0f)); GameObject obj = PrimitiveBuilder.CreateBox(name + "_Left", localPosition, size, color, container.transform); Vector3 localPosition2 = val2 + (isVertical ? new Vector3(0f, num, num2) : new Vector3(num2, num, 0f)); GameObject obj2 = PrimitiveBuilder.CreateBox(name + "_Right", localPosition2, size, color, container.transform); float num3 = doorWidth + 2f * frameWidth; float num4 = 0f - wallHeight / 2f + doorHeight + frameWidth / 2f; Vector3 size2 = (isVertical ? new Vector3(trimDepth, frameWidth, num3) : new Vector3(num3, frameWidth, trimDepth)); GameObject obj3 = PrimitiveBuilder.CreateBox(name + "_Top", val2 + new Vector3(0f, num4, 0f), size2, color, container.transform); if ((Object)(object)material != (Object)null) { ApplyMaterial(obj, material); ApplyMaterial(obj2, material); ApplyMaterial(obj3, material); } } private static void ApplyMaterial(GameObject obj, Material material) { Renderer component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = material; } } } public enum InteriorWallAxis { X, Z } public sealed class InteriorWallDefinition { public InteriorWallAxis Axis { get; } public float Position { get; } public float From { get; } public float To { get; } public WallOpening? Opening { get; } public Color? Color { get; } public Material? Material { get; } public InteriorWallDefinition(InteriorWallAxis axis, float position, float from, float to, WallOpening? opening = null, Color? color = null, Material? material = null) { Axis = axis; Position = position; From = from; To = to; Opening = opening; Color = color; Material = material; } } public sealed class DoorwayInfo { public Vector3 Center { get; } public float Width { get; } public float Height { get; } public bool FacesAlongZ { get; } public float WallThickness { get; } internal GameObject? WallContainer { get; set; } public DoorwayInfo(Vector3 center, float width, float height, bool facesAlongZ, float wallThickness) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Center = center; Width = width; Height = height; FacesAlongZ = facesAlongZ; WallThickness = wallThickness; } } public sealed class InteriorWallBuilder { private readonly Transform _parent; private readonly Vector3 _roomSize; private readonly float _wallThickness; private readonly BuildingPalette _palette; private readonly int _layer; private GameObject? _container; private readonly List _doorways = new List(); public IReadOnlyList Doorways => _doorways; public InteriorWallBuilder(Transform parent, Vector3 roomSize, float wallThickness, BuildingPalette palette, int layer = -1) { //IL_001b: 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) _parent = parent; _roomSize = roomSize; _wallThickness = wallThickness; _palette = palette; _layer = layer; } public GameObject? BuildInteriorWall(InteriorWallDefinition def) { //IL_0065: 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_006a: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (!Validate(def)) { return null; } if (_container == null) { _container = BuildingUtilities.CreateFolder("InteriorWalls", _parent); } float num = def.To - def.From; Color color = (Color)(((??)def.Color) ?? _palette.WallColor); Material material = def.Material ?? _palette.WallMaterial; (Vector3 center, Vector3 size, bool isVertical) wallTransform = GetWallTransform(def); Vector3 item = wallTransform.center; Vector3 item2 = wallTransform.size; bool item3 = wallTransform.isVertical; string name = $"InteriorWall_{def.Axis}_{def.Position:F1}"; GameObject val = ((def.Opening == null || def.Opening.Type == WallOpeningType.None) ? CreateSolidWall(name, item, item2, color, material) : ((def.Opening.Type != WallOpeningType.Door) ? CreateSolidWall(name, item, item2, color, material) : CreateWallWithDoor(name, item, item2, def.Opening, item3, color, material))); if ((Object)(object)val != (Object)null && _layer >= 0) { val.SetLayerRecursively(_layer); } return val; } private bool Validate(InteriorWallDefinition def) { float num = ((def.Axis == InteriorWallAxis.X) ? _roomSize.x : _roomSize.z); float num2 = ((def.Axis == InteriorWallAxis.X) ? _roomSize.z : _roomSize.x); if (def.Position < 0f || def.Position > num2) { DebugLog.Warning($"[InteriorWallBuilder] Position {def.Position} out of room bounds (0–{num2}). Skipping wall."); return false; } if (def.From >= def.To) { DebugLog.Warning($"[InteriorWallBuilder] From ({def.From}) >= To ({def.To}). Skipping wall."); return false; } float num3 = def.To - def.From; if (num3 < 0.5f) { DebugLog.Warning($"[InteriorWallBuilder] Wall length {num3:F2}m < minimum {0.5f}m. Skipping wall."); return false; } if (def.Opening != null && def.Opening.Type == WallOpeningType.Door && def.Opening.Width >= num3) { DebugLog.Warning($"[InteriorWallBuilder] Door width ({def.Opening.Width}) >= wall length ({num3:F2}). Skipping wall."); return false; } return true; } private (Vector3 center, Vector3 size, bool isVertical) GetWallTransform(InteriorWallDefinition def) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) float num = def.To - def.From; float num2 = (def.From + def.To) / 2f; if (def.Axis == InteriorWallAxis.X) { Vector3 item = default(Vector3); ((Vector3)(ref item))..ctor(num2, _roomSize.y / 2f, def.Position); Vector3 item2 = default(Vector3); ((Vector3)(ref item2))..ctor(num, _roomSize.y, _wallThickness); return (center: item, size: item2, isVertical: false); } Vector3 item3 = default(Vector3); ((Vector3)(ref item3))..ctor(def.Position, _roomSize.y / 2f, num2); Vector3 item4 = default(Vector3); ((Vector3)(ref item4))..ctor(_wallThickness, _roomSize.y, num); return (center: item3, size: item4, isVertical: true); } private GameObject CreateSolidWall(string name, Vector3 center, Vector3 size, Color color, Material? material) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrimitiveBuilder.CreateBox(name, center, size, color, _container.transform); ApplyMaterial(val, material); return val; } private GameObject CreateWallWithDoor(string name, Vector3 wallCenter, Vector3 wallSize, WallOpening opening, bool isVertical, Color color, Material? material) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0075: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder(name, _container.transform); float num = (isVertical ? wallSize.z : wallSize.x); float y = wallSize.y; float width = opening.Width; float height = opening.Height; float offset = opening.Offset; float num2 = (num - width) / 2f + offset; float num3 = (num - width) / 2f - offset; Vector3 val2 = (isVertical ? (Vector3.forward * offset) : (Vector3.right * offset)); Vector3 val3 = wallCenter + val2; if (num2 > 0.01f) { float num4 = width / 2f + num2 / 2f; Vector3 val4 = (isVertical ? (Vector3.back * num4) : (Vector3.left * num4)); Vector3 size = (isVertical ? new Vector3(_wallThickness, y, num2) : new Vector3(num2, y, _wallThickness)); GameObject go = PrimitiveBuilder.CreateBox(name + "_Left", val3 + val4, size, color, val.transform); ApplyMaterial(go, material); } if (num3 > 0.01f) { float num5 = width / 2f + num3 / 2f; Vector3 val5 = (isVertical ? (Vector3.forward * num5) : (Vector3.right * num5)); Vector3 size2 = (isVertical ? new Vector3(_wallThickness, y, num3) : new Vector3(num3, y, _wallThickness)); GameObject go2 = PrimitiveBuilder.CreateBox(name + "_Right", val3 + val5, size2, color, val.transform); ApplyMaterial(go2, material); } float num6 = y - height; if (num6 > 0.01f) { Vector3 size3 = (isVertical ? new Vector3(_wallThickness, num6, width) : new Vector3(width, num6, _wallThickness)); float num7 = y / 2f - num6 / 2f; Vector3 val6 = Vector3.up * num7; GameObject go3 = PrimitiveBuilder.CreateBox(name + "_Top", val3 + val6, size3, color, val.transform); ApplyMaterial(go3, material); } bool facesAlongZ = !isVertical; Vector3 center = default(Vector3); ((Vector3)(ref center))..ctor(val3.x, height / 2f, val3.z); DoorwayInfo doorwayInfo = new DoorwayInfo(center, width, height, facesAlongZ, _wallThickness); doorwayInfo.WallContainer = val; _doorways.Add(doorwayInfo); return val; } private void ApplyMaterial(GameObject go, Material? material) { if ((Object)(object)material != (Object)null) { Renderer component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = material; } } } } public enum ParapetPreset { Deep, Shallow } public sealed class RoofBuilder { private readonly Transform _parent; private readonly Vector3 _roomSize; private readonly float _wallThickness; private readonly BuildingPalette _palette; public RoofBuilder(Transform parent, Vector3 roomSize, float wallThickness, BuildingPalette palette) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) _parent = parent; _roomSize = roomSize; _wallThickness = wallThickness; _palette = palette; } public GameObject AddParapetRoof(ParapetPreset preset = ParapetPreset.Deep, float? parapetHeight = null, float? parapetDepth = null, float? capHeight = null, float? capOverhang = null, Color? parapetColor = null, Material? parapetMaterial = null, Color? capColor = null, Material? capMaterial = null) { //IL_00db: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) float num = parapetHeight ?? ((preset == ParapetPreset.Deep) ? 0.6f : 0.3f); float num2 = parapetDepth ?? (_wallThickness + 0.1f); float num3 = capHeight ?? ((preset == ParapetPreset.Deep) ? 0.25f : 0.15f); float num4 = capOverhang ?? ((preset == ParapetPreset.Deep) ? 0.15f : 0.05f); float num5 = num2 + num4; float num6 = num2 + 2f * num4; float num7 = num4 / 2f; GameObject val = BuildingUtilities.CreateFolder("ParapetRoof", _parent); Color color = (Color)(((??)parapetColor) ?? _palette.TrimColor); float num8 = _roomSize.y + num / 2f; GameObject obj = PrimitiveBuilder.CreateBox("Parapet_North", new Vector3(_roomSize.x / 2f, num8, _roomSize.z), new Vector3(_roomSize.x + num2, num, num2), color, val.transform); GameObject obj2 = PrimitiveBuilder.CreateBox("Parapet_South", new Vector3(_roomSize.x / 2f, num8, 0f), new Vector3(_roomSize.x + num2, num, num2), color, val.transform); GameObject obj3 = PrimitiveBuilder.CreateBox("Parapet_East", new Vector3(_roomSize.x, num8, _roomSize.z / 2f), new Vector3(num2, num, _roomSize.z - num2), color, val.transform); GameObject obj4 = PrimitiveBuilder.CreateBox("Parapet_West", new Vector3(0f, num8, _roomSize.z / 2f), new Vector3(num2, num, _roomSize.z - num2), color, val.transform); Material val2 = parapetMaterial ?? _palette.TrimMaterial; if ((Object)(object)val2 != (Object)null) { ApplyMaterial(obj, val2); ApplyMaterial(obj2, val2); ApplyMaterial(obj3, val2); ApplyMaterial(obj4, val2); } Color color2 = (Color)(((??)capColor) ?? _palette.AccentColor); float num9 = _roomSize.y + num + num3 / 2f; GameObject obj5 = PrimitiveBuilder.CreateBox("Cap_North", new Vector3(_roomSize.x / 2f, num9, _roomSize.z + num7), new Vector3(_roomSize.x + num6, num3, num5), color2, val.transform); GameObject obj6 = PrimitiveBuilder.CreateBox("Cap_South", new Vector3(_roomSize.x / 2f, num9, 0f - num7), new Vector3(_roomSize.x + num6, num3, num5), color2, val.transform); GameObject obj7 = PrimitiveBuilder.CreateBox("Cap_East", new Vector3(_roomSize.x + num7, num9, _roomSize.z / 2f), new Vector3(num5, num3, _roomSize.z - num2), color2, val.transform); GameObject obj8 = PrimitiveBuilder.CreateBox("Cap_West", new Vector3(0f - num7, num9, _roomSize.z / 2f), new Vector3(num5, num3, _roomSize.z - num2), color2, val.transform); Material val3 = capMaterial ?? _palette.AccentMaterial ?? _palette.TrimMaterial; if ((Object)(object)val3 != (Object)null) { ApplyMaterial(obj5, val3); ApplyMaterial(obj6, val3); ApplyMaterial(obj7, val3); ApplyMaterial(obj8, val3); } Material val4 = _palette.WallMaterial ?? MaterialPresets.Opaque(_palette.WallColor); float num10 = 0.15f; PrimitiveBuilder.CreateBox("ParapetRoofSlab", new Vector3(_roomSize.x / 2f, _roomSize.y + num10 / 2f, _roomSize.z / 2f), new Vector3(_roomSize.x, num10, _roomSize.z), val4.color, val.transform); return val; } public GameObject AddHipRoof(float ridgeHeight = 2f, float overhang = 0.3f, bool? ridgeAlongX = null, Color? roofColor = null, Material? roofMaterial = null, float baseSlabHeight = 0.15f) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) bool flag = ridgeAlongX ?? (_roomSize.x >= _roomSize.z); GameObject val = BuildingUtilities.CreateFolder("HipRoof", _parent); Material val2 = MaterialPresets.FindExistingMaterial("mansion_roof_mat"); if ((Object)(object)val2 == (Object)null) { DebugLog.Warning("[RoofBuilder] Material 'mansion_roof_mat' not found. Using fallback color."); } Material slopeMat = roofMaterial ?? val2 ?? MaterialPresets.Opaque((Color)(((??)roofColor) ?? new Color(0.45f, 0.35f, 0.3f))); float y = _roomSize.y; float ceilingY = y + baseSlabHeight; float ridgeY = y + ridgeHeight; if (baseSlabHeight > 0f) { Material material = _palette.WallMaterial ?? MaterialPresets.Opaque(_palette.WallColor); CreateRoofBaseSlab(val.transform, y, baseSlabHeight, overhang, material); } if (flag) { CreateHipAlongX(val.transform, ceilingY, ridgeY, overhang, slopeMat); } else { CreateHipAlongZ(val.transform, ceilingY, ridgeY, overhang, slopeMat); } return val; } private static void CreateSlopeQuad(string name, Transform parent, Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, float uvWidth, float uvHeight, Material material) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001f: 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_0028: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) new CustomMeshBuilder(name).AddVertices(v0, v1, v2, v3).AddVertices(v0, v1, v2, v3).AddQuad(0, 1, 2, 3) .AddQuad(7, 6, 5, 4) .SetUVs(new Vector2(0f, 0f), new Vector2(uvWidth, 0f), new Vector2(uvWidth, uvHeight), new Vector2(0f, uvHeight), new Vector2(0f, 0f), new Vector2(uvWidth, 0f), new Vector2(uvWidth, uvHeight), new Vector2(0f, uvHeight)) .SetMaterial(material) .Build(parent); } private void CreateHipAlongX(Transform container, float ceilingY, float ridgeY, float overhang, Material slopeMat) { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_014e: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) float num = ridgeY - ceilingY; float num2 = _roomSize.z / 2f; float num3 = _roomSize.z / 2f; float num4 = num3; float num5 = _roomSize.x - num3; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f - overhang, ceilingY, 0f - overhang); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(_roomSize.x + overhang, ceilingY, 0f - overhang); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(_roomSize.x + overhang, ceilingY, _roomSize.z + overhang); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0f - overhang, ceilingY, _roomSize.z + overhang); float num6 = num2 + overhang; float uvHeight = Mathf.Sqrt(num * num + num6 * num6); if (num5 > num4) { Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(num4, ridgeY, num2); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(num5, ridgeY, num2); float uvWidth = _roomSize.x + 2f * overhang; CreateSlopeQuad("Slope_South", container, val2, val, val5, val6, uvWidth, uvHeight, slopeMat); CreateSlopeQuad("Slope_North", container, val4, val3, val6, val5, uvWidth, uvHeight, slopeMat); float uvWidth2 = _roomSize.z + 2f * overhang; float num7 = num3 + overhang; float uvHeight2 = Mathf.Sqrt(num * num + num7 * num7); CreateSlopeTriangle("Hip_East", container, val3, val2, val6, uvWidth2, uvHeight2, slopeMat); CreateSlopeTriangle("Hip_West", container, val, val4, val5, uvWidth2, uvHeight2, slopeMat); } else { Vector3 v = default(Vector3); ((Vector3)(ref v))..ctor(_roomSize.x / 2f, ridgeY, num2); float uvWidth3 = _roomSize.x + 2f * overhang; float uvWidth4 = _roomSize.z + 2f * overhang; float num8 = _roomSize.x / 2f + overhang; float uvHeight3 = Mathf.Sqrt(num * num + num8 * num8); CreateSlopeTriangle("Slope_South", container, val2, val, v, uvWidth3, uvHeight, slopeMat); CreateSlopeTriangle("Slope_North", container, val4, val3, v, uvWidth3, uvHeight, slopeMat); CreateSlopeTriangle("Hip_East", container, val3, val2, v, uvWidth4, uvHeight3, slopeMat); CreateSlopeTriangle("Hip_West", container, val, val4, v, uvWidth4, uvHeight3, slopeMat); } } private void CreateHipAlongZ(Transform container, float ceilingY, float ridgeY, float overhang, Material slopeMat) { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_014e: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) float num = ridgeY - ceilingY; float num2 = _roomSize.x / 2f; float num3 = _roomSize.x / 2f; float num4 = num3; float num5 = _roomSize.z - num3; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f - overhang, ceilingY, 0f - overhang); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(_roomSize.x + overhang, ceilingY, 0f - overhang); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(_roomSize.x + overhang, ceilingY, _roomSize.z + overhang); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0f - overhang, ceilingY, _roomSize.z + overhang); float num6 = num2 + overhang; float uvHeight = Mathf.Sqrt(num * num + num6 * num6); if (num5 > num4) { Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(num2, ridgeY, num4); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(num2, ridgeY, num5); float uvWidth = _roomSize.z + 2f * overhang; CreateSlopeQuad("Slope_West", container, val, val4, val6, val5, uvWidth, uvHeight, slopeMat); CreateSlopeQuad("Slope_East", container, val3, val2, val5, val6, uvWidth, uvHeight, slopeMat); float uvWidth2 = _roomSize.x + 2f * overhang; float num7 = num3 + overhang; float uvHeight2 = Mathf.Sqrt(num * num + num7 * num7); CreateSlopeTriangle("Hip_North", container, val4, val3, val6, uvWidth2, uvHeight2, slopeMat); CreateSlopeTriangle("Hip_South", container, val2, val, val5, uvWidth2, uvHeight2, slopeMat); } else { Vector3 v = default(Vector3); ((Vector3)(ref v))..ctor(num2, ridgeY, _roomSize.z / 2f); float uvWidth3 = _roomSize.z + 2f * overhang; float uvWidth4 = _roomSize.x + 2f * overhang; float num8 = _roomSize.z / 2f + overhang; float uvHeight3 = Mathf.Sqrt(num * num + num8 * num8); CreateSlopeTriangle("Slope_West", container, val, val4, v, uvWidth3, uvHeight, slopeMat); CreateSlopeTriangle("Slope_East", container, val3, val2, v, uvWidth3, uvHeight, slopeMat); CreateSlopeTriangle("Hip_North", container, val4, val3, v, uvWidth4, uvHeight3, slopeMat); CreateSlopeTriangle("Hip_South", container, val2, val, v, uvWidth4, uvHeight3, slopeMat); } } private static void CreateSlopeTriangle(string name, Transform parent, Vector3 v0, Vector3 v1, Vector3 v2, float uvWidth, float uvHeight, Material material) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001f: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c3: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) new CustomMeshBuilder(name).AddVertices(v0, v1, v2).AddVertices(v0, v1, v2).AddTriangle(0, 1, 2) .AddTriangle(5, 4, 3) .SetUVs(new Vector2(0f, 0f), new Vector2(uvWidth, 0f), new Vector2(uvWidth / 2f, uvHeight), new Vector2(0f, 0f), new Vector2(uvWidth, 0f), new Vector2(uvWidth / 2f, uvHeight)) .SetMaterial(material) .Build(parent); } private void CreateRoofBaseSlab(Transform container, float ceilingY, float slabHeight, float overhang, Material material) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) float num = _roomSize.x + 2f * overhang; float num2 = _roomSize.z + 2f * overhang; float num3 = ceilingY + slabHeight / 2f; GameObject obj = PrimitiveBuilder.CreateBox("RoofBaseSlab", new Vector3(_roomSize.x / 2f, num3, _roomSize.z / 2f), new Vector3(num, slabHeight, num2), material.color, container); ApplyMaterial(obj, material); } private static void ApplyMaterial(GameObject obj, Material material) { Renderer component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = material; } } } public sealed class ClearingOptions { public float Padding { get; set; } = 2f; public bool ClearTerrainTrees { get; set; } = true; public bool ClearSceneObjects { get; set; } = true; public bool ClearVegetation { get; set; } = true; public string[]? VegetationKeywords { get; set; } = Constants.Terrain.DefaultVegetationKeywords; public string[]? ProtectedKeywords { get; set; } = Constants.Terrain.DefaultProtectedKeywords; public Transform[]? Preserved { get; set; } public Func? Filter { get; set; } public static ClearingOptions Default => new ClearingOptions(); } public static class TerrainClearer { internal static void ClearArea(Bounds bounds, ClearingOptions? options = null) { //IL_0021: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (options == null) { options = ClearingOptions.Default; } float padding = options.Padding; int num = 0; int num2 = 0; if (options.ClearTerrainTrees) { Bounds bounds2 = bounds; ((Bounds)(ref bounds2)).Expand(new Vector3(padding * 2f, padding * 2f, padding * 2f)); num = ClearTerrainTrees(bounds2); } if (options.ClearSceneObjects || options.ClearVegetation) { Bounds vegetationBounds = bounds; ((Bounds)(ref vegetationBounds)).Expand(new Vector3(padding, padding, padding)); num2 = ClearSceneObjects(bounds, vegetationBounds, options); } if (num + num2 > 0) { DebugLog.Info($"[TerrainClearer] Cleared {num} trees, {num2} objects"); } } public static bool ClearAroundBuilding(GameObject buildingRoot, Vector3 roomSize, ClearingOptions? options = null) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //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) try { if (ClearAroundBuildingCore(buildingRoot, roomSize, options)) { return true; } } catch (Exception ex) { DebugLog.Warning("[TerrainClearer] ClearAroundBuilding threw (will retry): " + ex.GetType().Name + ": " + ex.Message); } DebugLog.Info("[TerrainClearer] Terrain not available — queuing retry."); TerrainRetryQueue.Enqueue(buildingRoot, () => ClearAroundBuildingCore(buildingRoot, roomSize, options)); return false; } private static bool ClearAroundBuildingCore(GameObject buildingRoot, Vector3 roomSize, ClearingOptions? options) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) ClearingOptions clearingOptions = options ?? ClearingOptions.Default; if (clearingOptions.ClearTerrainTrees && ((Il2CppArrayBase)(object)Terrain.activeTerrains).Length == 0) { return false; } if (clearingOptions.Preserved == null) { ClearingOptions clearingOptions2 = new ClearingOptions(); clearingOptions2.Padding = clearingOptions.Padding; clearingOptions2.ClearTerrainTrees = clearingOptions.ClearTerrainTrees; clearingOptions2.ClearSceneObjects = clearingOptions.ClearSceneObjects; clearingOptions2.ClearVegetation = clearingOptions.ClearVegetation; clearingOptions2.VegetationKeywords = clearingOptions.VegetationKeywords; clearingOptions2.ProtectedKeywords = clearingOptions.ProtectedKeywords; clearingOptions2.Preserved = (Transform[]?)(object)new Transform[1] { buildingRoot.transform }; clearingOptions2.Filter = clearingOptions.Filter; clearingOptions = clearingOptions2; } Bounds bounds = ComputeWorldBounds(buildingRoot.transform, roomSize); ClearArea(bounds, clearingOptions); return true; } private static Bounds ComputeWorldBounds(Transform building, Vector3 roomSize) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; Vector3 val = building.TransformPoint(new Vector3(zero.x, zero.y, zero.z)); Vector3 val2 = building.TransformPoint(new Vector3(roomSize.x, zero.y, zero.z)); Vector3 val3 = building.TransformPoint(new Vector3(zero.x, zero.y, roomSize.z)); Vector3 val4 = building.TransformPoint(new Vector3(roomSize.x, zero.y, roomSize.z)); Vector3 val5 = building.TransformPoint(new Vector3(zero.x, roomSize.y, zero.z)); Vector3 val6 = building.TransformPoint(new Vector3(roomSize.x, roomSize.y, zero.z)); Vector3 val7 = building.TransformPoint(new Vector3(zero.x, roomSize.y, roomSize.z)); Vector3 val8 = building.TransformPoint(new Vector3(roomSize.x, roomSize.y, roomSize.z)); Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(val, Vector3.zero); ((Bounds)(ref result)).Encapsulate(val2); ((Bounds)(ref result)).Encapsulate(val3); ((Bounds)(ref result)).Encapsulate(val4); ((Bounds)(ref result)).Encapsulate(val5); ((Bounds)(ref result)).Encapsulate(val6); ((Bounds)(ref result)).Encapsulate(val7); ((Bounds)(ref result)).Encapsulate(val8); return result; } private static int ClearTerrainTrees(Bounds bounds) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) int num = 0; Vector3 val2 = default(Vector3); foreach (Terrain item in (Il2CppArrayBase)(object)Terrain.activeTerrains) { TerrainData terrainData; try { terrainData = item.terrainData; if (terrainData == null) { continue; } } catch (Exception ex) { DebugLog.Warning("[TerrainClearer] Could not access terrain data for '" + ((Object)item).name + "': " + ex.Message); continue; } Vector3 position = ((Component)item).transform.position; Vector3 size = terrainData.size; TreeInstance[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)terrainData.treeInstances); List list = new List(array.Length); int num2 = 0; foreach (TreeInstance val in array) { ((Vector3)(ref val2))..ctor(position.x + val.position.x * size.x, position.y + val.position.y * size.y, position.z + val.position.z * size.z); if (((Bounds)(ref bounds)).Contains(val2)) { num2++; } else { list.Add(val); } } if (num2 > 0) { terrainData.treeInstances = Il2CppStructArray.op_Implicit(list.ToArray()); TerrainCollider component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { component.terrainData = null; component.terrainData = terrainData; } item.Flush(); DebugLog.Info($"[TerrainClearer] Removed {num2} trees from terrain '{((Object)item).name}'"); } num += num2; } return num; } private static int ClearSceneObjects(Bounds buildingBounds, Bounds vegetationBounds, ClearingOptions options) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) Bounds val = buildingBounds; Vector3 min = ((Bounds)(ref val)).min; Vector3 max = ((Bounds)(ref val)).max; min.y = ((Bounds)(ref vegetationBounds)).min.y; max.y = ((Bounds)(ref vegetationBounds)).max.y; ((Bounds)(ref val)).SetMinMax(min, max); Renderer[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType()); HashSet hashSet = BuildPreservedSet(options); HashSet hashSet2 = new HashSet(); HashSet livingRoots = new HashSet(); HashSet staticRoots = new HashSet(); Renderer[] array2 = array; foreach (Renderer val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } Transform transform = ((Component)val2).transform; if ((Object)(object)((Component)transform).GetComponent() != (Object)null || hashSet.Contains(((Object)transform).GetInstanceID())) { continue; } bool flag = ((Bounds)(ref val)).Contains(transform.position); bool flag2 = !flag && ((Bounds)(ref vegetationBounds)).Contains(transform.position); if (!flag && !flag2) { continue; } GameObject val3 = ResolveLodRoot(((Component)transform).gameObject); if (BuildingUtilities.IsLivingEntity(transform, livingRoots, staticRoots)) { continue; } if (flag && options.ClearSceneObjects) { if ((options.ProtectedKeywords == null || !MatchesKeyword(((Object)val3).name, options.ProtectedKeywords)) && (options.Filter == null || !options.Filter(val3))) { hashSet2.Add(val3); } } else if (flag2 && options.ClearVegetation && options.VegetationKeywords != null && MatchesKeyword(((Object)val3).name, options.VegetationKeywords) && (options.Filter == null || !options.Filter(val3))) { hashSet2.Add(val3); } } if (options.VegetationKeywords != null && options.VegetationKeywords.Length != 0) { Transform[] array3 = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType()); Transform[] array4 = array3; foreach (Transform val4 in array4) { if ((Object)(object)val4 == (Object)null || (Object)(object)((Component)val4).GetComponent() != (Object)null || (Object)(object)((Component)val4).GetComponent() != (Object)null || hashSet.Contains(((Object)val4).GetInstanceID())) { continue; } bool flag3 = ((Bounds)(ref val)).Contains(val4.position); bool flag4 = !flag3 && ((Bounds)(ref vegetationBounds)).Contains(val4.position); if (!flag3 && !flag4) { continue; } GameObject gameObject = ((Component)val4).gameObject; if (!MatchesKeyword(((Object)gameObject).name, options.VegetationKeywords)) { continue; } if (flag3 && options.ClearSceneObjects) { if ((options.ProtectedKeywords == null || !MatchesKeyword(((Object)gameObject).name, options.ProtectedKeywords)) && (options.Filter == null || !options.Filter(gameObject))) { hashSet2.Add(gameObject); } } else if (flag4 && options.ClearVegetation && (options.Filter == null || !options.Filter(gameObject))) { hashSet2.Add(gameObject); } } } foreach (GameObject item in hashSet2) { Object.Destroy((Object)(object)item); } return hashSet2.Count; } private static GameObject ResolveLodRoot(GameObject obj) { Transform val = obj.transform; while ((Object)(object)val.parent != (Object)null) { if ((Object)(object)((Component)val.parent).GetComponent() != (Object)null) { return ((Component)val.parent).gameObject; } val = val.parent; } return obj; } private static bool MatchesKeyword(string name, string[] keywords) { foreach (string value in keywords) { if (name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static HashSet BuildPreservedSet(ClearingOptions options) { HashSet hashSet = new HashSet(); if (options.Preserved == null) { return hashSet; } Transform[] preserved = options.Preserved; foreach (Transform val in preserved) { if ((Object)(object)val == (Object)null) { continue; } foreach (Transform componentsInChild in ((Component)val).GetComponentsInChildren()) { hashSet.Add(((Object)componentsInChild).GetInstanceID()); } } return hashSet; } } public static class TerrainFlattener { private delegate IntPtr Internal_GetHeightsDelegate(IntPtr @this, int xBase, int yBase, int width, int height); private delegate void Internal_SetHeightsDelegate(IntPtr @this, int xBase, int yBase, int totalWidth, int totalHeight, IntPtr heights); private delegate IntPtr GetDetailLayerDelegate(IntPtr @this, int xBase, int yBase, int width, int height, int layer); private delegate void Internal_SetDetailLayerDelegate(IntPtr @this, int xBase, int yBase, int totalWidth, int totalHeight, int detailIndex, IntPtr data); private static Internal_GetHeightsDelegate? _getHeightsICall; private static Internal_SetHeightsDelegate? _setHeightsICall; private static bool _heightICallsResolved; private static GetDetailLayerDelegate? _getDetailLayerICall; private static Internal_SetDetailLayerDelegate? _setDetailLayerICall; private static bool _detailICallsResolved; private static bool ResolveHeightICalls() { if (_heightICallsResolved) { return _getHeightsICall != null && _setHeightsICall != null; } _heightICallsResolved = true; try { _getHeightsICall = IL2CPP.ResolveICall("UnityEngine.TerrainData::Internal_GetHeights"); _setHeightsICall = IL2CPP.ResolveICall("UnityEngine.TerrainData::Internal_SetHeights"); if (_getHeightsICall != null && _setHeightsICall != null) { DebugLog.Info("[TerrainFlattener] Resolved height ICalls."); } else { DebugLog.Error("[TerrainFlattener] Height ICalls resolved to null."); } } catch (Exception ex) { DebugLog.Error("[TerrainFlattener] Failed to resolve height ICalls: " + ex.Message); _getHeightsICall = null; _setHeightsICall = null; } return _getHeightsICall != null && _setHeightsICall != null; } private static bool ResolveDetailICalls() { if (_detailICallsResolved) { return _getDetailLayerICall != null && _setDetailLayerICall != null; } _detailICallsResolved = true; try { _getDetailLayerICall = IL2CPP.ResolveICall("UnityEngine.TerrainData::GetDetailLayer"); _setDetailLayerICall = IL2CPP.ResolveICall("UnityEngine.TerrainData::Internal_SetDetailLayer"); if (_getDetailLayerICall != null && _setDetailLayerICall != null) { DebugLog.Info("[TerrainFlattener] Resolved detail layer ICalls."); } else { DebugLog.Warning("[TerrainFlattener] Detail layer ICalls resolved to null — grass clearing unavailable."); } } catch (Exception ex) { DebugLog.Warning("[TerrainFlattener] Failed to resolve detail layer ICalls: " + ex.Message); _getDetailLayerICall = null; _setDetailLayerICall = null; } return _getDetailLayerICall != null && _setDetailLayerICall != null; } public static bool FlattenUnder(GameObject buildingRoot, Vector3 roomSize, float targetWorldY, float padding = 0.5f, bool clearDetails = true, float blendDistance = 0f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) try { if (FlattenUnderCore(buildingRoot, roomSize, targetWorldY, padding, clearDetails, blendDistance)) { return true; } } catch (Exception ex) { DebugLog.Warning("[TerrainFlattener] FlattenUnder threw (will retry): " + ex.GetType().Name + ": " + ex.Message); } DebugLog.Info("[TerrainFlattener] Terrain not available — queuing retry."); TerrainRetryQueue.Enqueue(buildingRoot, () => FlattenUnderCore(buildingRoot, roomSize, targetWorldY, padding, clearDetails, blendDistance)); return false; } private static bool FlattenUnderCore(GameObject buildingRoot, Vector3 roomSize, float targetWorldY, float padding, bool clearDetails, float blendDistance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_006b: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0096: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: 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) Bounds val = ComputeXZBounds(buildingRoot.transform, roomSize, padding); Bounds val2 = val; if (blendDistance > 0f) { ((Bounds)(ref val2)).Expand(new Vector3(blendDistance * 2f, 0f, blendDistance * 2f)); } Terrain val3 = FindCoveringTerrain(val); if ((Object)(object)val3 == (Object)null) { return false; } TerrainData terrainData = val3.terrainData; Vector3 position = ((Component)val3).transform.position; Vector3 size = terrainData.size; int heightmapResolution = terrainData.heightmapResolution; int num = Mathf.Clamp(Mathf.FloorToInt((((Bounds)(ref val2)).min.x - position.x) / size.x * (float)heightmapResolution), 0, heightmapResolution - 1); int num2 = Mathf.Clamp(Mathf.CeilToInt((((Bounds)(ref val2)).max.x - position.x) / size.x * (float)heightmapResolution), 0, heightmapResolution - 1); int num3 = Mathf.Clamp(Mathf.FloorToInt((((Bounds)(ref val2)).min.z - position.z) / size.z * (float)heightmapResolution), 0, heightmapResolution - 1); int num4 = Mathf.Clamp(Mathf.CeilToInt((((Bounds)(ref val2)).max.z - position.z) / size.z * (float)heightmapResolution), 0, heightmapResolution - 1); int num5 = num2 - num + 1; int num6 = num4 - num3 + 1; if (num5 <= 0 || num6 <= 0) { DebugLog.Warning("[TerrainFlattener] Computed zero-size sample region."); return false; } int blendSamplesX = ((blendDistance > 0f) ? Mathf.CeilToInt(blendDistance / size.x * (float)heightmapResolution) : 0); int blendSamplesZ = ((blendDistance > 0f) ? Mathf.CeilToInt(blendDistance / size.z * (float)heightmapResolution) : 0); float normalizedTarget = Mathf.Clamp01((targetWorldY - position.y) / size.y); FlattenIl2Cpp(terrainData, num, num3, num5, num6, normalizedTarget, blendSamplesX, blendSamplesZ); if (clearDetails) { ClearDetails(terrainData, position, size, val); } FlushTerrain(val3); DebugLog.Info($"[TerrainFlattener] Flattened {num5}x{num6} samples to Y={targetWorldY:F2} on terrain '{((Object)val3).name}'."); return true; } private static Terrain? FindCoveringTerrain(Bounds worldBounds) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0068: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) foreach (Terrain item in (Il2CppArrayBase)(object)Terrain.activeTerrains) { TerrainData terrainData; try { terrainData = item.terrainData; if ((Object)(object)terrainData == (Object)null) { continue; } } catch (Exception) { continue; } Vector3 position = ((Component)item).transform.position; Vector3 size = terrainData.size; if (((Bounds)(ref worldBounds)).min.x >= position.x && ((Bounds)(ref worldBounds)).max.x <= position.x + size.x && ((Bounds)(ref worldBounds)).min.z >= position.z && ((Bounds)(ref worldBounds)).max.z <= position.z + size.z) { return item; } } return null; } private static Bounds ComputeXZBounds(Transform building, Vector3 roomSize, float padding) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Vector3 val = building.TransformPoint(new Vector3(0f, 0f, 0f)); Vector3 val2 = building.TransformPoint(new Vector3(roomSize.x, 0f, 0f)); Vector3 val3 = building.TransformPoint(new Vector3(0f, 0f, roomSize.z)); Vector3 val4 = building.TransformPoint(new Vector3(roomSize.x, 0f, roomSize.z)); Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(val, Vector3.zero); ((Bounds)(ref result)).Encapsulate(val2); ((Bounds)(ref result)).Encapsulate(val3); ((Bounds)(ref result)).Encapsulate(val4); ((Bounds)(ref result)).Expand(new Vector3(padding * 2f, 0f, padding * 2f)); return result; } private static float ComputeBlendFactor(int x, int z, int sampleWidth, int sampleHeight, int blendSamplesX, int blendSamplesZ) { if (blendSamplesX <= 0 && blendSamplesZ <= 0) { return 0f; } float num = 0f; if (blendSamplesX > 0) { if (x < blendSamplesX) { num = (float)(blendSamplesX - x) / (float)blendSamplesX; } else if (x >= sampleWidth - blendSamplesX) { num = (float)(x - (sampleWidth - 1 - blendSamplesX)) / (float)blendSamplesX; } } float num2 = 0f; if (blendSamplesZ > 0) { if (z < blendSamplesZ) { num2 = (float)(blendSamplesZ - z) / (float)blendSamplesZ; } else if (z >= sampleHeight - blendSamplesZ) { num2 = (float)(z - (sampleHeight - 1 - blendSamplesZ)) / (float)blendSamplesZ; } } float num3 = Mathf.Clamp01(Mathf.Max(num, num2)); return num3 * num3 * (3f - 2f * num3); } private static void ClearDetails(TerrainData tData, Vector3 terrainPos, Vector3 terrainSize, Bounds worldBounds) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) int detailWidth = tData.detailWidth; int detailHeight = tData.detailHeight; if (detailWidth <= 0 || detailHeight <= 0) { return; } int num = Mathf.Clamp(Mathf.FloorToInt((((Bounds)(ref worldBounds)).min.x - terrainPos.x) / terrainSize.x * (float)detailWidth), 0, detailWidth - 1); int num2 = Mathf.Clamp(Mathf.CeilToInt((((Bounds)(ref worldBounds)).max.x - terrainPos.x) / terrainSize.x * (float)detailWidth), 0, detailWidth - 1); int num3 = Mathf.Clamp(Mathf.FloorToInt((((Bounds)(ref worldBounds)).min.z - terrainPos.z) / terrainSize.z * (float)detailHeight), 0, detailHeight - 1); int num4 = Mathf.Clamp(Mathf.CeilToInt((((Bounds)(ref worldBounds)).max.z - terrainPos.z) / terrainSize.z * (float)detailHeight), 0, detailHeight - 1); int num5 = num2 - num + 1; int num6 = num4 - num3 + 1; if (num5 <= 0 || num6 <= 0) { return; } Il2CppStructArray supportedLayers = tData.GetSupportedLayers(num, num3, num5, num6); int[] array = new int[((Il2CppArrayBase)(object)supportedLayers).Length]; for (int i = 0; i < ((Il2CppArrayBase)(object)supportedLayers).Length; i++) { array[i] = ((Il2CppArrayBase)(object)supportedLayers)[i]; } if (array.Length == 0) { return; } int num7 = 0; int[] array2 = array; foreach (int layer in array2) { if (ClearDetailLayerIl2Cpp(tData, num, num3, num5, num6, layer)) { num7++; } } if (num7 > 0) { DebugLog.Info($"[TerrainFlattener] Cleared {num7} detail layer(s) in {num5}x{num6} region."); } } private static void FlattenIl2Cpp(TerrainData tData, int xStart, int zStart, int sampleWidth, int sampleHeight, float normalizedTarget, int blendSamplesX, int blendSamplesZ) { if (!ResolveHeightICalls()) { DebugLog.Error("[TerrainFlattener] Cannot flatten terrain — height ICalls unavailable."); return; } IntPtr intPtr = IL2CPP.Il2CppObjectBaseToPtrNotNull((Il2CppObjectBase)(object)tData); IntPtr intPtr2 = _getHeightsICall(intPtr, xStart, zStart, sampleWidth, sampleHeight); if (intPtr2 == IntPtr.Zero) { DebugLog.Error("[TerrainFlattener] Internal_GetHeights returned null."); return; } Il2CppStructArray val = new Il2CppStructArray(intPtr2); Span span = val.AsSpan(); int num = sampleHeight * sampleWidth; bool flag = false; for (int i = 0; i < num; i++) { int z = i / sampleWidth; int x = i % sampleWidth; float num2 = ComputeBlendFactor(x, z, sampleWidth, sampleHeight, blendSamplesX, blendSamplesZ); float num3 = normalizedTarget + num2 * (span[i] - normalizedTarget); if (span[i] > num3) { span[i] = num3; flag = true; } } if (flag) { _setHeightsICall(intPtr, xStart, zStart, sampleWidth, sampleHeight, intPtr2); } } private static bool ClearDetailLayerIl2Cpp(TerrainData tData, int xStart, int zStart, int regionWidth, int regionHeight, int layer) { if (!ResolveDetailICalls()) { return false; } IntPtr intPtr = IL2CPP.Il2CppObjectBaseToPtrNotNull((Il2CppObjectBase)(object)tData); IntPtr intPtr2 = _getDetailLayerICall(intPtr, xStart, zStart, regionWidth, regionHeight, layer); if (intPtr2 == IntPtr.Zero) { DebugLog.Warning($"[TerrainFlattener] GetDetailLayer returned null for layer {layer}."); return false; } Il2CppStructArray val = new Il2CppStructArray(intPtr2); Span span = val.AsSpan(); bool flag = false; for (int i = 0; i < span.Length; i++) { if (span[i] != 0) { span[i] = 0; flag = true; } } if (flag) { _setDetailLayerICall(intPtr, xStart, zStart, regionWidth, regionHeight, layer, intPtr2); } return flag; } private static void FlushTerrain(Terrain terrain) { TerrainCollider component = ((Component)terrain).GetComponent(); if ((Object)(object)component != (Object)null) { component.terrainData = null; component.terrainData = terrain.terrainData; } terrain.Flush(); } } internal static class TerrainRetryQueue { private sealed class RetryState { public readonly List> Ops = new List>(); public int Attempts; public float NextRetryTime; } private const float RetryInterval = 1f; private const int MaxRetries = 30; private static readonly Dictionary States = new Dictionary(); internal static void Enqueue(GameObject target, Func operation) { TerrainRetryBehaviour terrainRetryBehaviour = TerrainRetryBehaviour.EnsureOn(target); int instanceID = ((Object)terrainRetryBehaviour).GetInstanceID(); if (!States.TryGetValue(instanceID, out RetryState value)) { value = new RetryState { NextRetryTime = Time.unscaledTime + 1f }; States[instanceID] = value; } value.Ops.Add(operation); DebugLog.Info($"[TerrainRetry] Queued operation ({value.Ops.Count} pending). Terrain.activeTerrains={((Il2CppArrayBase)(object)Terrain.activeTerrains).Length}, building='{((Object)target).name}'"); } internal static bool Tick(int id, string buildingName) { if (!States.TryGetValue(id, out RetryState value) || value.Ops.Count == 0) { States.Remove(id); return false; } if (Time.unscaledTime < value.NextRetryTime) { return true; } value.Attempts++; value.NextRetryTime = Time.unscaledTime + 1f; int length = ((Il2CppArrayBase)(object)Terrain.activeTerrains).Length; if (value.Attempts > 30) { DebugLog.Error($"[TerrainRetry] Gave up after {30} attempts ({value.Ops.Count} ops remaining). Terrain.activeTerrains={length}, building='{buildingName}'"); States.Remove(id); return false; } if (length == 0) { if (value.Attempts % 5 == 0) { DebugLog.Info($"[TerrainRetry] Waiting for terrain... attempt {value.Attempts}/{30}, building='{buildingName}'"); } return true; } DebugLog.Info($"[TerrainRetry] Terrain available ({length} active). Executing {value.Ops.Count} deferred ops after {value.Attempts} attempt(s)."); for (int num = value.Ops.Count - 1; num >= 0; num--) { try { if (value.Ops[num]()) { value.Ops.RemoveAt(num); } else { DebugLog.Warning("[TerrainRetry] Operation returned false despite terrain being available — removing."); value.Ops.RemoveAt(num); } } catch (Exception ex) { DebugLog.Error("[TerrainRetry] Operation threw: " + ex.Message + "\n" + ex.StackTrace); value.Ops.RemoveAt(num); } } if (value.Ops.Count == 0) { DebugLog.Info("[TerrainRetry] All deferred terrain operations completed."); States.Remove(id); return false; } return true; } internal static void Remove(int id) { States.Remove(id); } } internal sealed class TerrainRetryBehaviour : MonoBehaviour { private static bool _registered; internal static TerrainRetryBehaviour EnsureOn(GameObject target) { if (!_registered) { ClassInjector.RegisterTypeInIl2Cpp(); _registered = true; } TerrainRetryBehaviour component = target.GetComponent(); return ((Object)(object)component != (Object)null) ? component : target.AddComponent(); } private void Update() { if (!TerrainRetryQueue.Tick(((Object)this).GetInstanceID(), ((Object)((Component)this).gameObject).name)) { Object.Destroy((Object)(object)this); } } private void OnDestroy() { TerrainRetryQueue.Remove(((Object)this).GetInstanceID()); } } public sealed class WallAppearance { public Color? Color { get; } public Material? Material { get; } public Material? InteriorMaterial { get; } public Color? InteriorColor { get; } public WallAppearance(Color? color = null, Material? material = null, Material? interiorMaterial = null, Color? interiorColor = null) { Color = color; Material = material; InteriorMaterial = interiorMaterial; InteriorColor = interiorColor; } } public enum WallSide { North, South, East, West } public enum StairStyle { Solid, ClosedRiser, OpenStringer } public enum WallOpeningType { None, Door, Window } public sealed class WallOpening { public WallOpeningType Type { get; set; } = WallOpeningType.None; public float Width { get; set; } = 2f; public float Height { get; set; } = 2.2f; public float BottomOffset { get; set; } = 0f; public WallOpening? LeftWindow { get; set; } public WallOpening? RightWindow { get; set; } public int Count { get; set; } = 1; public float DividerWidth { get; set; } = 0.15f; public Material? GlassMaterial { get; set; } public float Offset { get; set; } = 0f; public Color? FrameColor { get; set; } public Material? FrameMaterial { get; set; } public static WallOpening Door(float width = 2f, float height = 2.2f, float offset = 0f) { return new WallOpening { Type = WallOpeningType.Door, Width = width, Height = height, BottomOffset = 0f, Offset = offset }; } public static WallOpening Window(float width = 2.5f, float height = 2f, float sillHeight = 0.8f, int count = 1, float dividerWidth = 0.15f, Material? glassMaterial = null, float offset = 0f, Material? frameMaterial = null, Color? frameColor = null) { return new WallOpening { Type = WallOpeningType.Window, Width = width, Height = height, BottomOffset = sillHeight, Count = count, DividerWidth = dividerWidth, GlassMaterial = glassMaterial, Offset = offset, FrameMaterial = frameMaterial, FrameColor = frameColor }; } public static WallOpening DoorWithWindows(float doorWidth = 2f, float doorHeight = 2.2f, WallOpening? leftWindow = null, WallOpening? rightWindow = null) { if (leftWindow == null && rightWindow == null) { WallOpening wallOpening = Window(1.5f, 1.5f); leftWindow = wallOpening; rightWindow = wallOpening; } return new WallOpening { Type = WallOpeningType.Door, Width = doorWidth, Height = doorHeight, BottomOffset = 0f, LeftWindow = leftWindow, RightWindow = rightWindow }; } } public sealed class WallBuilder { private static readonly Color FrameColor = new Color(0.1f, 0.1f, 0.1f); private static readonly Color GlassTint = new Color(0.7f, 0.9f, 1f); private readonly Transform _parent; private readonly Vector3 _roomSize; private readonly float _wallThickness; private readonly BuildingPalette _palette; private IReadOnlyDictionary? _wallOverrides; private GameObject? _wallsContainer; private WallSide _currentSide; private Material? _currentInteriorMaterial; private Color _currentInteriorColor; private bool _hasInteriorOverride; public WallBuilder(Transform parent, Vector3 roomSize, float wallThickness, BuildingPalette palette) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) _parent = parent; _roomSize = roomSize; _wallThickness = wallThickness; _palette = palette; } public GameObject BuildWalls(WallOpening? northOpening = null, WallOpening? southOpening = null, WallOpening? eastOpening = null, WallOpening? westOpening = null) { _wallsContainer = BuildingUtilities.CreateFolder("Walls", _parent); BuildWall(WallSide.North, northOpening); BuildWall(WallSide.South, southOpening); BuildWall(WallSide.East, eastOpening); BuildWall(WallSide.West, westOpening); return _wallsContainer; } public GameObject BuildWalls(WallOpening? northOpening, WallOpening? southOpening, WallOpening? eastOpening, WallOpening? westOpening, IReadOnlyDictionary wallOverrides) { _wallOverrides = wallOverrides; try { return BuildWalls(northOpening, southOpening, eastOpening, westOpening); } finally { _wallOverrides = null; } } public GameObject BuildWall(WallSide side, WallOpening? opening = null) { //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_0046: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if (_wallsContainer == null) { _wallsContainer = BuildingUtilities.CreateFolder("Walls", _parent); } Color wallColor = GetWallColor(side); Material wallMaterial = GetWallMaterial(side); _currentSide = side; _currentInteriorMaterial = GetWallInteriorMaterial(side); _currentInteriorColor = GetWallInteriorColor(side); _hasInteriorOverride = (Object)(object)_currentInteriorMaterial != (Object)null || HasExplicitInteriorColor(side); (Vector3 position, Vector3 size, bool isVertical) wallTransform = GetWallTransform(side); Vector3 item = wallTransform.position; Vector3 item2 = wallTransform.size; bool item3 = wallTransform.isVertical; string name = $"{side}Wall"; if (opening == null || opening.Type == WallOpeningType.None) { return CreateSolidWall(name, item, item2, wallColor, wallMaterial); } WallOpeningType type = opening.Type; if (1 == 0) { } GameObject result = (GameObject)(type switch { WallOpeningType.Door => (opening.LeftWindow == null && opening.RightWindow == null) ? CreateWallWithDoor(name, item, item2, opening, item3, wallColor, wallMaterial) : CreateWallWithDoorAndWindows(name, item, item2, opening, item3, wallColor, wallMaterial), WallOpeningType.Window => CreateWallWithWindow(name, item, item2, opening, item3, wallColor, wallMaterial), _ => CreateSolidWall(name, item, item2, wallColor, wallMaterial), }); if (1 == 0) { } return result; } private (Vector3 position, Vector3 size, bool isVertical) GetWallTransform(WallSide side) { //IL_0060: 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_00af: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) float num = _roomSize.x + _wallThickness; if (1 == 0) { } (Vector3, Vector3, bool) result = side switch { WallSide.North => (new Vector3(_roomSize.x / 2f, _roomSize.y / 2f, _roomSize.z), new Vector3(num, _roomSize.y, _wallThickness), false), WallSide.South => (new Vector3(_roomSize.x / 2f, _roomSize.y / 2f, 0f), new Vector3(num, _roomSize.y, _wallThickness), false), WallSide.East => (new Vector3(_roomSize.x, _roomSize.y / 2f, _roomSize.z / 2f), new Vector3(_wallThickness, _roomSize.y, _roomSize.z), true), WallSide.West => (new Vector3(0f, _roomSize.y / 2f, _roomSize.z / 2f), new Vector3(_wallThickness, _roomSize.y, _roomSize.z), true), _ => throw new ArgumentException($"Unknown wall side: {side}"), }; if (1 == 0) { } return result; } private GameObject CreateSolidWall(string name, Vector3 position, Vector3 size, Color wallColor, Material? wallMaterial) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return CreateWallSegment(name, position, size, wallColor, wallMaterial, _wallsContainer.transform); } private GameObject CreateWallWithDoor(string name, Vector3 wallCenter, Vector3 wallSize, WallOpening opening, bool isVertical, Color wallColor, Material? wallMaterial) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder(name, _wallsContainer.transform); float num = (isVertical ? wallSize.z : wallSize.x); float y = wallSize.y; float width = opening.Width; float height = opening.Height; float num2 = (num - width) / 2f; float num3 = Mathf.Clamp(opening.Offset, 0f - num2, num2); if (!Mathf.Approximately(num3, opening.Offset)) { DebugLog.Warning($"[WallBuilder] {_currentSide} wall: door offset {opening.Offset:F2}m exceeds wall margin (±{num2:F2}m) and was clamped to {num3:F2}m."); } float num4 = num2 + num3; float num5 = num2 - num3; Vector3 val2 = (isVertical ? (Vector3.forward * num3) : (Vector3.right * num3)); if (num4 > 0f) { float num6 = width / 2f + num4 / 2f; Vector3 val3 = (isVertical ? (Vector3.back * num6) : (Vector3.left * num6)); Vector3 size = (isVertical ? new Vector3(_wallThickness, y, num4) : new Vector3(num4, y, _wallThickness)); CreateWallSegment(name + "_Left", wallCenter + val2 + val3, size, wallColor, wallMaterial, val.transform); } if (num5 > 0f) { float num7 = width / 2f + num5 / 2f; Vector3 val4 = (isVertical ? (Vector3.forward * num7) : (Vector3.right * num7)); Vector3 size2 = (isVertical ? new Vector3(_wallThickness, y, num5) : new Vector3(num5, y, _wallThickness)); CreateWallSegment(name + "_Right", wallCenter + val2 + val4, size2, wallColor, wallMaterial, val.transform); } float num8 = y - height; if (num8 > 0f) { Vector3 size3 = (isVertical ? new Vector3(_wallThickness, num8, width) : new Vector3(width, num8, _wallThickness)); float num9 = y / 2f - num8 / 2f; Vector3 val5 = Vector3.up * num9; CreateWallSegment(name + "_Top", wallCenter + val2 + val5, size3, wallColor, wallMaterial, val.transform); } return val; } private GameObject CreateWallWithDoorAndWindows(string name, Vector3 wallCenter, Vector3 wallSize, WallOpening opening, bool isVertical, Color wallColor, Material? wallMaterial) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0075: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder(name, _wallsContainer.transform); float num = (isVertical ? wallSize.z : wallSize.x); float y = wallSize.y; float width = opening.Width; float height = opening.Height; float offset = opening.Offset; float num2 = (num - width) / 2f + offset; float num3 = (num - width) / 2f - offset; Vector3 val2 = (isVertical ? (Vector3.forward * offset) : (Vector3.right * offset)); Vector3 val3 = wallCenter + val2; if (num2 > 0f) { BuildDoorSideSegment(name, "_Left", val3, width, y, num2, opening.LeftWindow, isVertical, isLeftSide: true, val.transform, wallColor, wallMaterial); } if (num3 > 0f) { BuildDoorSideSegment(name, "_Right", val3, width, y, num3, opening.RightWindow, isVertical, isLeftSide: false, val.transform, wallColor, wallMaterial); } float num4 = y - height; if (num4 > 0f) { Vector3 size = (isVertical ? new Vector3(_wallThickness, num4, width) : new Vector3(width, num4, _wallThickness)); float num5 = y / 2f - num4 / 2f; Vector3 val4 = Vector3.up * num5; CreateWallSegment(name + "_Top", val3 + val4, size, wallColor, wallMaterial, val.transform); } return val; } private void BuildDoorSideSegment(string wallName, string suffix, Vector3 wallCenter, float doorWidth, float wallHeight, float fullSideWidth, WallOpening? sideWindow, bool isVertical, bool isLeftSide, Transform parent, Color wallColor, Material? wallMaterial) { //IL_0123: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) float num = (isLeftSide ? (-1f) : 1f); if (sideWindow == null || fullSideWidth < 1f) { Vector3 val = (isVertical ? new Vector3(0f, 0f, num * (doorWidth / 2f + fullSideWidth / 2f)) : new Vector3(num * (doorWidth / 2f + fullSideWidth / 2f), 0f, 0f)); Vector3 size = (isVertical ? new Vector3(_wallThickness, wallHeight, fullSideWidth) : new Vector3(fullSideWidth, wallHeight, _wallThickness)); CreateWallSegment(wallName + suffix, wallCenter + val, size, wallColor, wallMaterial, parent); return; } float num2 = Mathf.Min(0.5f, fullSideWidth - sideWindow.Width - 0.4f); num2 = Mathf.Max(0.3f, num2); float num3 = fullSideWidth - num2; float num4 = doorWidth / 2f + num2 / 2f; Vector3 val2 = (isVertical ? new Vector3(0f, 0f, num * num4) : new Vector3(num * num4, 0f, 0f)); Vector3 size2 = (isVertical ? new Vector3(_wallThickness, wallHeight, num2) : new Vector3(num2, wallHeight, _wallThickness)); CreateWallSegment(wallName + suffix, wallCenter + val2, size2, wallColor, wallMaterial, parent); float num5 = doorWidth / 2f + num2 + num3 / 2f; Vector3 sectionCenter = wallCenter + (isVertical ? new Vector3(0f, 0f, num * num5) : new Vector3(num * num5, 0f, 0f)); float windowOffset = (0f - num) * num2 / 2f; CreateWindowInSection(wallName + suffix + "Win", sectionCenter, num3, wallHeight, sideWindow, isVertical, parent, windowOffset, wallColor, wallMaterial); } private GameObject CreateWallWithWindow(string name, Vector3 wallCenter, Vector3 wallSize, WallOpening opening, bool isVertical, Color wallColor, Material? wallMaterial) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder(name, _wallsContainer.transform); float sectionWidth = (isVertical ? wallSize.z : wallSize.x); CreateWindowInSection(name, wallCenter, sectionWidth, wallSize.y, opening, isVertical, val.transform, opening.Offset, wallColor, wallMaterial); return val; } private void CreateWindowInSection(string namePrefix, Vector3 sectionCenter, float sectionWidth, float sectionHeight, WallOpening window, bool isVertical, Transform parent, float windowOffset, Color wallColor, Material? wallMaterial) { //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02af: 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_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_0438: 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_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: 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_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06ca: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0700: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_071f: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, window.Count); float num4; if (num > 1) { float num2 = Mathf.Min(window.Width, Mathf.Min(sectionWidth - 0.5f, 2f)); float num3 = (sectionWidth - (float)num * num2) / (float)(num + 1); if (num3 < 0.15f) { num3 = 0.15f; num2 = (sectionWidth - (float)(num + 1) * num3) / (float)num; } while (num2 < 0.3f && num > 1) { num--; num3 = (sectionWidth - (float)num * num2) / (float)(num + 1); if (num3 < 0.15f) { num3 = 0.15f; num2 = (sectionWidth - (float)(num + 1) * num3) / (float)num; } } num4 = (float)num * num2 + (float)(num - 1) * num3; } else { num4 = Mathf.Min(window.Width, sectionWidth - 0.5f); } float num5 = Mathf.Min(window.Height, sectionHeight - 1.2f); float bottomOffset = window.BottomOffset; float num6 = sectionHeight - (bottomOffset + num5); float num7 = (sectionWidth - num4) / 2f; float num8 = sectionHeight / 2f; float num9 = bottomOffset + num5 / 2f - num8; float num10 = Mathf.Clamp(windowOffset, 0f - num7, num7); if (!Mathf.Approximately(num10, windowOffset)) { DebugLog.Warning($"[WallBuilder] {_currentSide} wall: window offset {windowOffset:F2}m exceeds section margin (±{num7:F2}m) and was clamped to {num10:F2}m."); } Vector3 val = (isVertical ? new Vector3(0f, 0f, num10) : new Vector3(num10, 0f, 0f)); Vector3 val2 = sectionCenter + val; if (bottomOffset > 0.01f) { Vector3 size = (isVertical ? new Vector3(_wallThickness, bottomOffset, sectionWidth) : new Vector3(sectionWidth, bottomOffset, _wallThickness)); Vector3 val3 = Vector3.down * (num8 - bottomOffset / 2f); CreateWallSegment(namePrefix + "_Bottom", sectionCenter + val3, size, wallColor, wallMaterial, parent); } if (num6 > 0.01f) { Vector3 size2 = (isVertical ? new Vector3(_wallThickness, num6, sectionWidth) : new Vector3(sectionWidth, num6, _wallThickness)); Vector3 val4 = Vector3.up * (num8 - num6 / 2f); CreateWallSegment(namePrefix + "_Top", sectionCenter + val4, size2, wallColor, wallMaterial, parent); } float num11 = num7 - num10; float num12 = num7 + num10; float num13 = (isVertical ? num11 : num12); float num14 = (isVertical ? num12 : num11); if (num13 > 0.01f) { Vector3 size3 = (isVertical ? new Vector3(_wallThickness, num5, num13) : new Vector3(num13, num5, _wallThickness)); Vector3 val5 = (isVertical ? new Vector3(0f, num9, num4 / 2f + num13 / 2f) : new Vector3(0f - (num4 / 2f + num13 / 2f), num9, 0f)); CreateWallSegment(namePrefix + "_Left", val2 + val5, size3, wallColor, wallMaterial, parent); } if (num14 > 0.01f) { Vector3 size4 = (isVertical ? new Vector3(_wallThickness, num5, num14) : new Vector3(num14, num5, _wallThickness)); Vector3 val6 = (isVertical ? new Vector3(0f, num9, 0f - (num4 / 2f + num14 / 2f)) : new Vector3(num4 / 2f + num14 / 2f, num9, 0f)); CreateWallSegment(namePrefix + "_Right", val2 + val6, size4, wallColor, wallMaterial, parent); } float num15 = ((num > 1) ? num7 : window.DividerWidth); float num16 = ((num > 1) ? ((num4 - (float)(num - 1) * num15) / (float)num) : num4); float num17 = (0f - num4) / 2f + num16 / 2f; Color color = (Color)(((??)window.FrameColor) ?? FrameColor); for (int i = 0; i < num; i++) { float num18 = num17 + (float)i * (num16 + num15); Vector3 val7 = (isVertical ? new Vector3(0f, 0f, num18) : new Vector3(num18, 0f, 0f)); Vector3 val8 = val2 + val7; string namePrefix2 = ((num > 1) ? $"Frame{i}_" : "Frame"); CreateWindowFrame(parent, val8, num16, num5, num9, isVertical, color, window.FrameMaterial, namePrefix2); Vector3 size5 = (isVertical ? new Vector3(_wallThickness * 0.2f, num5 - 0.1f, num16 - 0.1f) : new Vector3(num16 - 0.1f, num5 - 0.1f, _wallThickness * 0.2f)); string text = ((num > 1) ? $"_{i}" : ""); GameObject val9 = PrimitiveBuilder.CreateBox(namePrefix + "_WindowGlass" + text, val8 + new Vector3(0f, num9, 0f), size5, GlassTint, parent); Material val10 = window.GlassMaterial ?? Materials.WindowGlass; if ((Object)(object)val10 != (Object)null) { Renderer component = val9.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = val10; } } if (i < num - 1) { float num19 = num18 + num16 / 2f + num15 / 2f; Vector3 val11 = (isVertical ? new Vector3(0f, 0f, num19) : new Vector3(num19, 0f, 0f)); Vector3 size6 = (isVertical ? new Vector3(_wallThickness, num5, num15) : new Vector3(num15, num5, _wallThickness)); CreateWallSegment($"{namePrefix}_Divider_{i}", val2 + val11 + new Vector3(0f, num9, 0f), size6, wallColor, wallMaterial, parent); } } } private void CreateWindowFrame(Transform parent, Vector3 wallCenter, float windowWidth, float windowHeight, float windowCenterY, bool isVertical, Color color, Material? material = null, string namePrefix = "Frame") { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) float num = 0.05f; float num2 = 0.1f; Vector3 size = (isVertical ? new Vector3(_wallThickness + num, num2, windowWidth) : new Vector3(windowWidth, num2, _wallThickness + num)); GameObject frame = PrimitiveBuilder.CreateBox(namePrefix + "Top", wallCenter + new Vector3(0f, windowCenterY + windowHeight / 2f - num2 / 2f, 0f), size, color, parent); GameObject frame2 = PrimitiveBuilder.CreateBox(namePrefix + "Bottom", wallCenter + new Vector3(0f, windowCenterY - windowHeight / 2f + num2 / 2f, 0f), size, color, parent); Vector3 size2 = (isVertical ? new Vector3(_wallThickness + num, windowHeight - 2f * num2, num2) : new Vector3(num2, windowHeight - 2f * num2, _wallThickness + num)); float num3 = windowWidth / 2f - num2 / 2f; Vector3 val = (isVertical ? new Vector3(0f, windowCenterY, num3) : new Vector3(0f - num3, windowCenterY, 0f)); Vector3 val2 = (isVertical ? new Vector3(0f, windowCenterY, 0f - num3) : new Vector3(num3, windowCenterY, 0f)); GameObject frame3 = PrimitiveBuilder.CreateBox(namePrefix + "Left", wallCenter + val, size2, color, parent); GameObject frame4 = PrimitiveBuilder.CreateBox(namePrefix + "Right", wallCenter + val2, size2, color, parent); if ((Object)(object)material != (Object)null) { ApplyFrameMaterial(frame, material); ApplyFrameMaterial(frame2, material); ApplyFrameMaterial(frame3, material); ApplyFrameMaterial(frame4, material); } } private Color GetWallColor(WallSide side) { //IL_0046: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (_wallOverrides != null && _wallOverrides.TryGetValue(side, out WallAppearance value) && value.Color.HasValue) { return value.Color.Value; } return _palette.WallColor; } private Material? GetWallMaterial(WallSide side) { if (_wallOverrides != null && _wallOverrides.TryGetValue(side, out WallAppearance value) && (Object)(object)value.Material != (Object)null) { return value.Material; } return _palette.WallMaterial; } private void ApplyWallMaterial(GameObject wall, Material? material) { if ((Object)(object)material != (Object)null) { Renderer component = wall.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = material; } } } private void ApplyFrameMaterial(GameObject frame, Material material) { Renderer component = frame.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = material; } } private Material? GetWallInteriorMaterial(WallSide side) { if (_wallOverrides != null && _wallOverrides.TryGetValue(side, out WallAppearance value) && (Object)(object)value.InteriorMaterial != (Object)null) { return value.InteriorMaterial; } return _palette.InteriorWallMaterial; } private Color GetWallInteriorColor(WallSide side) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (_wallOverrides != null && _wallOverrides.TryGetValue(side, out WallAppearance value) && value.InteriorColor.HasValue) { return value.InteriorColor.Value; } return (Color)(((??)_palette.InteriorWallColor) ?? _palette.WallColor); } private bool HasExplicitInteriorColor(WallSide side) { if (_wallOverrides != null && _wallOverrides.TryGetValue(side, out WallAppearance value) && value.InteriorColor.HasValue) { return true; } return _palette.InteriorWallColor.HasValue; } private GameObject CreateWallSegment(string name, Vector3 position, Vector3 size, Color wallColor, Material? wallMaterial, Transform parent) { //IL_001e: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (_hasInteriorOverride) { return CreateDualMaterialBox(name, position, size, wallColor, wallMaterial, parent); } GameObject val = PrimitiveBuilder.CreateBox(name, position, size, wallColor, parent); ApplyWallMaterial(val, wallMaterial); return val; } private GameObject CreateDualMaterialBox(string name, Vector3 position, Vector3 size, Color exteriorColor, Material? exteriorMaterial, Transform parent) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) WallSide currentSide = _currentSide; if (1 == 0) { } DualMaterialBoxGenerator.InteriorFace interiorFace = currentSide switch { WallSide.North => DualMaterialBoxGenerator.InteriorFace.NegZ, WallSide.South => DualMaterialBoxGenerator.InteriorFace.PosZ, WallSide.East => DualMaterialBoxGenerator.InteriorFace.NegX, WallSide.West => DualMaterialBoxGenerator.InteriorFace.PosX, _ => DualMaterialBoxGenerator.InteriorFace.NegZ, }; if (1 == 0) { } DualMaterialBoxGenerator.InteriorFace interiorFace2 = interiorFace; Mesh sharedMesh = DualMaterialBoxGenerator.Generate(interiorFace2); GameObject val = new GameObject(name); val.transform.SetParent(parent); val.transform.localPosition = position; val.transform.localScale = size; MeshFilter val2 = val.AddComponent(); val2.sharedMesh = sharedMesh; MeshRenderer val3 = val.AddComponent(); ((Renderer)val3).allowOcclusionWhenDynamic = false; Material val4 = exteriorMaterial ?? MaterialPresets.Opaque(exteriorColor); Material val5 = _currentInteriorMaterial ?? MaterialPresets.Opaque(_currentInteriorColor); ((Renderer)val3).materials = Il2CppReferenceArray.op_Implicit((Material[])(object)new Material[2] { val4, val5 }); val.AddComponent(); return val; } } } namespace S1MAPI.Building.Interior { public enum FurnitureType { Table, Chair, Desk, Bookshelf, Counter, CoffeeTable } public sealed class FurnitureBuilder { private readonly Transform _parent; private readonly BuildingPalette _palette; public FurnitureBuilder(Transform parent, BuildingPalette palette) { _parent = parent; _palette = palette; } public GameObject Create(FurnitureType type, Vector3 position, Quaternion rotation, Color? color = null) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_005b: 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_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0080: 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) Color color2 = (Color)(((??)color) ?? GetDefaultColor(type)); if (1 == 0) { } GameObject result = (GameObject)(type switch { FurnitureType.Table => CreateTable(position, rotation, color2), FurnitureType.Chair => CreateChair(position, rotation, color2), FurnitureType.Desk => CreateDesk(position, rotation, color2), FurnitureType.Bookshelf => CreateBookshelf(position, rotation, color2), FurnitureType.Counter => CreateCounter(position, rotation, color2), FurnitureType.CoffeeTable => CreateCoffeeTable(position, rotation, color2), _ => throw new ArgumentException($"Unknown furniture type: {type}"), }); if (1 == 0) { } return result; } public static Vector3 GetFootprint(FurnitureType type) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Vector3 result = (Vector3)(type switch { FurnitureType.Table => new Vector3(1.4f, 0.75f, 0.9f), FurnitureType.Chair => new Vector3(0.5f, 0.95f, 0.5f), FurnitureType.Desk => new Vector3(1.5f, 0.75f, 0.7f), FurnitureType.Bookshelf => new Vector3(1.2f, 2f, 0.3f), FurnitureType.Counter => new Vector3(2f, 0.95f, 0.6f), FurnitureType.CoffeeTable => new Vector3(1.1f, 0.45f, 0.6f), _ => Vector3.one, }); if (1 == 0) { } return result; } private Color GetDefaultColor(FurnitureType type) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result; switch (type) { case FurnitureType.Table: case FurnitureType.Chair: case FurnitureType.Desk: case FurnitureType.Bookshelf: result = new Color(0.55f, 0.35f, 0.2f); break; case FurnitureType.Counter: result = _palette.AccentColor; break; case FurnitureType.CoffeeTable: result = new Color(0.4f, 0.25f, 0.1f); break; default: result = new Color(0.5f, 0.5f, 0.5f); break; } if (1 == 0) { } return result; } private GameObject CreateTable(Vector3 position, Quaternion rotation, Color color) { //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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Table", _parent); val.transform.localPosition = position; val.transform.localRotation = rotation; Material woodMediumBrown = Materials.WoodMediumBrown; Color color2 = default(Color); ((Color)(ref color2))..ctor(0.2f, 0.2f, 0.2f); GameObject val2 = PrimitiveBuilder.CreateBox("TableTop", new Vector3(0f, 0.75f, 0f), new Vector3(1.4f, 0.08f, 0.9f), color, val.transform); if ((Object)(object)woodMediumBrown != (Object)null) { Renderer component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = woodMediumBrown; } } float num = 0.08f; Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(0.6f, 0.375f, 0.35f), new Vector3(-0.6f, 0.375f, 0.35f), new Vector3(0.6f, 0.375f, -0.35f), new Vector3(-0.6f, 0.375f, -0.35f) }; for (int i = 0; i < 4; i++) { PrimitiveBuilder.CreateBox($"Leg{i + 1}", array[i], new Vector3(num, 0.75f, num), color2, val.transform); } PrimitiveBuilder.CreateBox("CrossBrace1", new Vector3(0.6f, 0.2f, 0f), new Vector3(num, 0.05f, 0.7f), color2, val.transform); PrimitiveBuilder.CreateBox("CrossBrace2", new Vector3(-0.6f, 0.2f, 0f), new Vector3(num, 0.05f, 0.7f), color2, val.transform); PrimitiveBuilder.CreateBox("CrossBrace3", new Vector3(0f, 0.2f, 0f), new Vector3(1.2f, 0.05f, num), color2, val.transform); return val; } private GameObject CreateChair(Vector3 position, Quaternion rotation, Color color) { //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) //IL_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Chair", _parent); val.transform.localPosition = position; val.transform.localRotation = rotation; PrimitiveBuilder.CreateBox("Seat", new Vector3(0f, 0.45f, 0f), new Vector3(0.5f, 0.05f, 0.5f), color, val.transform); PrimitiveBuilder.CreateBox("Backrest", new Vector3(0f, 0.7f, -0.225f), new Vector3(0.5f, 0.5f, 0.05f), color, val.transform); float num = 0.03f; PrimitiveBuilder.CreateCylinder("Leg1", new Vector3(0.2f, 0.225f, 0.2f), new Vector3(num, 0.45f, num), color, val.transform); PrimitiveBuilder.CreateCylinder("Leg2", new Vector3(-0.2f, 0.225f, 0.2f), new Vector3(num, 0.45f, num), color, val.transform); PrimitiveBuilder.CreateCylinder("Leg3", new Vector3(0.2f, 0.225f, -0.2f), new Vector3(num, 0.45f, num), color, val.transform); PrimitiveBuilder.CreateCylinder("Leg4", new Vector3(-0.2f, 0.225f, -0.2f), new Vector3(num, 0.45f, num), color, val.transform); return val; } private GameObject CreateDesk(Vector3 position, Quaternion rotation, Color color) { //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) //IL_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00cd: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Desk", _parent); val.transform.localPosition = position; val.transform.localRotation = rotation; PrimitiveBuilder.CreateBox("DeskTop", new Vector3(0f, 0.75f, 0f), new Vector3(1.5f, 0.05f, 0.7f), color, val.transform); PrimitiveBuilder.CreateBox("LeftPanel", new Vector3(-0.6f, 0.375f, 0f), new Vector3(0.05f, 0.75f, 0.7f), color, val.transform); PrimitiveBuilder.CreateBox("RightPanel", new Vector3(0.6f, 0.375f, 0f), new Vector3(0.05f, 0.75f, 0.7f), color, val.transform); return val; } private GameObject CreateBookshelf(Vector3 position, Quaternion rotation, Color color) { //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) //IL_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("Bookshelf", _parent); val.transform.localPosition = position; val.transform.localRotation = rotation; PrimitiveBuilder.CreateBox("BackPanel", new Vector3(0f, 1f, 0f), new Vector3(1.2f, 2f, 0.05f), color, val.transform); for (int i = 0; i < 3; i++) { float num = (float)i * 0.6f + 0.35f; PrimitiveBuilder.CreateBox($"Shelf{i}", new Vector3(0f, num, 0.15f), new Vector3(1.2f, 0.03f, 0.3f), color, val.transform); } return val; } private GameObject CreateCounter(Vector3 position, Quaternion rotation, Color color) { //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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) GameObject val = BuildingUtilities.CreateFolder("Counter", _parent); val.transform.localPosition = position; val.transform.localRotation = rotation; Material metalDarkGrey = Materials.MetalDarkGrey; PrimitiveBuilder.CreateBox("CounterTop", new Vector3(0f, 0.9f, 0f), new Vector3(2f, 0.05f, 0.6f), color, val.transform); GameObject val2 = PrimitiveBuilder.CreateBox("Cabinet", new Vector3(0f, 0.45f, 0f), new Vector3(2f, 0.9f, 0.6f), color, val.transform); if ((Object)(object)metalDarkGrey != (Object)null) { Renderer component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = metalDarkGrey; } } return val; } private GameObject CreateCoffeeTable(Vector3 position, Quaternion rotation, Color color) { //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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("CoffeeTable", _parent); val.transform.localPosition = position; val.transform.localRotation = rotation; Material woodMediumBrown = Materials.WoodMediumBrown; Color color2 = default(Color); ((Color)(ref color2))..ctor(0.2f, 0.2f, 0.2f); GameObject val2 = PrimitiveBuilder.CreateBox("TableTop", new Vector3(0f, 0.45f, 0f), new Vector3(1.1f, 0.06f, 0.6f), color, val.transform); if ((Object)(object)woodMediumBrown != (Object)null) { Renderer component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = woodMediumBrown; } } float num = 0.06f; float num2 = 0.27f; float num3 = 0.22f; Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(num2, 0.225f, num3), new Vector3(0f - num2, 0.225f, num3), new Vector3(num2, 0.225f, 0f - num3), new Vector3(0f - num2, 0.225f, 0f - num3) }; for (int i = 0; i < 4; i++) { PrimitiveBuilder.CreateBox($"Leg{i + 1}", array[i], new Vector3(num, 0.45f, num), color2, val.transform); } return val; } } public class InteriorBuilder { private readonly string _name; private readonly List _furniture = new List(); private Transform? _parent; private GameObject? _interiorContainer; public InteriorBuilder(string name = "Interior") { _name = name; } public InteriorBuilder(Transform parent, string name = "Interior") { _name = name; _parent = parent; } private GameObject GetOrCreateContainer() { if ((Object)(object)_interiorContainer != (Object)null) { return _interiorContainer; } if ((Object)(object)_parent == (Object)null) { DebugLog.Warning("InteriorBuilder: No parent set. Furniture will not be organized in a container."); return null; } _interiorContainer = BuildingUtilities.CreateFolder(_name, _parent); return _interiorContainer; } private void ParentToContainer(GameObject obj, Vector3 localPosition, Quaternion? rotation = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObject orCreateContainer = GetOrCreateContainer(); if (!((Object)(object)orCreateContainer == (Object)null)) { obj.transform.SetParent(orCreateContainer.transform); obj.transform.localPosition = localPosition; obj.transform.localRotation = (Quaternion)(((??)rotation) ?? Quaternion.identity); } } public InteriorBuilder AddDesk(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Desk.Instantiate("Desk", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Desk mesh"); } return this; } public InteriorBuilder AddLocker(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.LockerShelf.Instantiate("Locker", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Locker mesh"); } return this; } public InteriorBuilder AddChair(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Chair.Instantiate("Chair", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Chair mesh"); } return this; } public InteriorBuilder AddArmchair(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Armchair.Instantiate("Armchair", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Armchair mesh"); } return this; } public InteriorBuilder AddTable(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.CoffeeTable.Instantiate("Table", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Table mesh"); } return this; } public InteriorBuilder AddOfficeTable(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.OfficeTable.Instantiate("OfficeTable", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Office Table mesh"); } return this; } public InteriorBuilder AddBench(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Bench.Instantiate("Bench", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Bench mesh"); } return this; } public InteriorBuilder AddBed(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Bed.Instantiate("Bed", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Bed mesh"); } return this; } public InteriorBuilder AddFridge(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Fridge.Instantiate("Fridge", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Fridge mesh"); } return this; } public InteriorBuilder AddBox(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Box.Instantiate("Box", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Box mesh"); } return this; } public InteriorBuilder AddBarrel(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Barrel.Instantiate("Barrel", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Barrel mesh"); } return this; } public InteriorBuilder AddCabinet(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Cabinet.Instantiate("Cabinet", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Cabinet mesh"); } return this; } public InteriorBuilder AddDrawer(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Drawer.Instantiate("Drawer", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Drawer mesh"); } return this; } public InteriorBuilder AddSafe(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Safe.Instantiate("Safe", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Safe mesh"); } return this; } public InteriorBuilder AddBin(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Bin.Instantiate("Bin", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Bin mesh"); } return this; } public InteriorBuilder AddPlant(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Plant.Instantiate("Plant", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Plant mesh"); } return this; } public InteriorBuilder AddPlanter(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Planter.Instantiate("Planter", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Planter mesh"); } return this; } public InteriorBuilder AddVase(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Vase.Instantiate("Vase", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Vase mesh"); } return this; } public InteriorBuilder AddPainting(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Paintings.Instantiate("Painting", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Painting mesh"); } return this; } public InteriorBuilder AddClock(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Clock.Instantiate("Clock", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Clock mesh"); } return this; } public InteriorBuilder AddWallClock(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.WallClock.Instantiate("WallClock", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Wall Clock mesh"); } return this; } public InteriorBuilder AddToilet(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Toilet.Instantiate("Toilet", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); BuildingUtilities.AddNavMeshObstacle(val); } else { DebugLog.Warning("Failed to instantiate Toilet mesh"); } return this; } public InteriorBuilder AddComputer(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Computer.Instantiate("Computer", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Computer mesh"); } return this; } public InteriorBuilder AddScreen(Vector3 position, Quaternion? rotation = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) GameObject val = Meshes.Screen.Instantiate("Screen", position, (Quaternion)(((??)rotation) ?? Quaternion.identity)); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate Screen mesh"); } return this; } public InteriorBuilder AddCustomObject(GameObject gameObject, Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject != (Object)null) { ParentToContainer(gameObject, position); _furniture.Add(gameObject); } return this; } public InteriorBuilder AddCustomMesh(MeshRef meshRef, string name, Vector3 position, Quaternion? rotation = null) { //IL_0003: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject val = meshRef.Instantiate(name, position, (Quaternion)(((??)rotation) ?? Quaternion.identity), _parent); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); } else { DebugLog.Warning("Failed to instantiate custom mesh: " + name); } return this; } public InteriorBuilder AddPrefab(PrefabRef prefab, Vector3 position, Quaternion? rotation = null, bool networked = false, bool enableComponents = true, Action? onCreated = null) { //IL_002f: 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_003c: 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) if ((Object)(object)_parent == (Object)null) { DebugLog.Warning("Cannot add prefab without parent transform. Use constructor with parent or call SetParent first."); return this; } PrefabPlacer prefabPlacer = new PrefabPlacer(_parent); GameObject val = prefabPlacer.Place(prefab, position, (Quaternion)(((??)rotation) ?? Quaternion.identity), networked, enableComponents); if ((Object)(object)val != (Object)null) { ParentToContainer(val, position, rotation); _furniture.Add(val); onCreated?.Invoke(val); } else { DebugLog.Warning("Failed to place prefab"); } return this; } public InteriorBuilder SetParent(Transform parent) { _parent = parent; return this; } public GameObject[] Build(GameObject parent) { if ((Object)(object)parent == (Object)null) { DebugLog.Warning("Interior parent is null, furniture will not be parented"); return _furniture.ToArray(); } if ((Object)(object)_parent == (Object)null || (Object)(object)parent != (Object)(object)((Component)_parent).gameObject) { _parent = parent.transform; _interiorContainer = null; } GameObject orCreateContainer = GetOrCreateContainer(); foreach (GameObject item in _furniture) { if ((Object)(object)item != (Object)null && (Object)(object)item.transform.parent == (Object)null) { item.transform.SetParent(orCreateContainer.transform); } } DebugLog.Info($"Built interior: {_name} with {_furniture.Count} pieces"); return _furniture.ToArray(); } public GameObject[] Build() { if ((Object)(object)_parent == (Object)null) { DebugLog.Warning("No parent set for interior builder. Use Build(GameObject) or set parent in constructor."); return _furniture.ToArray(); } return Build(((Component)_parent).gameObject); } public GameObject[] GetFurniture() { return _furniture.ToArray(); } } } namespace S1MAPI.Building.Config { public sealed class BuildingConfig { public float Width { get; set; } = 8f; public float Height { get; set; } = 3f; public float Depth { get; set; } = 6f; public float WallThickness { get; set; } = 0.2f; public float FloorThickness { get; set; } = 0.1f; public float CeilingThickness { get; set; } = 0.1f; public BuildingPalette Palette { get; set; } = new BuildingPalette(); public Vector3 Size => new Vector3(Width, Height, Depth); public Vector3 Center => new Vector3(Width / 2f, Height / 2f, Depth / 2f); public static BuildingConfig Default => new BuildingConfig(); public static BuildingConfig Tiny => new BuildingConfig { Width = 3f, Height = 2.4f, Depth = 3f }; public static BuildingConfig Small => new BuildingConfig { Width = 5f, Height = 3f, Depth = 4f }; public static BuildingConfig Medium => new BuildingConfig { Width = 8f, Height = 3f, Depth = 6f }; public static BuildingConfig Large => new BuildingConfig { Width = 12f, Height = 4f, Depth = 10f }; public static BuildingConfig Huge => new BuildingConfig { Width = 20f, Height = 6f, Depth = 15f }; public static BuildingConfig Warehouse => new BuildingConfig { Width = 20f, Height = 6f, Depth = 15f, Palette = new BuildingPalette { FloorMaterial = Materials.ConcreteLightGrey, FloorColor = new Color(0.75f, 0.75f, 0.75f), WallMaterial = Materials.GraniteDullSalmonLighter, WallColor = new Color(0.94f, 0.94f, 0.94f), CeilingMaterial = Materials.ConcreteLightGrey, CeilingColor = new Color(0.94f, 0.94f, 0.94f), TrimMaterial = Materials.BrickWallRed, TrimColor = new Color(0.6f, 0.3f, 0.2f), PillarMaterial = Materials.BrickWallRed, PillarColor = new Color(0.6f, 0.3f, 0.2f), AccentColor = new Color(0.29f, 0.48f, 0.29f), LightColor = new Color(1f, 0.98f, 0.95f), LightIntensity = 1.2f } }; public BuildingConfig Clone() { return new BuildingConfig { Width = Width, Height = Height, Depth = Depth, WallThickness = WallThickness, FloorThickness = FloorThickness, CeilingThickness = CeilingThickness, Palette = Palette.Clone() }; } public BuildingConfig WithDimensions(float width, float height, float depth) { Width = width; Height = height; Depth = depth; return this; } public BuildingConfig WithPalette(BuildingPalette palette) { Palette = palette; return this; } public BuildingConfig WithWallThickness(float thickness) { WallThickness = thickness; return this; } } public sealed class BuildingPalette { public Material? FloorMaterial { get; set; } public Color FloorColor { get; set; } = new Color(0.7f, 0.7f, 0.7f); public Material? WallMaterial { get; set; } public Color WallColor { get; set; } = new Color(0.9f, 0.85f, 0.7f); public Material? InteriorWallMaterial { get; set; } public Color? InteriorWallColor { get; set; } public Material? CeilingMaterial { get; set; } public Color CeilingColor { get; set; } = Color.white; public Material? TrimMaterial { get; set; } public Color TrimColor { get; set; } = new Color(0.6f, 0.3f, 0.2f); public Material? PillarMaterial { get; set; } public Color PillarColor { get; set; } = new Color(0.6f, 0.3f, 0.2f); public Color AccentColor { get; set; } = new Color(0.29f, 0.48f, 0.29f); public Material? AccentMaterial { get; set; } public Color LightColor { get; set; } = new Color(1f, 0.95f, 0.8f); public float LightIntensity { get; set; } = 1f; public BuildingPalette Clone() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0096: 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_00bd: Unknown result type (might be due to invalid IL or missing references) return new BuildingPalette { FloorMaterial = FloorMaterial, FloorColor = FloorColor, WallMaterial = WallMaterial, WallColor = WallColor, InteriorWallMaterial = InteriorWallMaterial, InteriorWallColor = InteriorWallColor, CeilingMaterial = CeilingMaterial, CeilingColor = CeilingColor, TrimMaterial = TrimMaterial, TrimColor = TrimColor, PillarMaterial = PillarMaterial, PillarColor = PillarColor, AccentColor = AccentColor, AccentMaterial = AccentMaterial, LightColor = LightColor, LightIntensity = LightIntensity }; } public BuildingPalette WithFloor(Material material) { FloorMaterial = material; return this; } public BuildingPalette WithWalls(Material material) { WallMaterial = material; return this; } public BuildingPalette WithInteriorWalls(Material material) { InteriorWallMaterial = material; return this; } } public enum BuildingPart { ExteriorWalls, Floor, Ceiling, Trim, Pillars, Accent, Foundation, Roof, Stairs, InteriorWalls } } namespace S1MAPI.Building.Components { public sealed class LightingBuilder { private readonly Transform _parent; private readonly Vector3 _roomSize; private readonly BuildingPalette _palette; public LightingBuilder(Transform parent, Vector3 roomSize, BuildingPalette palette) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) _parent = parent; _roomSize = roomSize; _palette = palette; } public GameObject AddCeilingLights(float? intensity = null, Color? color = null, float spacing = 4f) { //IL_001c: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) Color color2 = (Color)(((??)color) ?? _palette.LightColor); float intensity2 = intensity ?? _palette.LightIntensity; GameObject val = BuildingUtilities.CreateFolder("Lights", _parent); int num = Mathf.Max(1, Mathf.RoundToInt(_roomSize.x / spacing)); int num2 = Mathf.Max(1, Mathf.RoundToInt(_roomSize.z / spacing)); float num3 = _roomSize.x / (float)(num + 1); float num4 = _roomSize.z / (float)(num2 + 1); float num5 = _roomSize.y - 0.3f; Vector3 val2 = default(Vector3); for (int i = 1; i <= num; i++) { for (int j = 1; j <= num2; j++) { ((Vector3)(ref val2))..ctor((float)i * num3, num5, (float)j * num4); PrimitiveBuilder.CreatePointLight($"CeilingLight_{i}_{j}", val2, color2, 8f, intensity2, val.transform, (LightShadows)0, (LightRenderMode)1); PrimitiveBuilder.CreateCylinder($"LightFixture_{i}_{j}", val2 + Vector3.up * 0.1f, new Vector3(0.3f, 0.1f, 0.3f), color2, val.transform); } } return val; } public GameObject AddPointLight(Vector3 position, float intensity = 1f, Color? color = null, float range = 8f, bool includeFixture = true) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Color color2 = (Color)(((??)color) ?? _palette.LightColor); GameObject val = BuildingUtilities.CreateFolder("PointLight", _parent); PrimitiveBuilder.CreatePointLight("Light", position, color2, range, intensity, val.transform, (LightShadows)0, (LightRenderMode)1); if (includeFixture) { PrimitiveBuilder.CreateCylinder("Fixture", position + Vector3.up * 0.1f, new Vector3(0.3f, 0.1f, 0.3f), color2, val.transform); } return val; } public GameObject AddAmbientLighting(float intensity = 0.3f) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) GameObject val = BuildingUtilities.CreateFolder("AmbientLights", _parent); Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(0.5f, _roomSize.y - 0.5f, 0.5f), new Vector3(_roomSize.x - 0.5f, _roomSize.y - 0.5f, 0.5f), new Vector3(0.5f, _roomSize.y - 0.5f, _roomSize.z - 0.5f), new Vector3(_roomSize.x - 0.5f, _roomSize.y - 0.5f, _roomSize.z - 0.5f) }; for (int i = 0; i < array.Length; i++) { string name = $"AmbientLight_{i}"; Vector3 localPosition = array[i]; Color lightColor = _palette.LightColor; Vector3 roomSize = _roomSize; PrimitiveBuilder.CreatePointLight(name, localPosition, lightColor, ((Vector3)(ref roomSize)).magnitude / 2f, intensity, val.transform, (LightShadows)0, (LightRenderMode)1); } return val; } } internal static class NetworkedPrefabLinkerQueue { private sealed class LinkRequest { public string PrefabName; public Vector3 ExpectedWorldPos; public Transform Parent; public Vector3 LocalPosition; public Quaternion LocalRotation; public Action? OnLinked; public LinkRequest(string prefabName, Vector3 expectedWorldPos, Transform parent, Vector3 localPosition, Quaternion localRotation, Action? onLinked) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) PrefabName = prefabName; ExpectedWorldPos = expectedWorldPos; Parent = parent; LocalPosition = localPosition; LocalRotation = localRotation; OnLinked = onLinked; } } private sealed class LinkerState { public readonly List Requests = new List(); public int Attempts; public float NextPollTime; } private const float PollInterval = 0.5f; private const int MaxAttempts = 60; private const float PositionTolerance = 1f; private static readonly Dictionary States = new Dictionary(); internal static void Enqueue(GameObject target, string prefabName, Vector3 expectedWorldPos, Transform parent, Vector3 localPosition, Quaternion localRotation, Action? onLinked = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) LinkRequest linkRequest = new LinkRequest(prefabName, expectedWorldPos, parent, localPosition, localRotation, onLinked); if (TryMatchAndLink(linkRequest, 0)) { DebugLog.Info($"[PrefabLinker] Linked '{prefabName}' to '{((Object)parent).name}' " + "immediately (already replicated)."); return; } NetworkedPrefabLinkerBehaviour networkedPrefabLinkerBehaviour = NetworkedPrefabLinkerBehaviour.EnsureOn(target); int instanceID = ((Object)networkedPrefabLinkerBehaviour).GetInstanceID(); if (!States.TryGetValue(instanceID, out LinkerState value)) { value = new LinkerState { NextPollTime = Time.unscaledTime + 0.5f }; States[instanceID] = value; } value.Requests.Add(linkRequest); DebugLog.Info($"[PrefabLinker] Queued link for '{prefabName}' ({value.Requests.Count} pending). building='{((Object)target).name}'"); } internal static bool Tick(int id, string buildingName) { if (!States.TryGetValue(id, out LinkerState value) || value.Requests.Count == 0) { States.Remove(id); return false; } if (Time.unscaledTime < value.NextPollTime) { return true; } value.Attempts++; value.NextPollTime = Time.unscaledTime + 0.5f; if (value.Attempts > 60) { DebugLog.Warning($"[PrefabLinker] Gave up after {60} attempts ({value.Requests.Count} unresolved). building='{buildingName}'"); States.Remove(id); return false; } for (int num = value.Requests.Count - 1; num >= 0; num--) { LinkRequest linkRequest = value.Requests[num]; if ((Object)(object)linkRequest.Parent == (Object)null) { value.Requests.RemoveAt(num); } else if (TryMatchAndLink(linkRequest, value.Attempts)) { value.Requests.RemoveAt(num); } else if (value.Attempts % 10 == 0) { DebugLog.Info($"[PrefabLinker] Still waiting for '{linkRequest.PrefabName}'... attempt {value.Attempts}/{60}"); } } if (value.Requests.Count == 0) { DebugLog.Info("[PrefabLinker] All pending links resolved."); States.Remove(id); return false; } return true; } private static bool TryMatchAndLink(LinkRequest req, int attempts) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) GameObject[] array; try { Scene activeScene = SceneManager.GetActiveScene(); array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)((Scene)(ref activeScene)).GetRootGameObjects()); } catch (Exception) { return false; } GameObject val = null; float num = float.MaxValue; GameObject[] array2 = array; foreach (GameObject val2 in array2) { if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.Contains(req.PrefabName)) { float num2 = Vector3.Distance(val2.transform.position, req.ExpectedWorldPos); if (num2 <= 1f) { val = val2; num = num2; break; } if (num2 < num) { val = val2; num = num2; } } } if ((Object)(object)val != (Object)null) { if (num > 1f) { DebugLog.Info($"[PrefabLinker] Name-only match for '{((Object)val).name}' (dist={num:F1}m, expected within {1f:F1}m). FishNet likely spawned at wrong position."); } val.transform.SetParent(req.Parent); val.transform.localPosition = req.LocalPosition; val.transform.localRotation = req.LocalRotation; if (attempts > 0) { DebugLog.Info($"[PrefabLinker] Linked '{((Object)val).name}' to '{((Object)req.Parent).name}' after {attempts} poll(s)."); } try { req.OnLinked?.Invoke(val); } catch (Exception ex2) { DebugLog.Error("[PrefabLinker] OnLinked callback threw: " + ex2.Message); } return true; } return false; } internal static void Remove(int id) { States.Remove(id); } } internal sealed class NetworkedPrefabLinkerBehaviour : MonoBehaviour { private static bool _registered; internal static NetworkedPrefabLinkerBehaviour EnsureOn(GameObject target) { if (!_registered) { ClassInjector.RegisterTypeInIl2Cpp(); _registered = true; } NetworkedPrefabLinkerBehaviour component = target.GetComponent(); return ((Object)(object)component != (Object)null) ? component : target.AddComponent(); } private void Update() { if (!NetworkedPrefabLinkerQueue.Tick(((Object)this).GetInstanceID(), ((Object)((Component)this).gameObject).name)) { Object.Destroy((Object)(object)this); } } private void OnDestroy() { NetworkedPrefabLinkerQueue.Remove(((Object)this).GetInstanceID()); } } public sealed class PrefabPlacer { private readonly Transform _parent; public PrefabPlacer(Transform parent) { _parent = parent; } public GameObject? Place(PrefabRef prefab, Vector3 localPosition, Quaternion localRotation, bool networked = true, bool enableComponents = false, Action? onReady = null) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Action action = null; action = (Action)((enableComponents && onReady != null) ? ((Action)delegate(GameObject go) { go.EnableAllComponents(); onReady(go); }) : ((!enableComponents) ? ((MulticastDelegate)onReady) : ((MulticastDelegate)(Action)delegate(GameObject go) { go.EnableAllComponents(); }))); return PlaceInternal(prefab, localPosition, localRotation, networked, action); } public GameObject? PlaceWithComponents(PrefabRef prefab, Vector3 localPosition, Quaternion localRotation, string[] componentNames, bool networked = true) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return PlaceInternal(prefab, localPosition, localRotation, networked, delegate(GameObject go) { go.EnableComponentsByName(componentNames); }); } public GameObject? PlaceSlidingDoors(Vector3 localPosition, Quaternion localRotation, string openingHoursText = "6AM-6PM", Material? doorMaterial = null, Action? onServerReady = null) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) bool flag = onServerReady != null; GameObject val = PlaceInternal(Prefabs.SlidingDoors, localPosition, localRotation, networked: true, delegate(GameObject go) { CustomizeSlidingDoors(go, doorMaterial, openingHoursText); }, !flag); if ((Object)(object)val != (Object)null && flag) { onServerReady(val); if (!val.activeSelf) { val.SetActive(true); } } return val; } public GameObject? PlaceItem(PrefabRef prefab, Vector3 localPosition, Quaternion localRotation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return Place(prefab, localPosition, localRotation, networked: false); } public GameObject?[] PlaceItemRow(PrefabRef prefab, Vector3 startPosition, float spacing, int count, Quaternion baseRotation, float rotationVariance = 15f) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = (GameObject[])(object)new GameObject[count]; Vector3 val = default(Vector3); for (int i = 0; i < count; i++) { ((Vector3)(ref val))..ctor(spacing * ((float)i - (float)(count - 1) / 2f), 0f, 0f); float num = Random.Range(0f - rotationVariance, rotationVariance); Quaternion localRotation = baseRotation * Quaternion.Euler(0f, num, 0f); array[i] = PlaceItem(prefab, startPosition + val, localRotation); } return array; } private GameObject? PlaceInternal(PrefabRef prefab, Vector3 localPosition, Quaternion localRotation, bool networked, Action? onReady, bool activate = true) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) GameObject val = (networked ? prefab.InstantiateNetworkedInactive(_parent, localPosition, localRotation) : prefab.Instantiate()); if ((Object)(object)val == (Object)null) { if (!networked) { DebugLog.Warning("[PrefabPlacer] '" + prefab.Name + "' local instantiate returned null."); return null; } if ((Object)(object)_parent == (Object)null) { DebugLog.Warning("[PrefabPlacer] '" + prefab.Name + "' returned null and parent is destroyed — cannot queue link."); return null; } NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager != (Object)null && networkManager.IsClient) { Vector3 expectedWorldPos = _parent.TransformPoint(localPosition); NetworkedPrefabLinkerQueue.Enqueue(((Component)_parent).gameObject, prefab.Name, expectedWorldPos, _parent, localPosition, localRotation, onReady); } else { DebugLog.Warning($"[PrefabPlacer] '{prefab.Name}' returned null — nm={(Object)(object)networkManager != (Object)null}, isClient={((networkManager != null) ? new bool?(networkManager.IsClient) : ((bool?)null))}, isServer={((networkManager != null) ? new bool?(networkManager.IsServer) : ((bool?)null))}"); } return null; } if (!networked) { val.transform.SetParent(_parent); val.transform.localPosition = localPosition; val.transform.localRotation = localRotation; } onReady?.Invoke(val); if (activate && networked && !val.activeSelf) { val.SetActive(true); } return val; } private static void CustomizeSlidingDoors(GameObject doors, Material? doorMaterial, string? openingHoursText) { ((Object)doors).name = "SlidingDoors"; if ((Object)(object)doorMaterial != (Object)null) { ApplyMaterialToPath(doors, "Door/Door", doorMaterial); ApplyMaterialToPath(doors, "Door/Door (1)", doorMaterial); } if (!string.IsNullOrEmpty(openingHoursText)) { SetOpeningHoursText(doors, openingHoursText); } } private static void ApplyMaterialToPath(GameObject root, string path, Material material) { Transform val = root.transform.Find(path); if ((Object)(object)val != (Object)null) { Renderer component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.material = material; } } } private static void SetOpeningHoursText(GameObject doorInstance, string text) { Transform val = doorInstance.transform.Find("Door/Door/OpeningHoursSign"); if ((Object)(object)val != (Object)null) { TextMeshPro component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { ((TMP_Text)component).text = text; return; } } TextMeshPro[] array = Il2CppArrayBase.op_Implicit(doorInstance.GetComponentsInChildren(true)); TextMeshPro[] array2 = array; int num = 0; while (num < array2.Length) { TextMeshPro val2 = array2[num]; if (!(((Object)val2).name == "OpeningHoursSign")) { Transform parent = val2.transform.parent; if (!(((parent != null) ? ((Object)parent).name : null) == "OpeningHoursSign")) { num++; continue; } } ((TMP_Text)val2).text = text; break; } } } } namespace S1MAPI.ProceduralMesh { public static class AdvancedMeshOperations { public static Mesh? WeldVertices(Mesh mesh, float threshold = 0.001f) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh == (Object)null) { return null; } Vector3[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.vertices); Vector3[] array2 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.normals); Vector2[] array3 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.uv); int[] array4 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.triangles); List list = new List(); List list2 = new List(); List list3 = new List(); int[] array5 = new int[array.Length]; for (int i = 0; i < array.Length; i++) { Vector3 val = array[i]; bool flag = false; for (int j = 0; j < list.Count; j++) { if (Vector3.Distance(val, list[j]) <= threshold) { array5[i] = j; flag = true; break; } } if (!flag) { array5[i] = list.Count; list.Add(val); if (i < array2.Length) { list2.Add(array2[i]); } if (i < array3.Length) { list3.Add(array3[i]); } } } int[] array6 = new int[array4.Length]; for (int k = 0; k < array4.Length; k++) { array6[k] = array5[array4[k]]; } Mesh val2 = new Mesh(); ((Object)val2).name = ((Object)mesh).name + "_Welded"; val2.vertices = Il2CppStructArray.op_Implicit(list.ToArray()); val2.triangles = Il2CppStructArray.op_Implicit(array6); if (list2.Count == list.Count) { val2.normals = Il2CppStructArray.op_Implicit(list2.ToArray()); } if (list3.Count == list.Count) { val2.uv = Il2CppStructArray.op_Implicit(list3.ToArray()); } val2.RecalculateBounds(); val2.RecalculateNormals(); return val2; } public static float CalculateSurfaceArea(Mesh mesh) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) if ((Object)(object)mesh == (Object)null) { return 0f; } Vector3[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.vertices); int[] array2 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.triangles); float num = 0f; for (int i = 0; i < array2.Length; i += 3) { Vector3 val = array[array2[i]]; Vector3 val2 = array[array2[i + 1]]; Vector3 val3 = array[array2[i + 2]]; float num2 = num; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); num = num2 + ((Vector3)(ref val4)).magnitude * 0.5f; } return num; } public static float CalculateVolume(Mesh mesh) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh == (Object)null) { return 0f; } Vector3[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.vertices); int[] array2 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.triangles); float num = 0f; for (int i = 0; i < array2.Length; i += 3) { Vector3 p = array[array2[i]]; Vector3 p2 = array[array2[i + 1]]; Vector3 p3 = array[array2[i + 2]]; num += SignedVolumeOfTriangle(p, p2, p3); } return Mathf.Abs(num); } private static float SignedVolumeOfTriangle(Vector3 p1, Vector3 p2, Vector3 p3) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) float num = p3.x * p2.y * p1.z; float num2 = p2.x * p3.y * p1.z; float num3 = p3.x * p1.y * p2.z; float num4 = p1.x * p3.y * p2.z; float num5 = p2.x * p1.y * p3.z; float num6 = p1.x * p2.y * p3.z; return 1f / 6f * (0f - num + num2 + num3 - num4 - num5 + num6); } public static Mesh Subdivide(Mesh mesh, int levels = 1) { if (levels <= 0) { return InstantiateMesh(mesh); } DebugLog.Warning("Mesh subdivision not fully implemented yet."); return InstantiateMesh(mesh); } private static Mesh InstantiateMesh(Mesh mesh) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Mesh val = new Mesh(); val.vertices = mesh.vertices; val.triangles = mesh.triangles; val.normals = mesh.normals; val.uv = mesh.uv; return val; } } public sealed class CustomMeshBuilder { private readonly string _name; private readonly List _vertices = new List(); private readonly List _triangles = new List(); private readonly List _uvs = new List(); private Material? _material; private bool _calculateNormals = true; public CustomMeshBuilder(string name) { _name = name; } public CustomMeshBuilder AddVertex(Vector3 vertex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _vertices.Add(vertex); return this; } public CustomMeshBuilder AddVertices(params Vector3[] vertices) { _vertices.AddRange(vertices); return this; } public CustomMeshBuilder AddTriangle(int v0, int v1, int v2) { _triangles.Add(v0); _triangles.Add(v1); _triangles.Add(v2); return this; } public CustomMeshBuilder AddQuad(int v0, int v1, int v2, int v3) { _triangles.Add(v0); _triangles.Add(v1); _triangles.Add(v2); _triangles.Add(v0); _triangles.Add(v2); _triangles.Add(v3); return this; } public CustomMeshBuilder SetUVs(params Vector2[] uvs) { _uvs.Clear(); _uvs.AddRange(uvs); return this; } public CustomMeshBuilder ApplyPlanarUVs() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) _uvs.Clear(); foreach (Vector3 vertex in _vertices) { _uvs.Add(new Vector2(vertex.x, vertex.z)); } return this; } public CustomMeshBuilder ApplyPlanarUVs(Vector3 up, Vector3 offset) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) _uvs.Clear(); foreach (Vector3 vertex in _vertices) { Vector3 val = Vector3.ProjectOnPlane(vertex - offset, ((Vector3)(ref up)).normalized); _uvs.Add(new Vector2(val.x, val.z)); } return this; } public CustomMeshBuilder SetMaterial(Material material) { _material = material; return this; } public CustomMeshBuilder SetColor(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) _material = MaterialPresets.Opaque(color); return this; } public CustomMeshBuilder DontCalculateNormals() { _calculateNormals = false; return this; } public Mesh BuildMesh() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (_vertices.Count == 0) { DebugLog.Error("Cannot build mesh '" + _name + "': no vertices"); return null; } Mesh val = new Mesh { name = _name, vertices = Il2CppStructArray.op_Implicit(_vertices.ToArray()), triangles = Il2CppStructArray.op_Implicit(_triangles.ToArray()) }; if (_uvs.Count > 0) { if (_uvs.Count != _vertices.Count) { DebugLog.Warning($"UV count ({_uvs.Count}) != vertex count ({_vertices.Count}), ignoring UVs"); } else { val.uv = Il2CppStructArray.op_Implicit(_uvs.ToArray()); } } if (_calculateNormals) { val.RecalculateNormals(); } val.RecalculateBounds(); DebugLog.Info($"Built custom mesh: {_name} ({_vertices.Count} vertices, {_triangles.Count / 3} triangles)"); return val; } public GameObject Build() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) Mesh mesh = BuildMesh(); GameObject val = new GameObject(_name); val.AddComponent().mesh = mesh; MeshRenderer val2 = val.AddComponent(); ((Renderer)val2).material = _material ?? MaterialPresets.Opaque(Color.white); ((Renderer)val2).renderingLayerMask = uint.MaxValue; DebugLog.Info("Created GameObject: " + _name); return val; } public GameObject Build(Transform parent) { GameObject val = Build(); val.transform.SetParent(parent, false); return val; } } public static class MeshUtilities { private const int MaxVerticesPerMesh = 65535; public static Mesh? MergeMeshes(Mesh[] meshes, Vector3[]? offsets = null, string name = "MergedMesh") { //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) if (meshes == null || meshes.Length == 0) { DebugLog.Error("Cannot merge null or empty mesh array"); return null; } if (offsets != null && offsets.Length != meshes.Length) { DebugLog.Error($"Offsets array length ({offsets.Length}) must match meshes array length ({meshes.Length})"); return null; } List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); for (int i = 0; i < meshes.Length; i++) { Mesh val = meshes[i]; if ((Object)(object)val == (Object)null) { continue; } int count = list.Count; Vector3 val2 = ((offsets != null && i < offsets.Length) ? offsets[i] : Vector3.zero); foreach (Vector3 item in (Il2CppArrayBase)(object)val.vertices) { list.Add(item + val2); } list4.AddRange((IEnumerable)val.normals); if (((Il2CppArrayBase)(object)val.uv).Length > 0) { list3.AddRange((IEnumerable)val.uv); } int[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val.triangles); for (int j = 0; j < array.Length; j++) { list2.Add(array[j] + count); } } if (list.Count > 65535) { DebugLog.Warning($"Merged mesh has {list.Count} vertices, exceeding Unity's limit of {65535}"); } Mesh val3 = new Mesh { name = name, vertices = Il2CppStructArray.op_Implicit(list.ToArray()), triangles = Il2CppStructArray.op_Implicit(list2.ToArray()), normals = Il2CppStructArray.op_Implicit(list4.ToArray()) }; if (list3.Count > 0) { val3.uv = Il2CppStructArray.op_Implicit(list3.ToArray()); } val3.RecalculateBounds(); DebugLog.Info($"Merged {meshes.Length} meshes into: {name} ({list.Count} vertices)"); return val3; } public static Mesh? MergeMesh(Mesh mesh, Vector3 offset, string? name = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh == (Object)null) { DebugLog.Error("Cannot merge null mesh"); return null; } return MergeMeshes((Mesh[])(object)new Mesh[1] { mesh }, (Vector3[]?)(object)new Vector3[1] { offset }, name ?? (((Object)mesh).name + "_Offset")); } } public static class PrimitiveBuilder { public static GameObject CreatePrimitive(PrimitiveType type, string name, Vector3 localPosition, Vector3 localScale, Color color, Transform? parent = null) { //IL_0001: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); ((Object)val).name = name; if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent); } val.transform.localPosition = localPosition; val.transform.localScale = localScale; Renderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { SetupMaterial(component, name, color); } return val; } public static GameObject CreatePrimitive(PrimitiveType type, string name, Vector3 localPosition, Vector3 localScale, Color color, float scale, Transform? parent = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) return CreatePrimitive(type, name, localPosition * scale, localScale * scale, color, parent); } public static GameObject CreatePrefab(string prefabName, string name, Vector3 localPosition, Quaternion localRotation, Transform? parent = null) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load(prefabName); if ((Object)(object)val == (Object)null) { GameObject[] array = Il2CppArrayBase.op_Implicit(Resources.FindObjectsOfTypeAll()); GameObject[] array2 = array; foreach (GameObject val2 in array2) { if (((Object)val2).name.Equals(prefabName, StringComparison.OrdinalIgnoreCase) || ((Object)val2).name.Equals(prefabName + ".prefab", StringComparison.OrdinalIgnoreCase)) { val = val2; break; } } } if ((Object)(object)val == (Object)null) { DebugLog.Warning("Could not find prefab: " + prefabName); return null; } GameObject val3 = Object.Instantiate(val); ((Object)val3).name = name; if ((Object)(object)parent != (Object)null) { val3.transform.SetParent(parent); } val3.transform.localPosition = localPosition; val3.transform.localRotation = localRotation; return val3; } public static void SetupMaterial(Renderer renderer, string name, Color color) { //IL_0090: 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) if ((Object)(object)renderer == (Object)null) { DebugLog.Warning("Cannot setup material on null renderer"); return; } string text = name.ToLower(); Material material = ((!text.Contains("glass") && !text.Contains("window")) ? MaterialPresets.Opaque(color) : ((!text.Contains("clear") && !text.Contains("window")) ? MaterialPresets.Glass(color) : MaterialPresets.ClearGlass())); renderer.material = material; renderer.allowOcclusionWhenDynamic = false; } public static GameObject CreateBox(string name, Vector3 localPosition, Vector3 size, Color color, Transform? parent = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return CreatePrimitive((PrimitiveType)3, name, localPosition, size, color, parent); } public static GameObject CreateSphere(string name, Vector3 localPosition, float radius, Color color, Transform? parent = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) return CreatePrimitive((PrimitiveType)0, name, localPosition, Vector3.one * radius * 2f, color, parent); } public static GameObject CreateCylinder(string name, Vector3 localPosition, Vector3 size, Color color, Transform? parent = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return CreatePrimitive((PrimitiveType)2, name, localPosition, size, color, parent); } public static GameObject CreatePointLight(string name, Vector3 localPosition, Color color, float range, float intensity, Transform? parent = null, LightShadows shadows = (LightShadows)0, LightRenderMode renderMode = (LightRenderMode)1) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) GameObject val = new GameObject(name); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent); } val.transform.localPosition = localPosition; Light val2 = val.AddComponent(); val2.type = (LightType)2; val2.color = color; val2.range = range; val2.intensity = intensity; val2.shadows = shadows; val2.renderMode = renderMode; return val; } } public sealed class ProceduralMeshBuilder { internal readonly string _name; internal readonly List _vertices = new List(); internal readonly List _triangles = new List(); internal readonly List _uvs = new List(); internal readonly List _normals = new List(); internal Material? _material; internal bool _applyFlatShading = false; public ProceduralMeshBuilder(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name", "Mesh name cannot be null or empty"); } _name = name; } public ProceduralMeshBuilder AddBox(Vector3 center, Vector3 size) { //IL_000d: 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) BoxGenerator.Generate(_vertices, _triangles, center, size); DebugLog.Info("Added box to mesh: " + _name); return this; } public ProceduralMeshBuilder AddSphere(Vector3 center, float radius, int subdivisions = 8) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) SphereGenerator.Generate(_vertices, _triangles, _uvs, center, radius, subdivisions); DebugLog.Info("Added sphere to mesh: " + _name); return this; } public ProceduralMeshBuilder AddCylinder(Vector3 start, Vector3 end, float radius, int segments = 12) { //IL_000d: 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) CylinderGenerator.Generate(_vertices, _triangles, start, end, radius, segments); DebugLog.Info("Added cylinder to mesh: " + _name); return this; } public ProceduralMeshBuilder AddCapsule(Vector3 start, Vector3 end, float radius) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) AddCylinder(start + Vector3.up * radius, end - Vector3.up * radius, radius); AddSphere(start, radius, 6); AddSphere(end, radius, 6); DebugLog.Info("Added capsule to mesh: " + _name); return this; } public ProceduralMeshBuilder SetMaterial(Material material) { _material = material; return this; } public ProceduralMeshBuilder SetColor(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) _material = MaterialPresets.Opaque(color); return this; } public ProceduralMeshBuilder ApplyFlatShading() { _applyFlatShading = true; return this; } public Mesh BuildMesh() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_006c: Expected O, but got Unknown if (_vertices.Count == 0) { DebugLog.Warning("Building empty mesh: " + _name); } Mesh val = new Mesh { name = _name, vertices = Il2CppStructArray.op_Implicit(_vertices.ToArray()), triangles = Il2CppStructArray.op_Implicit(_triangles.ToArray()) }; if (_uvs.Count > 0) { val.uv = Il2CppStructArray.op_Implicit(_uvs.ToArray()); } if (_applyFlatShading) { val.ApplyFlatShading(); } else { val.RecalculateNormals(); } val.RecalculateBounds(); DebugLog.Info($"Built mesh: {_name} ({_vertices.Count} vertices, {_triangles.Count / 3} triangles)"); return val; } public GameObject Build() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) Mesh mesh = BuildMesh(); GameObject val = new GameObject(_name); MeshFilter val2 = val.AddComponent(); MeshRenderer val3 = val.AddComponent(); ((Renderer)val3).renderingLayerMask = uint.MaxValue; val2.mesh = mesh; if ((Object)(object)_material != (Object)null) { ((Renderer)val3).material = _material; } else { ((Renderer)val3).material = MaterialPresets.Opaque(Color.white); } DebugLog.Info("Built GameObject: " + _name); return val; } } } namespace S1MAPI.ProceduralMesh.Generators.Primitives { internal static class BoxGenerator { public static void Generate(List vertices, List triangles, Vector3 center, Vector3 size) { //IL_0008: 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_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_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_002b: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; Vector3 val = size * 0.5f; Vector3[] collection = (Vector3[])(object)new Vector3[8] { center + new Vector3(0f - val.x, 0f - val.y, 0f - val.z), center + new Vector3(val.x, 0f - val.y, 0f - val.z), center + new Vector3(val.x, 0f - val.y, val.z), center + new Vector3(0f - val.x, 0f - val.y, val.z), center + new Vector3(0f - val.x, val.y, 0f - val.z), center + new Vector3(val.x, val.y, 0f - val.z), center + new Vector3(val.x, val.y, val.z), center + new Vector3(0f - val.x, val.y, val.z) }; vertices.AddRange(collection); int[] array = new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 3, 7, 6, 3, 6, 2, 0, 4, 7, 0, 7, 3, 1, 2, 6, 1, 6, 5 }; int[] array2 = array; foreach (int num in array2) { triangles.Add(count + num); } } } internal static class CylinderGenerator { public static void Generate(List vertices, List triangles, Vector3 start, Vector3 end, float radius, int segments = 12) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0018: 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_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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) int count = vertices.Count; Vector3 val = end - start; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(normalized, Vector3.up); if (((Vector3)(ref val2)).magnitude < 0.001f) { val2 = Vector3.Cross(normalized, Vector3.right); } ((Vector3)(ref val2)).Normalize(); val = Vector3.Cross(normalized, val2); Vector3 normalized2 = ((Vector3)(ref val)).normalized; vertices.Add(start); vertices.Add(end); for (int i = 0; i <= segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); Vector3 val3 = (val2 * num2 + normalized2 * num3) * radius; vertices.Add(start + val3); vertices.Add(end + val3); } for (int j = 0; j < segments; j++) { triangles.Add(count); triangles.Add(count + 2 + j * 2); triangles.Add(count + 2 + (j + 1) * 2); } for (int k = 0; k < segments; k++) { triangles.Add(count + 1); triangles.Add(count + 3 + (k + 1) * 2); triangles.Add(count + 3 + k * 2); } for (int l = 0; l < segments; l++) { int num4 = count + 2 + l * 2; int num5 = count + 2 + (l + 1) * 2; int item = num4 + 1; int item2 = num5 + 1; triangles.Add(num4); triangles.Add(item); triangles.Add(num5); triangles.Add(num5); triangles.Add(item); triangles.Add(item2); } } } internal static class DualMaterialBoxGenerator { internal enum InteriorFace { NegZ, PosZ, NegX, PosX } private static readonly Mesh?[] Cache = (Mesh?[])(object)new Mesh[4]; internal static Mesh Generate(InteriorFace interiorFace) { Mesh val = Cache[(int)interiorFace]; if ((Object)(object)val != (Object)null) { return val; } Mesh val2 = BuildMesh(interiorFace); Cache[(int)interiorFace] = val2; return val2; } private static Mesh BuildMesh(InteriorFace interiorFace) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: 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_0400: 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: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[24]; Vector3[] array2 = (Vector3[])(object)new Vector3[24]; Vector2[] array3 = (Vector2[])(object)new Vector2[24]; (Vector3, Vector3, Vector3, Vector3)[] array4 = new(Vector3, Vector3, Vector3, Vector3)[6] { (Vector3.right, Vector3.forward, Vector3.up, Vector3.right * 0.5f), (Vector3.left, Vector3.back, Vector3.up, Vector3.left * 0.5f), (Vector3.up, Vector3.right, Vector3.forward, Vector3.up * 0.5f), (Vector3.down, Vector3.right, Vector3.back, Vector3.down * 0.5f), (Vector3.forward, Vector3.left, Vector3.up, Vector3.forward * 0.5f), (Vector3.back, Vector3.right, Vector3.up, Vector3.back * 0.5f) }; if (1 == 0) { } int num = interiorFace switch { InteriorFace.PosX => 0, InteriorFace.NegX => 1, InteriorFace.PosZ => 4, InteriorFace.NegZ => 5, _ => 5, }; if (1 == 0) { } int num2 = num; int[] array5 = new int[30]; int[] array6 = new int[6]; int num3 = 0; int num4 = 0; for (int i = 0; i < 6; i++) { int num5 = i * 4; var (val, val2, val3, val4) = array4[i]; array[num5] = val4 - val2 * 0.5f - val3 * 0.5f; array[num5 + 1] = val4 + val2 * 0.5f - val3 * 0.5f; array[num5 + 2] = val4 + val2 * 0.5f + val3 * 0.5f; array[num5 + 3] = val4 - val2 * 0.5f + val3 * 0.5f; array2[num5] = val; array2[num5 + 1] = val; array2[num5 + 2] = val; array2[num5 + 3] = val; array3[num5] = new Vector2(0f, 0f); array3[num5 + 1] = new Vector2(1f, 0f); array3[num5 + 2] = new Vector2(1f, 1f); array3[num5 + 3] = new Vector2(0f, 1f); if (i == num2) { array6[num4++] = num5; array6[num4++] = num5 + 2; array6[num4++] = num5 + 1; array6[num4++] = num5; array6[num4++] = num5 + 3; array6[num4++] = num5 + 2; } else { array5[num3++] = num5; array5[num3++] = num5 + 2; array5[num3++] = num5 + 1; array5[num3++] = num5; array5[num3++] = num5 + 3; array5[num3++] = num5 + 2; } } Mesh val5 = new Mesh { name = $"DualMaterialBox_{interiorFace}", vertices = Il2CppStructArray.op_Implicit(array), normals = Il2CppStructArray.op_Implicit(array2), uv = Il2CppStructArray.op_Implicit(array3), subMeshCount = 2 }; val5.SetTriangles(Il2CppStructArray.op_Implicit(array5), 0); val5.SetTriangles(Il2CppStructArray.op_Implicit(array6), 1); val5.RecalculateBounds(); val5.RecalculateTangents(); return val5; } } internal static class SphereGenerator { public static void Generate(List vertices, List triangles, List uvs, Vector3 center, float radius, int subdivisions = 8) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0096: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; int num = subdivisions * 2; Vector3 val = default(Vector3); for (int i = 0; i <= subdivisions; i++) { float num2 = (float)i * (float)Math.PI / (float)subdivisions; float num3 = Mathf.Sin(num2); float num4 = Mathf.Cos(num2); for (int j = 0; j <= num; j++) { float num5 = (float)(j * 2) * (float)Math.PI / (float)num; float num6 = Mathf.Sin(num5); float num7 = Mathf.Cos(num5); ((Vector3)(ref val))..ctor(radius * num3 * num7, radius * num4, radius * num3 * num6); vertices.Add(center + val); uvs.Add(new Vector2((float)j / (float)num, (float)i / (float)subdivisions)); } } for (int k = 0; k < subdivisions; k++) { for (int l = 0; l < num; l++) { int num8 = count + k * (num + 1) + l; int num9 = num8 + num + 1; triangles.Add(num8); triangles.Add(num9); triangles.Add(num8 + 1); triangles.Add(num8 + 1); triangles.Add(num9); triangles.Add(num9 + 1); } } } } } namespace S1MAPI.ProceduralMesh.Generators.Organic { public class BodyProfile { public RingProfile[] Rings { get; set; } public int RingSegments { get; set; } = 8; public static BodyProfile DefaultDogBody => new BodyProfile(new RingProfile[5] { new RingProfile(0.5f, 0.8f, 0.9f, 0.9f, 0f), new RingProfile(0.25f, 1f, 1f, 1f, 0f), new RingProfile(0f, 0.9f, 0.9f, 0.9f, -0.05f), new RingProfile(-0.25f, 0.7f, 0.7f, 0.7f, -0.1f), new RingProfile(-0.5f, 0.8f, 0.8f, 0.8f, 0f) }); public static BodyProfile Cylindrical => new BodyProfile(new RingProfile[2] { new RingProfile(0.5f, 1f, 1f, 1f, 0f), new RingProfile(-0.5f, 1f, 1f, 1f, 0f) }, 12); public static BodyProfile Tapered => new BodyProfile(new RingProfile[3] { new RingProfile(0.5f, 1f, 1f, 1f, 0f), new RingProfile(0f, 0.75f, 0.75f, 0.75f, 0f), new RingProfile(-0.5f, 0.5f, 0.5f, 0.5f, 0f) }); public BodyProfile(RingProfile[] rings, int ringSegments = 8) { Rings = rings; RingSegments = ringSegments; } } public struct RingProfile { public float ZPosition; public float WidthScale; public float HeightScaleTop; public float HeightScaleBottom; public float Asymmetry; public RingProfile(float zPosition, float widthScale, float heightScaleTop, float heightScaleBottom, float asymmetry) { ZPosition = zPosition; WidthScale = widthScale; HeightScaleTop = heightScaleTop; HeightScaleBottom = heightScaleBottom; Asymmetry = asymmetry; } } public class LimbProfile { public Vector3[] JointPositions { get; set; } public float[] JointRadii { get; set; } public float[] ForwardPush { get; set; } public int Segments { get; set; } = 12; public LimbProfile(Vector3[] jointPositions, float[] jointRadii, float[]? forwardPush = null, int segments = 12) { JointPositions = jointPositions; JointRadii = jointRadii; ForwardPush = forwardPush ?? new float[jointPositions.Length]; Segments = segments; } public static LimbProfile DefaultDogLeg(float height, float topRadius) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) float num = topRadius * 0.7f; return new LimbProfile((Vector3[])(object)new Vector3[4] { new Vector3(0f, height * 0.5f, 0f), new Vector3(0f, 0f, 0.1f * height), new Vector3(0f, (0f - height) * 0.4f, -0.05f * height), new Vector3(0f, (0f - height) * 0.5f, 0f) }, new float[4] { topRadius, topRadius * 0.9f, num * 1.1f, num }, new float[4] { 0.15f, 0.25f, 0f, 0f }); } public static LimbProfile SimpleCylinder(float height, float radius) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) return new LimbProfile((Vector3[])(object)new Vector3[2] { new Vector3(0f, height * 0.5f, 0f), new Vector3(0f, (0f - height) * 0.5f, 0f) }, new float[2] { radius, radius }, new float[2]); } public static LimbProfile Tapered(float height, float topRadius, float bottomRadius) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) return new LimbProfile((Vector3[])(object)new Vector3[2] { new Vector3(0f, height * 0.5f, 0f), new Vector3(0f, (0f - height) * 0.5f, 0f) }, new float[2] { topRadius, bottomRadius }, new float[2]); } } public abstract class OrganicShapeGenerator { private readonly string _name; protected OrganicShapeGenerator(string name) { _name = name; } public Mesh Generate() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown List list = new List(); List list2 = new List(); List list3 = new List(); GenerateGeometry(list, list2, list3); Mesh val = new Mesh { name = _name, vertices = Il2CppStructArray.op_Implicit(list.ToArray()), triangles = Il2CppStructArray.op_Implicit(list2.ToArray()) }; if (list3.Count > 0) { val.uv = Il2CppStructArray.op_Implicit(list3.ToArray()); } val.RecalculateNormals(); val.RecalculateBounds(); DebugLog.Info($"Generated organic shape mesh: {_name} ({list.Count} vertices)"); return val; } public void GenerateInto(List vertices, List triangles, List uvs, Vector3 offset = default(Vector3)) { //IL_0012: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; GenerateGeometry(vertices, triangles, uvs); if (offset != Vector3.zero) { for (int i = count; i < vertices.Count; i++) { int index = i; vertices[index] += offset; } } } protected abstract void GenerateGeometry(List vertices, List triangles, List uvs); protected void AddRing(List vertices, Vector3 position, float radius, int segments, Vector2 ellipticalScale = default(Vector2)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006a: Unknown result type (might be due to invalid IL or missing references) if (ellipticalScale == default(Vector2)) { ellipticalScale = Vector2.one; } for (int i = 0; i < segments; i++) { float num = (float)i / (float)segments * 2f * (float)Math.PI; float num2 = Mathf.Cos(num) * radius * ellipticalScale.x; float num3 = Mathf.Sin(num) * radius * ellipticalScale.y; vertices.Add(position + new Vector3(num2, 0f, num3)); } } protected void AddAsymmetricRing(List vertices, Vector3 position, float widthRadius, float heightRadiusTop, float heightRadiusBottom, int segments, float asymmetry = 0f) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < segments; i++) { float num = (float)i / (float)segments * (float)Math.PI * 2f; float num2 = Mathf.Cos(num) * widthRadius; float num3 = Mathf.Sin(num); float num4; if (num3 > 0f) { num4 = num3 * heightRadiusTop; num4 *= 1f - asymmetry * Mathf.Abs(Mathf.Cos(num)); } else { num4 = num3 * heightRadiusBottom; } vertices.Add(position + new Vector3(num2, num4, 0f)); } } protected void ConnectRings(List triangles, int startRingIndex, int endRingIndex, int segments) { for (int i = 0; i < segments; i++) { int item = startRingIndex + i; int item2 = startRingIndex + (i + 1) % segments; int item3 = endRingIndex + i; int item4 = endRingIndex + (i + 1) % segments; triangles.Add(item); triangles.Add(item3); triangles.Add(item2); triangles.Add(item2); triangles.Add(item3); triangles.Add(item4); } } protected void CapRing(List vertices, List triangles, int ringStartIndex, int segments, Vector3 centerPosition, bool flipNormals = false) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(centerPosition); for (int i = 0; i < segments; i++) { if (flipNormals) { triangles.Add(count); triangles.Add(ringStartIndex + i); triangles.Add(ringStartIndex + (i + 1) % segments); } else { triangles.Add(count); triangles.Add(ringStartIndex + (i + 1) % segments); triangles.Add(ringStartIndex + i); } } } } } namespace S1MAPI.Extensions { public static class CollectionExtensions { public static IEnumerable ForEach(this IEnumerable collection, Action action) { foreach (T item in collection) { action(item); } return collection; } public static IList Shuffle(this IList list) { int count = list.Count; for (int num = count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); int index = num; int index2 = num2; T value = list[num2]; T value2 = list[num]; list[index] = value; list[index2] = value2; } return list; } public static IEnumerable DistinctBy(this IEnumerable collection, Func keySelector) { return from g in collection.GroupBy(keySelector) select g.First(); } public static T? SafeGet(this IList list, int index) { return (T?)((index >= 0 && index < list.Count) ? ((object)list[index]) : ((object)default(T))); } public static List ToVector3List(this IEnumerable array) { return new List(array); } public static List ToIntList(this IEnumerable array) { return new List(array); } } public static class ComponentExtensions { public static T? GetComponent(this Component component) where T : class { return component.GetComponent(); } public static T Enable(this T component) where T : Behaviour { ((Behaviour)component).enabled = true; return component; } public static T Disable(this T component) where T : Behaviour { ((Behaviour)component).enabled = false; return component; } public static Component? GetComponentByName(this Component component, string componentName, bool includeInactive = false) { Il2CppArrayBase componentsInChildren = component.GetComponentsInChildren(includeInactive); foreach (Component item in componentsInChildren) { if (((object)item).GetType().Name == componentName) { return item; } } return null; } } public static class GameObjectExtensions { public static T GetOrAddComponent(this GameObject gameObject) where T : Component { T val = default(T); return gameObject.TryGetComponent(ref val) ? val : gameObject.AddComponent(); } public static bool HasComponent(this GameObject gameObject) where T : Component { T val = default(T); return gameObject.TryGetComponent(ref val); } public static void Destroy(this GameObject gameObject) { if ((Object)(object)gameObject != (Object)null) { Object.Destroy((Object)(object)gameObject); } } public static GameObject Hide(this GameObject gameObject) { gameObject.SetActive(false); return gameObject; } public static GameObject Show(this GameObject gameObject) { gameObject.SetActive(true); return gameObject; } public static GameObject SetLayerRecursively(this GameObject gameObject, int layer) { gameObject.layer = layer; for (int i = 0; i < gameObject.transform.childCount; i++) { ((Component)gameObject.transform.GetChild(i)).gameObject.SetLayerRecursively(layer); } return gameObject; } public static GameObject SetLayerRecursively(this GameObject gameObject, string layerName) { int num = LayerMask.NameToLayer(layerName); if (num == -1) { DebugLog.Warning("Layer not found: " + layerName); return gameObject; } return gameObject.SetLayerRecursively(num); } public static void EnableAllComponents(this GameObject gameObject, bool recursive = true) { if ((Object)(object)gameObject == (Object)null) { DebugLog.Warning("[S1MAPI] Cannot enable components on null GameObject"); return; } Il2CppArrayBase val = (recursive ? gameObject.GetComponentsInChildren(true) : gameObject.GetComponents()); foreach (MonoBehaviour item in val) { item?.Enable(); } } public static void EnableComponentsByName(this GameObject gameObject, string[] componentNames, bool recursive = true) { if ((Object)(object)gameObject == (Object)null) { DebugLog.Warning("[S1MAPI] Cannot enable components on null GameObject"); return; } if (componentNames == null || componentNames.Length == 0) { DebugLog.Warning("[S1MAPI] No component names provided"); return; } Il2CppArrayBase val = (recursive ? gameObject.GetComponentsInChildren(true) : gameObject.GetComponents()); foreach (MonoBehaviour item in val) { if ((Object)(object)item == (Object)null) { continue; } string name = ((object)item).GetType().Name; foreach (string text in componentNames) { if (name == text) { item.Enable(); DebugLog.Info("[S1MAPI] Enabled component: " + name); break; } } } } public static MonoBehaviour? GetComponentByName(this GameObject gameObject, string componentName, bool recursive = true) { if ((Object)(object)gameObject == (Object)null) { return null; } Il2CppArrayBase val = (recursive ? gameObject.GetComponentsInChildren(true) : gameObject.GetComponents()); foreach (MonoBehaviour item in val) { if ((Object)(object)item != (Object)null && ((object)item).GetType().Name == componentName) { return item; } } return null; } public static bool EnableAndSetup(this GameObject gameObject, string componentName, string? setupMethodName = null, bool recursive = true) { MonoBehaviour componentByName = gameObject.GetComponentByName(componentName, recursive); if ((Object)(object)componentByName == (Object)null) { DebugLog.Warning("[S1MAPI] Component '" + componentName + "' not found on " + ((Object)gameObject).name); return false; } componentByName.Enable(); if (!string.IsNullOrEmpty(setupMethodName)) { MethodInfo method = ((object)componentByName).GetType().GetMethod(setupMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { try { method.Invoke(componentByName, null); DebugLog.Info("[S1MAPI] Invoked " + setupMethodName + " on " + componentName); } catch (Exception ex) { DebugLog.Error("[S1MAPI] Failed to invoke " + setupMethodName + ": " + ex.Message); } } else { DebugLog.Warning("[S1MAPI] Method '" + setupMethodName + "' not found on " + componentName); } } return true; } } public static class MaterialExtensions { public static Material SetColorAlpha(this Material material, float alpha) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Color color = material.color; color.a = alpha; material.color = color; return material; } public static Material EnableKeyword(this Material material, string keyword) { material.EnableKeyword(keyword); return material; } public static Material DisableKeyword(this Material material, string keyword) { material.DisableKeyword(keyword); return material; } } public static class MeshExtensions { public static Mesh Clone(this Mesh mesh) { //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_001d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown return new Mesh { name = ((Object)mesh).name + "_Clone", vertices = mesh.vertices, triangles = mesh.triangles, normals = mesh.normals, tangents = mesh.tangents, uv = mesh.uv, uv2 = mesh.uv2, uv3 = mesh.uv3, uv4 = mesh.uv4, colors = mesh.colors, bounds = mesh.bounds }; } public static Vector3 GetCenter(this Mesh mesh) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = mesh.bounds; return ((Bounds)(ref bounds)).center; } public static bool IsValid(this Mesh mesh, bool checkVertexLimit = true) { if ((Object)(object)mesh == (Object)null) { return false; } if (((Il2CppArrayBase)(object)mesh.vertices).Length == 0) { return false; } if (((Il2CppArrayBase)(object)mesh.triangles).Length == 0) { return false; } if (checkVertexLimit && ((Il2CppArrayBase)(object)mesh.vertices).Length > 65535) { DebugLog.Warning($"Mesh has {((Il2CppArrayBase)(object)mesh.vertices).Length} vertices, exceeding Unity's {65535} limit"); return false; } return true; } public static bool Validate(this Mesh mesh) { if ((Object)(object)mesh == (Object)null) { DebugLog.Error("Mesh is null"); return false; } if (!mesh.IsValid()) { return false; } if (((Il2CppArrayBase)(object)mesh.triangles).Length % 3 != 0) { DebugLog.Error($"Mesh {((Object)mesh).name} has invalid triangle count: {((Il2CppArrayBase)(object)mesh.triangles).Length}"); return false; } return true; } public static void ApplyFlatShading(this Mesh mesh) { //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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh == (Object)null) { DebugLog.Error("Cannot apply flat shading to null mesh"); return; } Vector3[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.vertices); int[] array2 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)mesh.triangles); Vector3[] array3 = (Vector3[])(object)new Vector3[array2.Length]; Vector3[] array4 = (Vector3[])(object)new Vector3[array2.Length]; Vector2[] array5 = (Vector2[])(object)((((Il2CppArrayBase)(object)mesh.uv).Length > 0) ? new Vector2[array2.Length] : null); for (int i = 0; i < array2.Length; i += 3) { Vector3 val = array[array2[i]]; Vector3 val2 = array[array2[i + 1]]; Vector3 val3 = array[array2[i + 2]]; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); Vector3 normalized = ((Vector3)(ref val4)).normalized; array3[i] = val; array3[i + 1] = val2; array3[i + 2] = val3; array4[i] = normalized; array4[i + 1] = normalized; array4[i + 2] = normalized; array2[i] = i; array2[i + 1] = i + 1; array2[i + 2] = i + 2; if (array5 != null && ((Il2CppArrayBase)(object)mesh.uv).Length > 0) { array5[i] = ((Il2CppArrayBase)(object)mesh.uv)[array2[i]]; array5[i + 1] = ((Il2CppArrayBase)(object)mesh.uv)[array2[i + 1]]; array5[i + 2] = ((Il2CppArrayBase)(object)mesh.uv)[array2[i + 2]]; } } mesh.Clear(); mesh.vertices = Il2CppStructArray.op_Implicit(array3); mesh.triangles = Il2CppStructArray.op_Implicit(array2); mesh.normals = Il2CppStructArray.op_Implicit(array4); if (array5 != null) { mesh.uv = Il2CppStructArray.op_Implicit(array5); } mesh.RecalculateBounds(); DebugLog.Info("Applied flat shading to mesh: " + ((Object)mesh).name); } public static void CalculateNormals(this Mesh mesh, NormalCalculationMode mode = NormalCalculationMode.Smooth) { if ((Object)(object)mesh == (Object)null) { DebugLog.Error("Cannot calculate normals for null mesh"); return; } switch (mode) { case NormalCalculationMode.Smooth: mesh.RecalculateNormals(); break; case NormalCalculationMode.Flat: mesh.ApplyFlatShading(); break; default: mesh.RecalculateNormals(); break; } } } public enum NormalCalculationMode { Smooth, Flat } public static class NavMeshExtensions { public static NavMeshObstacle AddNavMeshObstacle(this GameObject gameObject, bool carving = true) { NavMeshObstacle orAddComponent = gameObject.GetOrAddComponent(); orAddComponent.carving = carving; return orAddComponent; } public static NavMeshObstacle WithCarving(this NavMeshObstacle obstacle, bool carving = true) { obstacle.carving = carving; return obstacle; } public static NavMeshObstacle WithCarveOnlyStationary(this NavMeshObstacle obstacle, bool carveOnly = true) { obstacle.carveOnlyStationary = carveOnly; return obstacle; } } public static class TransformExtensions { public static Transform Reset(this Transform transform) { //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; return transform; } public static Transform SetLocalPosition(this Transform transform, float? x = null, float? y = null, float? z = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Vector3 localPosition = transform.localPosition; if (x.HasValue) { localPosition.x = x.Value; } if (y.HasValue) { localPosition.y = y.Value; } if (z.HasValue) { localPosition.z = z.Value; } transform.localPosition = localPosition; return transform; } public static void DestroyChildren(this Transform transform) { for (int i = 0; i < transform.childCount; i++) { Object.Destroy((Object)(object)((Component)transform.GetChild(i)).gameObject); } } public static GameObject[] GetChildren(this Transform transform) { GameObject[] array = (GameObject[])(object)new GameObject[transform.childCount]; for (int i = 0; i < transform.childCount; i++) { array[i] = ((Component)transform.GetChild(i)).gameObject; } return array; } } public static class Vector3Extensions { public static Vector3 WithX(this Vector3 vector, float x) { //IL_0002: 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_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_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x, vector.y, vector.z); } public static Vector3 WithY(this Vector3 vector, float y) { //IL_0001: 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_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_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector3(vector.x, y, vector.z); } public static Vector3 WithZ(this Vector3 vector, float z) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0016: Unknown result type (might be due to invalid IL or missing references) return new Vector3(vector.x, vector.y, z); } public static Vector3 Flattened(this Vector3 vector) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return new Vector3(vector.x, 0f, vector.z); } public static float DistanceTo(this Vector3 from, Vector3 to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(from, to); } public static float AngleTo(this Vector3 from, Vector3 to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Vector3.Angle(from, to); } public static Vector2 ToVector2(this Vector3 vector) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new Vector2(vector.x, vector.y); } } } namespace S1MAPI.Core { public sealed class MeshRef { private Mesh? _cachedMesh; private GameObject? _cachedSource; public string Name { get; } public MeshRef(string name) { Name = name; } public GameObject? FindSource() { if ((Object)(object)_cachedSource != (Object)null) { return _cachedSource; } try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); foreach (GameObject item in val) { if (((Object)item).name == Name) { MeshFilter component = item.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { _cachedSource = item; _cachedMesh = component.sharedMesh; return item; } } } Il2CppArrayBase val2 = Resources.FindObjectsOfTypeAll(); foreach (MeshFilter item2 in val2) { if ((Object)(object)item2.sharedMesh != (Object)null && ((Object)item2.sharedMesh).name == Name) { _cachedSource = ((Component)item2).gameObject; _cachedMesh = item2.sharedMesh; return ((Component)item2).gameObject; } } } catch (Exception ex) { DebugLog.Error("[MeshRef] Error finding mesh '" + Name + "': " + ex.Message); } return null; } public Mesh? GetMesh() { if ((Object)(object)_cachedMesh != (Object)null) { return _cachedMesh; } FindSource(); return _cachedMesh; } public GameObject? Instantiate(string? name = null, Transform? parent = null, bool addCollider = true) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown Mesh mesh = GetMesh(); if ((Object)(object)mesh == (Object)null) { DebugLog.Warning("[MeshRef] Could not find mesh: " + Name); return null; } GameObject val = FindSource(); GameObject val2 = new GameObject(name ?? Name); if ((Object)(object)parent != (Object)null) { val2.transform.SetParent(parent); } MeshFilter val3 = val2.AddComponent(); val3.sharedMesh = mesh; MeshRenderer val4 = val2.AddComponent(); if ((Object)(object)val != (Object)null) { MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)val4).sharedMaterials = ((Renderer)component).sharedMaterials; } } if (addCollider) { val2.AddComponent(); } return val2; } public GameObject? Instantiate(string name, Vector3 localPosition, Quaternion localRotation, Transform? parent = null, bool addCollider = true) { //IL_0022: 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) GameObject val = Instantiate(name, parent, addCollider); if ((Object)(object)val == (Object)null) { return null; } val.transform.localPosition = localPosition; val.transform.localRotation = localRotation; return val; } public GameObject? InstantiateWithMaterial(string name, Material material, Transform? parent = null, bool addCollider = true) { GameObject val = Instantiate(name, parent, addCollider); if ((Object)(object)val == (Object)null) { return null; } MeshRenderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).material = material; } return val; } public GameObject? CloneVisuals(string? name = null, Transform? parent = null, bool stripColliders = true) { GameObject val = FindSource(); if ((Object)(object)val == (Object)null) { DebugLog.Warning("[MeshRef] Could not find source for cloning: " + Name); return null; } GameObject val2 = Object.Instantiate(val); ((Object)val2).name = name ?? (Name + "_Clone"); if (stripColliders) { foreach (Collider componentsInChild in val2.GetComponentsInChildren(true)) { Object.Destroy((Object)(object)componentsInChild); } } if ((Object)(object)parent != (Object)null) { val2.transform.SetParent(parent); } return val2; } public static GameObject? Clone(GameObject original, Vector3 position, Quaternion rotation, Transform? parent = null, bool stripColliders = true) { //IL_001d: 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) if ((Object)(object)original == (Object)null) { DebugLog.Error("Cannot clone null object"); return null; } GameObject val = Object.Instantiate(original, position, rotation, parent); ((Object)val).name = ((Object)original).name + "_Clone"; if (stripColliders) { foreach (Collider componentsInChild in val.GetComponentsInChildren(true)) { Object.Destroy((Object)(object)componentsInChild); } } return val; } public override string ToString() { return Name; } public static implicit operator string(MeshRef mesh) { return mesh.Name; } } public sealed class PrefabRef { public string Name { get; } public PrefabRef(string name) { Name = name; } public GameObject? Find() { try { NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager == (Object)null) { return null; } PrefabObjects prefabObjects = networkManager.GetPrefabObjects((ushort)0, false); if ((Object)(object)prefabObjects == (Object)null) { return null; } int objectCount = prefabObjects.GetObjectCount(); for (int i = 0; i < objectCount; i++) { NetworkObject val = prefabObjects.GetObject(true, i); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null && ((Object)((Component)val).gameObject).name == Name) { return ((Component)val).gameObject; } } } catch (Exception ex) { DebugLog.Error("[PrefabRef] Error finding prefab '" + Name + "': " + ex.Message); } return null; } public GameObject? Instantiate() { GameObject val = Find(); if ((Object)(object)val == (Object)null) { DebugLog.Warning("[PrefabRef] Could not find prefab: " + Name); return null; } return Object.Instantiate(val); } public GameObject? InstantiateNetworked() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return InstantiateNetworkedCore(null, Vector3.zero, Quaternion.identity, activate: true); } public GameObject? InstantiateNetworked(Transform parent, Vector3 localPosition, Quaternion localRotation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return InstantiateNetworkedCore(parent, localPosition, localRotation, activate: true); } internal GameObject? InstantiateNetworkedInactive(Transform parent, Vector3 localPosition, Quaternion localRotation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return InstantiateNetworkedCore(parent, localPosition, localRotation, activate: false); } private GameObject? InstantiateNetworkedCore(Transform? parent, Vector3 localPosition, Quaternion localRotation, bool activate) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsServer) { DebugLog.Warning("[PrefabRef] InstantiateNetworked called but not server — skipping '" + Name + "'."); return null; } GameObject val = Find(); if ((Object)(object)val == (Object)null) { DebugLog.Warning("[PrefabRef] Could not find prefab: " + Name); return null; } bool activeSelf = val.activeSelf; val.SetActive(false); GameObject val2 = Object.Instantiate(val); val.SetActive(activeSelf); if ((Object)(object)val2 == (Object)null) { return null; } InitializeGuidFields(val2); if ((Object)(object)parent != (Object)null) { val2.transform.position = parent.TransformPoint(localPosition); val2.transform.rotation = parent.rotation * localRotation; } NetworkObject component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { networkManager.ServerManager.Spawn(component, (NetworkConnection)null, default(Scene)); } if ((Object)(object)parent != (Object)null) { val2.transform.SetParent(parent); val2.transform.localPosition = localPosition; val2.transform.localRotation = localRotation; } if (activate) { val2.SetActive(true); } return val2; } private static void InitializeGuidFields(GameObject instance) { Il2CppArrayBase componentsInChildren = instance.GetComponentsInChildren(true); foreach (MonoBehaviour item in componentsInChildren) { if ((Object)(object)item == (Object)null) { continue; } Type type = ((object)item).GetType(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { try { if (fieldInfo.FieldType == typeof(string) && (fieldInfo.Name.Equals("guid", StringComparison.OrdinalIgnoreCase) || fieldInfo.Name.Contains("guid", StringComparison.OrdinalIgnoreCase))) { string text = fieldInfo.GetValue(item) as string; if (string.IsNullOrEmpty(text) || text == "00000000-0000-0000-0000-000000000000") { fieldInfo.SetValue(item, Guid.NewGuid().ToString()); DebugLog.Info("[PrefabRef] Initialized GUID field '" + fieldInfo.Name + "' on " + type.Name); } } else if (fieldInfo.FieldType == typeof(Guid) && fieldInfo.GetValue(item) is Guid guid && true && guid == Guid.Empty) { fieldInfo.SetValue(item, Guid.NewGuid()); DebugLog.Info("[PrefabRef] Initialized Guid field '" + fieldInfo.Name + "' on " + type.Name); } } catch (Exception ex) { DebugLog.Warning($"[PrefabRef] Failed to initialize field '{fieldInfo.Name}' on {type.Name}: {ex.Message}"); } } } } public override string ToString() { return Name; } public static implicit operator string(PrefabRef prefab) { return prefab.Name; } } public static class S1MAPI { public static string Version => "2.0.1"; public static string Name => "S1MAPI"; } }