Decompiled source of objImporter v6.3.0

3dSledImporter.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2Cpp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using ModelMod;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(CessnaImporter), "Cessna Importer Ultimate", "3.0.0", "Scott", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("3d modil importer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("3d modil importer")]
[assembly: AssemblyTitle("3d modil importer")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ModelMod;

public class CessnaImporter : MelonMod
{
	private bool _showMenu = false;

	private string _folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), "game");

	private string _status = "Ready";

	private Color _statusColor = Color.white;

	private Rect _windowRect = new Rect(100f, 100f, 400f, 550f);

	private Vector2 _scrollPos = Vector2.zero;

	private GameObject _spawnedModel;

	private GameObject _attachedSled;

	private float _scale = 1f;

	private Vector3 _rotation = Vector3.zero;

	private Vector3 _offset = Vector3.zero;

	private Texture2D _loadedTex;

	private List<Renderer> _hiddenRenderers = new List<Renderer>();

	private MelonPreferences_Category _prefCategory;

	private MelonPreferences_Entry<float> _prefScale;

	private MelonPreferences_Entry<Vector3> _prefRotation;

	private MelonPreferences_Entry<Vector3> _prefOffset;

	private GUIStyle _windowStyle;

	private GUIStyle _labelStyle;

	private GUIStyle _buttonStyle;

	private GUIStyle _textFieldStyle;

	private GUIStyle _headerStyle;

	private bool _stylesInitialized = false;

	public override void OnInitializeMelon()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		_prefCategory = MelonPreferences.CreateCategory("CessnaImporter", "Cessna Importer Settings");
		_prefScale = _prefCategory.CreateEntry<float>("Scale", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefRotation = _prefCategory.CreateEntry<Vector3>("Rotation", Vector3.zero, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefOffset = _prefCategory.CreateEntry<Vector3>("Offset", Vector3.zero, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_scale = _prefScale.Value;
		_rotation = _prefRotation.Value;
		_offset = _prefOffset.Value;
	}

	public override void OnUpdate()
	{
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)277))
		{
			_showMenu = !_showMenu;
			if (_showMenu)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}
		if ((Object)(object)_spawnedModel != (Object)null)
		{
			if ((Object)(object)_attachedSled != (Object)null)
			{
				_spawnedModel.transform.localPosition = _offset;
				_spawnedModel.transform.localRotation = Quaternion.Euler(_rotation);
				_spawnedModel.transform.localScale = Vector3.one * _scale;
			}
			else
			{
				_spawnedModel.transform.localScale = Vector3.one * _scale;
				_spawnedModel.transform.localRotation = Quaternion.Euler(_rotation);
			}
		}
		if (_showMenu)
		{
			if (Input.GetKey((KeyCode)273))
			{
				_scrollPos.y -= 500f * Time.deltaTime;
			}
			if (Input.GetKey((KeyCode)274))
			{
				_scrollPos.y += 500f * Time.deltaTime;
			}
			_scrollPos.y = Mathf.Max(0f, _scrollPos.y);
		}
	}

	public override void OnGUI()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (_showMenu)
		{
			InitializeStyles();
			GUI.backgroundColor = new Color(0.05f, 0.05f, 0.05f, 0.95f);
			_windowRect = GUI.Window(0, _windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "✈\ufe0f Cessna Importer Pro");
		}
	}

	private void InitializeStyles()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Expected O, but got Unknown
		if (!_stylesInitialized)
		{
			_windowStyle = new GUIStyle(GUI.skin.window);
			_windowStyle.padding = new RectOffset(15, 15, 25, 15);
			_headerStyle = new GUIStyle(GUI.skin.label);
			_headerStyle.fontStyle = (FontStyle)1;
			_headerStyle.fontSize = 14;
			_headerStyle.normal.textColor = new Color(0.8f, 0.8f, 1f);
			_labelStyle = new GUIStyle(GUI.skin.label);
			_labelStyle.fontSize = 12;
			_buttonStyle = new GUIStyle(GUI.skin.button);
			_buttonStyle.fixedHeight = 35f;
			_buttonStyle.fontStyle = (FontStyle)1;
			_buttonStyle.hover.textColor = Color.cyan;
			_textFieldStyle = new GUIStyle(GUI.skin.textField);
			_textFieldStyle.fixedHeight = 25f;
			_textFieldStyle.alignment = (TextAnchor)3;
			_stylesInitialized = true;
		}
	}

	private void DrawWindow(int id)
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fd: Expected O, but got Unknown
		//IL_0504: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04de: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Label("MODEL SOURCE CONFIGURATION", _headerStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Space(5f);
		GUILayout.Label("Directory Path:", _labelStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
		_folderPath = GUILayout.TextField(_folderPath, _textFieldStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(15f);
		if (GUILayout.Button("IMPORT AS WORLD OBJECT", _buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			if (Directory.Exists(_folderPath))
			{
				UpdateStatus("Processing model...", Color.yellow);
				LoadModel(_folderPath, attachToSled: false);
			}
			else
			{
				UpdateStatus("Error: Directory not found!", Color.red);
			}
		}
		if (GUILayout.Button("SPAWN & ATTACH TO SLED", _buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			if (Directory.Exists(_folderPath))
			{
				UpdateStatus("Attaching to sled...", Color.yellow);
				LoadModel(_folderPath, attachToSled: true);
			}
			else
			{
				UpdateStatus("Error: Directory not found!", Color.red);
			}
		}
		if ((Object)(object)_spawnedModel != (Object)null && GUILayout.Button("CLEAR / RESET SLED", _buttonStyle, Array.Empty<GUILayoutOption>()))
		{
			CleanupModel();
			UpdateStatus("Cleared.", Color.white);
		}
		if ((Object)(object)_spawnedModel != (Object)null)
		{
			_scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(300f) });
			GUILayout.Label("POSITION OFFSET", _headerStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Offset X:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_offset.x = GUILayout.HorizontalSlider(_offset.x, -5f, 5f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Offset Y:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_offset.y = GUILayout.HorizontalSlider(_offset.y, -5f, 5f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Offset Z:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_offset.z = GUILayout.HorizontalSlider(_offset.z, -5f, 5f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			GUILayout.Label("TRANSFORM CONTROLS", _headerStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label($"Scale: {_scale:F2}", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_scale = GUILayout.HorizontalSlider(_scale, 0.01f, 10f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Rotation X:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_rotation.x = GUILayout.HorizontalSlider(_rotation.x, 0f, 360f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Rotation Y:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_rotation.y = GUILayout.HorizontalSlider(_rotation.y, 0f, 360f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Rotation Z:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			_rotation.z = GUILayout.HorizontalSlider(_rotation.z, 0f, 360f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			if (GUILayout.Button("SAVE CURRENT TRANSFORM", _buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				SaveSettings();
				UpdateStatus("Transform Saved!", Color.green);
			}
			if (GUILayout.Button("Reset Transform", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				_scale = 1f;
				_rotation = Vector3.zero;
				_offset = Vector3.zero;
			}
			GUILayout.EndScrollView();
		}
		GUILayout.FlexibleSpace();
		GUIStyle val = new GUIStyle(_labelStyle);
		val.normal.textColor = _statusColor;
		val.fontStyle = (FontStyle)1;
		val.alignment = (TextAnchor)4;
		GUILayout.BeginVertical(GUI.skin.box, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Label(_status, val, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.EndVertical();
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	private void SaveSettings()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		_prefScale.Value = _scale;
		_prefRotation.Value = _rotation;
		_prefOffset.Value = _offset;
		_prefCategory.SaveToFile(true);
	}

	private void UpdateStatus(string msg, Color col)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		_status = msg;
		_statusColor = col;
		MelonLogger.Msg(msg);
	}

	private void CleanupModel()
	{
		if ((Object)(object)_attachedSled != (Object)null)
		{
			foreach (Renderer hiddenRenderer in _hiddenRenderers)
			{
				if ((Object)(object)hiddenRenderer != (Object)null)
				{
					hiddenRenderer.enabled = true;
				}
			}
			_hiddenRenderers.Clear();
			_attachedSled = null;
		}
		if ((Object)(object)_spawnedModel != (Object)null)
		{
			Object.Destroy((Object)(object)_spawnedModel);
			_spawnedModel = null;
		}
	}

	public void LoadModel(string path, bool attachToSled)
	{
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Expected O, but got Unknown
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Expected O, but got Unknown
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		string path2 = Path.Combine(path, "model.obj");
		string path3 = Path.Combine(path, "texture.png");
		if (!File.Exists(path2))
		{
			UpdateStatus("Error: model.obj missing!", Color.red);
			return;
		}
		PlayerControl val = Object.FindObjectOfType<PlayerControl>();
		if ((Object)(object)val == (Object)null)
		{
			UpdateStatus("Error: Player not found!", Color.red);
			return;
		}
		try
		{
			CleanupModel();
			Mesh val2 = ExampleDeserializer.ParseObj(path2);
			if ((Object)(object)val2 == (Object)null)
			{
				UpdateStatus("Error: Mesh parsing failed!", Color.red);
				return;
			}
			_spawnedModel = new GameObject("Cessna_Injected_Model");
			if (attachToSled)
			{
				Sled val3 = Object.FindObjectOfType<Sled>();
				if ((Object)(object)val3 == (Object)null)
				{
					UpdateStatus("Error: Sled not found in scene!", Color.red);
					Object.Destroy((Object)(object)_spawnedModel);
					_spawnedModel = null;
					return;
				}
				_attachedSled = ((Component)val3).gameObject;
				_spawnedModel.transform.SetParent(((Component)val3).transform, false);
				_spawnedModel.transform.localPosition = _offset;
				_spawnedModel.transform.localRotation = Quaternion.Euler(_rotation);
				foreach (Renderer componentsInChild in ((Component)val3).GetComponentsInChildren<Renderer>(true))
				{
					if ((Object)(object)((Component)componentsInChild).gameObject != (Object)(object)_spawnedModel && !((Component)componentsInChild).transform.IsChildOf(_spawnedModel.transform) && componentsInChild.enabled)
					{
						componentsInChild.enabled = false;
						_hiddenRenderers.Add(componentsInChild);
					}
				}
				MelonLogger.Msg($"Sled hidden. Disabled {_hiddenRenderers.Count} renderers.");
			}
			else
			{
				_spawnedModel.transform.position = ((Component)val).transform.position + ((Component)val).transform.forward * 7f + Vector3.up * 2f;
				_spawnedModel.transform.rotation = ((Component)val).transform.rotation;
			}
			_spawnedModel.AddComponent<MeshFilter>().mesh = val2;
			MeshRenderer val4 = _spawnedModel.AddComponent<MeshRenderer>();
			if (!attachToSled)
			{
				MeshCollider val5 = _spawnedModel.AddComponent<MeshCollider>();
				val5.sharedMesh = val2;
				val5.convex = false;
			}
			Shader shader = ((Renderer)((Component)val).GetComponentInChildren<MeshRenderer>()).material.shader;
			Material val6 = new Material(shader);
			if (File.Exists(path3))
			{
				byte[] array = File.ReadAllBytes(path3);
				_loadedTex = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(_loadedTex, Il2CppStructArray<byte>.op_Implicit(array), false);
				((Texture)_loadedTex).filterMode = (FilterMode)2;
				((Texture)_loadedTex).anisoLevel = 4;
				_loadedTex.Apply(true);
				string[] array2 = new string[4] { "_MainTex", "_BaseMap", "_Albedo", "_MainTexture" };
				string[] array3 = array2;
				foreach (string text in array3)
				{
					if (val6.HasProperty(text))
					{
						val6.SetTexture(text, (Texture)(object)_loadedTex);
					}
				}
				val6.color = Color.white;
				UpdateStatus("Success: Model & Texture Loaded!", Color.green);
			}
			else
			{
				UpdateStatus("Model loaded (No texture).", Color.yellow);
			}
			((Renderer)val4).material = val6;
			_spawnedModel.SetActive(true);
			Object.DontDestroyOnLoad((Object)(object)_spawnedModel);
		}
		catch (Exception ex)
		{
			UpdateStatus("Critical Error: " + ex.Message, Color.red);
			MelonLogger.Error(ex.ToString());
		}
	}
}
public static class ExampleDeserializer
{
	public static Mesh ParseObj(string path)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		if (!File.Exists(path))
		{
			return null;
		}
		try
		{
			Mesh val = new Mesh();
			((Object)val).name = Path.GetFileNameWithoutExtension(path);
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector3> list3 = new List<Vector3>();
			List<Vector3> list4 = new List<Vector3>();
			List<Vector2> list5 = new List<Vector2>();
			List<int> list6 = new List<int>();
			Dictionary<string, int> cache = new Dictionary<string, int>();
			string[] array = File.ReadAllLines(path);
			string[] array2 = array;
			foreach (string text in array2)
			{
				string text2 = text.Trim();
				if (string.IsNullOrEmpty(text2) || text2.StartsWith("#"))
				{
					continue;
				}
				string[] array3 = text2.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
				if (array3.Length < 2)
				{
					continue;
				}
				switch (array3[0])
				{
				case "v":
					list.Add(new Vector3(float.Parse(array3[1]), float.Parse(array3[2]), float.Parse(array3[3])));
					break;
				case "vt":
					list2.Add(new Vector2(float.Parse(array3[1]), float.Parse(array3[2])));
					break;
				case "vn":
					list3.Add(new Vector3(float.Parse(array3[1]), float.Parse(array3[2]), float.Parse(array3[3])));
					break;
				case "f":
				{
					for (int j = 1; j < array3.Length - 2; j++)
					{
						AddVertex(array3[1], list, list2, list4, list5, list6, cache);
						AddVertex(array3[j + 1], list, list2, list4, list5, list6, cache);
						AddVertex(array3[j + 2], list, list2, list4, list5, list6, cache);
					}
					break;
				}
				}
			}
			if (list4.Count == 0)
			{
				return null;
			}
			val.vertices = Il2CppStructArray<Vector3>.op_Implicit(list4.ToArray());
			val.uv = Il2CppStructArray<Vector2>.op_Implicit((Vector2[])((list5.Count == list4.Count) ? ((Array)list5.ToArray()) : ((Array)new Vector2[list4.Count])));
			val.triangles = Il2CppStructArray<int>.op_Implicit(list6.ToArray());
			val.RecalculateNormals();
			val.RecalculateBounds();
			val.bounds = new Bounds(Vector3.zero, Vector3.one * 10000f);
			return val;
		}
		catch (Exception ex)
		{
			Debug.LogError(Object.op_Implicit("[ExampleDeserializer] Error parsing OBJ: " + ex.Message));
			return null;
		}
	}

	private static void AddVertex(string vertexData, List<Vector3> v, List<Vector2> vt, List<Vector3> outV, List<Vector2> outVT, List<int> outT, Dictionary<string, int> cache)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		if (cache.TryGetValue(vertexData, out var value))
		{
			outT.Add(value);
			return;
		}
		string[] array = vertexData.Split('/');
		int num = int.Parse(array[0]);
		if (num < 0)
		{
			num = v.Count + num + 1;
		}
		outV.Add(v[num - 1]);
		if (array.Length > 1 && !string.IsNullOrEmpty(array[1]))
		{
			int num2 = int.Parse(array[1]);
			if (num2 < 0)
			{
				num2 = vt.Count + num2 + 1;
			}
			outVT.Add(vt[num2 - 1]);
		}
		else
		{
			outVT.Add(Vector2.zero);
		}
		int num3 = outV.Count - 1;
		outT.Add(num3);
		cache.Add(vertexData, num3);
	}
}