Decompiled source of PrimisPack v1.0.0

plugins/Sk737-ElevatorSymphony/ElevatorSymphony.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ElevatorSymphony.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ElevatorSymphony")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("ElevatorSymphony")]
[assembly: AssemblyTitle("ElevatorSymphony")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ElevatorSymphony
{
	[BepInPlugin("com.sk737.elevatorsymphony", "ElevatorSymphony", "1.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal const string GUID = "com.sk737.elevatorsymphony";

		internal const string NAME = "ElevatorSymphony";

		internal const string VERSION = "1.1.2";

		private string[] mClipFiles;

		private Harmony mHarmony = new Harmony("com.sk737.elevatorsymphony");

		private int mTotalWeight;

		internal static ManualLogSource LoggerInstance { get; private set; }

		internal static Plugin Instance { get; private set; }

		internal string ExecutingPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		internal List<AudioClip> Clips { get; set; } = new List<AudioClip>();


		internal Random Random { get; set; }

		public static Config Config { get; private set; }

		private void Awake()
		{
			Instance = this;
			LoggerInstance = ((BaseUnityPlugin)this).Logger;
			if (Directory.Exists(ExecutingPath + "/Music"))
			{
				List<string> list = new List<string>();
				list.AddRange(from f in Directory.GetFiles(ExecutingPath + "/Music")
					orderby f
					select f);
				mClipFiles = list.ToArray();
			}
			Config = new Config(((BaseUnityPlugin)this).Config, mClipFiles);
			foreach (ConfigEntry<int> songWeight in Config.SongWeights)
			{
				mTotalWeight += songWeight.Value;
			}
			string[] array = mClipFiles;
			foreach (string path in array)
			{
				LoadClip(path, delegate(AudioClip c)
				{
					lock (Clips)
					{
						Clips.Add(c);
					}
				});
			}
			mHarmony.PatchAll(typeof(RoundManagerPatch));
			mHarmony.PatchAll(typeof(StartStartOfRoundPatch));
			mHarmony.PatchAll(typeof(Plugin));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ElevatorSymphony is loaded!");
		}

		public AudioType GetAudioType(string extension)
		{
			return (AudioType)(extension switch
			{
				".mp3" => 13, 
				".wav" => 20, 
				_ => 14, 
			});
		}

		public async Task LoadClip(string path, Action<AudioClip> callback)
		{
			AudioType audioType = GetAudioType(Path.GetExtension(path));
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, audioType);
			try
			{
				request.SendWebRequest();
				while (!request.isDone)
				{
					await Task.Delay(50);
				}
				if ((int)request.result != 1)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load file:" + path + ", + " + request.error));
					return;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(request);
				((BaseUnityPlugin)this).Logger.LogMessage((object)("Loaded file: " + path));
				callback(content);
			}
			finally
			{
				if (request != null)
				{
					request.Dispose();
				}
			}
		}

		public void LoadNewAudioFile()
		{
			int num = Random.Next(0, mTotalWeight);
			int num2 = -1;
			int num3 = 0;
			for (int i = 0; i < Config.SongWeights.Count; i++)
			{
				int num4 = num3;
				num3 += Config.SongWeights[i].Value;
				if (num > num4 && num < num3)
				{
					num2 = i - 1;
					break;
				}
			}
			if (num2 >= 0 && mClipFiles.Length != 0)
			{
				LoadClip(mClipFiles[num2], SetElevator);
			}
		}

		public void SetElevator(AudioClip clip)
		{
			MineshaftElevatorController val = Object.FindObjectOfType<MineshaftElevatorController>();
			if ((Object)(object)val != (Object)null)
			{
				val.elevatorJingleMusic.clip = clip;
			}
		}
	}
	public class Config
	{
		public static List<ConfigEntry<int>> SongWeights = new List<ConfigEntry<int>>();

		public Config(ConfigFile config, string[] clipFiles)
		{
			SongWeights.Add(config.Bind<int>("General", "Default chance", 100, "Chance of the base games song being picked by the randomizer. The higher the value the greater the chance it is picked."));
			for (int i = 0; i < clipFiles.Length; i++)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(clipFiles[i]);
				SongWeights.Add(config.Bind<int>("General", fileNameWithoutExtension + " chance", 100, "Chance of " + fileNameWithoutExtension + " being picked by the randomizer. The higher the value the greater the chance it is picked."));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ElevatorSymphony";

		public const string PLUGIN_NAME = "ElevatorSymphony";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace ElevatorSymphony.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("InitializeRandomNumberGenerators")]
		[HarmonyPrefix]
		public static void SeedPatch(ref RoundManager __instance)
		{
			Plugin.LoggerInstance.LogInfo((object)$"Initializing random with seed {__instance.playersManager.randomMapSeed}");
			Plugin.Instance.Random = new Random(__instance.playersManager.randomMapSeed);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartStartOfRoundPatch
	{
		[HarmonyPatch("openingDoorsSequence")]
		[HarmonyPostfix]
		public static void openingDoorsSequencePatch()
		{
			Plugin.Instance.LoadNewAudioFile();
			MineshaftElevatorController val = Object.FindObjectOfType<MineshaftElevatorController>();
			if ((Object)(object)val != (Object)null)
			{
				List<AudioClip> list = new List<AudioClip>();
				list.AddRange(val.elevatorHalloweenClips.Concat(Plugin.Instance.Clips));
				val.elevatorHalloweenClips = list.ToArray();
				List<AudioClip> list2 = new List<AudioClip>();
				list2.AddRange(val.elevatorHalloweenClipsLoop.Concat(Plugin.Instance.Clips));
				val.elevatorHalloweenClipsLoop = list2.ToArray();
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/SpyPlayer-MoreJesterSound/MoreJesterSound.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using LCSoundTool;
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("MoreJesterSound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyInformationalVersion("1.0.6")]
[assembly: AssemblyProduct("MoreJesterSound")]
[assembly: AssemblyTitle("MoreJesterSound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 LethalCompanyTemplate
{
	[BepInPlugin("MoreJesterSound", "MoreJesterSound", "1.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> configSecondSound;

		private ConfigEntry<bool> configFirstSound;

		private ConfigEntry<string> configFirstName;

		private ConfigEntry<string> configSecondName;

		public static bool usingSecondSound;

		public static AudioClip firstSound;

		public static AudioClip secondSound;

		public static bool usingFirstSound;

		private void Awake()
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Enhanced Sound for Jester loaded");
			configFirstSound = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableFirst", true, "Enable a sound during the crank animation");
			configSecondSound = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableSecond", false, "Enable a sound during the walk animation");
			configFirstName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "firstSound", "firstsound.wav", "The name of the sound file to replace the default crank music");
			configSecondName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "secondSound", "", "The name of the second sound during the walk animation, leave empty if none");
			usingFirstSound = configFirstSound.Value;
			usingSecondSound = configSecondSound.Value;
			if (usingFirstSound)
			{
				firstSound = SoundTool.GetAudioClip("SpyPlayer-MoreJesterSound", configFirstName.Value);
			}
			if (usingSecondSound)
			{
				secondSound = SoundTool.GetAudioClip("SpyPlayer-MoreJesterSound", configSecondName.Value);
			}
			Harmony val = new Harmony("MoreJesterSound");
			val.PatchAll();
		}
	}
	[HarmonyPatch(typeof(JesterAI), "Update")]
	public class JesterPatch
	{
		private static void Prefix(out int __state, ref int ___previousState)
		{
			__state = ___previousState;
		}

		private static void Postfix(JesterAI __instance, int __state)
		{
			if (Plugin.usingSecondSound)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && __state != 2)
				{
					__instance.farAudio.clip = Plugin.secondSound;
					__instance.farAudio.Play();
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 0 && __state != 0)
				{
					__instance.farAudio.Stop();
				}
			}
		}
	}
	[HarmonyPatch(typeof(JesterAI), "Start")]
	public class JesterPatch2
	{
		private static void Postfix(JesterAI __instance)
		{
			if (Plugin.usingFirstSound)
			{
				__instance.popGoesTheWeaselTheme = Plugin.firstSound;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MoreJesterSound";

		public const string PLUGIN_NAME = "MoreJesterSound";

		public const string PLUGIN_VERSION = "1.0.6";
	}
}