Decompiled source of NoNPCs v1.0.2

GWYF.NoNPCs.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GWYF.NoNPCs.Code;
using HarmonyLib;
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("GWYF.NoNPCs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+180c5d566032808f00118f490114bf15541c065f")]
[assembly: AssemblyProduct("GWYF.NoNPCs")]
[assembly: AssemblyTitle("GWYF.NoNPCs")]
[assembly: AssemblyVersion("1.0.2.0")]
namespace GWYF.NoNPCs
{
	[BepInProcess("Gamble With Your Friends.exe")]
	[BepInPlugin("GWYF.Epoch.NoNPCs", "No NPCs!", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			SceneManager.sceneLoaded += OnSceneLoaded;
			new Harmony("GWYF.Epoch.NoNPCs").PatchAll();
			Logger.LogInfo((object)"Plugin GWYF.Epoch.NoNPCs is loaded!");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			CoreLogic.MakeNPCStaticsInactive(Logger);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GWYF.Epoch.NoNPCs";

		public const string PLUGIN_NAME = "No NPCs!";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace GWYF.NoNPCs.Code
{
	internal static class CoreLogic
	{
		internal static void MakeNPCStaticsInactive(ManualLogSource logger)
		{
			GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			int num = 0;
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name.Contains("NPC Static"))
				{
					val.SetActive(false);
					num++;
				}
			}
			logger.LogInfo((object)$"Disabled {num} NPC object(s).");
		}
	}
	[HarmonyPatch(typeof(NPCController), "RegisterNPC")]
	public static class Patch_NPCController_RegisterNPC
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(NPCSpawner), "SpawnAllCoroutine")]
	public static class Patch_SpawnAllCoroutine
	{
		[CompilerGenerated]
		private sealed class <EmptyCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EmptyCoroutine>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static bool Prefix(ref IEnumerator __result)
		{
			__result = EmptyCoroutine();
			return false;
		}

		[IteratorStateMachine(typeof(<EmptyCoroutine>d__1))]
		private static IEnumerator EmptyCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EmptyCoroutine>d__1(0);
		}
	}
	[HarmonyPatch(typeof(NPCSpawner), "SpawnNPCsForFloor")]
	public static class Patch_SpawnNPCsForFloor
	{
		[CompilerGenerated]
		private sealed class <EmptyCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EmptyCoroutine>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static bool Prefix(ref IEnumerator __result)
		{
			__result = EmptyCoroutine();
			return false;
		}

		[IteratorStateMachine(typeof(<EmptyCoroutine>d__1))]
		private static IEnumerator EmptyCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EmptyCoroutine>d__1(0);
		}
	}
}