Decompiled source of LC Responder Mod v1.0.0

ThibsLCMod.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using Unity.Netcode;
using UnityEngine;
using VoiceRecognitionAPI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ThibsLCMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("ThibsLCMod")]
[assembly: AssemblyCopyright("Copyright © HP 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c30d725f-7f5c-4476-a662-1706dd8472cf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ThibsLCMod;

[BepInPlugin("me.thibs.VoiceResponderMod", "Thib's mod responder", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class FirstModBase : BaseUnityPlugin
{
	private const string modGUID = "me.thibs.VoiceResponderMod";

	private const string modName = "Thib's mod responder";

	private const string modVersion = "1.0.0";

	public static ManualLogSource LoggerInstance;

	internal static FirstModBase Instance;

	private AudioSource source;

	internal static List<AudioClip> SoundFX;

	internal static List<AudioSource> Sources;

	internal static List<GameObject> Gms;

	internal static AssetBundle Bundle;

	internal static AssetBundle PrefabBundle;

	public static GameObject prefab;

	private bool added;

	public PlayerControllerB gameCode;

	private static readonly Harmony harmony = new Harmony("me.thibs.VoiceResponderMod");

	public NetworkVariable<ulong> ServerID = new NetworkVariable<ulong>(0uL, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	private LethalClientMessage<int> AudioClipSend = new LethalClientMessage<int>("AudioClipPong", (Action<int>)null, (Action<int, ulong>)null);

	private void Awake()
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Expected O, but got Unknown
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		LoggerInstance = ((BaseUnityPlugin)this).Logger;
		Voice.ListenForPhrase("active le mod", (Action<string>)OnPhraseRecognized, 0.7f);
		Voice.ListenForPhrases(new string[3] { "démarre le jeu", "commence le jeu", "ping" }, (Action<string>)OnMultiplePhrasesRecognized, 0.7f);
		SoundFX = new List<AudioClip>();
		Sources = new List<AudioSource>();
		Gms = new List<GameObject>();
		string location = ((BaseUnityPlugin)Instance).Info.Location;
		location = location.TrimEnd("ThibsLCMod.dll".ToCharArray());
		Bundle = AssetBundle.LoadFromFile(location + "pongbundle");
		if ((Object)(object)Bundle != (Object)null)
		{
			SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			LoggerInstance.LogMessage((object)("There is " + SoundFX.Count() + " elements playable with voice recognition "));
		}
		else
		{
			LoggerInstance.LogError((object)"Failed to load asset bundle !");
		}
		added = false;
		gameCode = new PlayerControllerB();
		PrefabBundle = AssetBundle.LoadFromFile(location + "prefabbundle");
		if ((Object)(object)PrefabBundle != (Object)null)
		{
			prefab = PrefabBundle.LoadAllAssets<GameObject>()[0];
			LoggerInstance.LogMessage((object)("Sucessfully loaded prefab from file : " + (object)prefab));
		}
		else
		{
			LoggerInstance.LogError((object)"Failed to load prefab ");
		}
		AudioClipSend.OnReceivedFromClient += ReceivedFromClient;
	}

	private void OnPhraseRecognized(string recognizedText)
	{
		LoggerInstance.LogInfo((object)("Phrase reconnue : " + recognizedText));
	}

	private void OnMultiplePhrasesRecognized(string recognizedText)
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		LoggerInstance.LogInfo((object)("Phrase multiple reconnue : " + recognizedText));
		if ((Object)(object)SoundFX[0] == (Object)null)
		{
			LoggerInstance.LogError((object)"Fichier audio non trouvé ");
			return;
		}
		Random random = new Random();
		int num = random.Next(0, SoundFX.Count());
		LoggerInstance.LogInfo((object)("Preparing to play " + (object)SoundFX[num]));
		Vector3 position = GameObject.FindGameObjectsWithTag("Player").ToList()[0].transform.position;
		LoggerInstance.LogMessage((object)("PlayNext :" + num));
		AudioClipSend.SendAllClients(num, true, false);
	}

	private void ReceivedFromClient(int clip, ulong clientID)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		LoggerInstance.LogMessage((object)"Received Oreder to play sound");
		GameObject val = new GameObject("SoundPlayer");
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.PlayOneShot(SoundFX[clip]);
	}
}