Decompiled source of RomeTweaksMod v1.4.0

RomeTweaksMod.dll

Decompiled 15 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RomeTweeksMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RomeTweeksMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d66f7c4f-d5fd-4cfa-bd73-ec8c6b2b1428")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RomeTweaksMod;

[HarmonyPatch]
[BepInPlugin("aromeral.RomeTweaksMod", "Rome's Tweaks Mod", "1.4.0")]
[BepInProcess("valheim.exe")]
public class RomeTweaksMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
	private class Player_Patch
	{
		private static void Prefix(Player __instance)
		{
			if (!enableFoodDecayPatch.Value)
			{
				return;
			}
			foreach (Food food in __instance.GetFoods())
			{
				food.m_health = food.m_item.m_shared.m_food;
				food.m_stamina = food.m_item.m_shared.m_foodStamina;
				food.m_eitr = food.m_item.m_shared.m_foodEitr;
			}
		}
	}

	private readonly Harmony harmony = new Harmony("aromeral.RomeTweaksMod");

	public static ConfigEntry<bool> enableFastProductionPatch;

	public static ConfigEntry<int> ProductionCharcoalKilnMaxFuel;

	public static ConfigEntry<int> ProductionCharcoalKilnMaxOre;

	public static ConfigEntry<int> ProductionCharcoalKilnFuelPerProduct;

	public static ConfigEntry<int> ProductionCharcoalKilnSecPerProduct;

	public static ConfigEntry<int> ProductionSmelterMaxFuel;

	public static ConfigEntry<int> ProductionSmelterMaxOre;

	public static ConfigEntry<int> ProductionSmelterFuelPerProduct;

	public static ConfigEntry<int> ProductionSmelterSecPerProduct;

	public static ConfigEntry<int> ProductionWindmillMaxOre;

	public static ConfigEntry<int> ProductionWindmillSecPerProduct;

	public static ConfigEntry<int> ProductionSpinningWheelMaxOre;

	public static ConfigEntry<int> ProductionSpinningWheelSecPerProduct;

	public static ConfigEntry<int> ProductionBlastFurnaceMaxFuel;

	public static ConfigEntry<int> ProductionBlastFurnaceMaxOre;

	public static ConfigEntry<int> ProductionBlastFurnaceFuelPerProduct;

	public static ConfigEntry<int> ProductionBlastFurnaceSecPerProduct;

	public static ConfigEntry<int> HotTubMaxFuel;

	public static ConfigEntry<float> HotTubSecPerFuel;

	public static ConfigEntry<int> ProductionDefaultSecPerProduct;

	public static ConfigEntry<bool> enableStoneCostPatch;

	public static ConfigEntry<int> stoneWall4x2Cost;

	public static ConfigEntry<int> stoneWall2x1Cost;

	public static ConfigEntry<int> stoneWall1x1Cost;

	public static ConfigEntry<int> stoneFloor2x2Cost;

	public static ConfigEntry<int> stoneArchCost;

	public static ConfigEntry<int> stonePillarCost;

	public static ConfigEntry<int> stoneStairCost;

	public static ConfigEntry<bool> enableIronCostPatch;

	public static ConfigEntry<int> cageFloor1x1Cost;

	public static ConfigEntry<int> cageFloor2x2Cost;

	public static ConfigEntry<int> cageWall1x1Cost;

	public static ConfigEntry<int> cageWall2x2Cost;

	public static ConfigEntry<int> ironGateCost;

	public static ConfigEntry<bool> enableBlackMarbleCostPatch;

	public static ConfigEntry<int> blackMarble1x1Cost;

	public static ConfigEntry<int> blackMarble2x1x1Cost;

	public static ConfigEntry<int> blackMarble2x2x2Cost;

	public static ConfigEntry<int> blackMarbleFloorCost;

	public static ConfigEntry<int> blackMarbleFloorTriangleCost;

	public static ConfigEntry<int> blackMarbleStairCost;

	public static ConfigEntry<int> blackMarbleTipCost;

	public static ConfigEntry<int> blackMarbleBase1;

	public static ConfigEntry<int> blackMarbleBasecorner;

	public static ConfigEntry<int> blackMarbleOut1;

	public static ConfigEntry<int> blackMarbleOutCorner;

	public static ConfigEntry<int> blackMarbleArchCost;

	public static ConfigEntry<int> blackMarbleColumn1Cost;

	public static ConfigEntry<int> blackMarbleColumn2Cost;

	public static ConfigEntry<bool> enableGraustenCostPatch;

	public static ConfigEntry<int> pieceGraustenStoneLadderCost;

	public static ConfigEntry<int> pieceGraustenStoneStairCost;

	public static ConfigEntry<int> pieceGraustenFloor1x1Cost;

	public static ConfigEntry<int> pieceGraustenFloor2x2Cost;

	public static ConfigEntry<int> pieceGraustenFloor4x4Cost;

	public static ConfigEntry<int> pieceGraustenPillarBaseSmallCost;

	public static ConfigEntry<int> pieceGraustenPillarBaseMediumCost;

	public static ConfigEntry<int> pieceGraustenPillarBaseTaperedCost;

	public static ConfigEntry<int> pieceGraustenPillarBaseTaperedInvertedCost;

	public static ConfigEntry<int> pieceGraustenPillarBeamSmallCost;

	public static ConfigEntry<int> pieceGraustenPillarBeamMediumCost;

	public static ConfigEntry<int> pieceGraustenPillarArchSmallCost;

	public static ConfigEntry<int> pieceGraustenPillarArchCost;

	public static ConfigEntry<int> pieceGraustenWallArchCost;

	public static ConfigEntry<int> pieceGraustenWallArchInvertedCost;

	public static ConfigEntry<int> pieceGraustenWall1x2Cost;

	public static ConfigEntry<int> pieceGraustenWall2x2Cost;

	public static ConfigEntry<int> pieceGraustenWall4x2Cost;

	public static ConfigEntry<int> pieceGraustenWindow2x2Cost;

	public static ConfigEntry<int> pieceGraustenWindow4x2Cost;

	public static ConfigEntry<int> pieceGraustenRoof45Cost;

	public static ConfigEntry<int> pieceGraustenRoof45CornerCost;

	public static ConfigEntry<int> pieceGraustenRoof45Corner2Cost;

	public static ConfigEntry<int> pieceGraustenRoof45ArchCost;

	public static ConfigEntry<int> pieceGraustenRoof45ArchCorner2Cost;

	public static ConfigEntry<int> pieceGraustenRoof45ArchCornerCost;

	public static ConfigEntry<bool> enableXpPatch;

	public static ConfigEntry<bool> enableSkillXpCostPatch;

	public static ConfigEntry<float> skillXpCostMultiplier;

	public static ConfigEntry<bool> enableFoodDecayPatch;

	public static ConfigEntry<bool> enablePotentialForgePatch;

	public static ConfigEntry<float> potentialForgeBreakChance;

	public static ConfigEntry<float> potentialForgeSuccessChance;

	public static ConfigEntry<bool> enableExplorationRadiusPatch;

	public static ConfigEntry<float> explorationRadius;

	[HarmonyPatch(typeof(Smelter), "Awake")]
	[HarmonyPostfix]
	private static void Smelter_Awake(ref string ___m_name, ref int ___m_maxFuel, ref int ___m_maxOre, ref int ___m_fuelPerProduct, ref float ___m_secPerProduct)
	{
		if (enableFastProductionPatch.Value)
		{
			switch (___m_name)
			{
			case "$piece_charcoalkiln":
				___m_maxFuel = ProductionCharcoalKilnMaxFuel.Value;
				___m_maxOre = ProductionCharcoalKilnMaxOre.Value;
				___m_fuelPerProduct = ProductionCharcoalKilnFuelPerProduct.Value;
				___m_secPerProduct = ProductionCharcoalKilnSecPerProduct.Value;
				break;
			case "$piece_smelter":
				___m_maxFuel = ProductionSmelterMaxFuel.Value;
				___m_maxOre = ProductionSmelterMaxOre.Value;
				___m_fuelPerProduct = ProductionSmelterFuelPerProduct.Value;
				___m_secPerProduct = ProductionSmelterSecPerProduct.Value;
				break;
			case "$piece_windmill":
				___m_maxOre = ProductionWindmillMaxOre.Value;
				___m_secPerProduct = ProductionWindmillSecPerProduct.Value;
				break;
			case "$piece_spinningwheel":
				___m_maxOre = ProductionSpinningWheelMaxOre.Value;
				___m_secPerProduct = ProductionSpinningWheelSecPerProduct.Value;
				break;
			case "$piece_blastfurnace":
				___m_maxFuel = ProductionBlastFurnaceMaxFuel.Value;
				___m_maxOre = ProductionBlastFurnaceMaxOre.Value;
				___m_fuelPerProduct = ProductionBlastFurnaceFuelPerProduct.Value;
				___m_secPerProduct = ProductionBlastFurnaceSecPerProduct.Value;
				break;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static void ObjectDB_Awake_Patch(ObjectDB __instance)
	{
		Piece[] array = Resources.FindObjectsOfTypeAll<Piece>();
		foreach (Piece val in array)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null))
			{
				switch (((Object)((Component)val).gameObject).name)
				{
				case "stone_wall_4x2":
					TrySetPieceCost(val, enableStoneCostPatch, stoneWall4x2Cost);
					break;
				case "stone_wall_2x1":
					TrySetPieceCost(val, enableStoneCostPatch, stoneWall2x1Cost);
					break;
				case "stone_wall_1x1":
					TrySetPieceCost(val, enableStoneCostPatch, stoneWall1x1Cost);
					break;
				case "stone_floor_2x2":
					TrySetPieceCost(val, enableStoneCostPatch, stoneFloor2x2Cost);
					break;
				case "stone_arch":
					TrySetPieceCost(val, enableStoneCostPatch, stoneArchCost);
					break;
				case "stone_pillar":
					TrySetPieceCost(val, enableStoneCostPatch, stonePillarCost);
					break;
				case "stone_stair":
					TrySetPieceCost(val, enableStoneCostPatch, stoneStairCost);
					break;
				case "iron_floor_1x1_v2":
					TrySetPieceCost(val, enableIronCostPatch, cageFloor1x1Cost);
					break;
				case "iron_floor_2x2":
					TrySetPieceCost(val, enableIronCostPatch, cageFloor2x2Cost);
					break;
				case "iron_wall_1x1":
					TrySetPieceCost(val, enableIronCostPatch, cageWall1x1Cost);
					break;
				case "iron_wall_2x2":
					TrySetPieceCost(val, enableIronCostPatch, cageWall2x2Cost);
					break;
				case "iron_grate":
					TrySetPieceCost(val, enableIronCostPatch, ironGateCost);
					break;
				case "blackmarble_1x1":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarble1x1Cost);
					break;
				case "blackmarble_2x1x1":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarble2x1x1Cost);
					break;
				case "blackmarble_2x2x2":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarble2x2x2Cost);
					break;
				case "blackmarble_floor":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleFloorCost);
					break;
				case "blackmarble_floor_triangle":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleFloorTriangleCost);
					break;
				case "blackmarble_stair":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleStairCost);
					break;
				case "blackmarble_tip":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleTipCost);
					break;
				case "blackmarble_base_1":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleBase1);
					break;
				case "blackmarble_basecorner":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleBasecorner);
					break;
				case "blackmarble_out_1":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleOut1);
					break;
				case "blackmarble_outcorner":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleOutCorner);
					break;
				case "blackmarble_arch":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleArchCost);
					break;
				case "blackmarble_column_1":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleColumn1Cost);
					break;
				case "blackmarble_column_2":
					TrySetPieceCost(val, enableBlackMarbleCostPatch, blackMarbleColumn2Cost);
					break;
				case "Piece_grausten_stone_ladder":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenStoneLadderCost);
					break;
				case "piece_grausten_stonestair":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenStoneStairCost);
					break;
				case "Piece_grausten_floor_1x1":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenFloor1x1Cost);
					break;
				case "Piece_grausten_floor_2x2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenFloor2x2Cost);
					break;
				case "Piece_grausten_floor_4x4":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenFloor4x4Cost);
					break;
				case "Piece_grausten_pillarbase_small":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarBaseSmallCost);
					break;
				case "Piece_grausten_pillarbase_medium":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarBaseMediumCost);
					break;
				case "Piece_grausten_pillarbase_tapered":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarBaseTaperedCost);
					break;
				case "Piece_grausten_pillarbase_tapered_inverted":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarBaseTaperedInvertedCost);
					break;
				case "Piece_grausten_pillarbeam_small":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarBeamSmallCost);
					break;
				case "Piece_grausten_pillarbeam_medium":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarBeamMediumCost);
					break;
				case "Piece_grausten_pillar_arch_small":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarArchSmallCost);
					break;
				case "Piece_grausten_pillar_arch":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenPillarArchCost);
					break;
				case "Piece_grausten_wall_arch":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWallArchCost);
					break;
				case "Piece_grausten_wall_arch_inverted":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWallArchInvertedCost);
					break;
				case "Piece_grausten_wall_1x2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWall1x2Cost);
					break;
				case "Piece_grausten_wall_2x2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWall2x2Cost);
					break;
				case "Piece_grausten_wall_4x2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWall4x2Cost);
					break;
				case "Piece_grausten_window_2x2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWindow2x2Cost);
					break;
				case "Piece_grausten_window_4x2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenWindow4x2Cost);
					break;
				case "piece_grausten_roof_45":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenRoof45Cost);
					break;
				case "piece_grausten_roof_45_corner":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenRoof45CornerCost);
					break;
				case "piece_grausten_roof_45_corner2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenRoof45Corner2Cost);
					break;
				case "piece_grausten_roof_45_arch":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenRoof45ArchCost);
					break;
				case "piece_grausten_roof_45_arch_corner2":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenRoof45ArchCorner2Cost);
					break;
				case "piece_grausten_roof_45_arch_corner":
					TrySetPieceCost(val, enableGraustenCostPatch, pieceGraustenRoof45ArchCornerCost);
					break;
				}
			}
		}
		ApplyPotentialForgeTweaks(__instance);
	}

	[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
	[HarmonyPrefix]
	private static bool Skills_LowerAllSkills_Prefix()
	{
		return !enableXpPatch.Value;
	}

	[HarmonyPatch(typeof(Skill), "GetNextLevelRequirement")]
	[HarmonyPostfix]
	private static void Skill_GetNextLevelRequirement_Postfix(ref float __result)
	{
		if (enableSkillXpCostPatch.Value)
		{
			__result *= skillXpCostMultiplier.Value;
		}
	}

	[HarmonyPatch(typeof(Minimap), "Start")]
	[HarmonyPostfix]
	private static void Minimap_Start_Postfix(ref float ___m_exploreRadius)
	{
		if (enableExplorationRadiusPatch.Value)
		{
			___m_exploreRadius = explorationRadius.Value;
		}
	}

	private void Awake()
	{
		//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a23: Expected O, but got Unknown
		//IL_0a56: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a60: Expected O, but got Unknown
		//IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abd: Expected O, but got Unknown
		enableFastProductionPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableFastProductionPatch", true, "Enable the Fast production patch");
		enableStoneCostPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableStoneCostPatch", true, "Enable the Stone building pieces patch");
		enableIronCostPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableIronCostPatch", true, "Enable the Iron building pieces patch");
		enableBlackMarbleCostPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableBlackMarbleCostPatch", true, "Enable the Black marble building pieces patch");
		enableGraustenCostPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableGraustenCostPatch", true, "Enable the Black marble building pieces patch");
		enableXpPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableXpPatch", true, "Enable the Black marble building pieces patch");
		enableSkillXpCostPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Skill Progression", "EnableSkillXpCostPatch", false, "Changes the XP required to increase skill levels.");
		enableFoodDecayPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableFoodDecayPatch", true, "Enable the Black marble building pieces patch");
		enablePotentialForgePatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Forge of Potential", "EnablePotentialForgePatch", false, "Enable custom Forge of Potential break chance.");
		ProductionCharcoalKilnMaxFuel = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionCharcoalKilnMaxFuel", 0, "Max fuel that can be added");
		ProductionCharcoalKilnMaxOre = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionCharcoalKilnMaxOre", 50, "Max ore that can be added");
		ProductionCharcoalKilnFuelPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionCharcoalKilnFuelPerProduct", 1, "How many fuel is consumed per product");
		ProductionCharcoalKilnSecPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionCharcoalKilnSecPerProduct", 2, "Cost of stone for this building piece");
		ProductionSmelterMaxFuel = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionSmelterMaxFuel", 50, "Max fuel that can be added");
		ProductionSmelterMaxOre = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionSmelterMaxOre", 20, "Max ore that can be added");
		ProductionSmelterFuelPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionSmelterFuelPerProduct", 1, "How many fuel is consumed per product");
		ProductionSmelterSecPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionSmelterSecPerProduct", 2, "How long take to produce one product");
		ProductionWindmillMaxOre = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionWindmillMaxOre", 50, "Max ore that can be added");
		ProductionWindmillSecPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionWindmillSecPerProduct", 2, "How long take to produce one product");
		ProductionSpinningWheelMaxOre = ((BaseUnityPlugin)this).Config.Bind<int>("Production", "ProductionSpinningWheelMaxOre", 40, "Maximum amount of flax that can be added to the Spinning Wheel.");
		ProductionSpinningWheelSecPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Production", "ProductionSpinningWheelSecPerProduct", 2, "Seconds required to produce one Linen Thread.");
		ProductionBlastFurnaceMaxFuel = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionBlastFurnaceMaxFuel", 50, "Max fuel that can be added");
		ProductionBlastFurnaceMaxOre = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionBlastFurnaceMaxOre", 20, "Max ore that can be added");
		ProductionBlastFurnaceFuelPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionBlastFurnaceFuelPerProduct", 1, "How many fuel is consumed per product");
		ProductionBlastFurnaceSecPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionBlastFurnaceSecPerProduct", 2, "How long take to produce one product");
		ProductionDefaultSecPerProduct = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "ProductionDefaultSecPerProduct", 2, "How long take to produce one product");
		stoneWall4x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stoneWall4x2Cost", 6, "Cost of stone for this building piece");
		stoneWall2x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stoneWall2x1Cost", 2, "Cost of stone for this building piece");
		stoneWall1x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stoneWall1x1Cost", 1, "Cost of stone for this building piece");
		stoneFloor2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stoneFloor2x2Cost", 4, "Cost of stone for this building piece");
		stoneArchCost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stoneArchCost", 2, "Cost of stone for this building piece");
		stonePillarCost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stonePillarCost", 2, "Cost of stone for this building piece");
		stoneStairCost = ((BaseUnityPlugin)this).Config.Bind<int>("Stone Cost", "stoneStairCost", 2, "Cost of stone for this building piece");
		cageFloor1x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Iron Cost", "cageFloor1x1Cost", 1, "Cost of iron for this building piece");
		cageFloor2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Iron Cost", "cageFloor2x2Cost", 2, "Cost of iron for this building piece");
		cageWall1x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Iron Cost", "cageWall1x1Cost", 1, "Cost of iron for this building piece");
		cageWall2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Iron Cost", "cageWall2x2Cost", 2, "Cost of iron for this building piece");
		ironGateCost = ((BaseUnityPlugin)this).Config.Bind<int>("Iron Cost", "ironGateCost", 2, "Cost of iron for this building piece");
		blackMarble1x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarble1x1Cost", 1, "Cost of black marble for this building piece");
		blackMarble2x1x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarble2x1x1Cost", 2, "Cost of black marble for this building piece");
		blackMarble2x2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarble2x2x2Cost", 4, "Cost of black marble for this building piece");
		blackMarbleFloorCost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleFloorCost", 2, "Cost of black marble for this building piece");
		blackMarbleFloorTriangleCost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleFloorTriangleCost", 1, "Cost of black marble for this building piece");
		blackMarbleStairCost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleStairCost", 2, "Cost of black marble for this building piece");
		blackMarbleTipCost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleTipCost", 1, "Cost of black marble for this building piece");
		blackMarbleBase1 = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleBase1", 1, "Cost of black marble for this building piece");
		blackMarbleBasecorner = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleBasecorner", 1, "Cost of black marble for this building piece");
		blackMarbleOut1 = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleOut1", 1, "Cost of black marble for this building piece");
		blackMarbleOutCorner = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleOutCorner", 1, "Cost of black marble for this building piece");
		blackMarbleArchCost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleArchCost", 1, "Cost of black marble for this building piece");
		blackMarbleColumn1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleColumn1Cost", 1, "Cost of black marble for this building piece");
		blackMarbleColumn2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Black marble Cost", "blackMarbleColumn2Cost", 2, "Cost of black marble for this building piece");
		pieceGraustenStoneLadderCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenStoneLadderCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenStoneStairCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenStoneStairCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenFloor1x1Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenFloor1x1Cost", 1, "Cost of Grausten for this building piece");
		pieceGraustenFloor2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenFloor2x2Cost", 2, "Cost of Grausten for this building piece");
		pieceGraustenFloor4x4Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenFloor4x4Cost", 4, "Cost of Grausten for this building piece");
		pieceGraustenPillarBaseSmallCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarBaseSmallCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarBaseMediumCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarBaseMediumCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarBaseTaperedCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarBaseTaperedCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarBaseTaperedInvertedCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarBaseTaperedInvertedCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarBeamSmallCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarBeamSmallCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarBeamMediumCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarBeamMediumCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarArchSmallCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarArchSmallCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenPillarArchCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenPillarArchCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenWallArchCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWallArchCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenWallArchInvertedCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWallArchInvertedCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenWall1x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWall1x2Cost", 2, "Cost of Grausten for this building piece");
		pieceGraustenWall2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWall2x2Cost", 4, "Cost of Grausten for this building piece");
		pieceGraustenWall4x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWall4x2Cost", 6, "Cost of Grausten for this building piece");
		pieceGraustenWindow2x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWindow2x2Cost", 1, "Cost of Grausten for this building piece");
		pieceGraustenWindow4x2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenWindow4x2Cost", 2, "Cost of Grausten for this building piece");
		pieceGraustenRoof45Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenRoof45Cost", 1, "Cost of Grausten for this building piece");
		pieceGraustenRoof45CornerCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenRoof45CornerCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenRoof45Corner2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenRoof45Corner2Cost", 1, "Cost of Grausten for this building piece");
		pieceGraustenRoof45ArchCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenRoof45ArchCost", 1, "Cost of Grausten for this building piece");
		pieceGraustenRoof45ArchCorner2Cost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenRoof45ArchCorner2Cost", 1, "Cost of Grausten for this building piece");
		pieceGraustenRoof45ArchCornerCost = ((BaseUnityPlugin)this).Config.Bind<int>("Grausten Cost", "pieceGraustenRoof45ArchCornerCost", 1, "Cost of Grausten for this building piece");
		skillXpCostMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Skill Progression", "SkillXpCostMultiplier", 0.2f, "Multiplier applied to the vanilla XP requirement. 0.2 = 20% of vanilla XP.");
		potentialForgeBreakChance = ((BaseUnityPlugin)this).Config.Bind<float>("Forge of Potential", "BreakChance", 0f, new ConfigDescription("Chance for an item to be destroyed when using the Forge of Potential. 0 = never break, 1 = always break.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		potentialForgeSuccessChance = ((BaseUnityPlugin)this).Config.Bind<float>("Forge of Potential", "SuccessChance", 0.7f, new ConfigDescription("Chance for an upgrade to succeed. 0 = 0%, 1 = 100%.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		enableExplorationRadiusPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Map Exploration", "EnableExplorationRadiusPatch", false, "Enable custom map exploration radius.");
		explorationRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Map Exploration", "ExplorationRadius", 100f, new ConfigDescription("Radius in meters revealed on the map while exploring. Vanilla = 100.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>()));
		harmony.PatchAll();
	}

	private static void TrySetPieceCost(Piece piece, ConfigEntry<bool> enabled, ConfigEntry<int> cost)
	{
		if (enabled.Value)
		{
			SetPieceCost(piece, cost.Value);
		}
	}

	private static void SetPieceCost(Piece piece, int cost)
	{
		if (piece.m_resources == null || piece.m_resources.Length == 0)
		{
			Debug.LogWarning((object)("[RomeTweaksMod] '" + ((Object)((Component)piece).gameObject).name + "' has no build requirements."));
		}
		else if (piece.m_resources[0] == null)
		{
			Debug.LogWarning((object)("[RomeTweaksMod] '" + ((Object)((Component)piece).gameObject).name + "' has a null build requirement."));
		}
		else
		{
			piece.m_resources[0].m_amount = cost;
		}
	}

	private static void ApplyPotentialForgeTweaks(ObjectDB objectDB)
	{
		if (!enablePotentialForgePatch.Value || objectDB?.m_recipes == null)
		{
			return;
		}
		float num = Mathf.Clamp01(potentialForgeSuccessChance.Value);
		float breakChance = Mathf.Clamp(potentialForgeBreakChance.Value, 0f, 1f - num);
		foreach (Recipe recipe in objectDB.m_recipes)
		{
			if (recipe?.m_resources == null)
			{
				continue;
			}
			Requirement[] resources = recipe.m_resources;
			foreach (Requirement val in resources)
			{
				if (val != null && val.m_upgraderResource && !((Object)(object)val.m_resItem == (Object)null))
				{
					SharedData val2 = val.m_resItem.m_itemData?.m_shared;
					if (val2 != null)
					{
						val2.m_upgradeChance = num;
						val2.m_breakChance = breakChance;
					}
				}
			}
		}
	}
}