Decompiled source of SkipToNuclearWinter v1.0.2

BepInEx/plugins/pauli-SkipToNuclearWinter/SkipToNuclearWinter.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Atomicrops.Core.InGameSelectable;
using Atomicrops.Game.GameState;
using Atomicrops.Game.Scenes.Farm.Devices;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SkipToNuclearWinter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SkipToNuclearWinter")]
[assembly: AssemblyTitle("SkipToNuclearWinter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 Template
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SkipToNuclearWinter";

		public const string PLUGIN_NAME = "SkipToNuclearWinter";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SkipToNuclearWinter
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "pauli.plugin.SkipToNuclearWinter";

		public const string PLUGIN_NAME = "SkipToNuclearWinter";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("pauli.plugin.SkipToNuclearWinter", "SkipToNuclearWinter", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SkipToNuclearWinter 1.0.0 is loaded!");
			Harmony val = new Harmony("pauli.plugin.SkipToNuclearWinter");
			val.PatchAll();
		}
	}
	[HarmonyPatch(typeof(CarToTown), "Awake")]
	internal class CarToTown_Awake_Patch
	{
		private delegate void OnInteractedCallbackDelegate();

		private static bool Prefix(CarToTown __instance)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Invalid comparison between Unknown and I4
			FieldInfo field = typeof(CarToTown).GetField("_selectable", BindingFlags.Instance | BindingFlags.NonPublic);
			InGameSelectable componentInChildren = ((Component)__instance).GetComponentInChildren<InGameSelectable>(true);
			componentInChildren.HoldFreq = 5f;
			MethodInfo method = AccessTools.Method(typeof(CarToTown), "_onInteractedCallback", (Type[])null, (Type[])null);
			OnInteractedCallbackDelegate onInteractedCallbackDelegate = (OnInteractedCallbackDelegate)Delegate.CreateDelegate(typeof(OnInteractedCallbackDelegate), __instance, method);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				Plugin.Log.LogError((object)"Selectable is null!");
				return true;
			}
			if (onInteractedCallbackDelegate == null)
			{
				Plugin.Log.LogError((object)"OnInteractedCallback is null!");
				return true;
			}
			componentInChildren.AllowHold = true;
			componentInChildren.OnInteractPress += onInteractedCallbackDelegate.Invoke;
			componentInChildren.OnInteractHold += CustomOnInteractHold;
			if (componentInChildren.AllowHold)
			{
				MethodInfo method2 = typeof(InGameSelectable).GetMethod("_holdTimerCo", BindingFlags.Instance | BindingFlags.NonPublic);
				if (method2 != null)
				{
					IEnumerator enumerator = (IEnumerator)method2.Invoke(componentInChildren, null);
					((MonoBehaviour)__instance).StartCoroutine(enumerator);
				}
			}
			if ((int)GameStateManager.GetCurrentScene() == 0)
			{
				__instance.Hide();
			}
			return false;
		}

		private static void CustomOnInteractHold()
		{
			GameStateManager.GoToFarmForFinalBoss((Action)null);
		}
	}
	[HarmonyPatch(typeof(TownManager), "_refreshTownToggler")]
	internal class TownManager_RefreshTownToggler_Patch
	{
		private static void Postfix()
		{
			GameObject val = GameObject.Find("__MOVE_but_BE_CAREFUL__/__HelicopterTown/Grp/InGameFloatText (1)/GameObject/");
			if ((Object)(object)val != (Object)null)
			{
				Text val2 = val.GetComponentsInChildren<Text>(true)[0];
				if ((Object)(object)val2 != (Object)null)
				{
					Plugin.Log.LogInfo((object)"Text component found and modified.");
					val2.text = "Return To Farm\n(Hold For Nuclear Winter)";
					val2.lineSpacing = 0.6f;
				}
				else
				{
					Plugin.Log.LogError((object)"Failed to find Text component on the specified GameObject or its children.");
				}
			}
			else
			{
				Plugin.Log.LogError((object)"Failed to find the specified GameObject.");
			}
		}
	}
}