Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of S1MAPI v1.0.0
UserLibs/S1MAPI_Il2Cpp.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Managing; using Il2CppFishNet.Managing.Object; using Il2CppFishNet.Object; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections; 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("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+64e8ce48b2f6106e63138134e5649f668c6ef814")] [assembly: AssemblyProduct("S1MAPI")] [assembly: AssemblyTitle("S1MAPI")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ifBars/S1MAPI")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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 static class Resources { public const float DefaultPixelsPerUnit = 100f; } public static class Spatial { public const float DefaultGridSize = 0.5f; } 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 = "1.0.0"; 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<byte>.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<T> AsEnumerable<T>(this List<T> list) { return list ?? new List<T>(); } public static List<T> ToIl2CppList<T>(this IEnumerable<T> source) { List<T> val = new List<T>(); foreach (T item in source) { val.Add(item); } return val; } public static List<T> ToCSharpList<T>(this List<T> il2CppList) { if (il2CppList == null) { return new List<T>(); } List<T> list = new List<T>(); T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray()); list.AddRange(collection); return list; } public static IEnumerable<T> AsEnumerable<T>(this List<T> list) { if (list == null) { return new List<T>(); } return ((IEnumerable<T>)list._items).Take(list._size); } } internal static class CrossType { public static Type Of<T>() { return Il2CppType.Of<T>(); } public static Type ToRuntimeType(Type systemType) { return Il2CppType.From(systemType); } public static bool Is<T>(object obj, out T result) where T : Object { Object val = (Object)((obj is Object) ? obj : null); if (val != null) { Type val2 = Il2CppType.Of<T>(); Type il2CppType = val.GetIl2CppType(); if (val2.IsAssignableFrom(il2CppType)) { result = ((Il2CppObjectBase)val).TryCast<T>(); 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<Texture>(textureName); if ((Object)(object)val == (Object)null) { Texture2D[] array = Il2CppArrayBase<Texture2D>.op_Implicit(Resources.FindObjectsOfTypeAll<Texture2D>()); 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<Material>(materialName); if ((Object)(object)val != (Object)null) { return val; } Material[] array = Il2CppArrayBase<Material>.op_Implicit(Resources.FindObjectsOfTypeAll<Material>()); 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 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)(ref color)).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 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)(ref color)).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 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)(ref color)).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 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)(ref color)).ToString(); if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } return val; } public 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)(ref color)).ToString(); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", color * intensity); val.EnableKeyword("_EMISSION"); } return val; } public 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)(ref color)).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 @string = Encoding.UTF8.GetString(data); return LoadGltfJson(@string, 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<GltfRoot>(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 @string = Encoding.UTF8.GetString(array); try { root = JsonConvert.DeserializeObject<GltfRoot>(@string); } 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<Texture2D> list = ProcessTextures(gltfLoadContext); List<Material> list2 = GltfMaterialProcessor.ProcessMaterials(gltfLoadContext); List<GltfMeshResult> 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<AnimationClip> list4 = GltfAnimationProcessor.ProcessAnimations(gltfLoadContext); if (list4.Count > 0) { Animation val2 = val.AddComponent<Animation>(); 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<Texture2D?> ProcessTextures(GltfLoadContext context) { GltfRoot root = context.Root; List<Texture2D> list = new List<Texture2D>(); 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); if ((Object)(object)val != (Object)null) { 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<byte>.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<GltfMeshResult> ProcessMeshes(GltfLoadContext context) { GltfRoot root = context.Root; byte[] binaryBuffer = root.buffers?[0]?.Data; List<GltfMeshResult> 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<GltfMeshResult> meshResults, List<Material> 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<int, Transform> dictionary = new Dictionary<int, Transform>(); 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_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_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_008a: 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_0092: 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_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_00b1: 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_00c5: 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_00d7: 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_016f: 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) if (node.matrix != null && node.matrix.Length == 16) { Matrix4x4 val = default(Matrix4x4); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { ((Matrix4x4)(ref val))[j, i] = node.matrix[i * 4 + j]; } } 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<Material> materials, GltfLoadContext context) { if ((Object)(object)meshResult?.mesh == (Object)null) { return; } MeshFilter val = go.AddComponent<MeshFilter>(); val.mesh = meshResult.mesh; MeshRenderer val2 = go.AddComponent<MeshRenderer>(); 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<Material>.op_Implicit(array); } private void AttachCamera(GameObject go, GltfCamera gltfCamera) { Camera val = go.AddComponent<Camera>(); 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<AnimationClip> ProcessAnimations(GltfLoadContext context) { List<AnimationClip> list = new List<AnimationClip>(); 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<Transform>(), "localPosition.x", val); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "localPosition.y", val2); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "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<Transform>(), "localRotation.x", val); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "localRotation.y", val2); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "localRotation.z", val3); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "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<Transform>(), "localScale.x", val); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "localScale.y", val2); clip.SetCurve(nodePath, Il2CppType.Of<Transform>(), "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<SkinnedMeshRenderer>(), text, array2[l]); } } private static string? GetNodePath(GltfLoadContext context, int nodeIndex) { Transform nodeTransform = c
UserLibs/S1MAPI_Mono.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using FishNet; using FishNet.Connection; using FishNet.Managing; using FishNet.Managing.Object; using FishNet.Object; 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 TMPro; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("S1MAPI Contributors")] [assembly: AssemblyConfiguration("Mono")] [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("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+64e8ce48b2f6106e63138134e5649f668c6ef814")] [assembly: AssemblyProduct("S1MAPI")] [assembly: AssemblyTitle("S1MAPI")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ifBars/S1MAPI")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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 static class Resources { public const float DefaultPixelsPerUnit = 100f; } public static class Spatial { public const float DefaultGridSize = 0.5f; } 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 = "1.0.0"; 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)("[S1MAPI] " + message)); } } public static void Warning(string message) { if (_debugEnabled) { Debug.LogWarning((object)("[S1MAPI] " + message)); } } public static void Error(string message) { Debug.LogError((object)("[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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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, 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<T> AsEnumerable<T>(this List<T> list) { return list ?? new List<T>(); } } internal static class CrossType { public static Type Of<T>() { return typeof(T); } public static Type ToRuntimeType(Type systemType) { return systemType; } public static bool Is<T>(object obj, out T result) where T : class { if (obj is T val) { result = val; return true; } result = null; return false; } } internal static class CrossException { public static void LogException(Exception ex) { Debug.LogException(ex); } public static void LogException(string message, Exception ex) { Debug.LogError((object)message); Debug.LogException(ex); } } 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_008e: 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_0113: 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) Texture val = Resources.Load<Texture>(textureName); if ((Object)(object)val == (Object)null) { Texture2D[] array = Resources.FindObjectsOfTypeAll<Texture2D>(); 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<Material>(materialName); if ((Object)(object)val != (Object)null) { return val; } Material[] array = Resources.FindObjectsOfTypeAll<Material>(); 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 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)(ref color)).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 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_002f: 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_0036: 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_004f: Expected O, but got Unknown Material val = new Material(DefaultShader) { name = $"MAPI_Transparent_{((object)(Color)(ref color)).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 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)(ref color)).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 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)(ref color)).ToString(); if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } return val; } public 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)(ref color)).ToString(); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", color * intensity); val.EnableKeyword("_EMISSION"); } return val; } public 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)(ref color)).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 @string = Encoding.UTF8.GetString(data); return LoadGltfJson(@string, 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<GltfRoot>(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 @string = Encoding.UTF8.GetString(array); try { root = JsonConvert.DeserializeObject<GltfRoot>(@string); } 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<Texture2D> list = ProcessTextures(gltfLoadContext); List<Material> list2 = GltfMaterialProcessor.ProcessMaterials(gltfLoadContext); List<GltfMeshResult> 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<AnimationClip> list4 = GltfAnimationProcessor.ProcessAnimations(gltfLoadContext); if (list4.Count > 0) { Animation val2 = val.AddComponent<Animation>(); 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<Texture2D?> ProcessTextures(GltfLoadContext context) { GltfRoot root = context.Root; List<Texture2D> list = new List<Texture2D>(); 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); if ((Object)(object)val != (Object)null) { 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, 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<GltfMeshResult> ProcessMeshes(GltfLoadContext context) { GltfRoot root = context.Root; byte[] binaryBuffer = root.buffers?[0]?.Data; List<GltfMeshResult> 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<GltfMeshResult> meshResults, List<Material> materials) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown GltfRoot root2 = context.Root; if (root2.nodes == null) { return; } Dictionary<int, Transform> dictionary = new Dictionary<int, Transform>(); 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_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_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_008a: 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_0092: 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_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_00b1: 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_00c5: 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_00d7: 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_016f: 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) if (node.matrix != null && node.matrix.Length == 16) { Matrix4x4 val = default(Matrix4x4); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { ((Matrix4x4)(ref val))[j, i] = node.matrix[i * 4 + j]; } } 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<Material> materials, GltfLoadContext context) { if ((Object)(object)meshResult?.mesh == (Object)null) { return; } MeshFilter val = go.AddComponent<MeshFilter>(); val.mesh = meshResult.mesh; MeshRenderer val2 = go.AddComponent<MeshRenderer>(); 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 = array; } private void AttachCamera(GameObject go, GltfCamera gltfCamera) { Camera val = go.AddComponent<Camera>(); 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<AnimationClip> ProcessAnimations(GltfLoadContext context) { List<AnimationClip> list = new List<AnimationClip>(); 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, typeof(Transform), "localPosition.x", val); clip.SetCurve(nodePath, typeof(Transform), "localPosition.y", val2); clip.SetCurve(nodePath, typeof(Transform), "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, typeof(Transform), "localRotation.x", val); clip.SetCurve(nodePath, typeof(Transform), "localRotation.y", val2); clip.SetCurve(nodePath, typeof(Transform), "localRotation.z", val3); clip.SetCurve(nodePath, typeof(Transform), "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, typeof(Transform), "localScale.x", val); clip.SetCurve(nodePath, typeof(Transform), "localScale.y", val2); clip.SetCurve(nodePath, typeof(Transform), "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, typeof(SkinnedMeshRenderer), 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<string> list = new List<string>(); 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 valueOrDefault = (context.GetBufferView(accessor.bufferView.GetValueOrDefault())?.byteStride).GetValueOrDefault(4); int count = accessor.count; float[] array = new float[count]; for (int i = 0; i < count; i++) { int num = accessor.byteOffset + i * valueOrDefault; if (num + 4 <= accessorData.Length) { array[i] = BitConverter.ToSingle(accessorData, num); } } 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