Decompiled source of SlowMotionMute v1.7.0

SlowMoMute.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using SlowMoMute;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "SlowMo Mute", "1.1.0", "SizinAdınız", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MelonLoaderMod1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MelonLoaderMod1")]
[assembly: AssemblyTitle("MelonLoaderMod1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 SlowMoMute
{
	public class Core : MelonMod
	{
		private bool wasInSlowMo = false;

		private readonly Dictionary<AudioSource, bool> mutedSources = new Dictionary<AudioSource, bool>();

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("SlowMo Mute v1.1 yüklendi.");
		}

		public override void OnUpdate()
		{
			bool flag = Time.timeScale < 0.95f;
			if (flag && !wasInSlowMo)
			{
				EnterSlowMo();
				wasInSlowMo = true;
			}
			else if (!flag && wasInSlowMo)
			{
				ExitSlowMo();
				wasInSlowMo = false;
			}
			else if (flag)
			{
				MuteNewSources();
			}
		}

		private void EnterSlowMo()
		{
			mutedSources.Clear();
			MuteNewSources();
			((MelonBase)this).LoggerInstance.Msg("Slow-Mo başladı → sesler susturuluyor.");
		}

		private void ExitSlowMo()
		{
			foreach (KeyValuePair<AudioSource, bool> mutedSource in mutedSources)
			{
				if ((Object)(object)mutedSource.Key != (Object)null)
				{
					mutedSource.Key.mute = mutedSource.Value;
				}
			}
			mutedSources.Clear();
			((MelonBase)this).LoggerInstance.Msg("Slow-Mo bitti → sesler geri açıldı.");
		}

		private void MuteNewSources()
		{
			Il2CppArrayBase<AudioSource> val = Object.FindObjectsOfType<AudioSource>();
			foreach (AudioSource item in val)
			{
				if (!((Object)(object)item == (Object)null) && !mutedSources.ContainsKey(item))
				{
					if (IsWeaponSound(item))
					{
						mutedSources[item] = item.mute;
						continue;
					}
					mutedSources[item] = item.mute;
					item.mute = true;
				}
			}
		}

		private bool IsWeaponSound(AudioSource source)
		{
			if ((Object)(object)source == (Object)null)
			{
				return false;
			}
			if ((Object)(object)source.outputAudioMixerGroup != (Object)null)
			{
				string text = ((Object)source.outputAudioMixerGroup).name.ToLower();
				if (text.Contains("gun") || text.Contains("shot") || text.Contains("bullet") || text.Contains("shell") || text.Contains("weapon") || text.Contains("impact"))
				{
					return true;
				}
			}
			if ((Object)(object)source.clip != (Object)null)
			{
				string text2 = ((Object)source.clip).name.ToLower();
				if (text2.Contains("gun") || text2.Contains("shot") || text2.Contains("fire") || text2.Contains("bullet") || text2.Contains("shell") || text2.Contains("pistol") || text2.Contains("rifle") || text2.Contains("shotgun") || text2.Contains("smg") || text2.Contains("weapon"))
				{
					return true;
				}
				if (text2.Contains("slow") || text2.Contains("time") || text2.Contains("timescale") || text2.Contains("slowdown") || text2.Contains("speedup") || text2.Contains("slowmo") || text2.Contains("bullet_time") || text2.Contains("player_time"))
				{
					return true;
				}
			}
			try
			{
				if ((Object)(object)Audio.Gunshot != (Object)null && (Object)(object)source.outputAudioMixerGroup == (Object)(object)Audio.Gunshot)
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}
	}
}