Decompiled source of PeakCold v1.0.1

PeakCold.dll

Decompiled 5 months 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.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: AssemblyTitle("PeakCold")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("P R C")]
[assembly: AssemblyProduct("PeakCold")]
[assembly: AssemblyCopyright("Copyright © P R C 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("775165f7-2c28-471d-bbc8-cccb7f9b4cba")]
[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")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 PeakCold
{
	[BepInPlugin("com.wuyachiyu.PeakCold", "PeakCold", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("com.wuyachiyu.PeakCold");
			try
			{
				val.PatchAll(typeof(CheckProgressPatch));
				Log.LogInfo((object)"PeakCold: MountainProgressHandler.CheckProgress fix applied");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("PeakCold: Patch failed - " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(MountainProgressHandler), "CheckProgress")]
	internal static class CheckProgressPatch
	{
		private static readonly FieldInfo _backingField = AccessTools.Field(typeof(MountainProgressHandler), "<maxProgressPointReached>k__BackingField");

		[HarmonyPrefix]
		private static void Prefix(MountainProgressHandler __instance, out int __state)
		{
			__state = __instance.maxProgressPointReached;
		}

		[HarmonyPostfix]
		private static void Postfix(MountainProgressHandler __instance, int __state)
		{
			if (__instance.maxProgressPointReached != __state)
			{
				_backingField.SetValue(__instance, __state);
			}
		}
	}
}