Decompiled source of Aloft Mod Framework v0.2.0

plugins/AloftModLoader.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using AloftModFramework;
using AloftModFramework.Construction;
using AloftModFramework.Cooking;
using AloftModFramework.Crafting;
using AloftModFramework.Entities;
using AloftModFramework.Equipment;
using AloftModFramework.Items;
using AloftModFramework.Localization;
using AloftModFramework.Spawners;
using AloftModFramework.Unlocks;
using Balance;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Crafting.Construction.EZSnap;
using Crafting.Inventory;
using Creator;
using Creator.Creator_IO;
using HarmonyLib;
using Inventory;
using Level_Manager;
using Player.Hands;
using Player.Player_Equip;
using Scriptable_Objects;
using Scriptable_Objects.Combat;
using Scriptable_Objects.Consumable;
using Scriptable_Objects.Cooking;
using Scriptable_Objects.Progression;
using Terrain.Platforms.Population;
using Terrain.Platforms.Population.BalanceSpawner;
using Terrain.World;
using UI;
using UI.Building;
using UI.InGame;
using UnityEngine;
using Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace AloftModLoader;

public class AloftModLoaderBuildingTab : ScriptableBuildingTab
{
	public bool hasParentCategory;

	public BuildingCategory parentCategory;
}
public class AloftModLoaderCraftingRecipe : ScriptableCraftRecipe
{
	public CraftingStation craftingStation;
}
public class AloftModLoaderEquipable : ScriptableEquipable
{
	public GameObject prefab;

	public EquippableTemplateReference equipableTemplate;
}
public class AloftModLoaderPopulationData : ScriptablePopulationData
{
	public GameObject prefab;

	public bool canBeLearnedFromSketching;

	public ConstructionBlueprint blueprintLearnedFromSketching;
}
public class AloftModLoaderPopulationSpawner : PopChance
{
	public CreatorTagBiomeID biome;

	public ID spawner;
}
public class ConstructionLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private readonly List<ScriptableBuildingTab> _constructionCategories;

	private readonly List<ScriptableCrafting> _constructionBlueprints;

	private bool _learnedConstructionBlueprints;

	private bool _customTabsAdded;

	public ConstructionLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		_logger = logger;
		_harmony = harmony;
		List<ConstructionCategory> source = assets.FilterAndCast<ConstructionCategory>().ToList();
		List<AloftModLoaderBuildingTab> tabsWithParents = source.Where((ConstructionCategory x) => x.useParentCategory).Select(delegate(ConstructionCategory x)
		{
			//IL_000c: 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)
			AloftModLoaderBuildingTab aloftModLoaderBuildingTab = ScriptableObject.CreateInstance<AloftModLoaderBuildingTab>();
			((ScriptableBuildingTab)aloftModLoaderBuildingTab).Category = (BuildingCategory)x.id;
			((ScriptableBuildingTab)aloftModLoaderBuildingTab).DisplayName = x.categoryName;
			((ScriptableBuildingTab)aloftModLoaderBuildingTab).DisplayIcon = x.displayIcon;
			((ScriptableBuildingTab)aloftModLoaderBuildingTab).SecondaryIcon = x.secondaryIcon;
			((ScriptableBuildingTab)aloftModLoaderBuildingTab).SubTabs = (ScriptableBuildingTab[])(object)new ScriptableBuildingTab[0];
			aloftModLoaderBuildingTab.parentCategory = x.parentCategory.GetCategory();
			aloftModLoaderBuildingTab.hasParentCategory = x.useParentCategory;
			return aloftModLoaderBuildingTab;
		}).ToList();
		List<ScriptableBuildingTab> first = source.Where((ConstructionCategory x) => !x.useParentCategory).Select(delegate(ConstructionCategory x)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			ScriptableBuildingTab obj = ScriptableObject.CreateInstance<ScriptableBuildingTab>();
			obj.Category = (BuildingCategory)x.id;
			obj.DisplayName = x.categoryName;
			obj.DisplayIcon = x.displayIcon;
			obj.SecondaryIcon = x.secondaryIcon;
			ScriptableBuildingTab[] subTabs = (ScriptableBuildingTab[])(object)(from subTab in tabsWithParents
				where subTab.hasParentCategory
				where (int)subTab.parentCategory == x.id
				select subTab).ToArray();
			obj.SubTabs = subTabs;
			return obj;
		}).ToList();
		_constructionCategories = first.Union((IEnumerable<ScriptableBuildingTab>)tabsWithParents).ToList();
		_constructionBlueprints = assets.FilterAndCast<ConstructionBlueprint>().Select(delegate(ConstructionBlueprint x)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			ScriptableCrafting val = ScriptableObject.CreateInstance<ScriptableCrafting>();
			val.ID = x.populationData.GetPopulationId();
			ScriptablePopulationData val2 = (val.PopData = Plugin.EntityLoader.GetDataForId(x.populationData.GetPopulationId()));
			val2.ScriptableCrafting = val;
			AloftModLoaderPopulationData aloftModLoaderPopulationData = val2 as AloftModLoaderPopulationData;
			if ((Object)(object)aloftModLoaderPopulationData != (Object)null && aloftModLoaderPopulationData.canBeLearnedFromSketching && (Object)(object)aloftModLoaderPopulationData.blueprintLearnedFromSketching == (Object)(object)x)
			{
				val2.SketchbookCraftingRef = val;
			}
			val2.ScriptableCrafting = val;
			val.DisplayName = x.displayName;
			val.DisplayDescription = x.description;
			val.DisplaySprite = x.sprite;
			val.HideInBuildMenu = x.hideInBuildMenu;
			val.Category = x.category.GetCategory();
			ManualLogSource logger2 = _logger;
			BuildingCategory category = x.category.GetCategory();
			logger2.LogDebug((object)("Category was: " + ((object)(BuildingCategory)(ref category)).ToString()));
			val.Variants = x.variants.Select((PopulationReference variant) => variant.GetPopulationId()).ToArray();
			val.IsVariantOf = x.isVariantOf.GetPopulationId();
			val.DefaultScale = x.defaultScale;
			val.CraftingCost = ((IEnumerable<ItemReferenceWithQuantity>)x.craftingCost).Select((Func<ItemReferenceWithQuantity, CraftingCostClass>)((ItemReferenceWithQuantity cost) => new CraftingCostClass(cost.GetItemId(), cost.quantity))).ToArray();
			val.HammerCost = ((IEnumerable<ItemReferenceWithQuantity>)x.hammerCost).Select((Func<ItemReferenceWithQuantity, CraftingCostClass>)((ItemReferenceWithQuantity cost) => new CraftingCostClass(cost.GetItemId(), cost.quantity))).ToArray();
			val.PopToUnlockAsWell = x.unlockedPopulations.Select((PopulationReference unlocks) => unlocks.GetPopulationId()).ToArray();
			val.AudioType = x.audioType.GetConstructionMaterial();
			return val;
		}).ToList();
	}

	public void Patch()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(UI_BuildingMenu), "Tabs_Initialize", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(ConstructionLoader), "Tabs_Initialize", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(ScriptableCraftingManager), "_GetCrafting", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ConstructionLoader), "_GetCrafting", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SEzSnapManager), "GetSnapData", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ConstructionLoader), "GetSnapData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(UI_Building_InfoWindow), "DisplayVariant", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(ConstructionLoader), "DisplayVariant", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static void Tabs_Initialize(UI_BuildingMenu __instance)
	{
		if (Plugin.ConstructionLoader._customTabsAdded)
		{
			return;
		}
		Plugin.ConstructionLoader._customTabsAdded = true;
		foreach (ScriptableBuildingTab constructionCategory in Plugin.ConstructionLoader._constructionCategories)
		{
			AloftModLoaderBuildingTab categoryAsChildTab = constructionCategory as AloftModLoaderBuildingTab;
			if ((Object)(object)categoryAsChildTab != (Object)null && categoryAsChildTab.hasParentCategory)
			{
				ScriptableBuildingTab val = ((IEnumerable<ScriptableBuildingTab>)__instance.ScriptableTabs).FirstOrDefault((Func<ScriptableBuildingTab, bool>)((ScriptableBuildingTab x) => x.Category == categoryAsChildTab.parentCategory));
				if ((Object)(object)val != (Object)null)
				{
					val.SubTabs = CollectionExtensions.AddToArray<ScriptableBuildingTab>(val.SubTabs, constructionCategory);
				}
			}
			else
			{
				__instance.ScriptableTabs = CollectionExtensions.AddToArray<ScriptableBuildingTab>(__instance.ScriptableTabs, constructionCategory);
			}
		}
	}

	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 (!Plugin.ConstructionLoader._learnedConstructionBlueprints)
		{
			Plugin.ConstructionLoader._learnedConstructionBlueprints = true;
			Plugin.ConstructionLoader._logger.LogDebug((object)"Force learning blueprints!");
			Plugin.ConstructionLoader._constructionBlueprints.ForEach(delegate(ScriptableCrafting blueprint)
			{
				Plugin.ConstructionLoader._logger.LogDebug((object)("Learning blueprint " + blueprint.DisplayName));
			});
		}
		ScriptableCrafting val = ((IEnumerable<ScriptableCrafting>)Plugin.ConstructionLoader._constructionBlueprints).FirstOrDefault((Func<ScriptableCrafting, bool>)((ScriptableCrafting x) => x.ID == id));
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		return __result;
	}

	public static SEzSnapData GetSnapData(SEzSnapData __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 ((Object)(object)__result == (Object)null)
		{
			ScriptableCrafting val = ((IEnumerable<ScriptableCrafting>)Plugin.ConstructionLoader._constructionBlueprints).FirstOrDefault((Func<ScriptableCrafting, bool>)((ScriptableCrafting x) => x.PopData.PopulationID == populationID));
			if ((Object)(object)val != (Object)null)
			{
				AloftModLoaderPopulationData aloftModLoaderPopulationData = val.PopData as AloftModLoaderPopulationData;
				if ((Object)(object)aloftModLoaderPopulationData != (Object)null)
				{
					EzSnapIO component = aloftModLoaderPopulationData.prefab.GetComponent<EzSnapIO>();
					if ((Object)(object)component != (Object)null)
					{
						return component.EzSnapData;
					}
				}
			}
		}
		return __result;
	}

	public static void DisplayVariant(UI_Building_InfoWindow __instance)
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		Console.WriteLine("Instance is: " + (object)__instance);
		List<ID> list = AccessTools.Field(typeof(UI_Building_InfoWindow), "_variantPopIDs").GetValue(__instance) as List<ID>;
		Console.WriteLine("Found X variants: " + list.Count);
		Console.WriteLine("Variants are: " + string.Join(",", list));
		foreach (ID item in list)
		{
			ScriptablePopulationData populationData = Level.TerrainManager.PopulationManager.GetPopulationData(item);
			Console.WriteLine(Object.op_Implicit((Object)(object)populationData));
			Console.WriteLine("Recipe: " + (object)populationData.ScriptableCrafting);
		}
	}
}
public class CookingLoader
{
	private readonly Harmony _harmony;

	private readonly ManualLogSource _logger;

	private List<SCookMeal> Meals;

	private List<SCookRecipe> CookingRecipes;

	public CookingLoader(ManualLogSource logger, Harmony harmony, List<Object> allAssets)
	{
		_harmony = harmony;
		_logger = logger;
		Meals = allAssets.FilterAndCast<Meal>().Select(delegate(Meal x)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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)
			SCookMeal obj = ScriptableObject.CreateInstance<SCookMeal>();
			obj.ItemID = x.item.GetItemId();
			obj.StatDuration = x.statDuration;
			obj.StatHpMaxAmount = x.statHpMaxAmount;
			obj.TriggerConditions = x.triggerConditions.Select((ConditionTriggerReference condition) => condition.GetConditionTrigger()).ToArray();
			obj.Edible = x.edible;
			obj.CookPreventBurning = x.preventBurning;
			obj.IngredientType = x.ingredientType.GetIngredientType();
			return obj;
		}).ToList();
		CookingRecipes = allAssets.FilterAndCast<CookingRecipe>().Select(delegate(CookingRecipe x)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			SCookRecipe val;
			if (x.isPerfectRecipe)
			{
				val = (SCookRecipe)(object)ScriptableObject.CreateInstance<SCookRecipePerfect>();
				((SCookRecipePerfect)val).Inputs = x.inputs.Select((ItemReference input) => input.GetItemId()).ToArray();
			}
			else
			{
				val = (SCookRecipe)(object)ScriptableObject.CreateInstance<SCookRecipeBastard>();
				((SCookRecipeBastard)val).RecipeVariations = x.variations;
			}
			val.Output = x.output.GetItemId();
			val.IsPerfectRecipe = x.isPerfectRecipe;
			val.Category = x.category.GetCategory();
			val.UnlockableByRecipePage = x.unlockableByRecipePage;
			return val;
		}).ToList();
	}

	public void Patch()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Expected O, but got Unknown
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SCookingManager), "GetMeal", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CookingLoader), "GetMeal", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SCookingManager), "GetMealRecipe", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CookingLoader), "GetMealRecipe", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SCookingManager), "GetMealFromRecipe", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CookingLoader), "GetMealFromRecipe", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(CanvasCooking), "GetInventoryItemStacks", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CookingLoader), "GetInventoryItemStacks", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(CanvasCooking), "GetRecipeItemStacks", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CookingLoader), "GetRecipeItemStacks", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SConsumableRecipePage), "GetRandomHiddenMeal", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CookingLoader), "GetRandomHiddenMeal", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static SCookMeal GetMeal(SCookMeal __result, ID mealID)
	{
		//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<SCookMeal>)Plugin.CookingLoader.Meals).FirstOrDefault((Func<SCookMeal, bool>)((SCookMeal x) => x.ItemID == mealID));
		}
		return __result;
	}

	public static SCookRecipe GetMealRecipe(SCookRecipe __result, ID mealID)
	{
		//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)
		{
			SCookRecipe val = ((IEnumerable<SCookRecipe>)Plugin.CookingLoader.CookingRecipes).FirstOrDefault((Func<SCookRecipe, bool>)((SCookRecipe x) => x.Output == mealID));
			if (val is SCookRecipeBastard)
			{
				return __result;
			}
			return val;
		}
		return __result;
	}

	public static SCookRecipe GetMealFromRecipe(SCookRecipe __result, ID[] itemIDs)
	{
		if ((Object)(object)__result == (Object)null || __result is SCookRecipeBastard)
		{
			SCookRecipe val = ((IEnumerable<SCookRecipe>)Plugin.CookingLoader.CookingRecipes).FirstOrDefault((Func<SCookRecipe, bool>)((SCookRecipe x) => x.IsCompatible(itemIDs)));
			if (val is SCookRecipeBastard)
			{
				return __result;
			}
			return val;
		}
		return __result;
	}

	public static ItemStackV2[] GetInventoryItemStacks(ItemStackV2[] __result)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		List<ItemStackV2> list = new List<ItemStackV2>();
		foreach (SCookMeal meal in Plugin.CookingLoader.Meals)
		{
			if ((int)meal.IngredientType != 0 && Inventory.HasItem(meal.ItemID, 1, true))
			{
				ItemStackV2 val = new ItemStackV2();
				val.SetItemStackV2(meal.ItemID, Inventory.GetQty(meal.ItemID, true), (ItemParameterV2[])null);
				if (val.Quantity > Inventory.GetQty(val.ItemID, false))
				{
					val.AddParameter((ParameterIDEnum)7, 1);
				}
				list.Add(val);
			}
		}
		return CollectionExtensions.AddRangeToArray<ItemStackV2>(__result, list.ToArray());
	}

	public static ItemStackV2[] GetRecipeItemStacks(ItemStackV2[] __result)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		List<ItemStackV2> list = new List<ItemStackV2>();
		foreach (SCookRecipe cookingRecipe in Plugin.CookingLoader.CookingRecipes)
		{
			if (Level.CraftingManager.UnlockRecipe.MealRecipeIsDiscovered(cookingRecipe.Output, false))
			{
				ItemStackV2 val = new ItemStackV2();
				val.SetItemStackV2(cookingRecipe.Output, cookingRecipe.HasAllIngredient() ? 1 : 0, (ItemParameterV2[])null);
				list.Add(val);
			}
		}
		return CollectionExtensions.AddRangeToArray<ItemStackV2>(__result, list.ToArray());
	}

	public static ID GetRandomHiddenMeal(ID __result)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: 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_0086: 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)
		if ((int)__result == 0)
		{
			List<ID> list = new List<ID>();
			foreach (SCookRecipe cookingRecipe in Plugin.CookingLoader.CookingRecipes)
			{
				if (cookingRecipe.UnlockableByRecipePage && !Level.CraftingManager.UnlockRecipe.MealRecipeIsDiscovered(cookingRecipe.Output, true))
				{
					list.Add(cookingRecipe.Output);
				}
			}
			if (list.Count != 0)
			{
				return list[Random.Range(0, list.Count)];
			}
			return __result;
		}
		return __result;
	}
}
public class CraftingRecipeLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private readonly List<AloftModLoaderCraftingRecipe> _recipes;

	private readonly List<ScriptableCraftRecipeGroup> _stations;

	private IList _patchedGroups = new List<CraftingStation>();

	public CraftingRecipeLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		CraftingRecipeLoader craftingRecipeLoader = this;
		_logger = logger;
		_harmony = harmony;
		_stations = assets.FilterAndCast<CraftingStation>().Select(delegate(CraftingStation x)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ScriptableCraftRecipeGroup obj3 = ScriptableObject.CreateInstance<ScriptableCraftRecipeGroup>();
			obj3.DisplayName = x.stationName;
			obj3.StationType = (CraftingStation)x.stationId;
			return obj3;
		}).ToList();
		_recipes = assets.FilterAndCast<CraftingRecipe>().Select(delegate(CraftingRecipe x)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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)
			//IL_00a6: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			AloftModLoaderCraftingRecipe aloftModLoaderCraftingRecipe = ScriptableObject.CreateInstance<AloftModLoaderCraftingRecipe>();
			ManualLogSource obj = logger;
			ID itemId = x.outputItem.GetItemId();
			obj.LogDebug((object)("Loaded recipe to craft " + ((object)(ID)(ref itemId)).ToString()));
			((ScriptableCraftRecipe)aloftModLoaderCraftingRecipe).Input = x.inputItems.Select((ItemReference input) => input.GetItemId()).ToArray();
			((ScriptableCraftRecipe)aloftModLoaderCraftingRecipe).Output = new CraftingCostClass(x.outputItem.GetItemId(), x.quantity);
			if (x.attachToStation)
			{
				aloftModLoaderCraftingRecipe.craftingStation = x.craftingStation.GetStation();
				ScriptableCraftRecipeGroup val = ((IEnumerable<ScriptableCraftRecipeGroup>)craftingRecipeLoader._stations).FirstOrDefault((Func<ScriptableCraftRecipeGroup, bool>)((ScriptableCraftRecipeGroup station) => station.StationType == x.craftingStation.GetStation()));
				if ((Object)(object)val != (Object)null)
				{
					ManualLogSource obj2 = logger;
					itemId = x.outputItem.GetItemId();
					obj2.LogDebug((object)("Attaching recipe for item " + ((object)(ID)(ref itemId)).ToString() + " to station " + ((object)(CraftingStation)(ref aloftModLoaderCraftingRecipe.craftingStation)).ToString()));
					val.Recipes = CollectionExtensions.AddToArray<ScriptableCraftRecipe>(val.Recipes, (ScriptableCraftRecipe)(object)aloftModLoaderCraftingRecipe);
				}
			}
			return aloftModLoaderCraftingRecipe;
		}).ToList();
	}

	public void Patch()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SRecipeManager), "GetRecipes", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CraftingRecipeLoader), "GetRecipes", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static ScriptableCraftRecipeGroup GetRecipes(ScriptableCraftRecipeGroup __result, CraftingStation stationType)
	{
		//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)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		if ((int)stationType == 0 && !Plugin.CraftingRecipeLoader._patchedGroups.Contains(stationType))
		{
			Plugin.CraftingRecipeLoader._logger.LogDebug((object)("Attaching " + Plugin.CraftingRecipeLoader._recipes.Count + " new recipes to the ALL station."));
			Plugin.CraftingRecipeLoader._patchedGroups.Add(stationType);
			__result.Recipes = CollectionExtensions.AddRangeToArray<ScriptableCraftRecipe>(__result.Recipes, Plugin.CraftingRecipeLoader._recipes.Cast<ScriptableCraftRecipe>().ToArray());
		}
		if ((Object)(object)__result == (Object)null)
		{
			ScriptableCraftRecipeGroup? result = ((IEnumerable<ScriptableCraftRecipeGroup>)Plugin.CraftingRecipeLoader._stations).FirstOrDefault((Func<ScriptableCraftRecipeGroup, bool>)((ScriptableCraftRecipeGroup x) => x.StationType == stationType));
			Plugin.CraftingRecipeLoader._logger.LogDebug((object)("Returning recipes for station " + ((object)(CraftingStation)(ref stationType)).ToString()));
			return result;
		}
		if (!Plugin.CraftingRecipeLoader._patchedGroups.Contains(stationType))
		{
			ScriptableCraftRecipe[] array = Plugin.CraftingRecipeLoader._recipes.Where((AloftModLoaderCraftingRecipe x) => x.craftingStation == stationType).Cast<ScriptableCraftRecipe>().ToArray();
			Plugin.CraftingRecipeLoader._logger.LogDebug((object)("Attaching " + array.Length + " new recipes to station " + ((object)(CraftingStation)(ref stationType)).ToString()));
			Plugin.CraftingRecipeLoader._patchedGroups.Add(stationType);
			__result.Recipes = CollectionExtensions.AddRangeToArray<ScriptableCraftRecipe>(__result.Recipes, array);
		}
		return __result;
	}
}
public class EntityLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private readonly List<AloftModLoaderPopulationData> _populations;

	private readonly Material _interactableSelectableMaterial;

	public EntityLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		EntityLoader entityLoader = this;
		_logger = logger;
		_harmony = harmony;
		_logger.LogDebug((object)"Loading material from standard workbench.");
		Object obj = Resources.Load("Platform Builder/Constructions/Machines/Pre_Construction_Workbench");
		MeshRenderer val = ((GameObject)((obj is GameObject) ? obj : null)).GetComponentsInChildren<MeshRenderer>().First();
		_interactableSelectableMaterial = ((Renderer)val).material;
		_logger.LogDebug((object)"Loading discovered populations.");
		_populations = assets.FilterAndCast<Population>().Select(delegate(Population x)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)("Loading population data " + ((Object)x).name + " at id " + x.id));
			AloftModLoaderPopulationData aloftModLoaderPopulationData = ScriptableObject.CreateInstance<AloftModLoaderPopulationData>();
			((ScriptablePopulationData)aloftModLoaderPopulationData).PopulationID = (ID)x.id;
			aloftModLoaderPopulationData.prefab = x.prefab;
			aloftModLoaderPopulationData.prefab.GetComponentsInChildren<MeshRenderer>().ForEach(delegate(MeshRenderer renderer)
			{
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Expected O, but got Unknown
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				entityLoader._logger.LogDebug((object)("Replacing material with " + ((Object)entityLoader._interactableSelectableMaterial).name));
				Texture texture = ((Renderer)renderer).material.GetTexture("_MainTex");
				Texture texture2 = ((Renderer)renderer).material.GetTexture("_BumpMap");
				Texture texture3 = ((Renderer)renderer).material.GetTexture("_DetailMask");
				Color color = ((Renderer)renderer).material.GetColor("_Color");
				Material val2 = new Material(entityLoader._interactableSelectableMaterial);
				((Object)val2).name = "AloftModLoader_InteractableSelectable_Material";
				entityLoader._logger.LogDebug((object)("Adding textures to material: " + ((object)texture)?.ToString() + " " + ((object)texture2)?.ToString() + " " + (object)texture3));
				val2.SetTexture("_TextureAlbedo", texture);
				val2.SetTexture("_TextureNormals", texture2);
				val2.SetTexture("_TextureMask", texture3);
				val2.SetVector("_ColorSelect", new Vector4(1.6f, 1.3f, 0.5f, 1f));
				val2.SetColor("_Color", color);
				((Renderer)renderer).material = val2;
			});
			((ScriptablePopulationData)aloftModLoaderPopulationData).CreatorParameters = new PopulationCreatorParameters
			{
				AvailableInCreator = true,
				FolderHierarchy = (PopFolder[])(object)new PopFolder[0]
			};
			((ScriptablePopulationData)aloftModLoaderPopulationData).BehaviourType = x.behaviorType.GetBehaviorType();
			((ScriptablePopulationData)aloftModLoaderPopulationData).MultiStepBehaviour = x.multistepBehavior.GetMultistepBehavior();
			((ScriptablePopulationData)aloftModLoaderPopulationData).LoadDistance = x.loadDistance;
			((ScriptablePopulationData)aloftModLoaderPopulationData).PopDataTags = x.dataTags.Select((DataTagReference tag) => tag.GetTag()).ToArray();
			((ScriptablePopulationData)aloftModLoaderPopulationData).PrefabPaths = new string[0];
			aloftModLoaderPopulationData.canBeLearnedFromSketching = x.learnedFromSketching;
			aloftModLoaderPopulationData.blueprintLearnedFromSketching = x.learnedBlueprint;
			return aloftModLoaderPopulationData;
		}).ToList();
	}

	public ScriptablePopulationData GetDataForId(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)
		return (ScriptablePopulationData)(object)_populations.First((AloftModLoaderPopulationData x) => ((ScriptablePopulationData)x).PopulationID == id);
	}

	public void Patch()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(PopulationManager), "GetPopulationData", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EntityLoader), "GetPopulationDataFromPopulationManager", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(PopulationManager), "GetPopulationData", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EntityLoader), "MuteException", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(ScriptablePopulationDataManager), "GetPopulation", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EntityLoader), "GetPopulationDataFromPopulationDataManager", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(PopulationManager), "Initialize", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EntityLoader), "Initialize", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(ScriptablePopulationData), "GetPrefabGameObject", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EntityLoader), "GetPrefabGameObject", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static IEnumerable<CodeInstruction> MuteException(IEnumerable<CodeInstruction> instructions, ILGenerator il)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		Action<object> del = Console.WriteLine;
		MethodInfo writeLineMethodInfo = del.GetMethodInfo();
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		int num = list.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Call && (MethodInfo)x.operand == writeLineMethodInfo);
		if (num != -1)
		{
			CodeInstruction val = list[num];
			list[num] = new CodeInstruction(OpCodes.Ret, (object)null);
			list[num].labels = val.labels;
			list[num].blocks = val.blocks;
		}
		if (Plugin.configLogDebugILPatches.Value)
		{
			Plugin.EntityLoader._logger.LogDebug((object)("New code: " + string.Join("\n", list)));
		}
		return list;
	}

	public static ScriptablePopulationData GetPopulationDataFromPopulationManager(ScriptablePopulationData __result, PopulationManager __instance, 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 ((Object)(object)__result == (Object)null)
		{
			AloftModLoaderPopulationData aloftModLoaderPopulationData = Plugin.EntityLoader._populations.FirstOrDefault((AloftModLoaderPopulationData x) => ((ScriptablePopulationData)x).PopulationID == populationID);
			if ((Object)(object)aloftModLoaderPopulationData != (Object)null)
			{
				Plugin.EntityLoader._logger.LogDebug((object)("Found population data for " + ((object)(ID)(ref ((ScriptablePopulationData)aloftModLoaderPopulationData).PopulationID)).ToString()));
				return (ScriptablePopulationData)(object)aloftModLoaderPopulationData;
			}
			Plugin.EntityLoader._logger.LogError((object)("Unable to find an entity with entity id: " + ((object)(ID)(ref populationID)).ToString()));
			return __instance.PopulationDataManager.AllPopulationData[0];
		}
		return __result;
	}

	public static ScriptablePopulationData GetPopulationDataFromPopulationDataManager(ScriptablePopulationData __result, ID popID)
	{
		//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)
		{
			AloftModLoaderPopulationData aloftModLoaderPopulationData = Plugin.EntityLoader._populations.FirstOrDefault((AloftModLoaderPopulationData x) => ((ScriptablePopulationData)x).PopulationID == popID);
			if ((Object)(object)aloftModLoaderPopulationData != (Object)null)
			{
				Plugin.EntityLoader._logger.LogDebug((object)("Found population data for " + ((object)(ID)(ref ((ScriptablePopulationData)aloftModLoaderPopulationData).PopulationID)).ToString()));
				return (ScriptablePopulationData)(object)aloftModLoaderPopulationData;
			}
		}
		return __result;
	}

	public static void Initialize(PopulationManager __instance)
	{
		if (Plugin.EntityLoader._populations.Count > 0 && Level.TerrainManager.PopulationManager.PopulationDataManager.AllPopulationData.Contains((ScriptablePopulationData)(object)Plugin.EntityLoader._populations.First()))
		{
			Plugin.EntityLoader._logger.LogWarning((object)"Extending population data twice.");
		}
		Plugin.EntityLoader._logger.LogDebug((object)"Extending population data.");
		Level.TerrainManager.PopulationManager.PopulationDataManager.AllPopulationData = CollectionExtensions.AddRangeToArray<ScriptablePopulationData>(Level.TerrainManager.PopulationManager.PopulationDataManager.AllPopulationData, Plugin.EntityLoader._populations.Cast<ScriptablePopulationData>().ToArray());
	}

	public static GameObject GetPrefabGameObject(GameObject __result, ScriptablePopulationData __instance)
	{
		if ((Object)(object)__result == (Object)null)
		{
			if (__instance is AloftModLoaderPopulationData)
			{
				GameObject prefab = ((AloftModLoaderPopulationData)(object)__instance).prefab;
				Plugin.EntityLoader._logger.LogDebug((object)("Loading a custom prefab for population " + ((object)(ID)(ref __instance.PopulationID)).ToString() + " as " + ((Object)prefab).name));
				return prefab;
			}
			Plugin.EntityLoader._logger.LogDebug((object)("Unable to find a prefab for population " + ((object)(ID)(ref __instance.PopulationID)).ToString()));
		}
		return __result;
	}
}
public class EquipmentLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private readonly List<ScriptableEquipable> scriptableEquippables;

	private readonly Material _interactableSelectableMaterial;

	public EquipmentLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		_logger = logger;
		_harmony = harmony;
		_logger.LogDebug((object)"Loading material from standard workbench.");
		Object obj = Resources.Load("Platform Builder/Constructions/Machines/Pre_Construction_Workbench");
		MeshRenderer val = ((GameObject)((obj is GameObject) ? obj : null)).GetComponentsInChildren<MeshRenderer>().First();
		_interactableSelectableMaterial = ((Renderer)val).material;
		scriptableEquippables = assets.FilterAndCast<Equippable>().Select(delegate(Equippable x)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			AloftModLoaderEquipable aloftModLoaderEquipable = ScriptableObject.CreateInstance<AloftModLoaderEquipable>();
			((ScriptableEquipable)aloftModLoaderEquipable).ItemID = x.item.GetItemId();
			((ScriptableEquipable)aloftModLoaderEquipable).EquipType = (Equipable)x.id;
			((ScriptableEquipable)aloftModLoaderEquipable).HandBehaviour = x.handBehaviour;
			aloftModLoaderEquipable.equipableTemplate = x.equippableTemplate;
			if ((Object)(object)x.equippableTemplate.template != (Object)null)
			{
				((ScriptableEquipable)aloftModLoaderEquipable).OverrideAnimations = x.equippableTemplate.template.overrideAnimations;
				((ScriptableEquipable)aloftModLoaderEquipable).ThirdPersonAnimations = x.equippableTemplate.template.thirdPersonAnimations;
			}
			aloftModLoaderEquipable.prefab = x.heldItemPrefab;
			aloftModLoaderEquipable.prefab.GetComponentsInChildren<MeshRenderer>().ForEach(delegate(MeshRenderer renderer)
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				_logger.LogDebug((object)("Replacing material with " + ((Object)_interactableSelectableMaterial).name));
				Texture texture = ((Renderer)renderer).material.GetTexture("_MainTex");
				Texture texture2 = ((Renderer)renderer).material.GetTexture("_BumpMap");
				Texture texture3 = ((Renderer)renderer).material.GetTexture("_DetailMask");
				Material val2 = new Material(_interactableSelectableMaterial);
				((Object)val2).name = "AloftModLoader_InteractableSelectable_Material";
				_logger.LogDebug((object)("Adding textures to material: " + ((object)texture)?.ToString() + " " + ((object)texture2)?.ToString() + " " + (object)texture3));
				val2.SetTexture("_TextureAlbedo", texture);
				val2.SetTexture("_TextureNormals", texture2);
				val2.SetTexture("_TextureMask", texture3);
				val2.SetVector("_ColorSelect", new Vector4(1.6f, 1.3f, 0.5f, 1f));
				val2.SetColor("_Color", new Color(1f, 1f, 1f, 1f));
				((Renderer)renderer).material = val2;
			});
			((ScriptableEquipable)aloftModLoaderEquipable).HoldInLeftHand = false;
			((ScriptableEquipable)aloftModLoaderEquipable).Instructions = (InstructionMapping[])(object)new InstructionMapping[0];
			((ScriptableEquipable)aloftModLoaderEquipable).PathTool = null;
			((ScriptableEquipable)aloftModLoaderEquipable).CombatData = x.combatValues;
			((ScriptableEquipable)aloftModLoaderEquipable).BowData = x.bowValues;
			return aloftModLoaderEquipable;
		}).Cast<ScriptableEquipable>()
			.ToList();
	}

	public void Patch()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(ScriptableInventoryManager), "GetEquipable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EquipmentLoader), "GetEquipable", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerEquipThirdPerson), "SpawnItemInHand", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EquipmentLoader), "SpawnItemInHand", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(Hands), "Init", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(EquipmentLoader), "Init", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static IEnumerable<CodeInstruction> SpawnItemInHand(IEnumerable<CodeInstruction> instructions, ILGenerator il)
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Expected O, but got Unknown
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Expected O, but got Unknown
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Expected O, but got Unknown
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Expected O, but got Unknown
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Expected O, but got Unknown
		FieldInfo fieldInfo = AccessTools.Field(typeof(ScriptableEquipable), "PathTool");
		MethodInfo methodInfo = AccessTools.Method(typeof(EquipmentLoader), "SpawnHeldItem", (Type[])null, (Type[])null);
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		int num = -1;
		bool flag = false;
		bool flag2 = false;
		Label label = il.DefineLabel();
		Label label2 = il.DefineLabel();
		for (int i = 0; i < list.Count; i++)
		{
			if (CodeInstructionExtensions.LoadsField(list[i], fieldInfo, false) && !flag)
			{
				num = i - 1;
				list[i - 1].labels.Add(label);
				flag = true;
			}
			if (list[i].opcode == OpCodes.Callvirt && !flag2)
			{
				flag2 = true;
				list[i].labels.Add(label2);
			}
		}
		List<CodeInstruction> list2 = new List<CodeInstruction>
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo),
			new CodeInstruction(OpCodes.Brtrue, (object)label),
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldarg_1, (object)null),
			new CodeInstruction(OpCodes.Ldarg_2, (object)null),
			new CodeInstruction(OpCodes.Call, (object)methodInfo),
			new CodeInstruction(OpCodes.Br_S, (object)label2)
		};
		if (num != -1)
		{
			list.InsertRange(num, list2);
		}
		if (Plugin.configLogDebugILPatches.Value)
		{
			Plugin.EquipmentLoader._logger.LogDebug((object)("New code: " + string.Join("\n", list2)));
		}
		return list;
	}

	public static GameObject SpawnHeldItem(ScriptableEquipable equipable, Transform parentLeft, Transform parentRight)
	{
		if (!(equipable is AloftModLoaderEquipable aloftModLoaderEquipable))
		{
			return null;
		}
		Transform val = (equipable.HoldInLeftHand ? parentLeft : parentRight);
		return Object.Instantiate<GameObject>(aloftModLoaderEquipable.prefab, val);
	}

	public static IEnumerable<CodeInstruction> Init(IEnumerable<CodeInstruction> instructions, ILGenerator il)
	{
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Expected O, but got Unknown
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Expected O, but got Unknown
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Expected O, but got Unknown
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		FieldInfo fieldInfo = AccessTools.Field(typeof(ScriptableEquipable), "PathTool");
		MethodInfo methodInfo = AccessTools.Method(typeof(EquipmentLoader), "InstantiateFromPrefab", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = new Func<string, GameObject>(Resources.Load<GameObject>).GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(typeof(GameObject));
		int num = -1;
		Label label = il.DefineLabel();
		Label label2 = il.DefineLabel();
		bool flag = false;
		bool flag2 = false;
		for (int i = 0; i < list.Count; i++)
		{
			if (CodeInstructionExtensions.LoadsField(list[i], fieldInfo, false) && !flag)
			{
				flag = true;
				num = i - 1;
				list[i - 1].labels.Add(label2);
			}
			if (list[i].opcode == OpCodes.Call && (MethodInfo)list[i].operand == methodInfo2 && !flag2)
			{
				flag2 = true;
				list[i + 1].labels.Add(label);
			}
		}
		List<CodeInstruction> list2 = new List<CodeInstruction>
		{
			new CodeInstruction(OpCodes.Ldarg_1, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo),
			new CodeInstruction(OpCodes.Brtrue, (object)label2),
			new CodeInstruction(OpCodes.Ldarg_1, (object)null),
			new CodeInstruction(OpCodes.Call, (object)methodInfo),
			new CodeInstruction(OpCodes.Br_S, (object)label)
		};
		if (num != -1)
		{
			list.InsertRange(num, list2);
		}
		if (Plugin.configLogDebugILPatches.Value)
		{
			Plugin.EquipmentLoader._logger.LogDebug((object)("New code: " + string.Join("\n", list2)));
		}
		return list;
	}

	public static GameObject InstantiateFromPrefab(ScriptableEquipable equipable)
	{
		if (!(equipable is AloftModLoaderEquipable aloftModLoaderEquipable))
		{
			return null;
		}
		return aloftModLoaderEquipable.prefab;
	}

	public static ScriptableEquipable GetEquipable(ScriptableEquipable __result, Equipable equip)
	{
		//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)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Invalid comparison between Unknown and I4
		if ((Object)(object)__result == (Object)null)
		{
			ScriptableEquipable val = ((IEnumerable<ScriptableEquipable>)Plugin.EquipmentLoader.scriptableEquippables).FirstOrDefault((Func<ScriptableEquipable, bool>)((ScriptableEquipable x) => x.EquipType == equip));
			Plugin.EquipmentLoader._logger.LogDebug((object)("Equipable is : " + (object)val));
			if ((Object)(object)val != (Object)null)
			{
				AloftModLoaderEquipable aloftModLoaderEquipable = val as AloftModLoaderEquipable;
				if ((Object)(object)aloftModLoaderEquipable != (Object)null)
				{
					VanillaEquippableTemplate vanillaTemplate = aloftModLoaderEquipable.equipableTemplate.vanillaTemplate;
					if ((int)vanillaTemplate != 0)
					{
						if ((int)vanillaTemplate == 1)
						{
							Plugin.EquipmentLoader._logger.LogDebug((object)"Finding override animations");
							ScriptableEquipable val2 = ((IEnumerable<ScriptableEquipable>)Level.ConstantManager.ConstantManagers.InventoryManager.Equipables).FirstOrDefault((Func<ScriptableEquipable, bool>)((ScriptableEquipable x) => (int)x.ItemID == 520));
							if ((Object)(object)val2 != (Object)null)
							{
								Plugin.EquipmentLoader._logger.LogDebug((object)"Setting override animations");
								((ScriptableEquipable)aloftModLoaderEquipable).OverrideAnimations = val2.OverrideAnimations;
								((ScriptableEquipable)aloftModLoaderEquipable).ThirdPersonAnimations = val2.ThirdPersonAnimations;
							}
						}
					}
					else
					{
						((ScriptableEquipable)aloftModLoaderEquipable).OverrideAnimations = aloftModLoaderEquipable.equipableTemplate.template.overrideAnimations;
						((ScriptableEquipable)aloftModLoaderEquipable).ThirdPersonAnimations = aloftModLoaderEquipable.equipableTemplate.template.thirdPersonAnimations;
					}
					return (ScriptableEquipable)(object)aloftModLoaderEquipable;
				}
				return val;
			}
		}
		return __result;
	}
}
public class ItemLoader
{
	private readonly Harmony _harmony;

	private readonly List<ScriptableInventoryItem> _items;

	private readonly ManualLogSource _logger;

	public ItemLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		_logger = logger;
		_harmony = harmony;
		_items = assets.FilterAndCast<Item>().Select(delegate(Item x)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_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)
			//IL_0089: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			ScriptableInventoryItem obj = ScriptableObject.CreateInstance<ScriptableInventoryItem>();
			logger.LogDebug((object)("Loaded " + x.itemName + " at item id " + x.id));
			obj.ID = (ID)x.id;
			obj.DisplayName = x.itemName;
			obj.DisplayDescription = x.description;
			obj.DisplaySprite = x.sprite;
			obj.Category = x.category.GetCategory();
			obj.Type = x.type.GetItemType();
			obj.Weight = x.weight.GetWeight();
			obj.EquipType = x.equipType.GetEquippable();
			obj.AudioPickupID = x.pickupAudioTag.GetAudioTag();
			obj.ItemTags = x.itemTags.Select((ItemTagReference tag) => tag.GetTag()).ToArray();
			return obj;
		}).ToList();
	}

	public void Patch()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(ScriptableInventoryManager), "GetItem", new Type[1] { typeof(ID) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ItemLoader), "GetItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static ScriptableInventoryItem GetItem(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)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected I4, but got Unknown
		if ((Object)(object)__result == (Object)null)
		{
			ScriptableInventoryItem val = ((IEnumerable<ScriptableInventoryItem>)Plugin.ItemLoader._items).FirstOrDefault((Func<ScriptableInventoryItem, bool>)((ScriptableInventoryItem x) => x.ID == id));
			Plugin.ItemLoader._logger.LogDebug((object)("Rewrote item id for " + (int)id + " to be " + (object)val));
			return val;
		}
		return __result;
	}
}
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;
	}

	public static IEnumerable<T> FilterAndCast<T>(this IEnumerable<Object> source)
	{
		return source.Where((Object x) => x is T).Cast<T>();
	}
}
public class LocalizationLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private readonly List<LocalizationResource> _localizationAssets;

	private readonly Dictionary<string, string> _localizationValues = new Dictionary<string, string>();

	public LocalizationLoader(ManualLogSource logger, Harmony harmony, List<Object> allAssets)
	{
		_logger = logger;
		_harmony = harmony;
		_localizationAssets = allAssets.FilterAndCast<LocalizationResource>().ToList();
		logger.LogDebug((object)("Found " + _localizationAssets.Count + " total localization assets."));
	}

	public void Patch()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(Localization), "SetLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(LocalizationLoader), "SetLanguage", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(Localization), "GetLocalizedValue", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(LocalizationLoader), "GetLocalizedValue", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static void SetLanguage(int index)
	{
		Plugin.LocalizationLoader._localizationValues.Clear();
		string localizationName = Localization.GetLanguageName(index);
		List<Localization> list = (from x in Plugin.LocalizationLoader._localizationAssets.Select(delegate(LocalizationResource asset)
			{
				Plugin.LocalizationLoader._logger.LogDebug((object)("Total localizations in this asset: " + asset.localizations.Length));
				Plugin.LocalizationLoader._logger.LogDebug((object)("Languages in this asset: " + string.Join(",", asset.localizations.Select((Localization x) => x.language).ToList())));
				return ((IEnumerable<Localization>)asset.localizations).FirstOrDefault((Func<Localization, bool>)((Localization localization) => localization.language == localizationName));
			})
			where x != null
			select x).ToList();
		Plugin.LocalizationLoader._logger.LogDebug((object)("Found " + list.Count + " localization resources."));
		foreach (Localization item in list)
		{
			string[] array = item.localizations.text.Split("\n");
			foreach (string text in array)
			{
				if (!string.IsNullOrEmpty(text))
				{
					string[] array2 = text.Split("\t");
					if (array2.Length != 2)
					{
						Plugin.LocalizationLoader._logger.LogWarning((object)("Localization line is invalid. " + text));
					}
					else
					{
						Plugin.LocalizationLoader._localizationValues.Add(array2[0], array2[1]);
					}
				}
			}
		}
	}

	public static string GetLocalizedValue(string __result, string key)
	{
		if (string.IsNullOrEmpty(__result) && Plugin.LocalizationLoader._localizationValues.TryGetValue(key, out var value))
		{
			return value;
		}
		return __result;
	}
}
[BepInPlugin("AloftModLoader", "AloftModLoader", "0.2.0")]
public class Plugin : BaseUnityPlugin
{
	public static List<AssetBundle> AllBundles;

	public static List<Object> AllAssets;

	public static LocalizationLoader LocalizationLoader;

	public static ItemLoader ItemLoader;

	public static CraftingRecipeLoader CraftingRecipeLoader;

	public static ConstructionLoader ConstructionLoader;

	public static EntityLoader EntityLoader;

	public static CookingLoader CookingLoader;

	public static SpawnerLoader SpawnerLoader;

	public static EquipmentLoader EquipmentLoader;

	public static UnlockLoader UnlockLoader;

	public static WorldGenerationLoader WorldGenerationLoader;

	public static VanillaGameAssetLocator AssetLocator;

	public static ConfigEntry<bool> configLogDebugILPatches;

	public Plugin()
	{
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Expected O, but got Unknown
		configLogDebugILPatches = ((BaseUnityPlugin)this).Config.Bind<bool>("Logging", "LogILPatchInstructions", false, "Log (at debug) the IL Patch instructions after the patch has been applied.");
		((BaseUnityPlugin)this).Logger.LogDebug((object)("Info location: " + ((BaseUnityPlugin)this).Info.Location));
		string text = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		if (!text.EndsWith("plugins"))
		{
			text = Path.Combine(text, "..");
		}
		string[] files = Directory.GetFiles(text, "*.amf.assetbundle", SearchOption.AllDirectories);
		((BaseUnityPlugin)this).Logger.LogDebug((object)("Found bundles: " + string.Join(",", files)));
		AllBundles = files.Select(delegate(string x)
		{
			((BaseUnityPlugin)this).Logger.LogDebug((object)("Loading bundle " + x));
			return AssetBundle.LoadFromFile(x);
		}).ToList();
		AllAssets = AllBundles.SelectMany((AssetBundle x) => x.LoadAllAssets()).ForEach(delegate(Object x)
		{
			((BaseUnityPlugin)this).Logger.LogDebug((object)("Loaded asset " + x.name));
			x.hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad(x);
		}).ToList();
		Harmony harmony = new Harmony("AloftModLoader");
		AssetLocator = new VanillaGameAssetLocator(((BaseUnityPlugin)this).Logger, harmony);
		AssetLocator.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading localizations");
		LocalizationLoader = new LocalizationLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		LocalizationLoader.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading items.");
		ItemLoader = new ItemLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		ItemLoader.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading entities.");
		EntityLoader = new EntityLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		EntityLoader.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading crafting recipes.");
		CraftingRecipeLoader = new CraftingRecipeLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		CraftingRecipeLoader.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading constructions.");
		ConstructionLoader = new ConstructionLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		ConstructionLoader.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading cooking assets.");
		CookingLoader = new CookingLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		CookingLoader.Patch();
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Loading spawners.");
		SpawnerLoader = new SpawnerLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		SpawnerLoader.Patch();
		EquipmentLoader = new EquipmentLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		EquipmentLoader.Patch();
		UnlockLoader = new UnlockLoader(((BaseUnityPlugin)this).Logger, harmony, AllAssets);
		UnlockLoader.Patch();
	}

	public void Awake()
	{
		Level.LoadSceneCallBack = (Action)Delegate.Combine(Level.LoadSceneCallBack, new Action(LoadSceneCallBack));
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Awake!");
	}

	private void LoadSceneCallBack()
	{
		ScriptableEquipable[] equipables = Level.ConstantManager.ConstantManagers.InventoryManager.Equipables;
		((BaseUnityPlugin)this).Logger.LogDebug((object)("During load scene callback found " + equipables.Length + " scriptable equipables."));
		UnlockLoader.LoadCallback();
	}
}
public class SpawnerLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private List<AloftModLoaderPopulationSpawner> populationChances;

	private List<PopBalanceList> AlreadyAdjustedPopBalancedLists = new List<PopBalanceList>();

	public SpawnerLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		_logger = logger;
		_harmony = harmony;
		populationChances = (from x in assets.FilterAndCast<PopulationSpawner>()
			select new AloftModLoaderPopulationSpawner
			{
				PopIDs = x.spawnedPopulations.Select((PopulationReference popRef) => popRef.GetPopulationId()).ToArray(),
				Spreading = x.spreading,
				biome = x.biome.GetBiome(),
				spawner = x.spawner.GetPopulationId(),
				Density = x.density,
				DebugTitle = ((Object)x).name,
				SpawnAmount = x.spawnAmount,
				ChanceToSpawn = Vector2.zero
			}).ToList();
	}

	public void Patch()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(SBalancingManager), "GetResourceBalancing", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(SpawnerLoader), "GetResourceBalancing", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static List<PopulationGroupDataKit> GetPopulationGroupDataKits(List<PopulationGroupDataKit> __result, Vector3 popLocalPosition, float seed, bool islandIsHealthy, bool islandIsCleansed, SPopBalancing __instance)
	{
		if (((Object)__instance).name.StartsWith("CropBalancing_"))
		{
			Plugin.SpawnerLoader._logger.LogDebug((object)(((Object)__instance).name + ": " + __result.Count + " : " + string.Join(",", __result.Select((PopulationGroupDataKit x) => (int)x.PopID).ToList())));
		}
		return __result;
	}

	public static SResourceBalancing GetResourceBalancing(SResourceBalancing __result, ID popSpawnerID, PopBalanceSpawner __instance)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__result != (Object)null)
		{
			ID spawnerBeingRequested = __result.SpawnerID;
			List<AloftModLoaderPopulationSpawner> list = Plugin.SpawnerLoader.populationChances.Where((AloftModLoaderPopulationSpawner x) => x.spawner == spawnerBeingRequested).ToList();
			if (list.Count == 0)
			{
				Plugin.SpawnerLoader._logger.LogDebug((object)("Did not find any relevant spawners for spawner " + ((object)(ID)(ref spawnerBeingRequested)).ToString()));
				return __result;
			}
			Vector2 val = default(Vector2);
			for (int i = 0; i < __result.PopListPerBiome.Length; i++)
			{
				PopBalanceList popListPerBiome = __result.PopListPerBiome[i];
				if (Plugin.SpawnerLoader.AlreadyAdjustedPopBalancedLists.Contains(popListPerBiome))
				{
					continue;
				}
				Plugin.SpawnerLoader.AlreadyAdjustedPopBalancedLists.Add(popListPerBiome);
				List<AloftModLoaderPopulationSpawner> list2 = list.Where((AloftModLoaderPopulationSpawner x) => x.biome == popListPerBiome.BiomeID).ToList();
				if (list2.Count == 0)
				{
					Plugin.SpawnerLoader._logger.LogDebug((object)("Did not find any relevant spawners for biome " + ((object)(CreatorTagBiomeID)(ref popListPerBiome.BiomeID)).ToString()));
					continue;
				}
				for (int j = 0; j < popListPerBiome.PopBalanceData.PopBalancings.Length; j++)
				{
					Plugin.SpawnerLoader._logger.LogDebug((object)("Attaching new spawning populations to " + ((object)(ID)(ref spawnerBeingRequested)).ToString() + ": " + string.Join(",", list2.Cast<PopChance>().ToList())));
					popListPerBiome.PopBalanceData.PopBalancings[j].Pops = CollectionExtensions.AddRangeToArray<PopChance>(popListPerBiome.PopBalanceData.PopBalancings[j].Pops, list2.Cast<PopChance>().ToArray());
					float num = 1f / (float)popListPerBiome.PopBalanceData.PopBalancings[j].Pops.Length;
					for (int k = 0; k < popListPerBiome.PopBalanceData.PopBalancings[j].Pops.Length; k++)
					{
						((Vector2)(ref val))..ctor(num * (float)k, num * (float)(k + 1));
						ManualLogSource logger = Plugin.SpawnerLoader._logger;
						Vector2 val2 = val;
						logger.LogDebug((object)("Chance set to : " + ((object)(Vector2)(ref val2)).ToString()));
						popListPerBiome.PopBalanceData.PopBalancings[j].Pops[k].ChanceToSpawn = val;
					}
				}
			}
		}
		return __result;
	}
}
public class AloftModLoaderBlueprint : SBlueprint
{
	public BiomeReference biome;

	public StoneType stoneType;
}
public class UnlockLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	private readonly Material _interactableSelectableMaterial;

	private readonly List<ScriptableUnlock> _unlocks;

	private readonly List<AloftModLoaderBlueprint> _stoneUnlocks;

	public UnlockLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		_logger = logger;
		_harmony = harmony;
		_unlocks = assets.FilterAndCast<AutomaticUnlock>().Select(delegate(AutomaticUnlock x)
		{
			ScriptableUnlock obj = ScriptableObject.CreateInstance<ScriptableUnlock>();
			obj.Buildings = x.requiredPopulations.Select((PopulationReference pop) => pop.GetPopulationId()).ToArray();
			obj.Items = x.requiredItems.Select((ItemReference item) => item.GetItemId()).ToArray();
			obj.RecipeBuildingID = x.unlockedPopulations.Select((PopulationReference pop) => pop.GetPopulationId()).ToArray();
			obj.RecipeItemID = x.unlockedItems.Select((ItemReference item) => item.GetItemId()).ToArray();
			obj.PreventIsNewTag = x.preventIsNewTag;
			return obj;
		}).ToList();
		_stoneUnlocks = assets.FilterAndCast<StoneUnlock>().Select(delegate(StoneUnlock x)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			AloftModLoaderBlueprint aloftModLoaderBlueprint = ScriptableObject.CreateInstance<AloftModLoaderBlueprint>();
			aloftModLoaderBlueprint.biome = x.biome;
			((SBlueprint)aloftModLoaderBlueprint).LoreText = x.loreText;
			((SBlueprint)aloftModLoaderBlueprint).UnlockRecipe = x.primaryUnlock.GetPopulationId();
			((SBlueprint)aloftModLoaderBlueprint).UnlockAdditionalRecipes = x.additionalUnlocks.Select((PopulationReference pop) => pop.GetPopulationId()).ToArray();
			aloftModLoaderBlueprint.stoneType = x.stoneType;
			return aloftModLoaderBlueprint;
		}).ToList();
	}

	public void LoadCallback()
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: 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_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Expected O, but got Unknown
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: 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_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: 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)
		Level.CraftingManager.UnlockRecipe.ScriptableUnlockManager.Unlocks = CollectionExtensions.AddRangeToArray<ScriptableUnlock>(Level.CraftingManager.UnlockRecipe.ScriptableUnlockManager.Unlocks, _unlocks.ToArray());
		foreach (AloftModLoaderBlueprint stoneUnlock in _stoneUnlocks)
		{
			if ((int)stoneUnlock.stoneType == 0)
			{
				SUnlockKnowledgeList blueprintsKnowledgeStone = Level.CraftingManager.UnlockRecipe.ScriptableUnlockManager.BlueprintsKnowledgeStone;
				UnlockListPerBiome val = ((IEnumerable<UnlockListPerBiome>)blueprintsKnowledgeStone.UnlockListPerBiomes).SingleOrDefault((Func<UnlockListPerBiome, bool>)((UnlockListPerBiome x) => x.BiomeID == stoneUnlock.biome.GetBiome()));
				if (val == null)
				{
					UnlockListPerBiome[] unlockListPerBiomes = blueprintsKnowledgeStone.UnlockListPerBiomes;
					UnlockListPerBiome val2 = new UnlockListPerBiome();
					val2.BiomeID = stoneUnlock.biome.GetBiome();
					val2.MessageUnlockDecorations = "You've unlocked something!";
					val2.MessageUnlocksNothing = "You've unlocked nothing!";
					UnlockListPerBiome obj = val2;
					UnlockListData[] array = new UnlockListData[1];
					UnlockListData val3 = default(UnlockListData);
					SBlueprint[] unlockList = (SBlueprint[])(object)new AloftModLoaderBlueprint[1] { stoneUnlock };
					val3.UnlockList = unlockList;
					array[0] = val3;
					obj.UnlockLists = (UnlockListData[])(object)array;
					blueprintsKnowledgeStone.UnlockListPerBiomes = CollectionExtensions.AddToArray<UnlockListPerBiome>(unlockListPerBiomes, val2);
				}
				else
				{
					UnlockListData val3 = default(UnlockListData);
					val3.UnlockList = (SBlueprint[])(object)new SBlueprint[1] { stoneUnlock };
					UnlockListData val4 = val3;
					val.UnlockLists = CollectionExtensions.AddToArray<UnlockListData>(val.UnlockLists, val4);
				}
			}
			else
			{
				SUnlockKnowledgeList blueprintsSailingStone = Level.CraftingManager.UnlockRecipe.ScriptableUnlockManager.BlueprintsSailingStone;
				UnlockListPerBiome val5 = ((IEnumerable<UnlockListPerBiome>)blueprintsSailingStone.UnlockListPerBiomes).SingleOrDefault((Func<UnlockListPerBiome, bool>)((UnlockListPerBiome x) => x.BiomeID == stoneUnlock.biome.GetBiome()));
				if (val5 == null)
				{
					UnlockListPerBiome[] unlockListPerBiomes2 = blueprintsSailingStone.UnlockListPerBiomes;
					UnlockListPerBiome val2 = new UnlockListPerBiome();
					val2.BiomeID = stoneUnlock.biome.GetBiome();
					val2.MessageUnlockDecorations = "You've unlocked something!";
					val2.MessageUnlocksNothing = "You've unlocked nothing!";
					UnlockListPerBiome obj2 = val2;
					UnlockListData[] array2 = new UnlockListData[1];
					UnlockListData val3 = default(UnlockListData);
					SBlueprint[] unlockList = (SBlueprint[])(object)new AloftModLoaderBlueprint[1] { stoneUnlock };
					val3.UnlockList = unlockList;
					array2[0] = val3;
					obj2.UnlockLists = (UnlockListData[])(object)array2;
					blueprintsSailingStone.UnlockListPerBiomes = CollectionExtensions.AddToArray<UnlockListPerBiome>(unlockListPerBiomes2, val2);
				}
				else
				{
					UnlockListData val3 = default(UnlockListData);
					val3.UnlockList = (SBlueprint[])(object)new SBlueprint[1] { stoneUnlock };
					UnlockListData val6 = val3;
					val5.UnlockLists = CollectionExtensions.AddToArray<UnlockListData>(val5.UnlockLists, val6);
				}
			}
		}
	}

	public void Patch()
	{
	}
}
public class VanillaGameAssetLocator
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	public VanillaGameAssetLocator(ManualLogSource logger, Harmony harmony)
	{
		_logger = logger;
		_harmony = harmony;
	}

	public void Patch()
	{
	}

	public static void Start()
	{
		Plugin.AssetLocator._logger.LogDebug((object)"Running late start!");
		ScriptableEquipable[] array = Object.FindObjectsOfType<ScriptableEquipable>();
		Plugin.AssetLocator._logger.LogDebug((object)("During start found " + array.Length + " scriptable equipables."));
		ScriptableEquipable[] equipables = Level.ConstantManager.ConstantManagers.InventoryManager.Equipables;
		Plugin.AssetLocator._logger.LogDebug((object)("During start found " + equipables.Length + " scriptable equipables."));
	}
}
public class WorldGenerationLoader
{
	private readonly ManualLogSource _logger;

	private readonly Harmony _harmony;

	public WorldGenerationLoader(ManualLogSource logger, Harmony harmony, List<Object> assets)
	{
		_logger = logger;
		_harmony = harmony;
	}

	public void Patch()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		_harmony.Patch((MethodBase)AccessTools.Method(typeof(WorldGenerator), "GenerateRings", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(WorldGenerationLoader), "GenerateRings", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static void GenerateRings(WorldGenerator __instance, SWorldGenerator generationData)
	{
		Console.WriteLine("Generating rings from world generator!");
		RingData[] ringDatas = generationData.RingGenerator.RingDatas;
		for (int i = 0; i < ringDatas.Length; i++)
		{
			Console.WriteLine("Cluster per sector count is: " + ringDatas[i].ClusterPerSectors.Min + " - " + ringDatas[i].ClusterPerSectors.Max);
		}
	}

	public void LoadCallback()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		Console.WriteLine("Load callback from world generator!");
		RingData[] ringDatas = Level.ConstantManager.ConstantManagers.WorldManager.RingGenerator.RingDatas;
		for (int i = 0; i < ringDatas.Length; i++)
		{
			Level.ConstantManager.ConstantManagers.WorldManager.RingGenerator.RingDatas[i].ClusterPerSectors = new MinMaxInt(20, 30);
		}
		MinMaxInt islandCountPerCluster = Level.ConstantManager.ConstantManagers.WorldManager.ClusterGenerator.GetCluster((CreatorTagBiomeID)1).IslandCountPerCluster;
		Console.WriteLine("Islnads for biome 1 per cluster: " + islandCountPerCluster.Min + " - " + islandCountPerCluster.Max);
	}
}

plugins/AloftModFramework.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using AloftModFramework.Construction;
using AloftModFramework.Entities;
using AloftModFramework.Equipment;
using AloftModFramework.Items;
using Audio;
using Crafting.MultiStep_Construction;
using Creator.Creator_IO;
using Player.Hands;
using Player.Player_Equip;
using Scriptable_Objects;
using Scriptable_Objects.Combat;
using Scriptable_Objects.Cooking;
using Terrain.Platforms.Population.Population_Soul;
using UnityEngine;
using Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace AloftModFramework
{
	[Serializable]
	public class IngredientTypeReference
	{
		public IngredientType vanillaType;

		public int id;

		public int GetIngredientTypeAsInt()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			if ((int)vanillaType != 0)
			{
				return (int)vanillaType;
			}
			return id;
		}

		public IngredientType GetIngredientType()
		{
			return (IngredientType)GetIngredientTypeAsInt();
		}
	}
	[Serializable]
	public class BiomeReference
	{
		public CreatorTagBiomeID vanillaBiome;

		public int GetBiomeAsInt()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			return (int)vanillaBiome;
		}

		public CreatorTagBiomeID GetBiome()
		{
			return (CreatorTagBiomeID)GetBiomeAsInt();
		}
	}
}
namespace AloftModFramework.Unlocks
{
	[CreateAssetMenu(fileName = "AutomaticUnlock", menuName = "Aloft Mod Framework/Automatic Unlock")]
	public class AutomaticUnlock : ScriptableObject
	{
		public ItemReference[] requiredItems;

		public PopulationReference[] requiredPopulations;

		public ItemReference[] unlockedItems;

		public PopulationReference[] unlockedPopulations;

		public bool preventIsNewTag;
	}
	public enum StoneType
	{
		KnowledgeStone,
		Anchor
	}
	[CreateAssetMenu(fileName = "StoneUnlock", menuName = "Aloft Mod Framework/Stone Unlock")]
	public class StoneUnlock : ScriptableObject
	{
		public StoneType stoneType;

		public BiomeReference biome;

		public string loreText;

		public PopulationReference primaryUnlock;

		public PopulationReference[] additionalUnlocks;
	}
}
namespace AloftModFramework.Spawners
{
	[CreateAssetMenu(fileName = "PopulationSpawner", menuName = "Aloft Mod Framework/Population Spawner")]
	public class PopulationSpawner : ScriptableObject
	{
		public PopulationReference[] spawnedPopulations;

		public PopulationReference spawner;

		public MinMaxInt spawnAmount;

		public MinMax spreading;

		[Range(0f, 1f)]
		public float density;

		public BiomeReference biome;
	}
}
namespace AloftModFramework.Localization
{
	[Serializable]
	public class Localization
	{
		public string language;

		public TextAsset localizations;
	}
	[CreateAssetMenu(fileName = "Localization", menuName = "Aloft Mod Framework/Localization")]
	public class LocalizationResource : ScriptableObject
	{
		public Localization[] localizations;
	}
}
namespace AloftModFramework.Items
{
	[CreateAssetMenu(fileName = "Item", menuName = "Aloft Mod Framework/Item")]
	public class Item : ScriptableObject
	{
		public int id;

		public string itemName;

		public string description;

		public Sprite sprite;

		public ItemCategoryReference category;

		public ItemTypeReference type;

		public ItemWeightReference weight;

		public EquippableReference equipType;

		public PickupAudioTagReference pickupAudioTag;

		public ItemTagReference[] itemTags;
	}
	public class ItemCategory : ScriptableObject
	{
		public int id;
	}
	[Serializable]
	public class ItemCategoryReference
	{
		public ItemCategory itemCategory;

		public ItemCatergory vanillaCategory;

		public int id;

		public int GetCategoryAsInt()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)itemCategory != (Object)null)
			{
				return itemCategory.id;
			}
			if ((int)vanillaCategory != 0)
			{
				return (int)vanillaCategory;
			}
			return id;
		}

		public ItemCatergory GetCategory()
		{
			return (ItemCatergory)GetCategoryAsInt();
		}
	}
	[Serializable]
	public class ItemReference
	{
		public Item item;

		public int id;

		public ID vanillaItem;

		public int GetItemIdAsInt()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)item != (Object)null)
			{
				return item.id;
			}
			if ((int)vanillaItem != 0)
			{
				return (int)vanillaItem;
			}
			return id;
		}

		public ID GetItemId()
		{
			return (ID)GetItemIdAsInt();
		}
	}
	[Serializable]
	public class ItemReferenceWithQuantity
	{
		public Item item;

		public int id;

		public ID vanillaItem;

		public int quantity;

		public int GetItemIdAsInt()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)item != (Object)null)
			{
				return item.id;
			}
			if ((int)vanillaItem != 0)
			{
				return (int)vanillaItem;
			}
			return id;
		}

		public ID GetItemId()
		{
			return (ID)GetItemIdAsInt();
		}
	}
	public class ItemTag : ScriptableObject
	{
		public int id;
	}
	[Serializable]
	public class ItemTagReference
	{
		public ItemTag itemTag;

		public ItemTagID vanillaTag;

		public int id = -1;

		public int GetTagAsInt()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if ((Object)(object)itemTag != (Object)null)
			{
				return itemTag.id;
			}
			if (id != -1)
			{
				return id;
			}
			return (int)vanillaTag;
		}

		public ItemTagID GetTag()
		{
			return (ItemTagID)GetTagAsInt();
		}
	}
	public class ItemType : ScriptableObject
	{
		public int id;
	}
	[Serializable]
	public class ItemTypeReference
	{
		public ItemType itemType;

		public ItemType vanillaType;

		public int id = -1;

		public int GetItemTypeAsInt()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if ((Object)(object)itemType != (Object)null)
			{
				return itemType.id;
			}
			if (id != -1)
			{
				return id;
			}
			return (int)vanillaType;
		}

		public ItemType GetItemType()
		{
			return (ItemType)GetItemTypeAsInt();
		}
	}
	public class ItemWeight : ScriptableObject
	{
		public int id;
	}
	[Serializable]
	public class ItemWeightReference
	{
		public ItemWeight itemWeight;

		public ItemWeight vanillaWeight;

		public int id = -1;

		public int GetWeightAsInt()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if ((Object)(object)itemWeight != (Object)null)
			{
				return itemWeight.id;
			}
			if (id != -1)
			{
				return id;
			}
			return (int)vanillaWeight;
		}

		public ItemWeight GetWeight()
		{
			return (ItemWeight)GetWeightAsInt();
		}
	}
	public class PickupAudioTag : ScriptableObject
	{
		public int id;
	}
	[Serializable]
	public class PickupAudioTagReference
	{
		public PickupAudioTag audioTag;

		public PickUpAudioTagID vanillaTag;

		public int id;

		public int GetWeightAsInt()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)audioTag != (Object)null)
			{
				return audioTag.id;
			}
			if ((int)vanillaTag != 0)
			{
				return (int)vanillaTag;
			}
			return id;
		}

		public PickUpAudioTagID GetAudioTag()
		{
			return (PickUpAudioTagID)GetWeightAsInt();
		}
	}
}
namespace AloftModFramework.Equipment
{
	[CreateAssetMenu(fileName = "Equippable", menuName = "Aloft Mod Framework/Equippable")]
	public class Equippable : ScriptableObject
	{
		public int id;

		public ItemReference item;

		public GameObject heldItemPrefab;

		public HandBehaviour handBehaviour;

		public SCombatValues combatValues;

		public SBowValues bowValues;

		public EquippableTemplateReference equippableTemplate;
	}
	[Serializable]
	public class EquippableReference
	{
		public Equippable equippable;

		public Equipable vanillaEquippable;

		public int id;

		public int GetEquippableAsInt()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)equippable != (Object)null)
			{
				return equippable.id;
			}
			if ((int)vanillaEquippable != 0)
			{
				return (int)vanillaEquippable;
			}
			return id;
		}

		public Equipable GetEquippable()
		{
			return (Equipable)GetEquippableAsInt();
		}
	}
	public class EquippableTemplate : ScriptableObject
	{
		public ScriptableCombatAnimationOverride overrideAnimations;

		public SCombatAnimationThirdPerson thirdPersonAnimations;
	}
	public enum VanillaEquippableTemplate
	{
		None,
		Pickaxe
	}
	[Serializable]
	public class EquippableTemplateReference
	{
		public EquippableTemplate template;

		public VanillaEquippableTemplate vanillaTemplate;
	}
}
namespace AloftModFramework.Entities
{
	[Serializable]
	public class BehaviorTypeReference
	{
		public BehaviourTypeEnum vanillaBehaviorType;

		public BehaviourTypeEnum GetBehaviorType()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return vanillaBehaviorType;
		}
	}
	[Serializable]
	public class DataTagReference
	{
		public PopDataTagID vanillaTag;

		public PopDataTagID GetTag()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return vanillaTag;
		}
	}
	[Serializable]
	public class MultistepBehaviorReference
	{
		public MultiStepBehaviour vanillaBehavior;

		public MultiStepBehaviour GetMultistepBehavior()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return vanillaBehavior;
		}
	}
	[CreateAssetMenu(fileName = "Population", menuName = "Aloft Mod Framework/Population")]
	public class Population : ScriptableObject
	{
		public int id;

		public GameObject prefab;

		public BehaviorTypeReference behaviorType;

		public MultistepBehaviorReference multistepBehavior;

		public SpawnDistance loadDistance = (SpawnDistance)2;

		public DataTagReference[] dataTags;

		public bool learnedFromSketching;

		public ConstructionBlueprint learnedBlueprint;
	}
	[Serializable]
	public class PopulationReference
	{
		public Population population;

		public ID vanillaPopulation;

		public int id;

		public int GetPopulationIdAsInt()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)population != (Object)null)
			{
				return population.id;
			}
			if ((int)vanillaPopulation != 0)
			{
				return (int)vanillaPopulation;
			}
			return id;
		}

		public ID GetPopulationId()
		{
			return (ID)GetPopulationIdAsInt();
		}
	}
}
namespace AloftModFramework.Crafting
{
	[CreateAssetMenu(fileName = "CraftingRecipe", menuName = "Aloft Mod Framework/Crafting Recipe")]
	public class CraftingRecipe : ScriptableObject
	{
		public ItemReference[] inputItems;

		public ItemReference outputItem;

		public int quantity;

		public bool attachToStation;

		public CraftingStationReference craftingStation;
	}
	[CreateAssetMenu(fileName = "CraftingStation", menuName = "Aloft Mod Framework/Crafting Station")]
	public class CraftingStation : ScriptableObject
	{
		public int stationId;

		public string stationName;
	}
	[Serializable]
	public class CraftingStationReference
	{
		public CraftingStation station;

		public CraftingStation vanillaStation;

		public int id = -1;

		public int GetStationAsInt()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if ((Object)(object)station != (Object)null)
			{
				return station.stationId;
			}
			if (id != -1)
			{
				return id;
			}
			return (int)vanillaStation;
		}

		public CraftingStation GetStation()
		{
			return (CraftingStation)GetStationAsInt();
		}
	}
}
namespace AloftModFramework.Cooking
{
	[Serializable]
	public class CategoryReference
	{
		public CookingCategory vanillaCategory;

		public int id;

		public int GetCategoryAsInt()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			if ((int)vanillaCategory != 0)
			{
				return (int)vanillaCategory;
			}
			return id;
		}

		public CookingCategory GetCategory()
		{
			return (CookingCategory)GetCategoryAsInt();
		}
	}
	[Serializable]
	public class ConditionTriggerReference
	{
		public ConditionTrigger vanillaConditionTrigger;

		public int id;

		public int GetConditionTriggerAsInt()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			if ((int)vanillaConditionTrigger != 0)
			{
				return (int)vanillaConditionTrigger;
			}
			return id;
		}

		public ConditionTrigger GetConditionTrigger()
		{
			return (ConditionTrigger)GetConditionTriggerAsInt();
		}
	}
	[CreateAssetMenu(fileName = "CookingRecipe", menuName = "Aloft Mod Framework/Cooking Recipe")]
	public class CookingRecipe : ScriptableObject
	{
		public bool isPerfectRecipe;

		public ItemReference[] inputs;

		public ItemReference output;

		public CategoryReference category;

		public bool unlockableByRecipePage;

		public RecipeVariationsStruct[] variations;
	}
	[CreateAssetMenu(fileName = "Meal", menuName = "Aloft Mod Framework/Cooking Meal")]
	public class Meal : ScriptableObject
	{
		public ItemReference item;

		public int statDuration;

		public int statHpMaxAmount;

		public ConditionTriggerReference[] triggerConditions;

		public bool edible;

		public bool preventBurning;

		public IngredientTypeReference ingredientType;
	}
}
namespace AloftModFramework.Construction
{
	[CreateAssetMenu(fileName = "Construction Blueprint", menuName = "Aloft Mod Framework/Construction Blueprint")]
	public class ConstructionBlueprint : ScriptableObject
	{
		public string displayName;

		public string description;

		public Sprite sprite;

		public PopulationReference populationData;

		public bool hideInBuildMenu;

		public ConstructionCategoryReference category;

		public float defaultScale = 1f;

		public ItemReferenceWithQuantity[] craftingCost;

		public ItemReferenceWithQuantity[] hammerCost;

		public PopulationReference isVariantOf;

		public PopulationReference[] variants;

		public PopulationReference[] unlockedPopulations;

		public ConstructionMaterialReference audioType;
	}
	[CreateAssetMenu(fileName = "ConstructionCategory", menuName = "Aloft Mod Framework/Construction Category")]
	public class ConstructionCategory : ScriptableObject
	{
		public int id;

		public string categoryName;

		public Sprite displayIcon;

		public Sprite secondaryIcon;

		public bool useParentCategory;

		public ConstructionCategoryReference parentCategory;
	}
	[Serializable]
	public class ConstructionCategoryReference
	{
		public ConstructionCategory category;

		public BuildingCategory vanillaCategory;

		public int id = -1;

		public int GetCategoryAsInt()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if ((Object)(object)category != (Object)null)
			{
				return category.id;
			}
			if (id != -1)
			{
				return id;
			}
			return (int)vanillaCategory;
		}

		public BuildingCategory GetCategory()
		{
			return (BuildingCategory)GetCategoryAsInt();
		}
	}
	public class ConstructionMaterial : ScriptableObject
	{
		public int id;
	}
	[Serializable]
	public class ConstructionMaterialReference
	{
		public ConstructionMaterial material;

		public ConstructionMaterial vanillaMaterial;

		public int id = -1;

		public int GetConstructionMaterialAsInt()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if ((Object)(object)material != (Object)null)
			{
				return material.id;
			}
			if (id != -1)
			{
				return id;
			}
			return (int)vanillaMaterial;
		}

		public ConstructionMaterial GetConstructionMaterial()
		{
			return (ConstructionMaterial)GetConstructionMaterialAsInt();
		}
	}
}