using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BaraphorSharedLibs;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("cheaper-stone-pieces")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("cheaper-stone-pieces")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("56310632-a8f4-496b-875a-97d1b4069f48")]
[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 CheaperStonePieces;
[BepInPlugin("com.baraphor.cheaperstonepieces", "Cheaper Stone Pieces", "1.0.0")]
[BepInProcess("valheim.exe")]
public class CheaperStonePiecesMod : BaseValheimMod
{
public static ConfigEntry<int> stone_wall_4x2;
public static ConfigEntry<int> stone_wall_2x1;
public static ConfigEntry<int> stone_wall_1x1;
public static ConfigEntry<int> stone_floor_2x2;
public static ConfigEntry<int> stone_arch;
public static ConfigEntry<int> stone_pillar;
public static ConfigEntry<int> stone_stair;
public CheaperStonePiecesMod()
: base("com.baraphor.cheaperstonepieces")
{
stone_wall_4x2 = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StoneWall4x2", 8, "The cost of the the StoneWall4x2 piece, the unmodded value is 6.");
stone_wall_2x1 = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StoneWall2x1", 2, "The cost of the the StoneWall4x2 piece, the unmodded value is 6.");
stone_wall_1x1 = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StoneWall1x1", 1, "The cost of the the StoneWall4x2 piece, the unmodded value is 3.");
stone_floor_2x2 = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StoneFloor2x2", 4, "The cost of the the StoneWall4x2 piece, the unmodded value is 6.");
stone_arch = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StoneArch", 2, "The cost of the the StoneWall4x2 piece, the unmodded value is 4.");
stone_pillar = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StonePillar", 2, "The cost of the the StoneWall4x2 piece, the unmodded value is 5.");
stone_stair = ((BaseUnityPlugin)this).Config.Bind<int>("StonePieceCosts", "StoneStair", 4, "The cost of the the StoneWall4x2 piece, the unmodded value is 8.");
((BaseUnityPlugin)this).Logger.LogDebug((object)"Loaded com.baraphor.cheaperstonepieces");
}
public void Awake()
{
base.Harmony.PatchAll();
}
}
[HarmonyPatch]
public class Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(ObjectDB), "Awake")]
public static void PieceTable_Awake_WallCost(ref ObjectDB __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
Object[] array = Resources.FindObjectsOfTypeAll(typeof(GameObject));
for (int i = 0; i < array.Length; i++)
{
GameObject val = (GameObject)array[i];
if (((Object)val).name == "stone_wall_4x2")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_wall_4x2.Value;
}
else if (((Object)val).name == "stone_wall_2x1")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_wall_2x1.Value;
}
else if (((Object)val).name == "stone_wall_1x1")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_wall_1x1.Value;
}
else if (((Object)val).name == "stone_floor_2x2")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_floor_2x2.Value;
}
else if (((Object)val).name == "stone_arch")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_arch.Value;
}
else if (((Object)val).name == "stone_pillar")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_pillar.Value;
}
else if (((Object)val).name == "stone_stair")
{
val.GetComponent<Piece>().m_resources[0].m_amount = CheaperStonePiecesMod.stone_stair.Value;
}
}
}
}