Decompiled source of StartNeedleStab v1.0.1

StartNeedleStab.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GlobalEnums;
using HarmonyLib;
using HutongGames.PlayMaker;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StartNeedleStab")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+60602b570f57eac324dd3831238bfc84c9c8ff88")]
[assembly: AssemblyProduct("StartNeedleStab")]
[assembly: AssemblyTitle("StartNeedleStab")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/FabBeyond/StartNeedleStab")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace StartNeedleStab
{
	[BepInPlugin("io.github.fabbeyond.startneedlestab", "StartNeedleStab", "1.0.1")]
	public class StartNeedleStabPlugin : BaseUnityPlugin
	{
		public static StartNeedleStabPlugin instance;

		public bool kill = false;

		public const string Id = "io.github.fabbeyond.startneedlestab";

		public static string Name => "StartNeedleStab";

		public static string Version => "1.0.1";

		public void Awake()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (Random.Range(0, 2) == 0)
			{
				kill = true;
			}
			instance = this;
			SceneManager.sceneLoaded += OnSceneLoaded;
			Harmony val = new Harmony("io.github.fabbeyond.startneedlestab");
			val.PatchAll();
		}

		public void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!kill || ((Scene)(ref scene)).name != "Tut_01")
			{
				return;
			}
			GameObject val = GameObject.Find("Tutorial Intro Cutscene");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			foreach (Transform item in val.transform)
			{
				Transform val2 = item;
				if (((Object)val2).name == "Needle" || ((Object)val2).name == "Crumbly Dust" || ((Object)val2).name == "Thunk Effect")
				{
					val2.localPosition = new Vector3(val2.localPosition.x + 0.9f, val2.localPosition.y, val2.localPosition.z);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayMakerFSM), "OnEnable")]
	public static class IntroFSMPatch
	{
		private static void Postfix(PlayMakerFSM __instance)
		{
			if (!StartNeedleStabPlugin.instance.kill)
			{
				return;
			}
			if (__instance.FsmName == "Control" && ((Object)((Component)__instance).gameObject).name == "Tutorial Intro Cutscene")
			{
				FsmState state = __instance.Fsm.GetState("Needle Land");
				if (state == null)
				{
					return;
				}
				InsertAction(state, (FsmStateAction)(object)new KillHornet(), 0);
			}
			if (__instance.FsmName == "Hero Death Anim")
			{
				FsmState state2 = __instance.Fsm.GetState("Ended");
				if (state2 != null)
				{
					InsertAction(state2, (FsmStateAction)(object)new StopGame(), 0);
				}
			}
		}

		private static void InsertAction(FsmState state, FsmStateAction action, int index)
		{
			List<FsmStateAction> list = state.Actions.ToList();
			list.Insert(index, action);
			state.Actions = list.ToArray();
			action.Init(state);
		}
	}
	public class KillHornet : FsmStateAction
	{
		public override void OnEnter()
		{
			HeroController.instance.TakeDamage((GameObject)null, (CollisionSide)4, 99, (HazardType)0, (DamagePropertyFlags)0);
			((FsmStateAction)this).Finish();
		}
	}
	public class StopGame : FsmStateAction
	{
		public override void OnEnter()
		{
			Application.Quit();
		}
	}
}