using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LCSoundTool;
using LCSoundTool.Networking;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using no00ob.Mod.LethalCompany.LCSoundToolTest;
using no00ob.Mod.LethalCompany.LCSoundToolTestMod.Patches;
[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("FireTypeGangModPack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replaces 2 menu button sounds. Useful for testing if LCSoundTool works.")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2")]
[assembly: AssemblyProduct("FireTypeGangModPack")]
[assembly: AssemblyTitle("FireTypeGangModPack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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 LCSoundToolTestMod
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "FireTypeGangModPack";
public const string PLUGIN_NAME = "FireTypeGangModPack";
public const string PLUGIN_VERSION = "1.2.2";
}
}
namespace no00ob.Mod.LethalCompany.LCSoundToolTest
{
[BepInPlugin("FireTypeGangModPack", "Fire Type Gang ModPack", "1.0.0")]
public class SoundToolTestBase : BaseUnityPlugin
{
private const string PLUGIN_GUID = "FireTypeGangModPack";
private const string PLUGIN_NAME = "Fire Type Gang ModPack";
private const string PLUGIN_VERSION = "1.0.0";
public static SoundToolTestBase Instance;
internal ManualLogSource logger;
private readonly Harmony harmony = new Harmony("FireTypeGangModPack");
public KeyboardShortcut sendNetworkAudioTest;
public KeyboardShortcut removeNetworkAudioTest;
public KeyboardShortcut logNetworkAudioTest;
public KeyboardShortcut syncNetworkAudioTest;
public bool wasKeyDown;
public bool wasKeyDown2;
public bool wasKeyDown3;
public bool wasKeyDown4;
public static AudioClip music;
public static AudioClip sound;
public static AudioClip randomSound1;
public static AudioClip randomSound2;
public static AudioClip networkedSound;
private NetworkHandler Instant = new NetworkHandler();
public static string networkedSoundName = "Scan";
private bool subbed;
private Random rnd = new Random();
private float timer = 0f;
private void Awake()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logger = Logger.CreateLogSource("FireTypeGangModPack");
logger.LogInfo((object)"Plugin FireTypeGangModPack is loaded!");
sendNetworkAudioTest = new KeyboardShortcut((KeyCode)284, (KeyCode[])(object)new KeyCode[0]);
removeNetworkAudioTest = new KeyboardShortcut((KeyCode)285, (KeyCode[])(object)new KeyCode[0]);
logNetworkAudioTest = new KeyboardShortcut((KeyCode)290, (KeyCode[])(object)new KeyCode[0]);
syncNetworkAudioTest = new KeyboardShortcut((KeyCode)291, (KeyCode[])(object)new KeyCode[0]);
harmony.PatchAll(typeof(BoomBoxItemPatch));
((NetworkBehaviour)Instant).OnNetworkSpawn();
string path = Path.Combine(Paths.BepInExConfigPath);
try
{
List<string> list = File.ReadAllLines(path).ToList();
int num = list.FindIndex((string line) => line.StartsWith("HideManagerGameObject"));
if (num != -1 && list[num].Contains("false"))
{
logger.LogInfo((object)"\"HideManagerGameObject\" value not correctly set. Fixing it now.");
list[num] = "HideManagerGameObject = true";
File.WriteAllLines(path, list);
}
else if (num != -1)
{
logger.LogInfo((object)"\"HideManagerGameObject\" is correctly set to true.");
}
}
catch (Exception ex)
{
logger.LogError((object)("Error modifying config file: " + ex.Message));
}
}
private void Start()
{
logger.LogDebug((object)"Fire Type Gang sound tool initialized");
string path = Path.Combine(Paths.PluginPath, "music");
string path2 = Path.Combine(Paths.PluginPath, "music.zi");
string path3 = Path.Combine(Paths.PluginPath, "music.zip");
string text = Path.Combine(Paths.PluginPath, "music2");
string text2 = Path.Combine(Paths.PluginPath, "music2.zi");
string text3 = Path.Combine(Paths.PluginPath, "music2.zip");
if (Directory.Exists(path))
{
Directory.Delete(path, recursive: true);
}
if (File.Exists(text2))
{
File.Delete(text2);
}
if (File.Exists(text3))
{
File.Delete(text3);
}
if (File.Exists(path2))
{
File.Delete(path2);
}
if (File.Exists(path3))
{
File.Delete(path3);
}
if (!Directory.Exists(text))
{
WebClient webClient = new WebClient();
webClient.Headers.Add("Accept: text/html, application/xhtml+xml, */*");
logger.LogWarning((object)"Music files not found, downloading them. This may take a while...");
webClient.DownloadFile(new Uri("https://link.storjshare.io/raw/jxdis7odkim6qsbnhgnudf7dianq/firetypegang%2Fmusic2.zip"), text2);
logger.LogWarning((object)"Download done, moving files...");
File.Move(text2, text3);
File.Delete(text2);
logger.LogWarning((object)"extracting files...");
ZipFile.ExtractToDirectory(text3, Paths.PluginPath, overwriteFiles: true);
File.Delete(text3);
logger.LogWarning((object)"Done extracting files!");
}
string[] directories = Directory.GetDirectories(text);
string[] array = directories;
foreach (string path4 in array)
{
DirectoryInfo directoryInfo = new DirectoryInfo(path4);
string name = directoryInfo.Name;
int num = directoryInfo.GetFiles().Length;
if (num == 0)
{
continue;
}
string[] array2 = directoryInfo.Name.Split('-');
string[] files = Directory.GetFiles(path4, "*.wav");
List<AudioClip> list = new List<AudioClip>();
int[] array3 = new int[num];
int num2 = 0;
foreach (int item in DivideEvenly(100, num))
{
array3[num2] = item;
num2++;
}
int num3 = 0;
string[] array4 = files;
foreach (string text4 in array4)
{
logger.LogDebug((object)text4);
AudioClip audioClip = SoundTool.GetAudioClip(text, name, Path.GetFileName(text4));
((Object)audioClip).name = Path.GetFileNameWithoutExtension(text4) + "-" + array3[num3];
list.Add(audioClip);
num3++;
}
string[] array5 = array2;
foreach (string text5 in array5)
{
foreach (AudioClip item2 in list)
{
SoundTool.ReplaceAudioClip(text5, item2);
}
}
}
if (!SoundTool.networkingAvailable)
{
logger.LogWarning((object)"LCSoundTool networking not enabled! This mod will not work fully and might run into problems.");
}
else
{
logger.LogWarning((object)"LCSoundTool networking is enabled!");
}
logger.LogWarning((object)"Fire Type Gang Mod Loaded Successfully!");
}
public static IEnumerable<int> DivideEvenly(int numerator, int denominator)
{
int rem;
int div = Math.DivRem(numerator, denominator, out rem);
for (int i = 0; i < denominator; i++)
{
yield return (i < rem) ? (div + 1) : div;
}
}
public void Update()
{
timer += Time.deltaTime;
if (timer >= 50f)
{
timer = 0f;
int num = int.Parse(DateTime.UtcNow.ToString("MMddHHmm"));
Random.InitState(num);
logger.LogWarning((object)num.ToString());
}
}
}
}
namespace no00ob.Mod.LethalCompany.LCSoundToolTestMod.Patches
{
[HarmonyPatch(typeof(BoomboxItem))]
internal class BoomBoxItemPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Start_Patch(BoomboxItem __instance)
{
AudioClip[] musicAudios = __instance.musicAudios;
__instance.musicAudios = (AudioClip[])(object)new AudioClip[musicAudios.Length + 1];
for (int i = 0; i < musicAudios.Length; i++)
{
__instance.musicAudios[i] = musicAudios[i];
}
__instance.musicAudios[__instance.musicAudios.Length - 1] = SoundToolTestBase.music;
SoundToolTestBase.Instance.logger.LogDebug((object)$"Patched {__instance} with 1 new music track!");
}
}
}