Decompiled source of Nothing To See Here v0.0.1

Plugins/Soundless.dll

Decompiled 2 years ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using Enemies;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Soundless")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Soundless")]
[assembly: AssemblyTitle("Soundless")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 Soundless
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Soundless", "Soundless", "0.0.2")]
	public class Plugin : BasePlugin
	{
		public class Soundless : MonoBehaviour
		{
			private Vector3 playerpos;

			private AIG_CourseNode node;

			public static void Initialize()
			{
				foreach (CellSoundEmitter item in Object.FindObjectsOfType<CellSoundEmitter>())
				{
					Behaviour component = ((Component)item).GetComponent<Behaviour>();
					if ((Object)(object)component != (Object)null)
					{
						component.enabled = false;
					}
					((MonoBehaviour)item).StopAllCoroutines();
					item.StopSound();
					if (item.m_sound != null)
					{
						item.m_sound.Recycle();
					}
					Debug.Log(Object.op_Implicit("Soundless - removed sound from " + ((Object)((Component)((Component)item).transform.parent).gameObject).name));
				}
				List<AIG_CourseNode> list = new List<AIG_CourseNode>();
				Enumerator<LG_Zone> enumerator2 = Builder.CurrentFloor.allZones.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					Enumerator<AIG_CourseNode> enumerator3 = enumerator2.Current.m_courseNodes.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						AIG_CourseNode current2 = enumerator3.Current;
						list.Add(current2);
					}
				}
				list.RemoveAt(0);
				list.RemoveAt(0);
				mutedrooms = list;
				foreach (AIG_CourseNode item2 in list)
				{
					foreach (CellSoundPlayer componentsInChild in item2.gameObject.GetComponentsInChildren<CellSoundPlayer>())
					{
						componentsInChild.Stop();
						componentsInChild.Recycle();
					}
				}
			}

			private void Update()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				if ((int)FocusStateManager.CurrentState != 4)
				{
					return;
				}
				List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
				if (playerAgentsInLevel == null)
				{
					return;
				}
				Enumerator<PlayerAgent> enumerator = playerAgentsInLevel.GetEnumerator();
				while (enumerator.MoveNext())
				{
					PlayerAgent current = enumerator.Current;
					playerpos = ((Agent)current).Position;
					node = current.m_courseNode;
					if (mutedrooms.Contains(node))
					{
						current.Sound.Stop();
					}
				}
			}
		}

		public class Muter : MonoBehaviour
		{
			private CellSoundPlayer sound;

			private AIG_CourseNode node;

			private EnemyAgent enemy;

			private void Awake()
			{
				enemy = ((Component)this).GetComponent<EnemyAgent>();
				node = enemy.m_courseNode;
				sound = ((Component)this).GetComponent<CellSoundPlayer>();
			}

			private void Update()
			{
				if (mutedrooms.Contains(node) && sound != null)
				{
					sound.Recycle();
				}
				sound = null;
				if (!mutedrooms.Contains(node) && mutedrooms.Contains(enemy.m_courseNode) && sound != null)
				{
					sound.Recycle();
				}
				sound = null;
			}
		}

		[HarmonyPatch]
		private class SoundlessPatcher
		{
			[HarmonyPatch(typeof(EnemyAllocator), "SpawnEnemy")]
			[HarmonyPostfix]
			private static void Post(EnemyAllocator __instance)
			{
				((Component)__instance.m_spawnedEnemyAgent).gameObject.AddComponent<Muter>();
			}
		}

		public static List<AIG_CourseNode> mutedrooms = new List<AIG_CourseNode>();

		public override void Load()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("Soundless").PatchAll();
			ClassInjector.RegisterTypeInIl2Cpp<Muter>();
			((BasePlugin)this).AddComponent<Soundless>();
			LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)Soundless.Initialize);
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "Soundless";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const bool GitIsDirty = false;
	}
}