Decompiled source of Randomstuff v0.0.4

modbutcool.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BitCode.Extensions;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using Landfall.TABS.UnitEditor;
using Microsoft.CodeAnalysis;
using TFBGames;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("modbutcool")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("modbutcool")]
[assembly: AssemblyTitle("modbutcool")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PROJECTNAMEHERE
{
	[BepInPlugin("org.bepinex.plugins.INSERTMODNAME", "INSERTMODNAME", "1.0.0")]
	internal class Loader : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			Harmony val = new Harmony("INSERTMODNAME");
			val.PatchAll();
			GameObject val2 = new GameObject("INSERTMODNAME");
			Object.DontDestroyOnLoad((Object)(object)val2);
			val2.AddComponent<Main>();
			val2.AddComponent<TME>();
		}
	}
	public class Main : MonoBehaviour
	{
		public void Awake()
		{
			Debug.Log((object)"Loaded INSERTMODNAME Successfully!");
			TME.LoadAssets(reload: false);
			TME.quickboot = false;
			TME.hotbundle = true;
		}
	}
	public class TME : MonoBehaviour
	{
		[HarmonyPatch(typeof(TABSBooter), "Init")]
		private class FastBoot
		{
			[HarmonyPrefix]
			public static void Prefix(TABSBooter __instance)
			{
				if (quickboot)
				{
					LoadLevel();
					Object.Destroy((Object)(object)__instance);
				}
			}
		}

		public static MapAsset MapToLoad;

		public static GameModeState GameMode = (GameModeState)2;

		public static bool quickboot;

		public static bool hotbundle;

		public void Update()
		{
			if (Input.GetKeyDown((KeyCode)290))
			{
				LoadAssets(reload: true);
			}
		}

		public static void LoadAssets(bool reload)
		{
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0911: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_092f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0934: Unknown result type (might be due to invalid IL or missing references)
			//IL_093f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0958: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0971: Unknown result type (might be due to invalid IL or missing references)
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0849: Unknown result type (might be due to invalid IL or missing references)
			//IL_0864: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_098f: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_0808: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0826: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce3: Unknown result type (might be due to invalid IL or missing references)
			LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
			string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TMEBundles");
			bool flag = !Directory.Exists(path);
			bool flag2 = false;
			if (flag)
			{
				Debug.LogError((object)"No TMEBundles Folder Exists!!!");
				flag2 = true;
			}
			string[] array = Array.Empty<string>();
			if (!flag2)
			{
				array = Directory.GetFiles(path);
			}
			if (array.Count() < 1)
			{
				Debug.LogError((object)"No Bundles in Folder!!!");
				flag2 = true;
				array = Assembly.GetExecutingAssembly().GetManifestResourceNames();
			}
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (reload)
				{
					AssetBundle.UnloadAllAssetBundles(true);
				}
				AssetBundle val = null;
				if (!flag2)
				{
					val = AssetBundle.LoadFromFile(text);
				}
				else
				{
					using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text);
					if (stream == null)
					{
						break;
					}
					val = AssetBundle.LoadFromStream(stream);
				}
				List<GameObject> list = val.LoadAllAssets<GameObject>().ToList();
				List<WeaponItem> list2 = (from x in list
					where (Object)(object)x.GetComponent<WeaponItem>() != (Object)null
					select x.GetComponent<WeaponItem>()).ToList();
				List<ProjectileEntity> list3 = (from x in list
					where (Object)(object)x.GetComponent<ProjectileEntity>() != (Object)null
					select x.GetComponent<ProjectileEntity>()).ToList();
				List<SpecialAbility> list4 = (from x in list
					where (Object)(object)x.GetComponent<SpecialAbility>() != (Object)null
					select x.GetComponent<SpecialAbility>()).ToList();
				List<PropItem> list5 = (from x in list
					where (Object)(object)x.GetComponent<PropItem>() != (Object)null
					select x.GetComponent<PropItem>()).ToList();
				List<UnitBlueprint> list6 = val.LoadAllAssets<UnitBlueprint>().ToList();
				List<Faction> list7 = val.LoadAllAssets<Faction>().ToList();
				Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ContentDatabase.Instance().AssetLoader);
				if (list.Count > 0)
				{
					Dictionary<DatabaseID, GameObject> dictionary2 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
					foreach (GameObject item in list)
					{
						Unit component = item.GetComponent<Unit>();
						if (!((Object)(object)component != (Object)null))
						{
							continue;
						}
						if (reload)
						{
							if (dictionary2.ContainsKey(component.Entity.GUID))
							{
								dictionary2.Remove(component.Entity.GUID);
							}
							if (dictionary.ContainsKey(component.Entity.GUID))
							{
								dictionary.Remove(component.Entity.GUID);
							}
						}
						dictionary2.Add(component.Entity.GUID, item.gameObject);
						dictionary.Add(component.Entity.GUID, (Object)(object)item.gameObject);
					}
					typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary2);
				}
				if (list2.Count > 0)
				{
					Dictionary<DatabaseID, GameObject> dictionary3 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
					foreach (WeaponItem item2 in list2)
					{
						if (reload)
						{
							if (dictionary3.ContainsKey(((CharacterItem)item2).Entity.GUID))
							{
								dictionary3.Remove(((CharacterItem)item2).Entity.GUID);
							}
							if (dictionary.ContainsKey(((CharacterItem)item2).Entity.GUID))
							{
								dictionary.Remove(((CharacterItem)item2).Entity.GUID);
							}
						}
						FixColor(((Component)item2).gameObject);
						dictionary3.Add(((CharacterItem)item2).Entity.GUID, ((Component)item2).gameObject);
						dictionary.Add(((CharacterItem)item2).Entity.GUID, (Object)(object)((Component)item2).gameObject);
					}
					typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary3);
				}
				if (list3.Count > 0)
				{
					Dictionary<DatabaseID, GameObject> dictionary4 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
					foreach (ProjectileEntity item3 in list3)
					{
						if (dictionary.ContainsKey(item3.Entity.GUID))
						{
							DatabaseEntity entity = item3.Entity;
							DatabaseID gUID = item3.Entity.GUID;
							gUID.m_ID = item3.Entity.GUID.m_ID + 1;
							gUID.m_modID = -1;
							entity.GUID = gUID;
						}
						if (reload)
						{
							if (dictionary4.ContainsKey(item3.Entity.GUID))
							{
								dictionary4.Remove(item3.Entity.GUID);
							}
							if (dictionary.ContainsKey(item3.Entity.GUID))
							{
								dictionary.Remove(item3.Entity.GUID);
							}
						}
						dictionary4.Add(item3.Entity.GUID, ((Component)item3).gameObject);
						dictionary.Add(item3.Entity.GUID, (Object)(object)((Component)item3).gameObject);
					}
					typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary4);
				}
				if (list4.Count > 0)
				{
					Dictionary<DatabaseID, GameObject> dictionary5 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
					foreach (SpecialAbility item4 in list4)
					{
						for (int num = 0; num < 5; num++)
						{
							if (dictionary.ContainsKey(((CharacterItem)item4).Entity.GUID))
							{
								DatabaseEntity entity2 = ((CharacterItem)item4).Entity;
								DatabaseID gUID = ((CharacterItem)item4).Entity.GUID;
								gUID.m_ID = ((((CharacterItem)item4).Entity.GUID.m_ID >= 2147483646) ? (((CharacterItem)item4).Entity.GUID.m_ID / 3 + 1) : (((CharacterItem)item4).Entity.GUID.m_ID + 2));
								gUID.m_modID = -1;
								entity2.GUID = gUID;
							}
						}
						if (reload)
						{
							if (dictionary5.ContainsKey(((CharacterItem)item4).Entity.GUID))
							{
								dictionary5.Remove(((CharacterItem)item4).Entity.GUID);
							}
							if (dictionary.ContainsKey(((CharacterItem)item4).Entity.GUID))
							{
								dictionary.Remove(((CharacterItem)item4).Entity.GUID);
							}
						}
						FixColor(((Component)item4).gameObject);
						dictionary5.Add(((CharacterItem)item4).Entity.GUID, ((Component)item4).gameObject);
						dictionary.Add(((CharacterItem)item4).Entity.GUID, (Object)(object)((Component)item4).gameObject);
					}
					typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary5);
				}
				if (list5.Count > 0)
				{
					Dictionary<DatabaseID, GameObject> dictionary6 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
					foreach (PropItem item5 in list5)
					{
						if (dictionary.ContainsKey(((CharacterItem)item5).Entity.GUID))
						{
							DatabaseEntity entity3 = ((CharacterItem)item5).Entity;
							DatabaseID gUID = ((CharacterItem)item5).Entity.GUID;
							gUID.m_ID = ((CharacterItem)item5).Entity.GUID.m_ID + 3;
							gUID.m_modID = -1;
							entity3.GUID = gUID;
						}
						if (reload)
						{
							if (dictionary6.ContainsKey(((CharacterItem)item5).Entity.GUID))
							{
								dictionary6.Remove(((CharacterItem)item5).Entity.GUID);
							}
							if (dictionary.ContainsKey(((CharacterItem)item5).Entity.GUID))
							{
								dictionary.Remove(((CharacterItem)item5).Entity.GUID);
							}
						}
						FixColor(((Component)item5).gameObject);
						dictionary6.Add(((CharacterItem)item5).Entity.GUID, ((Component)item5).gameObject);
						dictionary.Add(((CharacterItem)item5).Entity.GUID, (Object)(object)((Component)item5).gameObject);
					}
					typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary6);
				}
				if (list6.Count > 0)
				{
					Dictionary<DatabaseID, UnitBlueprint> dictionary7 = (Dictionary<DatabaseID, UnitBlueprint>)typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
					foreach (UnitBlueprint item6 in list6)
					{
						if (dictionary.ContainsKey(item6.Entity.GUID))
						{
							DatabaseEntity entity4 = item6.Entity;
							DatabaseID gUID = item6.Entity.GUID;
							gUID.m_ID = item6.Entity.GUID.m_ID + 4;
							gUID.m_modID = -1;
							entity4.GUID = gUID;
						}
						if (reload)
						{
							if (dictionary7.ContainsKey(item6.Entity.GUID))
							{
								dictionary7.Remove(item6.Entity.GUID);
							}
							if (dictionary.ContainsKey(item6.Entity.GUID))
							{
								dictionary.Remove(item6.Entity.GUID);
							}
						}
						dictionary7.Add(item6.Entity.GUID, item6);
						dictionary.Add(item6.Entity.GUID, (Object)(object)item6);
					}
					typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary7);
				}
				if (list7.Count <= 0)
				{
					continue;
				}
				Dictionary<DatabaseID, Faction> dictionary8 = (Dictionary<DatabaseID, Faction>)typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
				foreach (Faction item7 in list7)
				{
					if (dictionary.ContainsKey(item7.Entity.GUID))
					{
						DatabaseEntity entity5 = item7.Entity;
						DatabaseID gUID = item7.Entity.GUID;
						gUID.m_ID = item7.Entity.GUID.m_ID + 5;
						gUID.m_modID = -1;
						entity5.GUID = gUID;
					}
					if (reload)
					{
						if (dictionary8.ContainsKey(item7.Entity.GUID))
						{
							dictionary8.Remove(item7.Entity.GUID);
						}
						if (dictionary.ContainsKey(item7.Entity.GUID))
						{
							dictionary.Remove(item7.Entity.GUID);
						}
					}
					dictionary8.Add(item7.Entity.GUID, item7);
					dictionary.Add(item7.Entity.GUID, (Object)(object)item7);
				}
				typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary8);
			}
		}

		public static void FixColor(GameObject asset)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: 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_02a6: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)asset.GetComponent<WeaponItem>()))
			{
				LODGroup orAddComponent = GameObjectExtensions.GetOrAddComponent<LODGroup>(asset);
				orAddComponent.SetLODs((LOD[])(object)new LOD[1]
				{
					new LOD(0f, (from n in asset.GetComponentsInChildren<Renderer>()
						where !((Object)n).name.Contains("Hand") && !(n is ParticleSystemRenderer)
						select n).ToArray())
				});
				GameObjectExtensions.GetOrAddComponent<LodGroupMaterialIndexer>(asset);
			}
			MeshFilter[] array = (from n in asset.GetComponentsInChildren<MeshFilter>()
				where !((Object)n).name.Contains("Hand")
				select n).ToArray();
			Renderer[] array2 = (from n in asset.GetComponentsInChildren<Renderer>()
				where !((Object)n).name.Contains("Hand") && !(n is ParticleSystemRenderer)
				select n).ToArray();
			LodGroupMaterialIndexer componentInChildren = asset.GetComponentInChildren<LodGroupMaterialIndexer>();
			LodGroupMerger componentInChildren2 = asset.GetComponentInChildren<LodGroupMerger>();
			LODGroup componentInChildren3 = asset.GetComponentInChildren<LODGroup>();
			CharacterItem component = asset.GetComponent<CharacterItem>();
			if (Object.op_Implicit((Object)(object)component))
			{
				int num = (from rend in ((Component)component).GetComponentsInChildren<MeshFilter>()
					where Object.op_Implicit((Object)(object)rend) && ((Component)rend).gameObject.activeSelf && ((Component)rend).gameObject.activeInHierarchy && Object.op_Implicit((Object)(object)rend.mesh) && rend.mesh.subMeshCount > 0 && Object.op_Implicit((Object)(object)((Component)rend).GetComponent<MeshRenderer>()) && ((Renderer)((Component)rend).GetComponent<MeshRenderer>()).enabled
					select rend).Sum((MeshFilter rend) => rend.mesh.subMeshCount) + (from rend in ((Component)component).GetComponentsInChildren<SkinnedMeshRenderer>()
					where Object.op_Implicit((Object)(object)rend) && ((Component)rend).gameObject.activeSelf && Object.op_Implicit((Object)(object)rend.sharedMesh) && rend.sharedMesh.subMeshCount > 0 && ((Renderer)rend).enabled
					select rend).Sum((SkinnedMeshRenderer rend) => rend.sharedMesh.subMeshCount);
				if (num > 0)
				{
					float item = 1f / (float)num;
					List<float> list = new List<float>();
					for (int num2 = 0; num2 < num - 1; num2++)
					{
						list.Add(item);
					}
					component.SubmeshArea = list.ToArray();
				}
			}
			if (!Object.op_Implicit((Object)(object)componentInChildren3) || !Object.op_Implicit((Object)(object)componentInChildren) || array2.Length == 0)
			{
				return;
			}
			if (componentInChildren2 != null)
			{
				componentInChildren2.ConsolidateChildLodGroups();
			}
			componentInChildren3.SetLODs((LOD[])(object)new LOD[1]
			{
				new LOD(0f, array2)
			});
			List<LodMaterialContainer> list2 = new List<LodMaterialContainer>();
			for (int num3 = 0; num3 < array2.Length; num3++)
			{
				for (int num4 = 0; num4 < array2[num3].materials.Length; num4++)
				{
					list2.Add(new LodMaterialContainer
					{
						lod0Index = num4,
						lod1Index = num4,
						lod2Index = num4,
						lod0Renderer = array2[num3],
						lod1Renderer = array2[num3],
						lod2Renderer = array2[num3],
						material = array2[num3].material
					});
				}
			}
			typeof(LodGroupMaterialIndexer).GetField("indexedMaterials", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(componentInChildren, list2);
		}

		public static void LoadLevel()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			GameModeService service = ServiceLocator.GetService<GameModeService>();
			if ((int)GameMode == 2)
			{
				CampaignPlayerDataHolder.StartedPlayingSandbox();
				service.SetGameMode<SandboxGameMode>();
			}
			else if ((int)GameMode == 16)
			{
				service.SetGameMode<LocalMultiplayerGameMode>();
			}
			MapToLoad = (from x in ContentDatabase.Instance().GetAllMapAssetsOrdered().ToArray()
				where x.MapName == "00_Simulation_Day_VC"
				select x).First();
			TABSSceneManager.LoadMap(MapToLoad, true);
		}
	}
}