using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;
using xiaoye97;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BetterMachines")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterMachines")]
[assembly: AssemblyTitle("BetterMachines")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace InstallCheck
{
[BepInPlugin("org.kremnev8.plugin.BetterMachinesInstallCheck", "Better Machines Installation Checker", "1.2.1")]
public class InstallationChecker : BaseUnityPlugin
{
public const string MODNAME = "Better Machines Installation Checker";
public const string MODGUID = "org.kremnev8.plugin.BetterMachinesInstallCheck";
public const string LDBTOOL_GUID = "me.xiaoye97.plugin.Dyson.LDBTool";
public const string REBIND_BUILD_BAR_GUID = "org.kremnev8.plugin.RebindBuildBar";
public static bool ldbToolInstalled;
public static bool commonAPIInstalled;
public static bool rebindBuildBarInstalled;
public static bool assetBundleFound;
public static bool installationIsValid;
private void Awake()
{
if (Chainloader.PluginInfos.ContainsKey("me.xiaoye97.plugin.Dyson.LDBTool"))
{
ldbToolInstalled = true;
}
if (Chainloader.PluginInfos.ContainsKey("org.kremnev8.plugin.RebindBuildBar"))
{
rebindBuildBarInstalled = true;
}
if (Chainloader.PluginInfos.ContainsKey("dsp.common-api.CommonAPI"))
{
commonAPIInstalled = true;
}
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
assetBundleFound = File.Exists(directoryName + "/bettermachines");
installationIsValid = ldbToolInstalled && commonAPIInstalled && assetBundleFound;
Harmony.CreateAndPatchAll(typeof(UIMainMenuPatch), (string)null);
if (installationIsValid)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Check successful. Installation is correct!");
}
else
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Check failed. Mod is installed incorrectly!");
}
}
}
public static class UIMainMenuPatch
{
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
[HarmonyPostfix]
public static void OnMainMenuOpen()
{
if (!InstallationChecker.installationIsValid)
{
string text = "Mod installation is incorrect because:\n";
if (!InstallationChecker.assetBundleFound)
{
text += " - Asset Bundle in installation folder is missing!\n";
}
if (!InstallationChecker.ldbToolInstalled)
{
text += " - Plugin \"LDB Tool\" is missing\n";
}
if (!InstallationChecker.commonAPIInstalled)
{
text += " - Plugin \"Common API\" is missing\n";
}
if (!InstallationChecker.rebindBuildBarInstalled)
{
text += " - Recommended plugin \"Rebind Build Bar\" is missing\n";
}
text += "Please check your installation, make sure you followed installation instructions correctly.\nIf you are using a mod manager make sure that all dependencies have been downloaded!\nIf nothing helps you can message me via Discord: Kremnev8#3756";
UIMessageBox.Show("Better Machines mod installation is incorrect!", text, "Ok", 3);
}
}
}
}
namespace FasterMachines
{
[BepInPlugin("org.kremnev8.plugin.BetterMachines", "Better Machines", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "CustomDescSystem", "UtilSystem", "LocalizationModule" })]
public class BetterMachinesPlugin : BaseUnityPlugin
{
public const string MODNAME = "BetterMachines";
public const string MODGUID = "org.kremnev8.plugin.BetterMachines";
public const string MOD_DISP_NAME = "Better Machines";
public const string VERSION = "1.2.1";
public ItemProto smelterMk2item;
public static List<ItemProto> bmItems = new List<ItemProto>();
public ModelProto smelterMk3;
public ModelProto liquidTankMk2;
public ModelProto liquidTankMk3;
public ItemProto beltMk4Item;
public ModelProto beltMk4;
public static ResourceData resources;
public static ManualLogSource logger;
public static ConfigFile config;
public static Color belt4Color = new Color(43f / 85f, 0.4039216f, 82f / 85f);
public static Material gizmoMat;
public static Material gizmoLineMat;
private static readonly int emissionSwitch = Shader.PropertyToID("_EmissionSwitch");
private static readonly int emissionUsePower = Shader.PropertyToID("_EmissionUsePower");
private static readonly int albedoMultiplier = Shader.PropertyToID("_AlbedoMultiplier");
private static readonly int emissionMultiplier = Shader.PropertyToID("_EmissionMultiplier");
private static readonly int emissionJitter = Shader.PropertyToID("_EmissionJitter");
private static readonly int alphaClip = Shader.PropertyToID("_AlphaClip");
private static readonly int tintColor = Shader.PropertyToID("_TintColor");
private static readonly int invFade = Shader.PropertyToID("_InvFade");
private static readonly int bumpScale = Shader.PropertyToID("_BumpScale");
private static readonly int smoothMultiplier = Shader.PropertyToID("_SmoothMultiplier");
private static readonly int specularColor = Shader.PropertyToID("_SpecularColor");
private static readonly int rimColor = Shader.PropertyToID("_RimColor");
private static readonly int emissionColor = Shader.PropertyToID("_EmissionColor");
public static ConfigEntry<int> oldChemPlantID;
private void Awake()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_061b: Unknown result type (might be due to invalid IL or missing references)
//IL_0640: Unknown result type (might be due to invalid IL or missing references)
//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0718: Unknown result type (might be due to invalid IL or missing references)
//IL_0740: Unknown result type (might be due to invalid IL or missing references)
//IL_075f: Unknown result type (might be due to invalid IL or missing references)
//IL_0f68: Unknown result type (might be due to invalid IL or missing references)
//IL_10f3: Unknown result type (might be due to invalid IL or missing references)
//IL_10f9: Expected O, but got Unknown
logger = ((BaseUnityPlugin)this).Logger;
config = ((BaseUnityPlugin)this).Config;
oldChemPlantID = config.Bind<int>("General", "OldChemicalPlantID", 3702, "If you have rebound Chemical Plant Mk.III item ID, you will need to specify it here to allow for correct migration.");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
using (ProtoRegistry.StartModLoad("org.kremnev8.plugin.BetterMachines"))
{
resources = new ResourceData("org.kremnev8.plugin.BetterMachines", "BetterMachines", directoryName);
resources.LoadAssetBundle("bettermachines");
resources.ResolveVertaFolder();
ProtoRegistry.AddResource(resources);
LocalizationModule.EditTranslation("电弧熔炉", "Arc Smelter (MK.I)", "电弧熔炉 (MK.I)", "");
LocalizationModule.RegisterTranslation("smelterMk2", "Arc Smelter (MK.II)", "电弧熔炉 (MK.II)", "");
LocalizationModule.EditTranslation("位面熔炉", "Plane Smelter (MK.III)", "位面熔炉 (MK.III)", "");
LocalizationModule.EditTranslation("化工厂", "Chemical Plant MK.I", "化工厂 MK.I", "");
LocalizationModule.RegisterTranslation("chemicalPlantMk2", "Chemical Plant MK.II", "化工厂 MK.II", "");
LocalizationModule.EditTranslation("化工厂 Mk.II", "Quantum Chemical Plant (MK.III)", "量子化工厂 (MK.III)", "");
LocalizationModule.RegisterTranslation("storageMk3", "Storage MK.III", "型储物仓 MK.III", "");
LocalizationModule.RegisterTranslation("storageMk4", "Storage MK.IV", "型储物仓 MK.IV", "");
LocalizationModule.EditTranslation("储液罐", "Liquid Tank MK.I", "储液罐 MK.I", "Réservoir de stockage de liquide MK.I");
LocalizationModule.RegisterTranslation("liquidTankMk2", "Liquid Tank MK.II", "储液罐 MK.II", "Réservoir de stockage de liquide MK.II");
LocalizationModule.RegisterTranslation("liquidTankMk3", "Liquid Tank MK.III", "储液罐 MK.III", "Réservoir de stockage de liquide MK.III");
LocalizationModule.RegisterTranslation("smelterMk2Desc", "High temperature arc smelting can smelt ores and metals, and also be used for purification and crystal smelting. By increasing maximum furnace temperature arc smelter can now smelt faster!");
LocalizationModule.EditTranslation("位面冶金结果", "You have unlocked the more advanced smelter ━━ <color=\"#FD965ECC\">Plane Smelter</color>, which is faster as an Arc Smelter (MK.II)!", "你解锁了更高级的熔炉━━<color=\"#FD965ECC\">位面熔炉</color>, 它的速度比电弧炉(MK.II)还要高!", "You have unlocked the more advanced smelter ━━ <color=\"#FD965ECC\">Plane Smelter</color>, which is faster as an Arc Smelter (MK.II)!");
LocalizationModule.RegisterTranslation("chemicalPlantMk2Desc", "Chemical facility. Can process the primary products of Crude oil into more advanced chemical products. Production speed has been increased.");
LocalizationModule.EditTranslation("I小型储物仓", "Storage MK.I is designed to store Solids.");
LocalizationModule.EditTranslation("I大型储物仓", "Storage MK.II is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.I");
LocalizationModule.RegisterTranslation("storageMk3Desc", "Storage MK.III is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.II");
LocalizationModule.RegisterTranslation("storageMk4Desc", "Storage MK.IV is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.III");
LocalizationModule.EditTranslation("I储液罐", "Liquid Tank MK.I is designed to store Liquids. When dismantling a non-empty Storage Tank any remaining fluid will be lost.");
LocalizationModule.RegisterTranslation("liquidTankMk2Desc", "Liquid Tank MK.II is designed to store Liquids. Thanks to new materials it has more capacity than Liquid Tank Mk.I. When dismantling a non-empty Storage Tank any remaining fluid will be lost.");
LocalizationModule.RegisterTranslation("liquidTankMk3Desc", "Liquid Tank MK.III is designed to store Liquids. Thanks to new materials it has more capacity than Liquid Tank Mk.II. When dismantling a non-empty Storage Tank any remaining fluid will be lost.");
LocalizationModule.RegisterTranslation("highDensityStorageTech", "High density storage");
LocalizationModule.RegisterTranslation("highDensityStorageTechDesc", "By using new stronger materials maximum capacity of Storages and Liquid Tanks can be increased.");
LocalizationModule.RegisterTranslation("highDensityStorageTechConc", "You have obtained new Storage MK.IV and Liquid Tank Mk.III, which have increased storage capacity");
LocalizationModule.RegisterTranslation("beltMk4", "Belt MK.IV");
LocalizationModule.RegisterTranslation("beltMk4Desc", "Allows to transport items around. I have heard that it's so fast, that the game doesn't understand what to do with it.");
LocalizationModule.RegisterTranslation("BMModModificationWarn", " - [Better Machines] Replaced {0} buildings", " - [Better Machines] 取代 {0} 建筑物", "");
Material val = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-part1", "#DB5860FF", new string[5] { "Assets/BetterMachines/Textures/smelter-mk1-lod0-a", "Assets/BetterMachines/Textures/smelter-mk1-lod0-n", "Assets/BetterMachines/Textures/smelter-mk1-lod0-s", "Assets/BetterMachines/Textures/smelter-mk1-lod0-e", "Assets/BetterMachines/Textures/smelter-mk1-lod0-j" });
val.SetFloat(emissionSwitch, 1f);
val.SetFloat(emissionUsePower, 1f);
val.SetFloat(albedoMultiplier, 1.3f);
val.SetFloat(emissionMultiplier, 10f);
val.SetFloat(emissionJitter, 0.5f);
Material val2 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-part2", "#DB5860FF", new string[4] { "Assets/BetterMachines/Textures/smelter-mk3-lod0-a", "Assets/BetterMachines/Textures/smelter-mk3-lod0-n", "Assets/BetterMachines/Textures/smelter-mk3-lod0-s", "Assets/BetterMachines/Textures/smelter-mk3-lod0-e" });
val2.SetFloat(emissionSwitch, 1f);
val2.SetFloat(emissionUsePower, 1f);
val2.SetFloat(albedoMultiplier, 1.3f);
val2.SetFloat(emissionMultiplier, 10f);
val2.SetFloat(emissionJitter, 0.5f);
Material val3 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-lods", "#DB5860FF", new string[4] { "Assets/BetterMachines/Textures/smelter-mk2-lod1-a", "Assets/BetterMachines/Textures/smelter-mk2-lod1-n", "Assets/BetterMachines/Textures/smelter-mk2-lod1-s", "Assets/BetterMachines/Textures/smelter-mk2-lod1-e" });
val3.SetFloat(emissionSwitch, 1f);
val3.SetFloat(emissionUsePower, 1f);
val3.SetFloat(alphaClip, 0.5f);
Material val4 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "storage-mat", "#DB5860FF", new string[3] { "Assets/BetterMachines/Textures/storage-a", "Assets/BetterMachines/Textures/storage-n", "Assets/BetterMachines/Textures/storage-s" });
Material val5 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "storage-mat", "#DB5860FF", new string[3] { "Assets/BetterMachines/Textures/storage-lod-a", "Assets/BetterMachines/Textures/storage-lod-n", "Assets/BetterMachines/Textures/storage-lod-s" });
val5.SetFloat(alphaClip, 0.5f);
Material val6 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask", "black", "#00000000");
val6.renderQueue = 2980;
val6.SetColor(tintColor, Color.black);
val6.SetFloat(invFade, 1.5f);
Material val7 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask Vertex Toggle", "liquid-tank-black", "#00000000");
val7.renderQueue = 2980;
val7.SetColor(tintColor, Color.black);
val7.SetFloat(invFade, 1.5f);
Material val8 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Vertex Toggle", "liquid-tank-mat", "#FFFFFFFF", new string[3] { "Assets/BetterMachines/Textures/storage-tank-a", "Assets/BetterMachines/Textures/storage-tank-n", "Assets/BetterMachines/Textures/storage-tank-s" });
Material val9 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Tank Vertex Toggle", "liquid-tank-glass-mat", "#F2FFFA42", new string[3] { "", "", "Assets/BetterMachines/Textures/storage-tank-glass-s" });
val9.renderQueue = 2989;
val9.SetFloat(albedoMultiplier, 3f);
val9.SetFloat(bumpScale, 1f);
val9.SetFloat(emissionMultiplier, 10f);
val9.SetFloat(smoothMultiplier, 0.8f);
val9.SetFloat(emissionSwitch, 1f);
val9.SetColor(specularColor, new Color(21f / 106f, 21f / 106f, 21f / 106f, 1f));
val9.SetColor(rimColor, new Color(0.6039216f, 0.8462228f, 0.8588235f, 1f));
string[] array = new string[4] { "Assets/BetterMachines/Textures/chemical-plant-a", "Assets/BetterMachines/Textures/chemical-plant-n", "Assets/BetterMachines/Textures/chemical-plant-s", "Assets/BetterMachines/Textures/chemical-plant-e" };
Material val10 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#00FFE8FF", array);
val10.SetFloat(emissionSwitch, 1f);
val10.SetFloat(emissionUsePower, 1f);
Material val11 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Glass", "chemical-plant-glass", "#D7F7FF29", new string[3] { "", "", "Assets/BetterMachines/Textures/chemical-plant-glass-s" });
val11.renderQueue = 3001;
val11.SetColor(emissionColor, Color.black);
val11.SetColor(rimColor, new Color(0.6448024f, 0.8279268f, 0.8490566f, 1f));
Material val12 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Glass", "chemical-plant-glass", new Color(1f, 0.6380855f, 0.1650943f, 44f / 85f));
val12.renderQueue = 3000;
val12.SetColor(emissionColor, Color.black);
string[] array2 = new string[4] { "Assets/BetterMachines/Textures/chemical-plant-lod-a", "Assets/BetterMachines/Textures/chemical-plant-lod-n", "Assets/BetterMachines/Textures/chemical-plant-lod-s", "Assets/BetterMachines/Textures/chemical-plant-lod-e" };
Material val13 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2-lod", "#00FFE8FF", array2);
val13.SetFloat(emissionSwitch, 1f);
val13.SetFloat(emissionUsePower, 1f);
val13.SetFloat(alphaClip, 0.5f);
val13.SetFloat(emissionSwitch, 1f);
val13.SetFloat(emissionUsePower, 1f);
gizmoMat = resources.bundle.LoadAsset<Material>("Assets/BetterMachines/Materials/SolidGizmo.mat");
gizmoMat.shaderKeywords = new string[2] { "_ALPHABLEND_ON", "_EMISSION" };
gizmoLineMat = resources.bundle.LoadAsset<Material>("Assets/BetterMachines/Materials/SolidLine.mat");
gizmoLineMat.shaderKeywords = new string[2] { "_ALPHABLEND_ON", "_EMISSION" };
ItemProto val14 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2315);
ItemProtoExtenstion.SetIcon(val14, "Assets/BetterMachines/Icons/smelter-3", false);
smelterMk2item = ProtoRegistry.RegisterItem(3700, "smelterMk2", "smelterMk2Desc", "Assets/BetterMachines/Icons/smelter-2", ProtoRegistry.GetGridIndex(2, 7, 8), 50, (EItemType)6);
bmItems.Add(smelterMk2item);
ItemProto val15 = ProtoRegistry.RegisterItem(3701, "chemicalPlantMk2", "chemicalPlantMk2Desc", "Assets/BetterMachines/Icons/chemical-plant-mk2", ProtoRegistry.GetGridIndex(2, 6, 8), 50, (EItemType)6);
bmItems.Add(val15);
ItemProto val16 = ProtoRegistry.RegisterItem(3703, "storageMk3", "storageMk3Desc", "Assets/BetterMachines/Icons/storage-3", ProtoRegistry.GetGridIndex(2, 1, 8), 50, (EItemType)5);
bmItems.Add(val16);
ItemProto val17 = ProtoRegistry.RegisterItem(3704, "storageMk4", "storageMk4Desc", "Assets/BetterMachines/Icons/storage-4", ProtoRegistry.GetGridIndex(2, 2, 8), 50, (EItemType)5);
bmItems.Add(val17);
ItemProto val18 = ProtoRegistry.RegisterItem(3705, "liquidTankMk2", "liquidTankMk2Desc", "Assets/BetterMachines/Icons/storage-tank-2", ProtoRegistry.GetGridIndex(2, 3, 8), 50, (EItemType)5);
bmItems.Add(val18);
ItemProto val19 = ProtoRegistry.RegisterItem(3706, "liquidTankMk3", "liquidTankMk3Desc", "Assets/BetterMachines/Icons/storage-tank-3", ProtoRegistry.GetGridIndex(2, 4, 8), 50, (EItemType)5);
bmItems.Add(val19);
beltMk4Item = ProtoRegistry.RegisterItem(3707, "beltMk4", "beltMk4Desc", "Assets/BetterMachines/Icons/belt-4", ProtoRegistry.GetGridIndex(2, 5, 8), 300, (EItemType)5);
bmItems.Add(beltMk4Item);
ProtoRegistry.RegisterModel(672, smelterMk2item, "Assets/BetterMachines/Machines/smelter-mk2", (Material[])(object)new Material[2] { val, val2 }, new int[4] { 22, 11, 12, 1 }, 502, 2, new int[4] { 2302, 0, 2315, 2319 });
ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/smelter-mk2", 1, (Material[])(object)new Material[1] { val3 });
ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/smelter-mk2", 2, (Material[])(object)new Material[1] { val3 });
ProtoRegistry.RegisterModel(671, val15, "Assets/BetterMachines/Machines/chemical-plant-mk2", (Material[])(object)new Material[4] { val10, val11, val6, val12 }, new int[4] { 22, 11, 12, 1 }, 704, 2, new int[3] { 2309, 0, 2317 });
ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk2", 1, (Material[])(object)new Material[2] { val13, val11 });
ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk2", 2, (Material[])(object)new Material[2] { val13, val11 });
ProtoRegistry.RegisterModel(670, val16, "Assets/BetterMachines/Machines/storage-3", (Material[])(object)new Material[1] { val4 }, new int[2] { 17, 1 }, 664);
ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/storage-3", 1, (Material[])(object)new Material[1] { val5 });
ProtoRegistry.RegisterModel(669, val17, "Assets/BetterMachines/Machines/storage-4", (Material[])(object)new Material[1] { val4 }, new int[2] { 17, 1 }, 665);
ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/storage-4", 1, (Material[])(object)new Material[1] { val5 });
liquidTankMk2 = ProtoRegistry.RegisterModel(666, val18, "Assets/BetterMachines/Machines/liquid-tank-mk2", (Material[])(object)new Material[3] { val8, val7, val9 }, new int[2] { 30, 1 }, 406, 0, Array.Empty<int>(), 3);
liquidTankMk3 = ProtoRegistry.RegisterModel(667, val19, "Assets/BetterMachines/Machines/liquid-tank-mk3", (Material[])(object)new Material[3] { val8, val7, val9 }, new int[2] { 30, 1 }, 407, 0, Array.Empty<int>(), 3);
beltMk4 = ProtoRegistry.RegisterModel(668, beltMk4Item, "Assets/BetterMachines/Machines/belt-4", (Material[])null, new int[2] { 15, 1 }, 304, 4, new int[4] { 2001, 2002, 2003, 0 });
ItemProto val20 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2309);
ProtoRegistry.RegisterRecipe(250, (ERecipeType)4, 240, new int[4] { 2302, 1107, 1303, 1202 }, new int[4] { 1, 4, 4, 8 }, new int[1] { ((Proto)smelterMk2item).ID }, new int[1] { 1 }, "smelterMk2Desc", 1202);
int[] obj = new int[4] { 0, 1206, 1304, 1402 };
obj[0] = ((Proto)smelterMk2item).ID;
ProtoRegistry.EditRecipe(116, (ERecipeType)4, 300, obj, new int[4] { 1, 8, 4, 8 }, new int[1] { 2315 }, new int[1] { 1 }, "smelterMk3Desc", 1417, ProtoRegistry.GetGridIndex(2, 2, 4));
ProtoRegistry.RegisterRecipe(251, (ERecipeType)4, 360, new int[4] { 2309, 1107, 1119, 1303 }, new int[4] { 1, 4, 4, 4 }, new int[1] { ((Proto)val15).ID }, new int[1] { 1 }, "chemicalPlantMk2Desc", 1202);
ProtoRegistry.RegisterRecipe(253, (ERecipeType)4, 300, new int[2] { 1106, 1108 }, new int[2] { 12, 12 }, new int[1] { ((Proto)val16).ID }, new int[1] { 1 }, "storageMk3Desc", 1604);
RecipeProto val21 = ProtoRegistry.RegisterRecipe(254, (ERecipeType)4, 360, new int[2] { 1107, 1108 }, new int[2] { 16, 16 }, new int[1] { ((Proto)val17).ID }, new int[1] { 1 }, "storageMk4Desc", 1851);
ProtoRegistry.RegisterRecipe(255, (ERecipeType)4, 300, new int[3] { 1103, 1108, 1110 }, new int[3] { 12, 12, 8 }, new int[1] { ((Proto)val18).ID }, new int[1] { 1 }, "liquidTankMk2Desc", 1603);
RecipeProto val22 = ProtoRegistry.RegisterRecipe(256, (ERecipeType)4, 360, new int[3] { 1107, 1108, 1119 }, new int[3] { 16, 16, 12 }, new int[1] { ((Proto)val19).ID }, new int[1] { 1 }, "liquidTankMk3Desc", 1851);
ProtoRegistry.RegisterTech(1851, "highDensityStorageTech", "highDensityStorageTechDesc", "highDensityStorageTechConc", "Assets/BetterMachines/Icons/high-density-storage", new int[1] { 1414 }, new int[3] { 6001, 6002, 6003 }, new int[3] { 20, 20, 2 }, 216000L, new int[2]
{
((Proto)val21).ID,
((Proto)val22).ID
}, new Vector2(37f, 13f));
ProtoRegistry.RegisterRecipe(257, (ERecipeType)4, 360, new int[3] { 2003, 1304, 1124 }, new int[3] { 3, 1, 1 }, new int[1] { ((Proto)beltMk4Item).ID }, new int[1] { 3 }, "beltMk4Desc", 1605);
LDBTool.SetBuildBar(3, 4, ((Proto)beltMk4Item).ID);
LDBTool.SetBuildBar(3, 5, 2011);
LDBTool.SetBuildBar(3, 6, 2012);
LDBTool.SetBuildBar(3, 7, 2013);
LDBTool.SetBuildBar(3, 8, 2014);
LDBTool.SetBuildBar(3, 9, 2040);
LDBTool.SetBuildBar(3, 10, 2020);
LDBTool.SetBuildBar(4, 5, 2106);
LDBTool.SetBuildBar(4, 6, ((Proto)val18).ID);
LDBTool.SetBuildBar(4, 7, ((Proto)val19).ID);
LDBTool.SetBuildBar(4, 3, ((Proto)val16).ID);
LDBTool.SetBuildBar(4, 4, ((Proto)val17).ID);
LDBTool.SetBuildBar(5, 2, ((Proto)smelterMk2item).ID);
LDBTool.SetBuildBar(5, 3, 2315);
LDBTool.SetBuildBar(5, 4, 2303);
LDBTool.SetBuildBar(5, 5, 2304);
LDBTool.SetBuildBar(5, 6, 2305);
LDBTool.SetBuildBar(5, 7, 2308);
LDBTool.SetBuildBar(5, 8, 2309);
LDBTool.SetBuildBar(5, 9, 2314);
LDBTool.SetBuildBar(5, 10, 2310);
}
Harmony val23 = new Harmony("org.kremnev8.plugin.BetterMachines");
val23.PatchAll(Assembly.GetExecutingAssembly());
UtilSystem.AddLoadMessageHandler((Func<string>)EntityData_Patch.GetFixMessage);
ProtoRegistry.onLoadingFinished += ModifySpeed;
}
private void ModifySpeed()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_021e: 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_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Expected O, but got Unknown
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2304);
CustomAssemblerDesc customAssemblerDesc = new CustomAssemblerDesc
{
tier = 2,
assembleSpeed = 1f
};
((CustomDesc)customAssemblerDesc).ApplyProperties(new PrefabDesc());
val.prefabDesc.assemblerSpeed = (int)(customAssemblerDesc.assembleSpeed * 10000f);
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2305);
CustomAssemblerDesc customAssemblerDesc2 = new CustomAssemblerDesc
{
tier = 3,
assembleSpeed = 1.5f
};
((CustomDesc)customAssemblerDesc2).ApplyProperties(new PrefabDesc());
val2.prefabDesc.assemblerSpeed = (int)(customAssemblerDesc2.assembleSpeed * 10000f);
ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2302);
ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2315);
ItemProto val5 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2309);
ItemProto val6 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2317);
ItemProto val7 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2003);
val7.recipes = null;
val7.FindRecipes();
val3.FindRecipes();
val4.GridIndex = ProtoRegistry.GetGridIndex(2, 2, 4);
val3.recipes = null;
smelterMk2item.recipes = null;
val4.recipes = null;
val3.FindRecipes();
smelterMk2item.FindRecipes();
val4.FindRecipes();
val5.GridIndex = ProtoRegistry.GetGridIndex(2, 11, 6);
val5.recipes = null;
val5.FindRecipes();
val6.GridIndex = ProtoRegistry.GetGridIndex(2, 12, 2);
val6.recipes = null;
val6.FindRecipes();
ChemicalPlantDesc chemicalPlantDesc = new ChemicalPlantDesc
{
tier = 3,
processingSpeed = 2f
};
((CustomDesc)chemicalPlantDesc).ApplyProperties(val6.prefabDesc);
val6.prefabDesc.workEnergyPerTick = 48000L;
val6.prefabDesc.idleEnergyPerTick = 1600L;
((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(22).GridIndex = ProtoRegistry.GetGridIndex(2, 11, 3);
Color color = default(Color);
ColorUtility.TryParseHtmlString("#F9D352FF", ref color);
smelterMk3 = ((ProtoSet<ModelProto>)(object)LDB.models).Select(194);
smelterMk3.prefabDesc.lodMaterials[0][0].color = color;
smelterMk3.prefabDesc.lodMaterials[1][0].color = color;
smelterMk3.prefabDesc.lodMaterials[2][0].color = color;
SmelterDesc smelterDesc = new SmelterDesc
{
tier = 3,
smeltSpeed = 2f
};
((CustomDesc)smelterDesc).ApplyProperties(new PrefabDesc());
smelterMk3.prefabDesc.assemblerSpeed = (int)(smelterDesc.smeltSpeed * 10000f);
smelterMk3.prefabDesc.workEnergyPerTick = 24000L;
smelterMk3.prefabDesc.idleEnergyPerTick = 800L;
beltMk4Item.BuildMode = 2;
beltMk4.prefabDesc.beltPrototype = ((Proto)beltMk4Item).ID;
BeltLogic_Patches.AddMatAndMesh();
}
}
public class ChemicalPlantDesc : ConfigurableDesc
{
[UseConfigFile("Chemical plant processing speed multiplier for this tier. Mk1 Chemical Plant has multiplier of 1.")]
public float processingSpeed;
public override string configCategory => "ChemicalPlant";
public override ConfigFile modConfig => BetterMachinesPlugin.config;
public override void ApplyProperties(PrefabDesc desc)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
((ConfigurableDesc)this).ApplyProperties(desc);
desc.assemblerSpeed = Mathf.RoundToInt(processingSpeed * 10000f);
desc.assemblerRecipeType = (ERecipeType)2;
desc.isAssembler = true;
}
}
public class CustomAssemblerDesc : ConfigurableDesc
{
[UseConfigFile("Assembler processing speed multiplier for this tier. Mk1 Assembler has multiplier of 0.75")]
public float assembleSpeed;
public override string configCategory => "Assembler";
public override ConfigFile modConfig => BetterMachinesPlugin.config;
public override void ApplyProperties(PrefabDesc desc)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
((ConfigurableDesc)this).ApplyProperties(desc);
desc.assemblerSpeed = Mathf.RoundToInt(assembleSpeed * 10000f);
desc.assemblerRecipeType = (ERecipeType)4;
desc.isAssembler = true;
}
}
public class CustomStorageDesc : ConfigurableDesc
{
[UseConfigFile("How many columns will this tier have. Mk1 Storage has 10 columns")]
public int columnCount;
[UseConfigFile("How many rows will this tier have. Mk1 Storage has 3 rows, Mk2 Storage has 6 rows.")]
public int rowCount;
public override string configCategory => "Storage";
public override ConfigFile modConfig => BetterMachinesPlugin.config;
public override void ApplyProperties(PrefabDesc desc)
{
((ConfigurableDesc)this).ApplyProperties(desc);
desc.storageCol = columnCount;
desc.storageRow = rowCount;
desc.isStorage = desc.storageCol * desc.storageRow > 0;
}
}
public class LiquidTankDesc : ConfigurableDesc
{
[UseConfigFile("How much capacity will this tier have. Mk1 Liquid Tank has capacity of 10000.")]
public int fluidCapacity;
public override string configCategory => "LiquidTank";
public override ConfigFile modConfig => BetterMachinesPlugin.config;
public override void ApplyProperties(PrefabDesc desc)
{
((ConfigurableDesc)this).ApplyProperties(desc);
desc.isTank = true;
desc.fluidStorageCount = fluidCapacity;
}
}
public class SmelterDesc : ConfigurableDesc
{
[UseConfigFile("Smelting speed multiplier for this tier. Mk1 smelter has multiplier of 1.")]
public float smeltSpeed;
public override string configCategory => "Smelter";
public override ConfigFile modConfig => BetterMachinesPlugin.config;
public override void ApplyProperties(PrefabDesc desc)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
((ConfigurableDesc)this).ApplyProperties(desc);
desc.assemblerSpeed = Mathf.RoundToInt(smeltSpeed * 10000f);
desc.assemblerRecipeType = (ERecipeType)1;
desc.isAssembler = true;
}
}
[HarmonyPatch]
public static class BeltLogic_Patches
{
public delegate void RefAction<T1>(ref T1 arg1);
public delegate void RefAction<in T1, T2>(T1 arg1, ref T2 arg2);
public delegate void RefAction<in T1, T2, T3>(T1 arg1, ref T2 arg2, ref T3 arg3);
private static readonly int color4 = Shader.PropertyToID("_Color4");
private static readonly int emissionColor = Shader.PropertyToID("_EmissionColor");
private static readonly int uvSpeed = Shader.PropertyToID("_UVSpeed");
public static void AddMatAndMesh()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
BetterMachinesPlugin.logger.LogDebug((object)"Adding belts materials and meshes.");
Configs instance = Configs.instance;
BuiltinConfig builtin = instance.m_builtin;
List<Material> list = new List<Material>(builtin.beltMat);
for (int i = 0; i < 4; i++)
{
Material val = Object.Instantiate<Material>(builtin.beltMat[8 + i]);
val.color = BetterMachinesPlugin.belt4Color;
val.SetColor(emissionColor, BetterMachinesPlugin.belt4Color);
val.SetFloat(uvSpeed, 12f);
list.Add(Object.Instantiate<Material>(val));
}
builtin.beltMat = list.ToArray();
List<Mesh> list2 = new List<Mesh>(builtin.beltMesh);
for (int j = 0; j < 4; j++)
{
Mesh val2 = Object.Instantiate<Mesh>(builtin.beltMesh[8 + j]);
list2.Add(Object.Instantiate<Mesh>(val2));
}
builtin.beltMesh = list2.ToArray();
}
[HarmonyPatch(typeof(CargoTraffic), "AlterBeltRenderer")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> AddColors(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BeltComponent), "speed"), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null)
});
CodeMatcher val2 = val.Clone();
val2.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null)
});
object operand = val2.Operand;
val2.Advance(1);
object operand2 = val2.Operand;
val.Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_S, operand)
}).SetInstruction(Transpilers.EmitDelegate<Func<int, int, int>>((Func<int, int, int>)delegate(int speed, int other)
{
if (speed <= 1)
{
return other;
}
if (speed <= 2)
{
other += 4;
}
else if (speed <= 5)
{
other += 8;
}
else if (speed <= 12)
{
other += 12;
}
return other;
}))
.Advance(1)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stloc_S, operand)
})
.SetInstruction(new CodeInstruction(OpCodes.Br, operand2));
return val.InstructionEnumeration();
}
[HarmonyPatch(typeof(CargoTraffic), "Draw")]
[HarmonyPatch(typeof(CargoTraffic), "ClearStates")]
[HarmonyPatch(typeof(CargoTraffic), "CreateRenderingBatches")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> ColorPatch(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Ldc_I4_S && (sbyte)instr.operand == 12), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher matcher2)
{
matcher2.SetOperandAndAdvance((object)16);
}, (Action<string>)null);
return val.InstructionEnumeration();
}
[HarmonyPatch(typeof(ConnGizmoRenderer), "AddBlueprintBeltMajorPoint")]
[HarmonyPatch(typeof(ConnGizmoRenderer), "AddBlueprintBeltPoint")]
[HarmonyPatch(typeof(ConnGizmoRenderer), "AddBlueprintBeltConn")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> GizmoColor(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Initobj, (object)typeof(ConnGizmoObj), (string)null)
});
object operand = val.Operand;
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloca_S, operand)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<RefAction<ConnGizmoObj>>((RefAction<ConnGizmoObj>)delegate(ref ConnGizmoObj obj)
{
if (obj.color == 12)
{
obj.color = 6u;
}
}) });
return val.InstructionEnumeration();
}
[HarmonyPatch(typeof(ConnGizmoRenderer), "Update")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> GizmoColorUpdate(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ConnGizmoRenderer), "factory"), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null)
}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_S, (object)6)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloca_S, (object)0)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<RefAction<int, ConnGizmoObj>>((RefAction<int, ConnGizmoObj>)delegate(int speed, ref ConnGizmoObj renderer)
{
if (speed == 12 && renderer.color == 3)
{
renderer.color = 6u;
}
}) });
return val.InstructionEnumeration();
}
[HarmonyPatch(typeof(Configs), "Awake")]
[HarmonyPostfix]
public static void ChangeMats()
{
Configs.builtin.solidGizmoMats[0] = Object.Instantiate<Material>(BetterMachinesPlugin.gizmoMat);
Configs.builtin.solidGizmoMats[1] = Object.Instantiate<Material>(BetterMachinesPlugin.gizmoMat);
Configs.builtin.solidGizmoMats[2] = Object.Instantiate<Material>(BetterMachinesPlugin.gizmoLineMat);
Configs.builtin.solidGizmoMats[5] = Object.Instantiate<Material>(BetterMachinesPlugin.gizmoMat);
Configs.builtin.solidGizmoMats[6] = Object.Instantiate<Material>(BetterMachinesPlugin.gizmoLineMat);
Configs.builtin.solidGizmoMats[7] = Object.Instantiate<Material>(BetterMachinesPlugin.gizmoMat);
}
[HarmonyPatch(typeof(CargoTraffic), "SetBeltSelected")]
[HarmonyPrefix]
public static bool SetBeltSelected(CargoTraffic __instance, int beltId)
{
int num = __instance.beltPool[beltId].speed;
if (num == 12)
{
num = 5;
}
__instance.SetBeltState(beltId, num);
return false;
}
[HarmonyPatch(typeof(CargoPath), "InsertChunk")]
[HarmonyPrefix]
public static void FixSpeedBugFast(ref int speed)
{
speed = Math.Min(10, speed);
}
[HarmonyPatch(typeof(CargoPath), "Import")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> CargoPathPatchFast(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[8]
{
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(CargoPath), "chunks"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.IsLdloc(x, (LocalBuilder)null)), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_3, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_2, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.IsLdarg(x, (int?)null)), (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)((int speed) => Math.Min(10, speed))) });
return val.InstructionEnumeration();
}
}
[HarmonyPatch]
public static class BlueprintData_Patch
{
[HarmonyPatch(typeof(BlueprintData), "Import")]
[HarmonyPostfix]
public static void FixBlueprint(BlueprintData __instance)
{
BlueprintBuilding[] buildings = __instance.buildings;
foreach (BlueprintBuilding val in buildings)
{
foreach (ItemProto bmItem in BetterMachinesPlugin.bmItems)
{
if (val.itemId == ((Proto)bmItem).ID)
{
if (val.modelIndex == bmItem.ModelIndex)
{
return;
}
val.modelIndex = (short)bmItem.ModelIndex;
}
}
if (val.itemId == BetterMachinesPlugin.oldChemPlantID.Value)
{
val.itemId = 2317;
val.modelIndex = 376;
}
}
}
}
[HarmonyPatch]
public static class EntityData_Patch
{
public static int updateCounter;
[HarmonyPatch(typeof(EntityData), "Import")]
[HarmonyPostfix]
public static void Postfix(ref EntityData __instance)
{
int protoId = __instance.protoId;
int modelIndex = __instance.modelIndex;
foreach (ItemProto bmItem in BetterMachinesPlugin.bmItems)
{
if (protoId == ((Proto)bmItem).ID)
{
if (modelIndex == bmItem.ModelIndex)
{
return;
}
__instance.modelIndex = (short)bmItem.ModelIndex;
updateCounter++;
}
}
if (protoId == BetterMachinesPlugin.oldChemPlantID.Value)
{
__instance.protoId = 2317;
__instance.modelIndex = 376;
updateCounter++;
}
}
internal static string GetFixMessage()
{
if (updateCounter <= 0)
{
return "";
}
return string.Format(Localization.Translate("BMModModificationWarn"), updateCounter);
}
}
[HarmonyPatch]
public static class FactoryStorage_Patch
{
public delegate void RefAction<T1, T2>(ref T1 arg1, ref T2 arg2);
[HarmonyPatch(typeof(FactoryStorage), "GameTick")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> ChangeFunction(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).End().MatchBack(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null)
}).Advance(1)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FactoryStorage), "tankPool"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_S, (object)4)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldelema, (object)typeof(TankComponent))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_0, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_S, (object)5)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldelema, (object)typeof(AnimData))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<RefAction<TankComponent, AnimData>>((RefAction<TankComponent, AnimData>)delegate(ref TankComponent tank, ref AnimData anim)
{
if (tank.fluidCapacity > 11000)
{
anim.time = InverseFunction(anim.time);
}
}) });
return val.InstructionEnumeration();
}
private static float InverseFunction(float x)
{
float num = 4.6600313f - 13.5f * x;
float num2 = Mathf.Pow(-6.75f * x + Mathf.Sqrt(num * num + 0.01619275f) / 2f + 2.3300157f, 1f / 3f);
float num3 = (0f - num2) / 3f + 0.525f + 0.0421875f / num2;
if (num3 > 0.9999f)
{
return 0.1466f + x;
}
return num3;
}
}
[HarmonyPatch]
public static class UIStorageWindow_Patch
{
[HarmonyPatch(typeof(UIStorageWindow), "OnStorageIdChange")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> OnStorageIdChanged(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ManualBehaviour), "_Init", (Type[])null, (Type[])null), (string)null)
}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_1, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action<UIStorageWindow, ItemProto>>((Action<UIStorageWindow, ItemProto>)delegate(UIStorageWindow window, ItemProto proto)
{
if (proto != null)
{
window.storageUI.colCount = proto.prefabDesc.storageCol;
window.storageUI.rowCount = proto.prefabDesc.storageRow;
}
}) });
return val.InstructionEnumeration();
}
[HarmonyPatch(typeof(UIStorageWindow), "_OnUpdate")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> OnUpdate(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(UIStorageWindow), "windowTrans"), (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
}).Advance(1).RemoveInstructions(3)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<UIStorageWindow, float>>((Func<UIStorageWindow, float>)((UIStorageWindow window) => window.storageUI.colCount * 50 + 80)) });
return val.InstructionEnumeration();
}
}
}