using System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("WarfareEWSizeFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WarfareEWSizeFix")] [assembly: AssemblyTitle("WarfareEWSizeFix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WarfareEWSizeFix { [BepInPlugin("gand.valheim.warfareewsizefix", "Warfare EW Size Fix", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private const string ModGuid = "gand.valheim.warfareewsizefix"; private const string ModName = "Warfare EW Size Fix"; private const string ModVersion = "1.0.1"; private const string WarfareHarmonyId = "Therzie.WarfareFireAndIce"; private Harmony _harmony; internal static ManualLogSource Log; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("gand.valheim.warfareewsizefix"); UnpatchWorldGeneratorGetBiomeOverloads(); UnpatchHeightmapBuilderBuild(); Log.LogInfo((object)"Warfare EW Size Fix loaded. Disabled Warfare Fire & Ice Deep North terrain conversion."); } private void UnpatchWorldGeneratorGetBiomeOverloads() { Type type = AccessTools.TypeByName("WorldGenerator"); if (type == null) { Log.LogWarning((object)"Could not find type: WorldGenerator."); return; } MethodInfo[] array = (from method in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where method.Name == "GetBiome" select method).ToArray(); if (array.Length == 0) { Log.LogWarning((object)"Could not find any WorldGenerator.GetBiome overloads."); return; } int num = 0; MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { _harmony.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)2, "Therzie.WarfareFireAndIce"); num++; } Log.LogInfo((object)$"Checked {num} WorldGenerator.GetBiome overload(s) for Warfare Fire & Ice postfixes."); } private void UnpatchHeightmapBuilderBuild() { Type type = AccessTools.TypeByName("HeightmapBuilder"); if (type == null) { Log.LogWarning((object)"Could not find type: HeightmapBuilder."); return; } MethodInfo methodInfo = AccessTools.Method(type, "Build", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"Could not find HeightmapBuilder.Build."); return; } _harmony.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)2, "Therzie.WarfareFireAndIce"); Log.LogInfo((object)"Removed Warfare Fire & Ice postfix from HeightmapBuilder.Build."); } } }