Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GoofySounds v1.0.0
GoofySounds.dll
Decompiled a day agousing System; using System.Collections; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Audio; 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: AssemblyCompany("GoofySounds")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6923bc52837d774cb0eae2979624c7cdf5f688a0")] [assembly: AssemblyProduct("GoofySounds")] [assembly: AssemblyTitle("GoofySounds")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 GoofySounds { internal static class CustomSounds { private class Target { public string Enemy; public string Field; public int EnemyId; public Transform Follow; public Transform Root; } internal class Decision { public AudioClip Clip; public MonsterSettings Reglages; public ActivePlay Play; public bool BaseReduite; public Transform Follow; public Transform Root; } internal class ActivePlay { public int EnemyId; public AudioClip Clip; public AudioSource Source; public float Start; public float End; } public const string DossierTous = "_TousLesMonstres"; private static readonly Dictionary<string, List<AudioClip>> Clips = new Dictionary<string, List<AudioClip>>(); private static readonly FieldInfo CenterTransformField = AccessTools.Field(typeof(Enemy), "CenterTransform"); private static readonly List<ActivePlay> Active = new List<ActivePlay>(); private static AudioClip _silence; private static readonly ConditionalWeakTable<Sound, Target> Registry = new ConditionalWeakTable<Sound, Target>(); private static readonly HashSet<string> KnownEnemies = new HashSet<string>(); private static readonly HashSet<string> TxtEcrits = new HashSet<string>(); private static readonly Dictionary<Type, List<FieldInfo>> FieldCache = new Dictionary<Type, List<FieldInfo>>(); private static readonly string[] Extensions = new string[3] { ".mp3", ".wav", ".ogg" }; public static string SonsRoot { get; private set; } public static bool IsLoading { get; private set; } public static int ClipCount { get; private set; } public static string Status { get; private set; } = "Pas encore chargé"; private static AudioClip Silence { get { if (!((Object)(object)_silence != (Object)null)) { return _silence = AudioClip.Create("GoofySilence", 441, 1, 44100, false); } return _silence; } } public static void Init() { SonsRoot = Path.Combine(Paths.ConfigPath, "GoofySounds", "Sons"); Directory.CreateDirectory(Path.Combine(SonsRoot, "_TousLesMonstres")); string[] directories = Directory.GetDirectories(SonsRoot); for (int i = 0; i < directories.Length; i++) { string fileName = Path.GetFileName(directories[i]); if (fileName != "_TousLesMonstres") { KnownEnemies.Add(fileName); } } string path = Path.Combine(SonsRoot, "LISEZ-MOI.txt"); if (!File.Exists(path)) { File.WriteAllText(path, "GoofySounds - Sons perso\r\n========================\r\n\r\nGlisse tes fichiers .mp3, .wav ou .ogg dans ces dossiers :\r\n\r\n _TousLesMonstres\\ -> joués pour TOUS les monstres\r\n NomDuMonstre\\ -> joués pour ce monstre\r\n NomDuMonstre\\nomDuSon\\ -> joués uniquement pour ce son précis\r\n\r\nLes dossiers des monstres sont créés automatiquement quand tu lances une partie.\r\nChaque dossier de monstre contient un fichier _sons_disponibles.txt avec la liste de ses sons.\r\n\r\nS'il y a plusieurs fichiers dans un dossier, un fichier est choisi au hasard à chaque fois.\r\nAprès avoir ajouté des fichiers, clique sur \"Recharger les sons\" dans le menu GoofySounds.\r\n"); } } public static IEnumerator ReloadAll() { if (IsLoading) { yield break; } IsLoading = true; Status = "Chargement..."; EnemyMusic.StopAll(); foreach (List<AudioClip> value2 in Clips.Values) { foreach (AudioClip item in value2) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } } Clips.Clear(); ClipCount = 0; Active.Clear(); int erreurs = 0; List<string> list = (from f in Directory.GetFiles(SonsRoot, "*.*", SearchOption.AllDirectories) where Extensions.Contains(Path.GetExtension(f).ToLowerInvariant()) select f).ToList(); foreach (string item2 in list) { string directoryName = Path.GetDirectoryName(item2); string cle = KeyFromFolder(directoryName); if (string.IsNullOrEmpty(cle)) { continue; } AudioClip clip = null; yield return LoadClip(item2, delegate(AudioClip c) { clip = c; }); if ((Object)(object)clip == (Object)null) { erreurs++; continue; } if (!Clips.TryGetValue(cle, out var value)) { value = (Clips[cle] = new List<AudioClip>()); } value.Add(clip); ClipCount++; } try { MonsterActions.Load(SonsRoot, GetClips); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Lecture des _actions.txt : " + ex.Message)); } Status = $"{ClipCount} son(s) chargé(s) dans {Clips.Count} dossier(s)" + ((erreurs > 0) ? $", {erreurs} erreur(s)" : ""); Plugin.Log.LogInfo((object)("Sons perso : " + Status)); foreach (KeyValuePair<string, List<AudioClip>> clip2 in Clips) { Plugin.Log.LogInfo((object)$" - {clip2.Key} : {clip2.Value.Count} fichier(s)"); } IsLoading = false; } private static IEnumerator LoadClip(string path, Action<AudioClip> done) { string text = Path.GetExtension(path).ToLowerInvariant(); AudioType val = ((text == ".wav") ? ((AudioType)20) : ((!(text == ".ogg")) ? ((AudioType)13) : ((AudioType)14))); string absoluteUri = new Uri(path).AbsoluteUri; UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, val); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Plugin.Log.LogWarning((object)("Impossible de charger " + path + " : " + req.error)); done(null); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(req); if ((Object)(object)content == (Object)null || content.length <= 0f) { Plugin.Log.LogWarning((object)("Fichier audio vide ou illisible : " + path)); done(null); yield break; } ((Object)content).name = Path.GetFileNameWithoutExtension(path); done(content); } finally { ((IDisposable)req)?.Dispose(); } } private static string KeyFromFolder(string folder) { string text = folder.Substring(SonsRoot.Length).Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); if (text.Length == 0) { return null; } string[] array = text.Split(new char[2] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); if (array.Length < 2) { return array[0].ToLowerInvariant(); } return (array[0] + "/" + array[1]).ToLowerInvariant(); } public static void RegisterEnemy(EnemyParent enemy) { if ((Object)(object)enemy == (Object)null) { return; } string text = SafeName(enemy.enemyName); if (string.IsNullOrEmpty(text)) { return; } Transform val = null; try { Enemy componentInChildren = ((Component)enemy).GetComponentInChildren<Enemy>(true); if ((Object)(object)componentInChildren != (Object)null) { object? obj = CenterTransformField?.GetValue(componentInChildren); val = (Transform)(((obj is Transform) ? obj : null) ?? ((Component)componentInChildren).transform); } } catch { } SortedSet<string> sortedSet = new SortedSet<string>(); AudioMixerGroup val2 = null; foreach (var (val3, text2, val4) in FindSounds(((Component)enemy).gameObject)) { sortedSet.Add(text2); if ((Object)(object)val2 == (Object)null && (Object)(object)val3.Source != (Object)null) { val2 = val3.Source.outputAudioMixerGroup; } Registry.Remove(val3); Registry.Add(val3, new Target { Enemy = text, Field = text2, EnemyId = ((Object)enemy).GetInstanceID(), Follow = (((Object)(object)val != (Object)null) ? val : ((Component)val4).transform), Root = ((Component)enemy).transform }); } EnsureEnemyFolder(text, sortedSet); SightSounds.Track(enemy, text, val, val2); EnemyMusic.Track(enemy, text, val, val2); } public static void ScanEnemyPrefabs(EnemyDirector director) { try { List<EnemySetup> list = new List<EnemySetup>(); string[] array = new string[3] { "enemiesDifficulty1", "enemiesDifficulty2", "enemiesDifficulty3" }; foreach (string text in array) { if (AccessTools.Field(typeof(EnemyDirector), text)?.GetValue(director) is IEnumerable<EnemySetup> collection) { list.AddRange(collection); } } FieldInfo fieldInfo = AccessTools.Field(typeof(EnemySetup), "spawnObjects"); foreach (EnemySetup item in list.Where((EnemySetup s) => (Object)(object)s != (Object)null).Distinct()) { if (!(fieldInfo?.GetValue(item) is IEnumerable enumerable)) { continue; } foreach (object item2 in enumerable) { if (item2 == null) { continue; } PropertyInfo propertyInfo = AccessTools.Property(item2.GetType(), "Prefab"); GameObject val = null; try { object? obj = propertyInfo?.GetValue(item2); val = (GameObject)((obj is GameObject) ? obj : null); } catch { } if ((Object)(object)val == (Object)null) { continue; } EnemyParent componentInChildren = val.GetComponentInChildren<EnemyParent>(true); if ((Object)(object)componentInChildren == (Object)null) { continue; } string text2 = SafeName(componentInChildren.enemyName); if (!string.IsNullOrEmpty(text2) && (!KnownEnemies.Contains(text2) || !File.Exists(Path.Combine(SonsRoot, text2, "_sons_disponibles.txt")))) { SortedSet<string> champs = new SortedSet<string>(from x in FindSounds(val) select x.field); EnsureEnemyFolder(text2, champs); } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Scan des monstres impossible : " + ex.Message)); } } private static void EnsureEnemyFolder(string name, SortedSet<string> champs) { if (!TxtEcrits.Add(name)) { return; } KnownEnemies.Add(name); try { string text = Path.Combine(SonsRoot, name); Directory.CreateDirectory(text); File.WriteAllText(Path.Combine(text, "_sons_disponibles.txt"), "Sons du monstre \"" + name + "\"\r\n\r\nMets tes fichiers (.mp3, .wav, .ogg) directement dans ce dossier :\r\nils sont joués quand le monstre te repère, te poursuit ou attaque.\r\n(S'il n'y en a pas, ceux de _TousLesMonstres sont utilisés.)\r\n\r\nPour info, la liste de ses sons dans le jeu :\r\n\r\n " + string.Join("\r\n ", champs) + "\r\n"); Plugin.Log.LogInfo((object)$"Monstre détecté : {name} ({champs.Count} sons)"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Impossible de créer le dossier de " + name + " : " + ex.Message)); } } private static IEnumerable<(Sound sound, string field, MonoBehaviour comp)> FindSounds(GameObject root) { MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour comp in componentsInChildren) { if ((Object)(object)comp == (Object)null) { continue; } foreach (FieldInfo f in GetSoundFields(((object)comp).GetType())) { object value; try { value = f.GetValue(comp); } catch { continue; } Sound val = (Sound)((value is Sound) ? value : null); if (val != null) { yield return (sound: val, field: f.Name, comp: comp); } else { if (!(value is IEnumerable<Sound> enumerable)) { continue; } foreach (Sound item in enumerable) { if (item != null) { yield return (sound: item, field: f.Name, comp: comp); } } } } } } private static List<FieldInfo> GetSoundFields(Type type) { if (FieldCache.TryGetValue(type, out var value)) { return value; } List<FieldInfo> list = new List<FieldInfo>(); Type type2 = type; while (type2 != null && type2 != typeof(MonoBehaviour)) { FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(Sound) || typeof(IEnumerable<Sound>).IsAssignableFrom(fieldInfo.FieldType)) { list.Add(fieldInfo); } } type2 = type2.BaseType; } FieldCache[type] = list; return list; } private static string SafeName(string name) { if (string.IsNullOrWhiteSpace(name)) { return null; } char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { name = name.Replace(oldChar, '_'); } return name.Trim(); } public static Decision Decide(Sound sound) { if (!Plugin.SonsActifs.Value || IsLoading || ClipCount == 0 || sound == null) { return null; } if (!Registry.TryGetValue(sound, out var target)) { return null; } if (Plugin.ModeVue) { if (Plugin.DebugSons.Value) { Plugin.Log.LogInfo((object)("[son du jeu] " + target.Enemy + " / " + target.Field)); } MonsterActions.Rule rule = MonsterActions.Get(target.Enemy, target.Field); if (rule != null) { bool flag = SightSounds.OnEnemyAction(target.EnemyId, rule); MonsterSettings monsterSettings = MonsterSettings.Get(target.Enemy); if (rule.Remplace && monsterSettings.Actif.Value && (flag || IsEnemyPlaying(target.EnemyId))) { return new Decision { Clip = Silence, Reglages = monsterSettings }; } return null; } if (IsAttack(target.Field)) { SightSounds.OnEnemyAttack(target.EnemyId); } return null; } MonsterSettings monsterSettings2 = MonsterSettings.Get(target.Enemy); if (!monsterSettings2.Actif.Value) { return null; } string text = target.Enemy.ToLowerInvariant(); string text2 = target.Field.ToLowerInvariant(); Clips.TryGetValue(text + "/" + text2, out var value); if (value == null && (monsterSettings2.InclurePas.Value || !IsIgnored(text2)) && !Clips.TryGetValue(text, out value)) { Clips.TryGetValue("_TousLesMonstres".ToLowerInvariant(), out value); } if (value == null || value.Count == 0) { return null; } Decision decision = new Decision { Reglages = monsterSettings2, Follow = target.Follow, Root = target.Root }; if (Random.Range(0f, 100f) >= EffectiveChance(monsterSettings2)) { decision.BaseReduite = true; return decision; } CleanupActive(); List<AudioClip> list = (Active.Any((ActivePlay a) => a.EnemyId == target.EnemyId) ? new List<AudioClip>() : value.Where((AudioClip c) => (Object)(object)c != (Object)null && !Active.Any((ActivePlay a) => (Object)(object)a.Clip == (Object)(object)c)).ToList()); if (list.Count == 0) { decision.BaseReduite = true; return decision; } AudioClip val = (decision.Clip = list[Random.Range(0, list.Count)]); decision.Play = new ActivePlay { EnemyId = target.EnemyId, Clip = val, Start = Time.time, End = Time.time + val.length + 0.2f }; Active.Add(decision.Play); return decision; } public static AudioClip PickSightClip(string monstreNom, int enemyId, out ActivePlay play) { play = null; if (IsLoading || ClipCount == 0) { return null; } List<AudioClip> list = ClassicClips(monstreNom); if (list.Count == 0) { return null; } CleanupActive(); if (Active.Any((ActivePlay a) => a.EnemyId == enemyId)) { return null; } List<AudioClip> list2 = list.Where((AudioClip c) => (Object)(object)c != (Object)null && !Active.Any((ActivePlay a) => (Object)(object)a.Clip == (Object)(object)c)).ToList(); if (list2.Count == 0) { return null; } AudioClip val = list2[Random.Range(0, list2.Count)]; play = new ActivePlay { EnemyId = enemyId, Clip = val, Start = Time.time, End = Time.time + val.length + 0.2f }; Active.Add(play); return val; } public static List<AudioClip> ClassicClips(string monstreNom) { string key = monstreNom.ToLowerInvariant(); List<AudioClip> value; List<AudioClip> list = (Clips.TryGetValue(key, out value) ? value.Where((AudioClip c) => (Object)(object)c != (Object)null && !MonsterActions.IsReserved(monstreNom, c)).ToList() : new List<AudioClip>()); if (list.Count == 0 && Clips.TryGetValue("_TousLesMonstres".ToLowerInvariant(), out var value2)) { list = value2.Where((AudioClip c) => (Object)(object)c != (Object)null).ToList(); } return list; } public static AudioClip PickActionClip(MonsterActions.Rule regle, string monstreNom, int enemyId, out ActivePlay play) { play = null; if (IsLoading || regle == null) { return null; } List<AudioClip> list = new List<AudioClip>(regle.Clips); if (regle.Classiques) { list.AddRange(ClassicClips(monstreNom)); } list = list.Where((AudioClip c) => (Object)(object)c != (Object)null).Distinct().ToList(); if (list.Count == 0) { return null; } CleanupActive(); if (regle.Prioritaire) { StopEnemySounds(enemyId); } else if (Active.Any((ActivePlay a) => a.EnemyId == enemyId)) { return null; } List<AudioClip> list2 = list.Where((AudioClip c) => !Active.Any((ActivePlay a) => (Object)(object)a.Clip == (Object)(object)c)).ToList(); if (list2.Count == 0 && regle.Prioritaire) { list2 = list; } if (list2.Count == 0) { return null; } AudioClip val = list2[Random.Range(0, list2.Count)]; play = new ActivePlay { EnemyId = enemyId, Clip = val, Start = Time.time, End = Time.time + val.length + 0.2f }; Active.Add(play); return val; } public static float EffectiveChance(MonsterSettings reglages) { return reglages.Chance.Value; } public static void ConfirmPlay(ActivePlay play, AudioSource source) { if (play != null) { if ((Object)(object)source == (Object)null) { Active.Remove(play); return; } play.Source = source; play.End = Time.time + play.Clip.length / Mathf.Max(Mathf.Abs(source.pitch), 0.05f) + 0.1f; } } private static void CleanupActive() { float now = Time.time; Active.RemoveAll((ActivePlay a) => now > a.End || (Object)(object)a.Clip == (Object)null || ((Object)(object)a.Source == (Object)null && now - a.Start > 0.5f) || ((Object)(object)a.Source != (Object)null && !a.Source.isPlaying && now - a.Start > 0.2f)); } public static void ClearActive() { Active.Clear(); } public static AudioClip PickAnyClip() { List<AudioClip> list = (from c in Clips.Values.SelectMany((List<AudioClip> l) => l) where (Object)(object)c != (Object)null select c).ToList(); if (list.Count != 0) { return list[Random.Range(0, list.Count)]; } return null; } public static List<AudioClip> ClipsForMonster(string monstre) { string m = monstre.ToLowerInvariant(); return (from c in Clips.Where((KeyValuePair<string, List<AudioClip>> kv) => kv.Key == m || kv.Key.StartsWith(m + "/")).SelectMany((KeyValuePair<string, List<AudioClip>> kv) => kv.Value) where (Object)(object)c != (Object)null select c).ToList(); } public static List<string> MonsterNames() { return KnownEnemies.OrderBy((string n) => n).ToList(); } public static string MonsterFolder(string monstre) { return Path.Combine(SonsRoot, monstre); } public static bool IsEnemyPlaying(int enemyId) { CleanupActive(); return Active.Any((ActivePlay a) => a.EnemyId == enemyId); } public static void StopEnemySounds(int enemyId) { foreach (ActivePlay item in Active.Where((ActivePlay a) => a.EnemyId == enemyId).ToList()) { if ((Object)(object)item.Source != (Object)null) { item.Source.Stop(); } Active.Remove(item); } } public static List<AudioClip> GetClips(string cle) { if (!Clips.TryGetValue(cle.ToLowerInvariant(), out var value)) { return null; } return value; } private static bool IsAttack(string soundName) { string text = soundName.ToLowerInvariant(); string[] array = Plugin.MotsAttaque.Value.Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim().ToLowerInvariant(); if (text2.Length > 0 && text.Contains(text2)) { return true; } } return false; } private static bool IsIgnored(string soundName) { string value = Plugin.MotsIgnores.Value; if (string.IsNullOrWhiteSpace(value)) { return false; } string[] array = value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim().ToLowerInvariant(); if (text.Length > 0 && soundName.Contains(text)) { return true; } } return false; } } internal static class EnemyMusic { private class Entry { public EnemyParent Parent; public string Name; public string Dossier; public int Id; public AudioMixerGroup Mixer; public Func<bool> Actif; public Func<Transform> Suivre; public AudioSource Source; } private static readonly Dictionary<int, Entry> Entries = new Dictionary<int, Entry>(); private static float _nextCheck; private static readonly FieldInfo SpewerAttachTarget = AccessTools.Field(typeof(EnemySlowMouth), "attachTarget"); public static void Track(EnemyParent parent, string name, Transform centre, AudioMixerGroup mixer) { if ((Object)(object)parent == (Object)null) { return; } int instanceID = ((Object)parent).GetInstanceID(); EnemyCeilingEye eye = ((Component)parent).GetComponentInChildren<EnemyCeilingEye>(true); if ((Object)(object)eye != (Object)null) { Add(new Entry { Parent = parent, Name = name, Id = instanceID, Mixer = mixer, Dossier = "_musique", Actif = () => (Object)(object)eye != (Object)null && (int)eye.currentState == 3, Suivre = () => (!((Object)(object)centre != (Object)null)) ? ((!((Object)(object)eye != (Object)null)) ? null : ((Component)eye).transform) : centre }); return; } EnemySlowMouth spewer = ((Component)parent).GetComponentInChildren<EnemySlowMouth>(true); if (!((Object)(object)spewer != (Object)null)) { return; } Add(new Entry { Parent = parent, Name = name, Id = instanceID, Mixer = mixer, Dossier = "_possession", Actif = () => (Object)(object)spewer != (Object)null && ((int)spewer.currentState == 9 || (int)spewer.currentState == 10), Suivre = delegate { object? obj = SpewerAttachTarget?.GetValue(spewer); PlayerAvatar val = (PlayerAvatar)((obj is PlayerAvatar) ? obj : null); if ((Object)(object)val != (Object)null) { return ((Component)val).transform; } return (!((Object)(object)centre != (Object)null)) ? ((!((Object)(object)spewer != (Object)null)) ? null : ((Component)spewer).transform) : centre; } }); } private static void Add(Entry e) { try { Directory.CreateDirectory(Path.Combine(CustomSounds.MonsterFolder(e.Name), e.Dossier)); } catch { } Entries[e.Id] = e; } public static bool IsPlaying(int enemyId) { if (Entries.TryGetValue(enemyId, out var value)) { return (Object)(object)value.Source != (Object)null; } return false; } public static void Update() { if (Time.time < _nextCheck) { return; } _nextCheck = Time.time + 0.1f; foreach (Entry item in Entries.Values.ToList()) { if ((Object)(object)item.Parent == (Object)null) { Stop(item); Entries.Remove(item.Id); continue; } MonsterSettings monsterSettings = MonsterSettings.Get(item.Name); bool flag; try { flag = Plugin.SonsActifs.Value && monsterSettings.Actif.Value && item.Actif(); } catch { flag = false; } Transform val = (flag ? item.Suivre() : null); if (flag && (Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy) { if ((Object)(object)item.Source == (Object)null || (Object)(object)item.Source.clip == (Object)null || !item.Source.isPlaying) { Next(item, monsterSettings, val); } else { SoundController.AttachPerso(item.Source, item.Source.clip, monsterSettings, val, null); } } else if ((Object)(object)item.Source != (Object)null) { Stop(item); } } } private static void Next(Entry e, MonsterSettings reglages, Transform suivre) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) AudioClip precedent = (((Object)(object)e.Source != (Object)null) ? e.Source.clip : null); bool flag = (Object)(object)e.Source == (Object)null; Stop(e, log: false); List<AudioClip> clips = CustomSounds.GetClips(e.Name + "/" + e.Dossier); if (clips == null || clips.Count == 0) { return; } List<AudioClip> list = clips.Where((AudioClip c) => (Object)(object)c != (Object)null && (Object)(object)c != (Object)(object)precedent).ToList(); if (list.Count == 0) { list = clips.Where((AudioClip c) => (Object)(object)c != (Object)null).ToList(); } if (list.Count != 0) { if (flag) { CustomSounds.StopEnemySounds(e.Id); } AudioClip val = list[Random.Range(0, list.Count)]; GameObject val2 = new GameObject("GoofySonEtat"); val2.transform.position = suivre.position; AudioSource val3 = val2.AddComponent<AudioSource>(); val3.clip = val; val3.loop = false; val3.spatialBlend = 1f; val3.dopplerLevel = 0f; val3.playOnAwake = false; if ((Object)(object)e.Mixer != (Object)null) { val3.outputAudioMixerGroup = e.Mixer; } val3.Play(); e.Source = val3; SoundController.AttachPerso(val3, val, reglages, suivre, null); if (Plugin.DebugSons.Value) { Plugin.Log.LogInfo((object)("[" + e.Dossier + "] " + e.Name + " : \"" + ((Object)val).name + "\"")); } } } private static void Stop(Entry e, bool log = true) { if (!((Object)(object)e.Source == (Object)null)) { if (log && Plugin.DebugSons.Value) { Plugin.Log.LogInfo((object)("[" + e.Dossier + "] " + e.Name + " : arrêt")); } Object.Destroy((Object)(object)((Component)e.Source).gameObject); e.Source = null; } } public static void StopAll() { foreach (Entry value in Entries.Values) { Stop(value, log: false); } } } internal static class ModMenu { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static BuilderDelegate <>9__2_0; public static BuilderDelegate <>9__2_1; public static ScrollViewBuilderDelegate <>9__3_0; public static Action<bool> <>9__3_12; public static ScrollViewBuilderDelegate <>9__3_1; public static Action<int> <>9__3_13; public static ScrollViewBuilderDelegate <>9__3_2; public static Action<int> <>9__3_14; public static ScrollViewBuilderDelegate <>9__3_3; public static ScrollViewBuilderDelegate <>9__3_4; public static ScrollViewBuilderDelegate <>9__3_5; public static Action <>9__3_15; public static ScrollViewBuilderDelegate <>9__3_6; public static ScrollViewBuilderDelegate <>9__3_7; public static ScrollViewBuilderDelegate <>9__3_8; public static ScrollViewBuilderDelegate <>9__3_9; public static Action<bool> <>9__3_16; public static ScrollViewBuilderDelegate <>9__3_10; public static ScrollViewBuilderDelegate <>9__4_0; internal void <Init>b__2_0(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("GoofySounds", (Action)OpenPage, parent, new Vector2(550f, 22f)); } internal void <Init>b__2_1(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("GoofySounds", (Action)OpenPage, parent, new Vector2(126f, 86f)); } internal RectTransform <OpenPage>b__3_0(Transform sv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOLabel("<b>Sons perso des monstres</b>", sv, Vector2.zero)).rectTransform; } internal RectTransform <OpenPage>b__3_1(Transform sv) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOToggle("Sons perso", (Action<bool>)delegate(bool b) { Plugin.SonsActifs.Value = b; }, sv, Vector2.zero, "ON", "OFF", Plugin.SonsActifs.Value)).rectTransform; } internal void <OpenPage>b__3_12(bool b) { Plugin.SonsActifs.Value = b; } internal RectTransform <OpenPage>b__3_2(Transform sv) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOSlider("Volume", "Volume de tes sons", (Action<int>)delegate(int v) { Plugin.VolumePourcent.Value = v; }, sv, Vector2.zero, 0, 200, Plugin.VolumePourcent.Value, "", "%", (BarBehavior)0)).rectTransform; } internal void <OpenPage>b__3_13(int v) { Plugin.VolumePourcent.Value = v; } internal RectTransform <OpenPage>b__3_3(Transform sv) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOSlider("Portée", "Distance d'écoute de tes sons", (Action<int>)delegate(int v) { Plugin.PorteeSons.Value = v; }, sv, Vector2.zero, 5, 100, Plugin.PorteeSons.Value, "", " m", (BarBehavior)0)).rectTransform; } internal void <OpenPage>b__3_14(int v) { Plugin.PorteeSons.Value = v; } internal RectTransform <OpenPage>b__3_4(Transform sv) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOButton("Réglages par monstre >", (Action)OpenMonsterListPage, sv, Vector2.zero)).rectTransform; } internal RectTransform <OpenPage>b__3_5(Transform sv) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOButton("Recharger les sons", (Action)Reload, sv, Vector2.zero)).rectTransform; } internal RectTransform <OpenPage>b__3_6(Transform sv) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOButton("Ouvrir le dossier des sons", (Action)delegate { OpenFolder(CustomSounds.SonsRoot); }, sv, Vector2.zero)).rectTransform; } internal void <OpenPage>b__3_15() { OpenFolder(CustomSounds.SonsRoot); } internal RectTransform <OpenPage>b__3_7(Transform sv) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOButton("Tester un son au hasard", (Action)PlayRandomPreview, sv, Vector2.zero)).rectTransform; } internal RectTransform <OpenPage>b__3_8(Transform sv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _statusLabel = MenuAPI.CreateREPOLabel(CustomSounds.Status, sv, Vector2.zero); return ((REPOElement)_statusLabel).rectTransform; } internal RectTransform <OpenPage>b__3_9(Transform sv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOLabel("<b>Divers</b>", sv, Vector2.zero)).rectTransform; } internal RectTransform <OpenPage>b__3_10(Transform sv) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOToggle("Texte à l'écran", (Action<bool>)delegate(bool b) { Plugin.AfficherTexte.Value = b; }, sv, Vector2.zero, "ON", "OFF", Plugin.AfficherTexte.Value)).rectTransform; } internal void <OpenPage>b__3_16(bool b) { Plugin.AfficherTexte.Value = b; } internal RectTransform <OpenMonsterListPage>b__4_0(Transform sv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((REPOElement)MenuAPI.CreateREPOLabel("Lance une partie pour détecter les monstres", sv, Vector2.zero)).rectTransform; } } private static REPOLabel _statusLabel; private static AudioSource _previewSource; public static void Init() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown object obj = <>c.<>9__2_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("GoofySounds", (Action)OpenPage, parent, new Vector2(550f, 22f)); }; <>c.<>9__2_0 = val; obj = (object)val; } MenuAPI.AddElementToMainMenu((BuilderDelegate)obj); object obj2 = <>c.<>9__2_1; if (obj2 == null) { BuilderDelegate val2 = delegate(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("GoofySounds", (Action)OpenPage, parent, new Vector2(126f, 86f)); }; <>c.<>9__2_1 = val2; obj2 = (object)val2; } MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj2); } private static void OpenPage() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_006c: 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_0077: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown REPOPopupPage page = MenuAPI.CreateREPOPopupPage("GoofySounds", (PresetSide)0, false, true, 1.5f); REPOPopupPage obj = page; object obj2 = <>c.<>9__3_0; if (obj2 == null) { ScrollViewBuilderDelegate val = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOLabel("<b>Sons perso des monstres</b>", sv, Vector2.zero)).rectTransform; <>c.<>9__3_0 = val; obj2 = (object)val; } obj.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f); REPOPopupPage obj3 = page; object obj4 = <>c.<>9__3_1; if (obj4 == null) { ScrollViewBuilderDelegate val2 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOToggle("Sons perso", (Action<bool>)delegate(bool b) { Plugin.SonsActifs.Value = b; }, sv, Vector2.zero, "ON", "OFF", Plugin.SonsActifs.Value)).rectTransform; <>c.<>9__3_1 = val2; obj4 = (object)val2; } obj3.AddElementToScrollView((ScrollViewBuilderDelegate)obj4, 0f, 0f); REPOPopupPage obj5 = page; object obj6 = <>c.<>9__3_2; if (obj6 == null) { ScrollViewBuilderDelegate val3 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOSlider("Volume", "Volume de tes sons", (Action<int>)delegate(int v) { Plugin.VolumePourcent.Value = v; }, sv, Vector2.zero, 0, 200, Plugin.VolumePourcent.Value, "", "%", (BarBehavior)0)).rectTransform; <>c.<>9__3_2 = val3; obj6 = (object)val3; } obj5.AddElementToScrollView((ScrollViewBuilderDelegate)obj6, 0f, 0f); REPOPopupPage obj7 = page; object obj8 = <>c.<>9__3_3; if (obj8 == null) { ScrollViewBuilderDelegate val4 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOSlider("Portée", "Distance d'écoute de tes sons", (Action<int>)delegate(int v) { Plugin.PorteeSons.Value = v; }, sv, Vector2.zero, 5, 100, Plugin.PorteeSons.Value, "", " m", (BarBehavior)0)).rectTransform; <>c.<>9__3_3 = val4; obj8 = (object)val4; } obj7.AddElementToScrollView((ScrollViewBuilderDelegate)obj8, 0f, 0f); REPOPopupPage obj9 = page; object obj10 = <>c.<>9__3_4; if (obj10 == null) { ScrollViewBuilderDelegate val5 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton("Réglages par monstre >", (Action)OpenMonsterListPage, sv, Vector2.zero)).rectTransform; <>c.<>9__3_4 = val5; obj10 = (object)val5; } obj9.AddElementToScrollView((ScrollViewBuilderDelegate)obj10, 10f, 0f); REPOPopupPage obj11 = page; object obj12 = <>c.<>9__3_5; if (obj12 == null) { ScrollViewBuilderDelegate val6 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton("Recharger les sons", (Action)Reload, sv, Vector2.zero)).rectTransform; <>c.<>9__3_5 = val6; obj12 = (object)val6; } obj11.AddElementToScrollView((ScrollViewBuilderDelegate)obj12, 10f, 0f); REPOPopupPage obj13 = page; object obj14 = <>c.<>9__3_6; if (obj14 == null) { ScrollViewBuilderDelegate val7 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton("Ouvrir le dossier des sons", (Action)delegate { OpenFolder(CustomSounds.SonsRoot); }, sv, Vector2.zero)).rectTransform; <>c.<>9__3_6 = val7; obj14 = (object)val7; } obj13.AddElementToScrollView((ScrollViewBuilderDelegate)obj14, 0f, 0f); REPOPopupPage obj15 = page; object obj16 = <>c.<>9__3_7; if (obj16 == null) { ScrollViewBuilderDelegate val8 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton("Tester un son au hasard", (Action)PlayRandomPreview, sv, Vector2.zero)).rectTransform; <>c.<>9__3_7 = val8; obj16 = (object)val8; } obj15.AddElementToScrollView((ScrollViewBuilderDelegate)obj16, 0f, 0f); REPOPopupPage obj17 = page; object obj18 = <>c.<>9__3_8; if (obj18 == null) { ScrollViewBuilderDelegate val9 = delegate(Transform sv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _statusLabel = MenuAPI.CreateREPOLabel(CustomSounds.Status, sv, Vector2.zero); return ((REPOElement)_statusLabel).rectTransform; }; <>c.<>9__3_8 = val9; obj18 = (object)val9; } obj17.AddElementToScrollView((ScrollViewBuilderDelegate)obj18, 10f, 0f); REPOPopupPage obj19 = page; object obj20 = <>c.<>9__3_9; if (obj20 == null) { ScrollViewBuilderDelegate val10 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOLabel("<b>Divers</b>", sv, Vector2.zero)).rectTransform; <>c.<>9__3_9 = val10; obj20 = (object)val10; } obj19.AddElementToScrollView((ScrollViewBuilderDelegate)obj20, 20f, 0f); REPOPopupPage obj21 = page; object obj22 = <>c.<>9__3_10; if (obj22 == null) { ScrollViewBuilderDelegate val11 = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOToggle("Texte à l'écran", (Action<bool>)delegate(bool b) { Plugin.AfficherTexte.Value = b; }, sv, Vector2.zero, "ON", "OFF", Plugin.AfficherTexte.Value)).rectTransform; <>c.<>9__3_10 = val11; obj22 = (object)val11; } obj21.AddElementToScrollView((ScrollViewBuilderDelegate)obj22, 0f, 0f); page.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Retour", (Action)delegate { page.ClosePage(true); }, parent, new Vector2(77f, 34f)); }); page.OpenPage(false); } private static void OpenMonsterListPage() { //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_0050: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown REPOPopupPage page = MenuAPI.CreateREPOPopupPage("Monstres", (PresetSide)1, false, false, 1.5f); List<string> list = CustomSounds.MonsterNames(); if (list.Count == 0) { REPOPopupPage obj = page; object obj2 = <>c.<>9__4_0; if (obj2 == null) { ScrollViewBuilderDelegate val = (Transform sv) => ((REPOElement)MenuAPI.CreateREPOLabel("Lance une partie pour détecter les monstres", sv, Vector2.zero)).rectTransform; <>c.<>9__4_0 = val; obj2 = (object)val; } obj.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f); } foreach (string item in list) { string monstre = item; page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton(MonsterButtonText(monstre), (Action)delegate { OpenMonsterPage(monstre); }, sv, Vector2.zero)).rectTransform), 0f, 0f); } page.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Retour", (Action)delegate { page.ClosePage(true); }, parent, new Vector2(390f, 34f)); }); page.OpenPage(true); } private static string MonsterButtonText(string monstre) { MonsterSettings monsterSettings = MonsterSettings.Get(monstre); int count = CustomSounds.ClipsForMonster(monstre).Count; string text = ((!monsterSettings.Actif.Value) ? " <color=#ff5555>OFF</color>" : ((count > 0) ? $" <color=#55ff55>({count})</color>" : "")); return monstre + text; } private static void OpenMonsterPage(string monstre) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown MonsterSettings reglages = MonsterSettings.Get(monstre); REPOLabel infoLabel = null; REPOPopupPage page = MenuAPI.CreateREPOPopupPage(monstre, (PresetSide)1, false, false, 1.5f); page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOToggle("Sons perso", (Action<bool>)delegate(bool b) { reglages.Actif.Value = b; }, sv, Vector2.zero, "ON", "OFF", reglages.Actif.Value)).rectTransform), 0f, 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOSlider("Chance", "Chance pour ce monstre", (Action<int>)delegate(int v) { reglages.Chance.Value = v; }, sv, Vector2.zero, 0, 100, reglages.Chance.Value, "", "%", (BarBehavior)0)).rectTransform), 0f, 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOSlider("Volume", "Volume pour ce monstre", (Action<int>)delegate(int v) { reglages.Volume.Value = v; }, sv, Vector2.zero, 0, 200, reglages.Volume.Value, "", "%", (BarBehavior)0)).rectTransform), 0f, 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOSlider("Portée", "0 = portée générale", (Action<int>)delegate(int v) { reglages.Portee.Value = v; }, sv, Vector2.zero, 0, 150, reglages.Portee.Value, "", " m", (BarBehavior)0)).rectTransform), 0f, 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton("Ouvrir son dossier", (Action)delegate { OpenFolder(CustomSounds.MonsterFolder(monstre)); }, sv, Vector2.zero)).rectTransform), 10f, 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOButton("Tester un de ses sons", (Action)delegate { List<AudioClip> list = CustomSounds.ClipsForMonster(monstre); if (list.Count == 0) { SetLabel(infoLabel, "Aucun son perso pour ce monstre"); } else { AudioClip val = list[Random.Range(0, list.Count)]; PlayPreview(val, reglages); SetLabel(infoLabel, "Lecture : " + ((Object)val).name); } }, sv, Vector2.zero)).rectTransform), 0f, 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform sv) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) int count = CustomSounds.ClipsForMonster(monstre).Count; infoLabel = MenuAPI.CreateREPOLabel((count > 0) ? $"{count} son(s) perso" : "Pas de son perso (utilise _TousLesMonstres)", sv, Vector2.zero); return ((REPOElement)infoLabel).rectTransform; }, 10f, 0f); page.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Retour", (Action)delegate { page.ClosePage(true); }, parent, new Vector2(390f, 34f)); }); page.OpenPage(true); } private static void SetLabel(REPOLabel label, string text) { if ((Object)(object)label != (Object)null && (Object)(object)label.labelTMP != (Object)null) { ((TMP_Text)label.labelTMP).text = text; } } private static void Reload() { if (!CustomSounds.IsLoading) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ReloadAndRefresh()); } } private static IEnumerator ReloadAndRefresh() { SetStatus("Chargement..."); yield return CustomSounds.ReloadAll(); SetStatus(CustomSounds.Status); } private static void SetStatus(string text) { if ((Object)(object)_statusLabel != (Object)null && (Object)(object)_statusLabel.labelTMP != (Object)null) { ((TMP_Text)_statusLabel.labelTMP).text = text; } } private static void OpenFolder(string path) { try { Directory.CreateDirectory(path); Application.OpenURL(new Uri(path).AbsoluteUri); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Impossible d'ouvrir le dossier : " + ex.Message)); } } private static void PlayRandomPreview() { AudioClip val = CustomSounds.PickAnyClip(); if ((Object)(object)val == (Object)null) { SetStatus("Aucun son chargé : ajoute des fichiers puis recharge !"); return; } PlayPreview(val, null); SetStatus("Lecture : " + ((Object)val).name); } private static void PlayPreview(AudioClip clip, MonsterSettings reglages) { if ((Object)(object)_previewSource == (Object)null) { _previewSource = ((Component)Plugin.Instance).gameObject.AddComponent<AudioSource>(); _previewSource.spatialBlend = 0f; _previewSource.ignoreListenerPause = true; } _previewSource.Stop(); _previewSource.volume = 1f; _previewSource.clip = clip; _previewSource.Play(); SoundController.AttachPerso(_previewSource, clip, reglages, null, null); } } internal static class MonsterActions { internal class Rule { public List<AudioClip> Clips = new List<AudioClip>(); public bool Classiques; public bool Prioritaire; public bool Remplace; public string Texte; } public const string Fichier = "_actions.txt"; private static readonly Dictionary<string, Dictionary<string, Rule>> Rules = new Dictionary<string, Dictionary<string, Rule>>(); private static readonly Dictionary<string, HashSet<string>> Reserved = new Dictionary<string, HashSet<string>>(); public static void Load(string sonsRoot, Func<string, List<AudioClip>> clipsDuDossier) { Rules.Clear(); Reserved.Clear(); string[] directories = Directory.GetDirectories(sonsRoot); foreach (string text in directories) { string path = Path.Combine(text, "_actions.txt"); if (!File.Exists(path)) { continue; } string text2 = Path.GetFileName(text).ToLowerInvariant(); List<AudioClip> source = clipsDuDossier(text2) ?? new List<AudioClip>(); Dictionary<string, Rule> dictionary = new Dictionary<string, Rule>(); HashSet<string> hashSet = new HashSet<string>(); string[] array = File.ReadAllLines(path); for (int j = 0; j < array.Length; j++) { string text3 = array[j].Trim(); if (text3.Length == 0 || text3.StartsWith("#")) { continue; } int num = text3.IndexOf('='); if (num < 0) { continue; } string text4 = text3.Substring(0, num).Trim(); string text5 = text3.Substring(num + 1).Trim(); Rule rule = new Rule { Texte = text3 }; while (text4.Length > 0 && (text4[0] == '!' || text4[0] == '~')) { if (text4[0] == '!') { rule.Prioritaire = true; } else { rule.Remplace = true; } text4 = text4.Substring(1).Trim(); } string[] array2 = text5.Split(','); foreach (string obj in array2) { string text6 = obj.Trim(); if (text6.Length == 0) { continue; } if (text6 == "*") { rule.Classiques = true; continue; } string sansExt = Path.GetFileNameWithoutExtension(text6).ToLowerInvariant(); AudioClip val = ((IEnumerable<AudioClip>)source).FirstOrDefault((Func<AudioClip, bool>)((AudioClip c) => (Object)(object)c != (Object)null && ((Object)c).name.ToLowerInvariant() == sansExt)); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("[actions] " + Path.GetFileName(text) + " : fichier \"" + text6 + "\" introuvable dans le dossier")); } else { rule.Clips.Add(val); hashSet.Add(sansExt); } } if (rule.Clips.Count == 0 && !rule.Classiques && !rule.Remplace) { continue; } array2 = text4.Split(','); for (int k = 0; k < array2.Length; k++) { string text7 = array2[k].Trim().ToLowerInvariant(); if (text7.Length > 0) { dictionary[text7] = rule; } } } if (dictionary.Count > 0) { Rules[text2] = dictionary; Reserved[text2] = hashSet; Plugin.Log.LogInfo((object)$"[actions] {Path.GetFileName(text)} : {dictionary.Count} son(s) du jeu avec une action"); } } } public static Rule Get(string monstre, string sonDuJeu) { if (!Rules.TryGetValue(monstre.ToLowerInvariant(), out var value) || !value.TryGetValue(sonDuJeu.ToLowerInvariant(), out var value2)) { return null; } return value2; } public static bool IsReserved(string monstre, AudioClip clip) { if ((Object)(object)clip != (Object)null && Reserved.TryGetValue(monstre.ToLowerInvariant(), out var value)) { return value.Contains(((Object)clip).name.ToLowerInvariant()); } return false; } } internal class MonsterSettings { public ConfigEntry<bool> Actif; public ConfigEntry<int> Chance; public ConfigEntry<int> Volume; public ConfigEntry<bool> InclurePas; public ConfigEntry<int> Portee; private static readonly Dictionary<string, MonsterSettings> All = new Dictionary<string, MonsterSettings>(); public static MonsterSettings Get(string monstre) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown string key = monstre.ToLowerInvariant(); if (All.TryGetValue(key, out var value)) { return value; } ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config; string text = "Monstre - " + monstre; value = new MonsterSettings { Actif = config.Bind<bool>(text, "Actif", true, "Sons perso activés pour ce monstre."), Chance = config.Bind<int>(text, "Chance", 100, new ConfigDescription("Chance (en %) pour ce monstre. Combinée avec la chance générale.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())), Volume = config.Bind<int>(text, "Volume", 100, new ConfigDescription("Volume (en %) pour ce monstre. Combiné avec le volume général.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())), Portee = config.Bind<int>(text, "Portee", 0, new ConfigDescription("Portée (en mètres) des sons de ce monstre. 0 = portée générale du menu.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 150), Array.Empty<object>())), InclurePas = config.Bind<bool>(text, "InclurePas", false, "Remplace aussi ses bruits de pas, de déplacement, etc. (les mots ignorés).") }; All[key] = value; return value; } } [HarmonyPatch(typeof(EnemyParent), "Awake")] internal static class EnemyParentAwakePatch { private static void Postfix(EnemyParent __instance) { try { CustomSounds.RegisterEnemy(__instance); } catch (Exception ex) { Plugin.Log.LogWarning((object)("RegisterEnemy : " + ex)); } } } [HarmonyPatch(typeof(EnemyDirector), "Start")] internal static class EnemyDirectorStartPatch { private static void Postfix(EnemyDirector __instance) { CustomSounds.ScanEnemyPrefabs(__instance); } } [HarmonyPatch] internal static class SoundPlayPatch { internal class State { public AudioClip[] Original; public CustomSounds.Decision D; } private static Sound _enCours; private static IEnumerable<MethodBase> TargetMethods() { return from m in AccessTools.GetDeclaredMethods(typeof(Sound)) where m.Name == "Play" select m; } private static void Prefix(Sound __instance, out State __state) { __state = null; if (__instance == _enCours) { return; } try { CustomSounds.Decision decision = CustomSounds.Decide(__instance); if (decision != null) { __state = new State { D = decision }; _enCours = __instance; if ((Object)(object)decision.Clip != (Object)null) { __state.Original = __instance.Sounds; __instance.Sounds = (AudioClip[])(object)new AudioClip[1] { decision.Clip }; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Sound.Play prefix : " + ex.Message)); } } private static void Postfix(Sound __instance, State __state, AudioSource __result) { if (__state == null) { return; } Restore(__instance, __state); CustomSounds.Decision d = __state.D; try { if (d.Play != null) { CustomSounds.ConfirmPlay(d.Play, __result); SoundController.AttachPerso(__result, d.Clip, d.Reglages, d.Follow, d.Root); } else if (d.BaseReduite) { AudioClip clip = ((__state.Original == null && __instance.Sounds != null) ? (from c in __instance.Sounds where (Object)(object)c != (Object)null orderby c.length descending select c).FirstOrDefault() : null); SoundController.AttachBase(__result, clip, d.Reglages); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Sound.Play postfix : " + ex.Message)); } } private static Exception Finalizer(Sound __instance, State __state, Exception __exception) { if (__state != null) { Restore(__instance, __state); } return __exception; } private static void Restore(Sound sound, State state) { if (state.Original != null) { sound.Sounds = state.Original; state.Original = null; } _enCours = null; } } [BepInPlugin("natan.goofysounds", "GoofySounds", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "natan.goofysounds"; public const string PluginName = "GoofySounds"; public const string PluginVersion = "1.0.0"; internal static Plugin Instance; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry<bool> SonsActifs; internal static ConfigEntry<int> VolumePourcent; internal static ConfigEntry<string> MotsIgnores; internal static ConfigEntry<bool> AfficherTexte; internal static ConfigEntry<bool> DebugSons; internal static ConfigEntry<int> PorteeSons; internal static readonly bool ModeVue = true; internal static ConfigEntry<string> MotsAttaque; private void Awake() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; MigrerAncienMod(); SonsActifs = ((BaseUnityPlugin)this).Config.Bind<bool>("Sons perso", "Actif", true, "Active tes sons perso : un monstre joue un de tes sons quand il repère un joueur ou attaque."); MotsAttaque = ((BaseUnityPlugin)this).Config.Bind<string>("Sons perso", "MotsAttaque", "attack,bite,shoot,swing,chomp,slash,stab,punch,smash,cleaver,pickaxe,tongue", "Mode \"quand il nous voit\" : un son du jeu dont le nom contient un de ces mots est considéré comme une attaque, et fait jouer un de tes sons au monstre."); VolumePourcent = ((BaseUnityPlugin)this).Config.Bind<int>("Sons perso", "Volume", 100, new ConfigDescription("Volume de tes sons (en %).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())); MotsIgnores = ((BaseUnityPlugin)this).Config.Bind<string>("Sons perso", "MotsIgnores", "footstep,step,move,walk,land,breathe,skitter,impact", "Les sons dont le nom contient un de ces mots ne sont PAS remplacés par le dossier principal du monstre (pour éviter que chaque bruit de pas joue ton MP3). Tu peux quand même les remplacer avec un sous-dossier au nom exact du son."); PorteeSons = ((BaseUnityPlugin)this).Config.Bind<int>("Sons perso", "Portee", 30, new ConfigDescription("Distance (en mètres) jusqu'à laquelle on entend tes sons. À fond jusqu'à 3 m, puis baisse jusqu'à cette distance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 100), Array.Empty<object>())); DebugSons = ((BaseUnityPlugin)this).Config.Bind<bool>("Divers", "DebugSons", false, "Écrit dans le log chaque son de monstre détecté et pourquoi un son perso est joué ou non (pour le dépannage)."); AfficherTexte = ((BaseUnityPlugin)this).Config.Bind<bool>("Divers", "AfficherTexte", false, "Affiche l'état du mod en haut à gauche de l'écran."); CustomSounds.Init(); _harmony = new Harmony("natan.goofysounds"); _harmony.PatchAll(); ModMenu.Init(); ((MonoBehaviour)this).StartCoroutine(CustomSounds.ReloadAll()); Log.LogInfo((object)"GoofySounds v1.0.0 est chargé !"); } private void MigrerAncienMod() { try { string text = Path.Combine(Paths.ConfigPath, "repopolo.repopolomod.cfg"); if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath) && File.Exists(text)) { File.Copy(text, ((BaseUnityPlugin)this).Config.ConfigFilePath); ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Réglages de RepopoloMod récupérés."); } string text2 = Path.Combine(Paths.ConfigPath, "RepopoloMod"); string text3 = Path.Combine(Paths.ConfigPath, "GoofySounds"); if (!Directory.Exists(text3) && Directory.Exists(text2)) { Directory.Move(text2, text3); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Dossier des sons de RepopoloMod déplacé vers GoofySounds."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Migration RepopoloMod : " + ex.Message)); } } private void Update() { SightSounds.Update(); EnemyMusic.Update(); } private void OnGUI() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (AfficherTexte.Value) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 16, fontStyle = (FontStyle)1 }; val.normal.textColor = Color.green; GUI.Label(new Rect(10f, 10f, 900f, 30f), string.Format("GoofySounds | Sons perso : {0} ({1} sons)", SonsActifs.Value ? "ON" : "OFF", CustomSounds.ClipCount), val); } } } internal static class SightSounds { private class Watched { public EnemyParent Parent; public Enemy Enemy; public string Name; public int Id; public Transform Centre; public AudioMixerGroup Mixer; public EnemyState LastState; public float LastVision = -100f; } private delegate AudioClip Picker(out CustomSounds.ActivePlay play); private static readonly Dictionary<int, Watched> Enemies = new Dictionary<int, Watched>(); private static float _nextCheck; private static readonly FieldInfo CurrentStateField = AccessTools.Field(typeof(Enemy), "CurrentState"); public static void Track(EnemyParent parent, string name, Transform centre, AudioMixerGroup mixer) { if (!((Object)(object)parent == (Object)null)) { int instanceID = ((Object)parent).GetInstanceID(); Enemies[instanceID] = new Watched { Parent = parent, Enemy = ((Component)parent).GetComponentInChildren<Enemy>(true), Name = name, Id = instanceID, Centre = (((Object)(object)centre != (Object)null) ? centre : ((Component)parent).transform), Mixer = mixer }; } } public static void OnEnemySawPlayer(Component visionComponent) { if ((Object)(object)visionComponent == (Object)null) { return; } EnemyParent componentInParent = visionComponent.GetComponentInParent<EnemyParent>(); if (!((Object)(object)componentInParent == (Object)null) && Enemies.TryGetValue(((Object)componentInParent).GetInstanceID(), out var value)) { bool num = Time.time - value.LastVision > 3f; value.LastVision = Time.time; if (num) { TryPlay(value); } } } public static void OnEnemyAttack(int enemyId) { if (Enemies.TryGetValue(enemyId, out var value)) { TryPlay(value); } } public static bool OnEnemyAction(int enemyId, MonsterActions.Rule regle) { if (Enemies.TryGetValue(enemyId, out var w)) { return TryPlay(w, delegate(out CustomSounds.ActivePlay p) { return CustomSounds.PickActionClip(regle, w.Name, w.Id, out p); }); } return false; } private static void Debug(Watched w, string raison) { if (Plugin.DebugSons.Value) { Plugin.Log.LogInfo((object)("[son perso] " + w.Name + " : rien joué (" + raison + ")")); } } public static void Update() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Invalid comparison between Unknown and I4 //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _nextCheck) { return; } _nextCheck = Time.time + 0.1f; if (CurrentStateField == null) { return; } foreach (Watched item in Enemies.Values.ToList()) { if ((Object)(object)item.Parent == (Object)null) { Enemies.Remove(item.Id); } else if (!((Object)(object)item.Enemy == (Object)null)) { EnemyState val; try { val = (EnemyState)CurrentStateField.GetValue(item.Enemy); } catch { continue; } bool num = (int)val == 3 || (int)val == 4; bool flag = (int)item.LastState == 3 || (int)item.LastState == 4; if (num && !flag) { TryPlay(item); } item.LastState = val; } } } private static bool TryPlay(Watched w, Picker picker = null) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown if (!Plugin.SonsActifs.Value || CustomSounds.ClipCount == 0) { return false; } if ((Object)(object)w.Centre == (Object)null || !((Component)w.Centre).gameObject.activeInHierarchy) { Debug(w, "monstre pas actif"); return false; } MonsterSettings monsterSettings = MonsterSettings.Get(w.Name); if (!monsterSettings.Actif.Value) { Debug(w, "monstre désactivé dans le menu"); return false; } if (EnemyMusic.IsPlaying(w.Id)) { Debug(w, "sa musique est en cours"); return false; } if (Random.Range(0f, 100f) >= CustomSounds.EffectiveChance(monsterSettings)) { Debug(w, "chance ratée"); return false; } CustomSounds.ActivePlay play; AudioClip val = ((picker != null) ? picker(out play) : CustomSounds.PickSightClip(w.Name, w.Id, out play)); if ((Object)(object)val == (Object)null) { Debug(w, "aucun fichier libre (ou son déjà en cours)"); return false; } if (Plugin.DebugSons.Value) { Plugin.Log.LogInfo((object)("[son perso] " + w.Name + " joue \"" + ((Object)val).name + "\"")); } GameObject val2 = new GameObject("GoofySightSound"); val2.transform.position = w.Centre.position; AudioSource val3 = val2.AddComponent<AudioSource>(); val3.clip = val; val3.spatialBlend = 1f; val3.dopplerLevel = 0f; val3.playOnAwake = false; if ((Object)(object)w.Mixer != (Object)null) { val3.outputAudioMixerGroup = w.Mixer; } val3.Play(); Object.Destroy((Object)val2, val.length + 1f); CustomSounds.ConfirmPlay(play, val3); SoundController.AttachPerso(val3, val, monsterSettings, w.Centre, null); return true; } } [HarmonyPatch(typeof(EnemyVision), "VisionTrigger")] internal static class EnemyVisionTriggerPatch { private static void Postfix(EnemyVision __instance) { try { SightSounds.OnEnemySawPlayer((Component)(object)__instance); } catch (Exception ex) { Plugin.Log.LogWarning((object)("VisionTrigger : " + ex.Message)); } } } internal class SoundController : MonoBehaviour { private enum Mode { Perso, Base } private Mode _mode; private MonsterSettings _reglages; private Transform _follow; private float _finTemps; private volatile float _gain = 1f; private AudioSource _src; private bool _reglagesModifies; private AudioRolloffMode _rolloffOrig; private float _minDistOrig; private float _maxDistOrig; public static void AttachPerso(AudioSource source, AudioClip clip, MonsterSettings reglages, Transform follow, Transform root) { SoundController soundController = Get(source, clip); if (!((Object)(object)soundController == (Object)null)) { soundController._mode = Mode.Perso; soundController._reglages = reglages; soundController.ApplyLoudSettings(); soundController._follow = null; if ((Object)(object)follow != (Object)null && (Object)(object)((Component)source).transform != (Object)(object)follow && !((Component)source).transform.IsChildOf(((Object)(object)root != (Object)null) ? root : follow)) { soundController._follow = follow; } soundController.Refresh(); } } public static void AttachBase(AudioSource source, AudioClip clip, MonsterSettings reglages) { SoundController soundController = Get(source, clip); if (!((Object)(object)soundController == (Object)null)) { soundController.RestoreSettings(); soundController._mode = Mode.Base; soundController._reglages = reglages; soundController._follow = null; soundController.Refresh(); } } private static SoundController Get(AudioSource source, AudioClip clip) { if ((Object)(object)source == (Object)null) { return null; } SoundController soundController = ((Component)source).GetComponent<SoundController>(); if ((Object)(object)soundController == (Object)null) { soundController = ((Component)source).gameObject.AddComponent<SoundController>(); } soundController._src = source; float num = (((Object)(object)clip != (Object)null) ? clip.length : (((Object)(object)source.clip != (Object)null) ? source.clip.length : 3f)); float num2 = Mathf.Max(Mathf.Abs(source.pitch), 0.05f); soundController._finTemps = Time.unscaledTime + num / num2 + 0.5f; return soundController; } private void Update() { Refresh(); } private void LateUpdate() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (_mode == Mode.Perso && !(Time.unscaledTime > _finTemps)) { if ((Object)(object)_follow != (Object)null) { ((Component)this).transform.position = _follow.position; } ApplyLoudSettings(); } } private void ApplyLoudSettings() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_src == (Object)null)) { if (!_reglagesModifies) { _rolloffOrig = _src.rolloffMode; _minDistOrig = _src.minDistance; _maxDistOrig = _src.maxDistance; _reglagesModifies = true; } int num = ((_reglages != null) ? _reglages.Portee.Value : 0); float num2 = Mathf.Max(5f, (float)((num > 0) ? num : Plugin.PorteeSons.Value)); _src.rolloffMode = (AudioRolloffMode)1; _src.minDistance = Mathf.Min(3f, num2 * 0.5f); _src.maxDistance = num2; _src.volume = 1f; } } private void RestoreSettings() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (_reglagesModifies && !((Object)(object)_src == (Object)null)) { _src.rolloffMode = _rolloffOrig; _src.minDistance = _minDistOrig; _src.maxDistance = _maxDistOrig; _reglagesModifies = false; } } private void Refresh() { if (Time.unscaledTime > _finTemps) { _gain = 1f; _follow = null; RestoreSettings(); } else if (_mode == Mode.Perso) { float num = (float)Plugin.VolumePourcent.Value / 100f; if (_reglages != null) { num *= (float)_reglages.Volume.Value / 100f; } _gain = num; } else { float num2 = ((_reglages != null) ? CustomSounds.EffectiveChance(_reglages) : 100f); _gain = Mathf.Clamp01(1f - num2 / 100f); } } private void OnAudioFilterRead(float[] data, int channels) { float gain = _gain; if (gain != 1f) { for (int i = 0; i < data.Length; i++) { float num = data[i] * gain; data[i] = ((num > 1f) ? 1f : ((num < -1f) ? (-1f) : num)); } } } } }