Decompiled source of Aloft Mod Framework v0.1.1

plugins/AloftModFramework.dll

Decompiled 2 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Audio;
using Crafting.MultiStep_Construction;
using Player.Player_Equip;
using Scriptable_Objects;
using Terrain.Platforms.Population.Population_Soul;
using UnityEngine;
using Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AloftModFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AloftModFramework")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2c8094d2-d585-4522-856b-887566291b48")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AloftModFramework.Items;

[CreateAssetMenu(fileName = "Item", menuName = "AloftModFramework/Item")]
public class AloftModFrameworkItem : ScriptableObject
{
	public int ItemId;

	public string Name;

	public string Description;

	public Sprite DisplaySprite;

	public ItemCatergory Category;

	public ItemType Type;

	public ItemWeight Weight;

	public Equipable EquipType;

	public PickUpAudioTagID AudioPickupID;

	public ItemTagID[] ItemTags;
}
[CreateAssetMenu(fileName = "Item", menuName = "AloftModFramework/Crafting Recipe")]
public class AloftModFrameworkCraftingRecipe : ScriptableObject
{
	public int[] InputItems;

	public ID OutputVanillaItem;

	public int OutputItemId;

	public AloftModFrameworkItem OutputModItem;

	public int Quantity;
}
[CreateAssetMenu(fileName = "Item", menuName = "AloftModFramework/Localization Resource")]
public class AloftModFrameworkLocalization : ScriptableObject
{
	public TextAsset LocalizationFile;

	public string Language;
}
[CreateAssetMenu(fileName = "Item", menuName = "AloftModFramework/Building")]
public class AloftModFrameworkBuildingData : ScriptableObject
{
	public int PopulationId;

	public GameObject InstancePrefab;

	public BehaviourTypeEnum BehaviourType;

	public MultiStepBehaviour MultiStepBehaviour;

	public SpawnDistance LoadDistance = (SpawnDistance)2;

	public PopDataTagID[] PopDataTags;

	public bool CanLearnViaSketchbook;
}
[CreateAssetMenu(fileName = "Item", menuName = "AloftModFramework/Building Blueprint")]
public class AloftModFrameworkBuildingBlueprint : ScriptableObject
{
	public bool HideInBuildMenu;

	public string DisplayName;

	public string DisplayDescription;

	public Sprite DisplaySprite;

	public BuildingCategory Category;

	public AloftModFrameworkBuildingData BuildingData;

	public AloftModFrameworkBuildingData IsVariantOf;

	public AloftModFrameworkBuildingData[] Variants;

	public float DefaultScale = 1f;

	public CraftingCostClass[] CraftingCost;

	public CraftingCostClass[] HammerCost;

	public ID[] PopToUnlockAsWell;

	public ConstructionMaterial AudioType;
}

plugins/AloftModLoader.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AloftModFramework.Items;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using HarmonyLib;
using Level_Manager;
using Scriptable_Objects;
using Terrain.Platforms;
using Terrain.Platforms.Population;
using Terrain.Platforms.Population.Population_Soul;
using Terrain.Platforms.Types;
using UI;
using UnityEngine;
using Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AloftModLoader")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AloftModLoader")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ca65db7c-4146-4b05-9939-88295bc95139")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AloftModLoader;

public static class LinqExtensions
{
	public static IEnumerable<T> ForEach<T>(this IEnumerable<T> source, Action<T> action)
	{
		foreach (T item in source)
		{
			action(item);
		}
		return source;
	}
}
internal static class ItemPatches
{
	public static ScriptableInventoryItem RewriteItemIdResult(ScriptableInventoryItem __result, ID id)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__result == (Object)null)
		{
			return ((IEnumerable<ScriptableInventoryItem>)AloftModLoader.Items).FirstOrDefault((Func<ScriptableInventoryItem, bool>)((ScriptableInventoryItem x) => x.ID == id));
		}
		return __result;
	}
}
internal static class RecipePatches
{
	private static IList PatchedGroups = new List<CraftingStation>();

	public static ScriptableCraftRecipeGroup RewriteRecipeResult(ScriptableCraftRecipeGroup __result, CraftingStation stationType)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__result == (Object)null)
		{
		}
		if (!PatchedGroups.Contains(stationType))
		{
			__result.Recipes = CollectionExtensions.AddRangeToArray<ScriptableCraftRecipe>(__result.Recipes, AloftModLoader.Recipes.ToArray());
			Level.CraftingManager.UnlockRecipe.UnlockRecipes(AloftModLoader.Recipes.Select((ScriptableCraftRecipe recipe) => recipe.Output.ItemID).ToArray());
			foreach (ScriptableCraftRecipe recipe in AloftModLoader.Recipes)
			{
			}
			PatchedGroups.Add(stationType);
		}
		return __result;
	}
}
internal static class LocalizationPatches
{
	public static Dictionary<string, string> LocalizationValues = new Dictionary<string, string>();

	public static void SetLanguage(int index)
	{
		LocalizationValues.Clear();
		string localizationName = Localization.GetLanguageName(index);
		AloftModFrameworkLocalization val = ((IEnumerable<AloftModFrameworkLocalization>)AloftModLoader.Localizations).FirstOrDefault((Func<AloftModFrameworkLocalization, bool>)((AloftModFrameworkLocalization x) => x.Language.Equals(localizationName)));
		AloftModFrameworkLocalization val2 = (((Object)(object)val == (Object)null) ? AloftModLoader.Localizations.FirstOrDefault() : null);
		if (!((Object)(object)val2 != (Object)null))
		{
			return;
		}
		string[] array = val2.LocalizationFile.text.Split(new char[1] { '\n' });
		foreach (string text in array)
		{
			if (!string.IsNullOrEmpty(text))
			{
				string[] array2 = text.Split(new char[1] { '\t' });
				if (array2.Length == 2)
				{
					LocalizationValues.Add(array2[0], array2[1]);
				}
				else
				{
					Console.WriteLine("Error with entry: " + text);
				}
			}
		}
	}

	public static string GetLocalizedValue(string __result, string key)
	{
		if (string.IsNullOrEmpty(__result) && LocalizationValues.TryGetValue(key, out var value))
		{
			return value;
		}
		return __result;
	}
}
internal static class BuildingHooks
{
	public static bool PopulationDataAdded;

	private static bool Learned;

	public static void InitListExtension()
	{
		if (!PopulationDataAdded)
		{
			PopulationDataAdded = true;
			ScriptablePopulationDataManager populationDataManager = Level.TerrainManager.PopulationManager.PopulationDataManager;
			ScriptablePopulationData[] allPopulationData = Level.TerrainManager.PopulationManager.PopulationDataManager.AllPopulationData;
			ScriptablePopulationData[] array = (ScriptablePopulationData[])(object)AloftModLoader.Buildings.ToArray();
			populationDataManager.AllPopulationData = CollectionExtensions.AddRangeToArray<ScriptablePopulationData>(allPopulationData, array);
		}
	}

	public static ScriptableCrafting GetCrafting(ScriptableCrafting __result, ID id)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		if (!Learned)
		{
			Learned = true;
			Console.WriteLine("Learning blueprints!");
			AloftModLoader.BuildingBlueprints.ForEach(delegate(ScriptableCrafting blueprint)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				Console.WriteLine("Learning blueprint " + ((Object)blueprint).name);
				Level.CraftingManager.UnlockRecipe.UnlockNewRecipeBuilding(blueprint.PopData.PopulationID, true, false);
			});
		}
		InitListExtension();
		ScriptableCrafting val = ((IEnumerable<ScriptableCrafting>)AloftModLoader.BuildingBlueprints).FirstOrDefault((Func<ScriptableCrafting, bool>)((ScriptableCrafting x) => x.ID == id));
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		return __result;
	}

	public static ScriptablePopulationData GetPopulationData(ScriptablePopulationData __result, ID populationID)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		if (AloftModLoader.Buildings != null && AloftModLoader.Buildings.Count > 0)
		{
			AloftModFrameworkPopulationData aloftModFrameworkPopulationData = AloftModLoader.Buildings.FirstOrDefault((AloftModFrameworkPopulationData x) => ((ScriptablePopulationData)x).PopulationID == populationID);
			if ((Object)(object)aloftModFrameworkPopulationData != (Object)null)
			{
				return (ScriptablePopulationData)(object)aloftModFrameworkPopulationData;
			}
		}
		return __result;
	}

	public static ScriptablePopulationData GetPopulationData2(ScriptablePopulationData __result, ID popID)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		return GetPopulationData(__result, popID);
	}

	public static GameObject GetPrefabGameObject(GameObject __result, ScriptablePopulationData __instance)
	{
		if ((Object)(object)__result == (Object)null && __instance is AloftModFrameworkPopulationData)
		{
			return ((AloftModFrameworkPopulationData)(object)__instance).Prefab;
		}
		return __result;
	}
}
public static class Cheats
{
	public static bool ProcessCommand(ref bool __result, string input)
	{
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: 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_02f9: Unknown result type (might be due to invalid IL or missing references)
		string[] array = input.Split(new char[1] { ' ' });
		if (array.Length != 0)
		{
			Console.WriteLine(input);
			switch (array[0])
			{
			case "showpop":
			{
				PlatformGlobalData homeIsland = Level.TerrainManager.PlatformManager.HomeIsland;
				Console.WriteLine("Is island null? " + (homeIsland == null));
				PopulationSoul val4 = ((IEnumerable<PopulationSoul>)homeIsland.PopulationSouls.Values).FirstOrDefault((Func<PopulationSoul, bool>)((PopulationSoul x) => (int)x.PopulationID == 400003));
				Console.WriteLine("Is bee pop null? " + (val4 == null));
				Vector3 localPosition = val4.LocalPosition;
				Console.WriteLine("Pop location is " + ((object)(Vector3)(ref localPosition)).ToString());
				__result = true;
				return false;
			}
			case "learn":
			{
				string text3 = array[1];
				string text4 = text3;
				if (!(text4 == "building"))
				{
					if (!(text4 == "recipe") || !int.TryParse(array[2], out var result))
					{
						break;
					}
					Level.CraftingManager.UnlockRecipe.LearnItemRecipe((ID)result);
					__result = true;
					return false;
				}
				Console.WriteLine("Learning building!");
				if (!int.TryParse(array[2], out var result2))
				{
					break;
				}
				Console.WriteLine("Learned building!");
				Level.CraftingManager.UnlockRecipe.UnlockNewRecipeBuilding((ID)result2, true, false);
				__result = true;
				return false;
			}
			case "spawn":
			{
				string text = array[1];
				string text2 = text;
				if (text2 == "pop" && int.TryParse(array[2], out var popId))
				{
					AloftModFrameworkPopulationData aloftModFrameworkPopulationData = AloftModLoader.Buildings.FirstOrDefault((AloftModFrameworkPopulationData x) => (int)((ScriptablePopulationData)x).PopulationID == popId);
					if ((Object)(object)aloftModFrameworkPopulationData != (Object)null)
					{
						PlatformAbstract cachedPlatform = ((AffectedByPlatform)Level.PlayerManager.AffectedByPlatform).CachedPlatform;
						Vector3 val = cachedPlatform.AffectedObjectParent.InverseTransformPoint(Level.PlayerManager.Anatomy.Pivot.position);
						Transform pivot = Level.PlayerManager.Anatomy.Pivot;
						Console.WriteLine("Location is " + val.x + "," + val.y + "," + val.z);
						Console.WriteLine("Ghost prefab is" + ((Object)((ScriptablePopulationData)aloftModFrameworkPopulationData).ScriptableCrafting.CustomGhostPrefab).name);
						Vector3 val2 = default(Vector3);
						((Vector3)(ref val2))..ctor(6010f, 724f, 26658f);
						GameObject val3 = Object.Instantiate<GameObject>(((ScriptablePopulationData)aloftModFrameworkPopulationData).ScriptableCrafting.CustomGhostPrefab, val2, Quaternion.identity);
						__result = true;
						return false;
					}
				}
				break;
			}
			}
		}
		return true;
	}
}
public class AloftModFrameworkPopulationData : ScriptablePopulationData
{
	public GameObject Prefab;
}
[BepInPlugin("aloftmodloader.sessional.dev", "Aloft Mod Loader", "0.1.1")]
public class AloftModLoader : BaseUnityPlugin
{
	private const string GUID = "aloftmodloader.sessional.dev";

	private const string NAME = "Aloft Mod Loader";

	private const string VERSION = "0.1.1";

	public static Shader shaderEveryoneNeeds;

	private static List<AssetBundle> bundles;

	private static List<Object> allAssets;

	public static List<ScriptableInventoryItem> Items;

	public static List<ScriptableCraftRecipe> Recipes;

	public static List<ScriptableCrafting> BuildingBlueprints;

	public static List<AloftModFrameworkPopulationData> Buildings;

	public static List<AloftModFrameworkLocalization> Localizations;

	public static List<GameObject> GameObjects;

	public static Material hackyShader;

	private static FieldInfo LocalizationField;

	public static ManualLogSource LoggerRef;

	public void Start()
	{
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_039c: Expected O, but got Unknown
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Expected O, but got Unknown
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Expected O, but got Unknown
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Expected O, but got Unknown
		//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c1: Expected O, but got Unknown
		//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Expected O, but got Unknown
		//IL_053e: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Expected O, but got Unknown
		//IL_0583: Unknown result type (might be due to invalid IL or missing references)
		//IL_0590: Expected O, but got Unknown
		//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Expected O, but got Unknown
		//IL_060d: Unknown result type (might be due to invalid IL or missing references)
		//IL_061a: Expected O, but got Unknown
		//IL_0651: Unknown result type (might be due to invalid IL or missing references)
		//IL_065f: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Running!");
		string text = Path.Combine(Application.streamingAssetsPath, "amf");
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Bundle directory: " + text));
		string[] files = Directory.GetFiles(text);
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Bundle names: " + string.Join(",", files)));
		shaderEveryoneNeeds = Shader.Find("Amplify/V2/DefaultPBR_Interactive");
		Texture2D val = Resources.Load<Texture2D>("white");
		bundles = files.Where((string x) => !x.EndsWith(".manifest")).Distinct().Select(delegate(string x)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Loading asset bundle {x}");
			return AssetBundle.LoadFromFile(x);
		})
			.ToList();
		allAssets = bundles.SelectMany((AssetBundle x) => x.LoadAllAssets()).ForEach(delegate(Object x)
		{
			Object.DontDestroyOnLoad(x);
			x.hideFlags = (HideFlags)61;
		}).ToList();
		Items = allAssets.Where((Object x) => x is AloftModFrameworkItem).Cast<AloftModFrameworkItem>().Select(delegate(AloftModFrameworkItem x)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			ScriptableObject obj4 = ScriptableObject.CreateInstance(typeof(ScriptableInventoryItem));
			ScriptableInventoryItem val11 = (ScriptableInventoryItem)(object)((obj4 is ScriptableInventoryItem) ? obj4 : null);
			val11.DisplayName = x.Name;
			val11.DisplayDescription = x.Description;
			val11.Category = x.Category;
			val11.DisplaySprite = x.DisplaySprite;
			val11.ID = (ID)x.ItemId;
			val11.Type = x.Type;
			val11.Weight = x.Weight;
			val11.EquipType = x.EquipType;
			val11.AudioPickupID = x.AudioPickupID;
			val11.ItemTags = x.ItemTags;
			((Object)val11).hideFlags = (HideFlags)61;
			return val11;
		})
			.ToList();
		Recipes = allAssets.Where((Object x) => x is AloftModFrameworkCraftingRecipe).Cast<AloftModFrameworkCraftingRecipe>().Select(delegate(AloftModFrameworkCraftingRecipe x)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c8: Expected O, but got Unknown
			ScriptableObject obj3 = ScriptableObject.CreateInstance(typeof(ScriptableCraftRecipe));
			ScriptableCraftRecipe val9 = (ScriptableCraftRecipe)(object)((obj3 is ScriptableCraftRecipe) ? obj3 : null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Generating recipe: " + ((Object)x).name));
			val9.Input = x.InputItems.Select((int input) => (ID)input).ToArray();
			((Object)val9).hideFlags = (HideFlags)61;
			ID val10 = (((int)x.OutputVanillaItem > 0) ? x.OutputVanillaItem : ((!((Object)(object)x.OutputModItem != (Object)null)) ? ((ID)x.OutputItemId) : ((ID)x.OutputModItem.ItemId)));
			val9.Output = new CraftingCostClass(val10, x.Quantity);
			return val9;
		})
			.ToList();
		List<AloftModFrameworkBuildingBlueprint> buildingBlueprints = allAssets.Where((Object x) => x is AloftModFrameworkBuildingBlueprint).Cast<AloftModFrameworkBuildingBlueprint>().ToList();
		List<AloftModFrameworkPopulationData> list = (from AloftModFrameworkBuildingData x in allAssets.Where((Object x) => x is AloftModFrameworkBuildingData)
			where (Object)(object)((IEnumerable<AloftModFrameworkBuildingBlueprint>)buildingBlueprints).FirstOrDefault((Func<AloftModFrameworkBuildingBlueprint, bool>)((AloftModFrameworkBuildingBlueprint y) => y.BuildingData.PopulationId == x.PopulationId)) == (Object)null
			select x).Select(delegate(AloftModFrameworkBuildingData x)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			AloftModFrameworkPopulationData aloftModFrameworkPopulationData2 = ScriptableObject.CreateInstance(typeof(AloftModFrameworkPopulationData)) as AloftModFrameworkPopulationData;
			((ScriptablePopulationData)aloftModFrameworkPopulationData2).PopulationID = (ID)x.PopulationId;
			aloftModFrameworkPopulationData2.Prefab = x.InstancePrefab;
			((ScriptablePopulationData)aloftModFrameworkPopulationData2).BehaviourType = x.BehaviourType;
			((ScriptablePopulationData)aloftModFrameworkPopulationData2).MultiStepBehaviour = x.MultiStepBehaviour;
			((ScriptablePopulationData)aloftModFrameworkPopulationData2).LoadDistance = x.LoadDistance;
			((ScriptablePopulationData)aloftModFrameworkPopulationData2).PopDataTags = x.PopDataTags;
			if (x.CanLearnViaSketchbook)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"A building {((Object)x).name} was marked with CanLearnViaSketchbook but it has no corresponding Blueprint to make it buildable.");
			}
			return aloftModFrameworkPopulationData2;
		}).ToList();
		var source = (from AloftModFrameworkBuildingData x in allAssets.Where((Object x) => x is AloftModFrameworkBuildingData)
			where (Object)(object)((IEnumerable<AloftModFrameworkBuildingBlueprint>)buildingBlueprints).FirstOrDefault((Func<AloftModFrameworkBuildingBlueprint, bool>)((AloftModFrameworkBuildingBlueprint y) => y.BuildingData.PopulationId == x.PopulationId)) != (Object)null
			select x).Select(delegate(AloftModFrameworkBuildingData building)
		{
			//IL_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Building building data:" + ((Object)building).name));
			AloftModFrameworkPopulationData aloftModFrameworkPopulationData = ScriptableObject.CreateInstance(typeof(AloftModFrameworkPopulationData)) as AloftModFrameworkPopulationData;
			((Object)aloftModFrameworkPopulationData).hideFlags = (HideFlags)61;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).PopulationID = (ID)building.PopulationId;
			aloftModFrameworkPopulationData.Prefab = building.InstancePrefab;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).BehaviourType = building.BehaviourType;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).MultiStepBehaviour = building.MultiStepBehaviour;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).LoadDistance = building.LoadDistance;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).PopDataTags = building.PopDataTags;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).PrefabPaths = new string[0];
			AloftModFrameworkBuildingBlueprint val7 = buildingBlueprints.First((AloftModFrameworkBuildingBlueprint blueprint) => (Object)(object)blueprint.BuildingData == (Object)(object)building);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Building corresponding blueprint data:" + ((Object)val7).name));
			ScriptableObject obj2 = ScriptableObject.CreateInstance(typeof(ScriptableCrafting));
			ScriptableCrafting val8 = (ScriptableCrafting)(object)((obj2 is ScriptableCrafting) ? obj2 : null);
			((Object)val8).hideFlags = (HideFlags)61;
			val8.ID = ((ScriptablePopulationData)aloftModFrameworkPopulationData).PopulationID;
			val8.PopData = (ScriptablePopulationData)(object)aloftModFrameworkPopulationData;
			val8.DisplayName = val7.DisplayName;
			val8.DisplayDescription = val7.DisplayDescription;
			val8.DisplaySprite = val7.DisplaySprite;
			val8.HideInBuildMenu = val7.HideInBuildMenu;
			val8.Category = val7.Category;
			val8.Variants = val7.Variants.Select((AloftModFrameworkBuildingData variant) => (ID)variant.PopulationId).ToArray();
			val8.IsVariantOf = (ID)((!((Object)(object)val7.IsVariantOf == (Object)null)) ? val7.IsVariantOf.PopulationId : 0);
			val8.DefaultScale = val7.DefaultScale;
			val8.CraftingCost = val7.CraftingCost;
			val8.HammerCost = val7.HammerCost;
			val8.PopToUnlockAsWell = val7.PopToUnlockAsWell;
			val8.AudioType = val7.AudioType;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).ScriptableCrafting = val8;
			((ScriptablePopulationData)aloftModFrameworkPopulationData).SketchbookCraftingRef = val8;
			return new
			{
				Blueprint = val8,
				Building = aloftModFrameworkPopulationData
			};
		}).ToList();
		BuildingBlueprints = source.Select(x => x.Blueprint).ToList();
		Object obj = Resources.Load("Platform Builder/Constructions/Machines/Pre_Construction_Workbench");
		GameObject val2 = (GameObject)(object)((obj is GameObject) ? obj : null);
		MeshRenderer val3 = val2.GetComponentsInChildren<MeshRenderer>().First();
		Material workbenchMaterial = ((Renderer)val3).material;
		Buildings = source.Select(x => x.Building).ForEach(delegate(AloftModFrameworkPopulationData x)
		{
			x.Prefab.GetComponentsInChildren<MeshRenderer>().ForEach(delegate(MeshRenderer mesh)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Expected O, but got Unknown
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Expected O, but got Unknown
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				Texture texture = ((Renderer)mesh).material.GetTexture("_MainTex");
				Texture texture2 = ((Renderer)mesh).material.GetTexture("_BumpMap");
				Texture texture3 = ((Renderer)mesh).material.GetTexture("_DetailMask");
				Material val5 = new Material(workbenchMaterial);
				((Object)val5).name = "AloftModFramework_DefaultPBR_Interactive_Material";
				((Object)val5).hideFlags = (HideFlags)61;
				val5.SetTexture("_TextureAlbedo", texture);
				val5.SetTexture("_TextureNormals", texture2);
				val5.SetTexture("_TextureMask", texture3);
				val5.SetVector("_ColorSelect", new Vector4(1.6f, 1.3f, 0.5f, 1f));
				val5.SetColor("_Color", new Color(1f, 1f, 1f, 1f));
				((Renderer)mesh).material = val5;
				for (int i = 0; i < ((Renderer)mesh).materials.Length; i++)
				{
					Material val6 = new Material(workbenchMaterial);
					((Object)val6).name = "AloftModLoaderMaterial";
					((Object)val6).hideFlags = (HideFlags)61;
					val6.SetTexture("_TextureAlbedo", texture);
					val6.SetTexture("_TextureNormals", texture2);
					val6.SetTexture("_TextureMask", texture3);
					val6.SetVector("_ColorSelect", new Vector4(1.6f, 1.3f, 0.5f, 1f));
					val6.SetColor("_Color", new Color(1f, 1f, 1f, 1f));
					((Renderer)mesh).materials[i] = val6;
				}
			});
		}).ToList();
		Localizations = allAssets.Where((Object x) => x is AloftModFrameworkLocalization).Cast<AloftModFrameworkLocalization>().ToList();
		LoggerRef = ((BaseUnityPlugin)this).Logger;
		Harmony val4 = new Harmony("aloftmodloader.sessional.dev");
		MethodInfo methodInfo = AccessTools.Method(typeof(ScriptableInventoryManager), "GetItem", new Type[1] { typeof(ID) }, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(ItemPatches), "RewriteItemIdResult", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(SRecipeManager), "GetRecipes", (Type[])null, (Type[])null);
		MethodInfo methodInfo4 = AccessTools.Method(typeof(RecipePatches), "RewriteRecipeResult", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo5 = AccessTools.Method(typeof(Localization), "SetLanguage", (Type[])null, (Type[])null);
		MethodInfo methodInfo6 = AccessTools.Method(typeof(LocalizationPatches), "SetLanguage", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo7 = AccessTools.Method(typeof(Localization), "GetLocalizedValue", (Type[])null, (Type[])null);
		MethodInfo methodInfo8 = AccessTools.Method(typeof(LocalizationPatches), "GetLocalizedValue", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo9 = AccessTools.Method(typeof(ScriptableCraftingManager), "_GetCrafting", (Type[])null, (Type[])null);
		MethodInfo methodInfo10 = AccessTools.Method(typeof(BuildingHooks), "GetCrafting", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo9, (HarmonyMethod)null, new HarmonyMethod(methodInfo10), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo11 = AccessTools.Method(typeof(PopulationManager), "GetPopulationData", (Type[])null, (Type[])null);
		MethodInfo methodInfo12 = AccessTools.Method(typeof(BuildingHooks), "GetPopulationData", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo11, (HarmonyMethod)null, new HarmonyMethod(methodInfo12), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo13 = AccessTools.Method(typeof(ScriptablePopulationDataManager), "GetPopulation", (Type[])null, (Type[])null);
		MethodInfo methodInfo14 = AccessTools.Method(typeof(BuildingHooks), "GetPopulationData2", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo13, (HarmonyMethod)null, new HarmonyMethod(methodInfo14), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo15 = AccessTools.Method(typeof(ScriptablePopulationDataManager), "InitList", (Type[])null, (Type[])null);
		MethodInfo methodInfo16 = AccessTools.Method(typeof(BuildingHooks), "InitListExtension", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo15, (HarmonyMethod)null, new HarmonyMethod(methodInfo16), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo17 = AccessTools.Method(typeof(ScriptablePopulationData), "GetPrefabGameObject", (Type[])null, (Type[])null);
		MethodInfo methodInfo18 = AccessTools.Method(typeof(BuildingHooks), "GetPrefabGameObject", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo17, (HarmonyMethod)null, new HarmonyMethod(methodInfo18), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo19 = AccessTools.Method(typeof(CanvasConsole), "EnterCommand", (Type[])null, (Type[])null);
		MethodInfo methodInfo20 = AccessTools.Method(typeof(Cheats), "ProcessCommand", (Type[])null, (Type[])null);
		val4.Patch((MethodBase)methodInfo19, new HarmonyMethod(methodInfo20), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}
}