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 DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using Landfall.TABS.UnitEditor;
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(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[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")]
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 static void LoadAssets(bool reload)
{
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0564: Unknown result type (might be due to invalid IL or missing references)
//IL_057f: Unknown result type (might be due to invalid IL or missing references)
//IL_0505: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_068f: Unknown result type (might be due to invalid IL or missing references)
//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0630: Unknown result type (might be due to invalid IL or missing references)
//IL_0534: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_07ba: 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_075b: Unknown result type (might be due to invalid IL or missing references)
//IL_065f: 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_054e: Unknown result type (might be due to invalid IL or missing references)
//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0886: Unknown result type (might be due to invalid IL or missing references)
//IL_078a: Unknown result type (might be due to invalid IL or missing references)
//IL_0775: Unknown result type (might be due to invalid IL or missing references)
//IL_0679: Unknown result type (might be due to invalid IL or missing references)
//IL_0a06: Unknown result type (might be due to invalid IL or missing references)
//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
//IL_08a0: Unknown result type (might be due to invalid IL or missing references)
//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
//IL_09c1: Unknown result type (might be due to invalid IL or missing references)
//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
//IL_09f0: 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");
if (!Directory.Exists(path))
{
Debug.LogError((object)"No TMEBundles Folder Exists!!!");
return;
}
string[] files = Directory.GetFiles(path);
if (files.Count() < 1)
{
Debug.LogError((object)"No Bundles in Folder!!!");
return;
}
string[] array = files;
foreach (string text in array)
{
if (reload)
{
AssetBundle.UnloadAllAssetBundles(true);
}
AssetBundle val = AssetBundle.LoadFromFile(text);
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);
}
}
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 (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)
{
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);
}
}
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 (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);
}
}
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 (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 (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 void Update()
{
if (Input.GetKeyDown((KeyCode)290))
{
LoadAssets(reload: true);
}
}
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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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);
}
}