Decompiled source of JitShip CustomDropShipMusic v1.3.0

JitShip.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LCSoundTool;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("JitShip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JitShip")]
[assembly: AssemblyTitle("JitShip")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JitShip;

[BepInPlugin("Specter.JitShip", "JitShip", "1.2.0.0")]
public class Plugin : BaseUnityPlugin
{
	private const string modGUID = "Specter.JitShip";

	private const string modName = "JitShip";

	private const string modVersion = "1.2.0.0";

	private readonly Harmony harmony = new Harmony("Specter.JitShip");

	private static Plugin Instance;

	public static ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("Specter.JitShip");
		mls.LogInfo((object)"JitShip is online.");
		harmony.PatchAll(typeof(Plugin));
		LoadAndPlayAudioClip();
	}

	private void LoadAndPlayAudioClip()
	{
		string filePath = Paths.PluginPath + "\\Specter-JitShip_CustomDropShipMusic\\your_audio_file.wav";
		LoadAudioFile(filePath);
	}

	private static void LoadAudioFile(string filePath)
	{
		if (File.Exists(filePath))
		{
			AudioClip audioClip = SoundTool.GetAudioClip(Path.GetDirectoryName(filePath), filePath);
			SoundTool.ReplaceAudioClip("IcecreamTruckV2", audioClip);
			SoundTool.ReplaceAudioClip("IcecreamTruckV2Christmas", audioClip);
			SoundTool.ReplaceAudioClip("IcecreamTruckV2ChristmasFar", audioClip);
			SoundTool.ReplaceAudioClip("IcecreamTruckV2Far", audioClip);
			audioClip = AdjustVolume(audioClip, 0.25f);
			SoundTool.ReplaceAudioClip("IcecreamTruckFar", audioClip);
		}
		else
		{
			mls.LogError((object)("Error loading audio file. File not found: " + filePath));
		}
	}

	private static AudioClip AdjustVolume(AudioClip clip, float volume)
	{
		float[] array = new float[clip.samples];
		clip.GetData(array, 0);
		for (int i = 0; i < array.Length; i++)
		{
			array[i] *= volume;
		}
		AudioClip val = AudioClip.Create("AdjustedClip", array.Length, clip.channels, clip.frequency, false);
		val.SetData(array, 0);
		return val;
	}
}