void Awake() { logger = Logger; config = Config; string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); resources = new ResourceData(GUID, "BetterMachines", pluginfolder); resources.LoadAssetBundle("minerbundle"); resources.ResolveVertaFolder(); ProtoRegistry.AddResource(resources); EnableMinerMk3 = Config.Bind("General", "EnableMinerMk3", true, "Should Miner Mk3 item be added? Do note that loading a save that has Miners mk3 without this enabled will result in loss of these miners"); Config.Bind("AdvancedMiners", "Tier-2_miningRange", 10f, "How much range this tier has(Range of miner mk.1 is 7.75m). Note that this applies only to new miners built, already existing will not have their range changed!"); Config.MigrateConfig <float>("General", "MinerMk2Range", "AdvancedMiners", "Tier-2_miningRange"); Harmony harmony = new Harmony(GUID); harmony.PatchAll(Assembly.GetExecutingAssembly()); string[] textures = { "Assets/BetterMachines/Textures/mining-drill-a", "Assets/BetterMachines/Textures/mining-drill-n", "Assets/BetterMachines/Textures/mining-drill-s", "Assets/BetterMachines/Textures/mining-drill-e" }; Material mk2Mat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "mining-drill-mk2", "#00FFE8FF", textures); mk2Mat.SetFloat(albedoMultiplier, 1.5f); mk2Mat.SetFloat(emissionMultiplier, 15f); mk2Mat.SetFloat(emissionSwitch, 1f); mk2Mat.SetFloat(emissionUsePower, 1f); mk2Mat.SetFloat(albedoMultiplier, 1.5f); Material mk3Mat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "mining-drill-mk3", "#5FB9FFFF", textures); mk3Mat.SetFloat(albedoMultiplier, 1.5f); mk3Mat.SetFloat(emissionMultiplier, 15f); mk3Mat.SetFloat(emissionSwitch, 1f); mk3Mat.SetFloat(emissionUsePower, 1f); mk3Mat.SetFloat(albedoMultiplier, 1.5f); Material blackMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask", "mining-drill-black", "#00000000"); blackMat.renderQueue = 2980; blackMat.SetColor(tintColor, Color.black); blackMat.SetFloat(invFade, 1.5f); //Register and create buildings, items, models, etc ProtoRegistry.RegisterString("advancedMiningDrill", "Mining drill Mk.II"); ProtoRegistry.RegisterString("advancedMiningDrillDesc", "Thanks to some hard to pronounce tech this drill has better range!"); ProtoRegistry.RegisterString("miningDrillMk3", "Mining drill Mk.III"); ProtoRegistry.RegisterString("miningDrillMk3Desc", "They did it again. Technology that makes this machine possible is so hard to pronounce that its name contains unknown symbols and math equations! Has better range and mining speed."); ItemProto miner = ProtoRegistry.RegisterItem(2000, "advancedMiningDrill", "advancedMiningDrillDesc", "Assets/BetterMachines/Icons/mining-drill-mk2", 2504); ItemProto minerMk3 = default; if (EnableMinerMk3.Value) { minerMk3 = ProtoRegistry.RegisterItem(2550, "miningDrillMk3", "miningDrillMk3Desc", "Assets/BetterMachines/Icons/mining-drill-mk3", 2505); } ModelProto model = ProtoRegistry.RegisterModel(178, "Assets/BetterMachines/Machines/mining-drill-mk2", new[] { mk2Mat, blackMat }); int[] upgrades = EnableMinerMk3.Value ? new[] { 2301, 0, minerMk3.ID } : new[] { 2301, 0 }; ProtoRegistry.AddModelToItemProto(model, miner, new[] { 18, 19, 11, 12, 1 }, 204, 2, upgrades); ProtoRegistry.RegisterRecipe(105, ERecipeType.Assemble, 60, new[] { 2301, 1106, 1303, 1206 }, new[] { 1, 4, 2, 2 }, new[] { miner.ID }, new[] { 1 }, "advancedMiningDrillDesc", 1202); if (EnableMinerMk3.Value) { ModelProto modelMk3 = ProtoRegistry.RegisterModel(270, "Assets/BetterMachines/Machines/mining-drill-mk3", new[] { mk3Mat, blackMat }); ProtoRegistry.AddModelToItemProto(modelMk3, minerMk3, new[] { 18, 19, 11, 12, 1 }, 205, 3, new[] { 2301, miner.ID, 0 }); ProtoRegistry.RegisterRecipe(260, ERecipeType.Assemble, 60, new[] { miner.ID, 1107, 1305, 1402 }, new[] { 1, 4, 2, 8 }, new[] { minerMk3.ID }, new[] { 1 }, "miningDrillMk3Desc", 1203); } logger.LogInfo("Advanced Miner mod is initialized!"); //ProtoRegistry.onLoadingFinished += onPostAdd; }
private void Awake() { logger = Logger; config = Config; string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); resources = new ResourceData(MODGUID, "BetterMachines", pluginfolder); resources.LoadAssetBundle("bettermachines"); resources.ResolveVertaFolder(); ProtoRegistry.AddResource(resources); #region Strings ProtoRegistry.EditString("电弧熔炉", "Arc Smelter (MK.I)", "电弧熔炉 (MK.I)"); ProtoRegistry.RegisterString("smelterMk2", "Arc Smelter (MK.II)", "电弧熔炉 (MK.II)"); ProtoRegistry.EditString("位面熔炉", "Plane Smelter (MK.III)", "位面熔炉 (MK.III)"); ProtoRegistry.EditString("化工厂", "Chemical Plant MK.I", "化工厂 MK.I"); ProtoRegistry.RegisterString("chemicalPlantMk2", "Chemical Plant MK.II", "化工厂 MK.II"); ProtoRegistry.RegisterString("chemicalPlantMk3", "Chemical Plant MK.III", "化工厂 MK.III"); ProtoRegistry.RegisterString("storageMk3", "Storage MK.III", "型储物仓 MK.III"); ProtoRegistry.RegisterString("storageMk4", "Storage MK.IV", "型储物仓 MK.IV"); ProtoRegistry.EditString("储液罐", "Liquid Tank MK.I", "储液罐 MK.I", "Réservoir de stockage de liquide MK.I"); ProtoRegistry.RegisterString("liquidTankMk2", "Liquid Tank MK.II", "储液罐 MK.II", "Réservoir de stockage de liquide MK.II"); ProtoRegistry.RegisterString("liquidTankMk3", "Liquid Tank MK.III", "储液罐 MK.III", "Réservoir de stockage de liquide MK.III"); ProtoRegistry.RegisterString("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!"); ProtoRegistry.EditString("位面冶金结果", "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)!"); ProtoRegistry.RegisterString("chemicalPlantMk2Desc", "Chemical facility. Can process the primary products of Crude oil into more advanced chemical products. Production speed has been increased."); ProtoRegistry.RegisterString("chemicalPlantMk3Desc", "Chemical facility. Can process the primary products of Crude oil into more advanced chemical products. Production speed has been greatly increased."); ProtoRegistry.EditString("I小型储物仓", "Storage MK.I is designed to store Solids."); ProtoRegistry.EditString("I大型储物仓", "Storage MK.II is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.I"); ProtoRegistry.RegisterString("storageMk3Desc", "Storage MK.III is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.II"); ProtoRegistry.RegisterString("storageMk4Desc", "Storage MK.IV is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.III"); ProtoRegistry.EditString("I储液罐", "Liquid Tank MK.I is designed to store Liquids. When dismantling a non-empty Storage Tank any remaining fluid will be lost."); ProtoRegistry.RegisterString("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."); ProtoRegistry.RegisterString("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."); ProtoRegistry.RegisterString("highDensityStorageTech", "High density storage"); ProtoRegistry.RegisterString("highDensityStorageTechDesc", "By using new stronger materials maximum capacity of Storages and Liquid Tanks can be increased."); ProtoRegistry.RegisterString("highDensityStorageTechConc", "You have obtained new Storage MK.IV and Liquid Tank Mk.III, which have increased storage capacity"); ProtoRegistry.RegisterString("beltMk4", "Belt MK.IV"); ProtoRegistry.RegisterString("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."); #endregion #region Materials Material smelterMk2Part1 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-part1", "#DB5860FF", new[] { "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" }); smelterMk2Part1.SetFloat(emissionSwitch, 1); smelterMk2Part1.SetFloat(emissionUsePower, 1); smelterMk2Part1.SetFloat(albedoMultiplier, 1.3f); smelterMk2Part1.SetFloat(emissionMultiplier, 10); smelterMk2Part1.SetFloat(emissionJitter, 0.5f); Material smelterMk2Part2 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-part2", "#DB5860FF", new[] { "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" }); smelterMk2Part2.SetFloat(emissionSwitch, 1); smelterMk2Part2.SetFloat(emissionUsePower, 1); smelterMk2Part2.SetFloat(albedoMultiplier, 1.3f); smelterMk2Part2.SetFloat(emissionMultiplier, 10); smelterMk2Part2.SetFloat(emissionJitter, 0.5f); Material smelterMk2Lods = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-lods", "#DB5860FF", new[] { "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" }); smelterMk2Lods.SetFloat(emissionSwitch, 1); smelterMk2Lods.SetFloat(emissionUsePower, 1); smelterMk2Lods.SetFloat(alphaClip, 0.5f); Material storageMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "storage-mat", "#DB5860FF", new[] { "Assets/BetterMachines/Textures/storage-a", "Assets/BetterMachines/Textures/storage-n", "Assets/BetterMachines/Textures/storage-s" }); Material storageMatLod1 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "storage-mat", "#DB5860FF", new[] { "Assets/BetterMachines/Textures/storage-lod-a", "Assets/BetterMachines/Textures/storage-lod-n", "Assets/BetterMachines/Textures/storage-lod-s" }); storageMatLod1.SetFloat(alphaClip, 0.5f); Material blackMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask", "black", "#00000000"); blackMat.renderQueue = 2980; blackMat.SetColor(tintColor, Color.black); blackMat.SetFloat(invFade, 1.5f); Material blackMatToggle = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask Vertex Toggle", "liquid-tank-black", "#00000000"); blackMatToggle.renderQueue = 2980; blackMatToggle.SetColor(tintColor, Color.black); blackMatToggle.SetFloat(invFade, 1.5f); Material liquidTankMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Vertex Toggle", "liquid-tank-mat", "#FFFFFFFF", new[] { "Assets/BetterMachines/Textures/storage-tank-a", "Assets/BetterMachines/Textures/storage-tank-n", "Assets/BetterMachines/Textures/storage-tank-s" }); Material liquidTankGlassMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Tank Vertex Toggle", "liquid-tank-glass-mat", "#F2FFFA42", new [] { "", "", "Assets/BetterMachines/Textures/storage-tank-glass-s" }); liquidTankGlassMat.renderQueue = 2989; liquidTankGlassMat.SetFloat(albedoMultiplier, 3); liquidTankGlassMat.SetFloat(bumpScale, 1); liquidTankGlassMat.SetFloat(emissionMultiplier, 10); liquidTankGlassMat.SetFloat(smoothMultiplier, 0.8f); liquidTankGlassMat.SetFloat(emissionSwitch, 1); liquidTankGlassMat.SetColor(specularColor, new Color(0.1981132f, 0.1981132f, 0.1981132f, 1)); liquidTankGlassMat.SetColor(rimColor, new Color(0.6039216f, 0.8462228f, 0.8588235f, 1)); string[] chemicalTextures = { "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 chemicalPlantMatMk2 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#00FFE8FF", chemicalTextures); Material chemicalPlantMatMk3 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#5FB9FFFF", chemicalTextures); Material chemicalPlantMatGlass = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Glass", "chemical-plant-glass", "#D7F7FF29", new [] { "", "", "Assets/BetterMachines/Textures/chemical-plant-glass-s" }); chemicalPlantMatGlass.renderQueue = 3001; chemicalPlantMatGlass.SetColor(emissionColor, Color.black); chemicalPlantMatGlass.SetColor(rimColor, new Color(0.6448024f, 0.8279268f, 0.8490566f, 1f)); Material chemicalPlantMatWater = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Glass", "chemical-plant-glass", new Color(1f, 0.6380855f, 0.1650943f, 0.5176471f)); chemicalPlantMatWater.renderQueue = 3000; chemicalPlantMatWater.SetColor(emissionColor, Color.black); string[] chemicallodTextures = { "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 chemicalPlantMatMk2Lod = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#00FFE8FF", chemicallodTextures); Material chemicalPlantMatMk3Lod = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#5FB9FFFF", chemicallodTextures); gizmoMat = resources.bundle.LoadAsset <Material>("Assets/BetterMachines/Materials/SolidGizmo.mat"); gizmoMat.shaderKeywords = new[] { "_ALPHABLEND_ON", "_EMISSION" }; gizmoLineMat = resources.bundle.LoadAsset <Material>("Assets/BetterMachines/Materials/SolidLine.mat"); gizmoLineMat.shaderKeywords = new[] { "_ALPHABLEND_ON", "_EMISSION" }; #endregion #region Items ItemProto smelterMk3Item = LDB.items.Select(2315); smelterMk3Item.SetIcon("Assets/BetterMachines/Icons/smelter-3", false); smelterMk2item = ProtoRegistry.RegisterItem(3700, "smelterMk2", "smelterMk2Desc", "Assets/BetterMachines/Icons/smelter-2", ProtoRegistry.GetGridIndex(2, 5, 4), 50, EItemType.Production); ItemProto chemicalPlantMk2item = ProtoRegistry.RegisterItem(3701, "chemicalPlantMk2", "chemicalPlantMk2Desc", "Assets/BetterMachines/Icons/chemical-plant-mk2", ProtoRegistry.GetGridIndex(2, 5, 5), 50, EItemType.Production); ItemProto chemicalPlantMk3item = ProtoRegistry.RegisterItem(3702, "chemicalPlantMk3", "chemicalPlantMk3Desc", "Assets/BetterMachines/Icons/chemical-plant-mk3", ProtoRegistry.GetGridIndex(2, 6, 5), 50, EItemType.Production); ItemProto storageMk3Item = ProtoRegistry.RegisterItem(3703, "storageMk3", "storageMk3Desc", "Assets/BetterMachines/Icons/storage-3", ProtoRegistry.GetGridIndex(2, 1, 6), 50, EItemType.Logistics); ItemProto storageMk4Item = ProtoRegistry.RegisterItem(3704, "storageMk4", "storageMk4Desc", "Assets/BetterMachines/Icons/storage-4", ProtoRegistry.GetGridIndex(2, 2, 6), 50, EItemType.Logistics); ItemProto tankMk2Item = ProtoRegistry.RegisterItem(3705, "liquidTankMk2", "liquidTankMk2Desc", "Assets/BetterMachines/Icons/storage-tank-2", ProtoRegistry.GetGridIndex(2, 1, 5), 50, EItemType.Logistics); ItemProto tankMk3Item = ProtoRegistry.RegisterItem(3706, "liquidTankMk3", "liquidTankMk3Desc", "Assets/BetterMachines/Icons/storage-tank-3", ProtoRegistry.GetGridIndex(2, 2, 5), 50, EItemType.Logistics); beltMk4Item = ProtoRegistry.RegisterItem(3707, "beltMk4", "beltMk4Desc", "Assets/BetterMachines/Icons/belt-4", ProtoRegistry.GetGridIndex(2, 3, 5), 300, EItemType.Logistics); #endregion #region Models ProtoRegistry.RegisterModel(260, smelterMk2item, "Assets/BetterMachines/Machines/smelter-mk2", new [] { smelterMk2Part1, smelterMk2Part2 }, new[] { 22, 11, 12, 1 }, 502, 2, new [] { 2302, 0, 2315 }); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/smelter-mk2", 1, new [] { smelterMk2Lods }); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/smelter-mk2", 2, new [] { smelterMk2Lods }); ProtoRegistry.RegisterModel(261, chemicalPlantMk2item, "Assets/BetterMachines/Machines/chemical-plant-mk2", new [] { chemicalPlantMatMk2, chemicalPlantMatGlass, blackMat, chemicalPlantMatWater }, new[] { 22, 11, 12, 1 }, 704, 2, new [] { 2309, 0, chemicalPlantMk3item.ID }); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk2", 1, new [] { chemicalPlantMatMk2Lod, chemicalPlantMatGlass }); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk2", 2, new [] { chemicalPlantMatMk2Lod, chemicalPlantMatGlass }); ProtoRegistry.RegisterModel(262, chemicalPlantMk3item, "Assets/BetterMachines/Machines/chemical-plant-mk3", new [] { chemicalPlantMatMk3, chemicalPlantMatGlass, blackMat, chemicalPlantMatWater }, new[] { 22, 11, 12, 1 }, 705, 3, new [] { 2309, chemicalPlantMk2item.ID, 0 }); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk3", 1, new [] { chemicalPlantMatMk3Lod, chemicalPlantMatGlass }); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk3", 2, new [] { chemicalPlantMatMk3Lod, chemicalPlantMatGlass }); ProtoRegistry.RegisterModel(263, storageMk3Item, "Assets/BetterMachines/Machines/storage-3", new [] { storageMat }, new[] { 17, 1 }, 403); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/storage-3", 1, new [] { storageMatLod1 }); ProtoRegistry.RegisterModel(264, storageMk4Item, "Assets/BetterMachines/Machines/storage-4", new [] { storageMat }, new[] { 17, 1 }, 404); ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/storage-4", 1, new [] { storageMatLod1 }); liquidTankMk2 = ProtoRegistry.RegisterModel(265, tankMk2Item, "Assets/BetterMachines/Machines/liquid-tank-mk2", new [] { liquidTankMat, blackMatToggle, liquidTankGlassMat }, new[] { 30, 1 }, 406, 0, new int [0], 3); liquidTankMk3 = ProtoRegistry.RegisterModel(266, tankMk3Item, "Assets/BetterMachines/Machines/liquid-tank-mk3", new [] { liquidTankMat, blackMatToggle, liquidTankGlassMat }, new[] { 30, 1 }, 407, 0, new int[0], 3); beltMk4 = ProtoRegistry.RegisterModel(267, beltMk4Item, "Assets/BetterMachines/Machines/belt-4", null, new[] { 15, 1 }, 304, 4, new [] { 2001, 2002, 2003, 0 }); #endregion #region Recipes // Smelter mk2 <= Smelter mk1, Titanium alloy * 4, Processor * 4, Magnetic coil * 8 ProtoRegistry.RegisterRecipe(250, ERecipeType.Assemble, 240, new[] { 2302, 1107, 1303, 1202 }, new[] { 1, 4, 4, 8 }, new[] { smelterMk2item.ID }, new[] { 1 }, "smelterMk2Desc", 1202); // Smelter mk3 <= Smelter mk2, Particle container * 8, Plane filter * 4, Particle broadband * 8 ProtoRegistry.EditRecipe(116, ERecipeType.Assemble, 300, new[] { smelterMk2item.ID, 1206, 1304, 1402 }, new[] { 1, 8, 4, 8 }, new[] { 2315 }, new[] { 1 }, "smelterMk3Desc", 1417, ProtoRegistry.GetGridIndex(2, 6, 4)); // Chem plant mk2 <= Chem plant mk1, Titanium alloy * 4, Titanium glass * 4, Processor * 4 ProtoRegistry.RegisterRecipe(251, ERecipeType.Assemble, 360, new[] { 2309, 1107, 1119, 1303 }, new[] { 1, 4, 4, 4 }, new[] { chemicalPlantMk2item.ID }, new[] { 1 }, "chemicalPlantMk2Desc", 1202); // Chem plant mk3 <= Chem plant mk2, Particle broadband * 4, Plane filter * 2, Quantum chip * 2 ProtoRegistry.RegisterRecipe(252, ERecipeType.Assemble, 420, new[] { chemicalPlantMk2item.ID, 1402, 1304, 1305 }, new[] { 1, 4, 2, 2 }, new[] { chemicalPlantMk3item.ID }, new[] { 1 }, "chemicalPlantMk2Desc", 1203); ProtoRegistry.RegisterRecipe(253, ERecipeType.Assemble, 300, new[] { 1106, 1108 }, new[] { 12, 12 }, new[] { storageMk3Item.ID }, new[] { 1 }, "storageMk3Desc", 1604); RecipeProto storageMk4Recipe = ProtoRegistry.RegisterRecipe(254, ERecipeType.Assemble, 360, new[] { 1107, 1108 }, new[] { 16, 16 }, new[] { storageMk4Item.ID }, new[] { 1 }, "storageMk4Desc", 1851); ProtoRegistry.RegisterRecipe(255, ERecipeType.Assemble, 300, new[] { 1103, 1108, 1110 }, new[] { 12, 12, 8 }, new[] { tankMk2Item.ID }, new[] { 1 }, "liquidTankMk2Desc", 1603); RecipeProto liquidTankMk3Recipe = ProtoRegistry.RegisterRecipe(256, ERecipeType.Assemble, 360, new[] { 1107, 1108, 1119 }, new[] { 16, 16, 12 }, new[] { tankMk3Item.ID }, new[] { 1 }, "liquidTankMk3Desc", 1851); ProtoRegistry.RegisterTech(1851, "highDensityStorageTech", "highDensityStorageTechDesc", "highDensityStorageTechConc", "Assets/BetterMachines/Icons/high-density-storage", new[] { 1414 }, new[] { 6001, 6002, 6003 }, new[] { 20, 20, 2 }, 216000, new[] { storageMk4Recipe.ID, liquidTankMk3Recipe.ID }, new Vector2(37, 13)); ProtoRegistry.RegisterRecipe(257, ERecipeType.Assemble, 360, new[] { 2003, 1304, 1124 }, new[] { 3, 1, 1 }, new[] { beltMk4Item.ID }, new[] { 3 }, "beltMk4Desc", 1605); #endregion LDBTool.SetBuildBar(3, 4, beltMk4Item.ID); // Insert belt mk4 LDBTool.SetBuildBar(3, 5, 2011); LDBTool.SetBuildBar(3, 6, 2012); LDBTool.SetBuildBar(3, 7, 2013); LDBTool.SetBuildBar(3, 8, 2040); LDBTool.SetBuildBar(3, 9, 2030); LDBTool.SetBuildBar(3, 10, 2020); LDBTool.SetBuildBar(4, 5, 2106); //Move default position for Liquid Tank mk1 LDBTool.SetBuildBar(5, 2, smelterMk2item.ID); LDBTool.SetBuildBar(5, 3, 2315); //Move default position for Plane Smelter (MK.III) 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 harmony = new Harmony(MODGUID); harmony.PatchAll(Assembly.GetExecutingAssembly()); ProtoRegistry.onLoadingFinished += ModifySpeed; }
void Awake() { logger = Logger; mode = Config.Bind("General", "Mode", ModeType.SIMPLE, "Which mode to use:\n" + "Simple means only one model for substation, and fully safe to use(Removing this mod will not harm saves).\n" + "Advanced means that all substation types will be available at once.\n" + "Downside is that it is not save safe(Removing this mod will cause you to lose all built substations)\n" + "Remove mode is intended to prepare your save to removal of this mod. In it all placed substations will revert back to original when save is LOADED"); type = Config.Bind("General", "SubstationType", SubstaionType.GROUND, "Which model to use(Has no effect in advanced mode!)"); string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); resource = new ResourceData(ID, "custommachines", pluginfolder); resource.LoadAssetBundle("substationbundle"); resource.ResolveVertaFolder(); ProtoRegistry.AddResource(resource); Material mainMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Substation", "ground-substation", "#FF7070FF", new[] { "assets/custommachines/texture2d/orbital-substation-a", "assets/custommachines/texture2d/orbital-substation-n", "assets/custommachines/texture2d/orbital-substation-s", "assets/custommachines/texture2d/orbital-substation-e" }); //VF Shaders/Forward/Unlit Additive Substation Material effectMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Unlit Additive Substation", "substation-effects", "#00000000", new[] { "assets/custommachines/texture2d/orbital-substation-effect", "assets/custommachines/texture2d/orbital-substation-effect-mask" }, null, new[] { Shader.PropertyToID("_MainTex"), Shader.PropertyToID("_MaskTex") }); effectMat.SetFloat(Multiplier, 20); effectMat.SetVector(UVSpeed, new Vector4(0, 1, 0, 0)); effectMat.SetFloat(InvFade, 0.4f); ProtoRegistry.RegisterString("SubstationModificationWarn", " - [GroundSubstation] Replaced {0} buildings"); ProtoRegistry.RegisterString("SubstationRestoreWarn", " - [GroundSubstation] Restored {0} buildings (Save the game! You can now remove this mod safely)"); if (mode.Value == ModeType.SIMPLE) { Logger.LogInfo("Initialising in SIMPLE mode"); switch (type.Value) { case SubstaionType.GROUND: ProtoRegistry.AddLodMaterials("assets/custommachines/prefabs/ground-substation", 0, new [] { mainMat, effectMat }); break; case SubstaionType.SATELITE: ProtoRegistry.AddLodMaterials("assets/custommachines/prefabs/orbital-substation", 0, new [] { mainMat, effectMat }); break; } Harmony.CreateAndPatchAll(typeof(VFPreloadPatch), "groundsubstation"); Harmony.CreateAndPatchAll(typeof(BuildTool_ClickPatch), "groundsubstation"); } else if (mode.Value == ModeType.ADVANCED) { Logger.LogInfo("Initialising in ADVANCED mode"); ProtoRegistry.RegisterModel(firstSubstationId, "Entities/Prefabs/orbital-substation", new[] { mainMat, effectMat }); ProtoRegistry.RegisterModel(firstSubstationId + 1, "assets/custommachines/prefabs/ground-substation", new[] { mainMat, effectMat }); ProtoRegistry.RegisterModel(firstSubstationId + 2, "assets/custommachines/prefabs/orbital-substation", new[] { mainMat, effectMat }); Harmony.CreateAndPatchAll(typeof(BuildTool_ClickPatch), "groundsubstation"); Harmony.CreateAndPatchAll(typeof(GameDataPatch), "groundsubstation"); Harmony.CreateAndPatchAll(typeof(EntityDataPatch), "groundsubstation"); Harmony.CreateAndPatchAll(typeof(PlayerControlGizmoPatch), "groundsubstation"); } else { Logger.LogInfo("Initialising in REMOVE mode"); Harmony.CreateAndPatchAll(typeof(GameDataPatch), "groundsubstation"); Harmony.CreateAndPatchAll(typeof(EntityDataPatch), "groundsubstation"); } UtilSystem.AddLoadMessageHandler(GetReplaceMessage); Logger.LogInfo("Ground Substation mod is initialized!"); ProtoRegistry.onLoadingFinished += AfterLoad; }