Decompiled source of NoLooker v1.0.0

NoLooker.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[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("NoLooker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoLooker")]
[assembly: AssemblyTitle("NoLooker")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace PeakAccessibility
{
	[BepInPlugin("com.snosz.nolooker", "NoLooker", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Looker), "Start")]
		private static class LookerStartPatch
		{
			private static void Prefix(Looker __instance)
			{
				if (disableLooker.Value)
				{
					((Component)__instance).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(MapHandler), "Start")]
		public static class MapHandlerStartPatch
		{
			private static void Postfix(MapHandler __instance)
			{
				Transform val = ((Component)__instance).transform.Find("Global");
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Transform val2 = ((Component)val).transform.Find("Looker");
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
				if (disableLookerForAllClients.Value)
				{
					if (PhotonNetwork.IsMasterClient)
					{
						Looker[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Looker>();
						Looker[] array = componentsInChildren;
						foreach (Looker val3 in array)
						{
							PhotonNetwork.Destroy(((Component)val3).GetComponent<PhotonView>());
						}
					}
					if (!disableLooker.Value)
					{
						Object.Destroy((Object)(object)((Component)val2).gameObject);
					}
				}
				if (disableLooker.Value)
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
				}
			}
		}

		public static ConfigEntry<bool> disableLooker;

		public static ConfigEntry<bool> disableLookerForAllClients;

		private void Awake()
		{
			disableLooker = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableLooker", true, "If set to true, will disable looker, if set to false, will enable the looker. (client side only)");
			disableLookerForAllClients = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableLookerForAllClients", true, "If set to true, will disable looker for all connected players (if you are the host), and yourself.");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.snosz.nolooker");
		}
	}
}