Decompiled source of LetTheDeadRest v1.0.2

LetTheDeadRest.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using LetTheDeadRest.Patches;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
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("LetTheDeadRest")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9af27cd54458c783bac3fcf5c296376ec869b0a2")]
[assembly: AssemblyProduct("LetTheDeadRest")]
[assembly: AssemblyTitle("LetTheDeadRest")]
[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 LetTheDeadRest
{
	[BepInPlugin("dummy.LetTheDeadRest", "dummy.LetTheDeadRest", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("dummy.LetTheDeadRest");

		public static Plugin instance;

		public ConfigEntry<float> volumeMultiplier;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			InitializeConfigValues();
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LetTheDeadRest loaded");
		}

		private void InitializeConfigValues()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_005b: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			LethalConfigManager.SetModDescription("LetTheDeadRest");
			volumeMultiplier = ((BaseUnityPlugin)instance).Config.Bind<float>("LetTheDeadRest", "Volume Multiplier", 0.2f, "How loud alive players are compared to your fellow dead players. From 0.0 to 1.0.");
			FloatSliderOptions val = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = 1f;
			FloatSliderOptions val2 = val;
			FloatSliderConfigItem val3 = new FloatSliderConfigItem(volumeMultiplier, val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			volumeMultiplier.SettingChanged += delegate
			{
				StartOfRound.Instance.UpdatePlayerVoiceEffects();
			};
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)(message ?? ""));
		}

		public static void LogError(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogError((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "dummy.LetTheDeadRest";

		public const string PLUGIN_NAME = "LetTheDeadRest";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace LetTheDeadRest.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("UpdatePlayerVoiceEffects")]
		private static void ChangeVolumeWhileDead(PlayerControllerB[] ___allPlayerScripts)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			foreach (PlayerControllerB val in ___allPlayerScripts)
			{
				if ((val.isPlayerControlled || val.isPlayerDead) && !((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController) && GameNetworkManager.Instance.localPlayerController.isPlayerDead)
				{
					if (val.isPlayerDead)
					{
						val.voicePlayerState.Volume = 1f;
					}
					else
					{
						val.voicePlayerState.Volume = Plugin.instance.volumeMultiplier.Value;
					}
				}
			}
		}
	}
}