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 KomarDive v1.0.0
KomarDive.dll
Decompiled a day agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("KomarDive")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("KomarDive")] [assembly: AssemblyTitle("KomarDive")] [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 KomarDive { [BepInPlugin("groshyr.komardive", "KomarDive", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "groshyr.komardive"; public const string ModName = "KomarDive"; public const string Version = "1.0.0"; private const string ClipFile = "komar.mp3"; private const string SquitoPrefab = "Deathsquito"; private const string AttackTrigger = "attack"; private const string DonorSound = "sfx_deathsquito_attack"; private const string SourceName = "komar_dive"; private const float PlayerReach = 5f; private static Plugin _instance; private static AudioClip _clip; private ConfigEntry<float> _volume; private ConfigEntry<bool> _restart; private void Awake() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown _instance = this; _volume = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "Volume", 1f, new ConfigDescription("Volume of the dive sound (on top of the game's effects volume).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _restart = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "Restart on every dive", false, "true = every dive starts the sound from the beginning; false = a mosquito still playing it lets it finish."); ((MonoBehaviour)this).StartCoroutine(LoadClip()); Harmony.CreateAndPatchAll(typeof(Plugin), "groshyr.komardive"); } private IEnumerator LoadClip() { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath, "komar.mp3"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)(text + " not found, mosquitoes stay quiet")); yield break; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(text).AbsoluteUri, (AudioType)13); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { ((BaseUnityPlugin)this).Logger.LogError((object)("komar.mp3 could not be loaded (" + request.error + "), mosquitoes stay quiet")); yield break; } _clip = DownloadHandlerAudioClip.GetContent(request); ((Object)_clip).name = Path.GetFileNameWithoutExtension("komar.mp3"); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Loaded {0}: {1:0.0} s, {2} channel(s), {3} Hz", "komar.mp3", _clip.length, _clip.channels, _clip.frequency)); } finally { ((IDisposable)request)?.Dispose(); } } [HarmonyPatch(typeof(ZSyncAnimation), "RPC_SetTrigger")] [HarmonyPostfix] private static void OnTrigger(ZSyncAnimation __instance, string name) { if (!(name != "attack") && !((Object)(object)_clip == (Object)null) && !((Object)(object)_instance == (Object)null) && !(Utils.GetPrefabName(((Component)__instance).gameObject) != "Deathsquito")) { _instance.Dive(((Component)__instance).gameObject); } } private void Dive(GameObject squito) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Character component = squito.GetComponent<Character>(); if (!((Object)(object)component == (Object)null) && !component.IsDead() && NearPlayer(squito.transform.position)) { Transform val = squito.transform.Find("komar_dive"); AudioSource val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<AudioSource>() : CreateSource(squito.transform)); if (!val2.isPlaying || _restart.Value) { val2.volume = _volume.Value; val2.Play(); } } } private static bool NearPlayer(Vector3 position) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) foreach (Player allPlayer in Player.GetAllPlayers()) { if ((Object)(object)allPlayer != (Object)null && !((Character)allPlayer).IsDead() && Vector3.Distance(((Component)allPlayer).transform.position, position) <= 5f) { return true; } } return false; } private static AudioSource CreateSource(Transform squito) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 GameObject val = new GameObject("komar_dive"); val.transform.SetParent(squito, false); AudioSource val2 = val.AddComponent<AudioSource>(); val2.clip = _clip; val2.playOnAwake = false; val2.loop = false; val2.spatialBlend = 1f; GameObject val3 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("sfx_deathsquito_attack") : null); AudioSource val4 = (((Object)(object)val3 != (Object)null) ? val3.GetComponentInChildren<AudioSource>(true) : null); if ((Object)(object)val4 != (Object)null) { val2.outputAudioMixerGroup = val4.outputAudioMixerGroup; val2.rolloffMode = val4.rolloffMode; val2.minDistance = val4.minDistance; val2.maxDistance = val4.maxDistance; val2.dopplerLevel = val4.dopplerLevel; val2.spread = val4.spread; if ((int)val4.rolloffMode == 2) { val2.SetCustomCurve((AudioSourceCurveType)0, val4.GetCustomCurve((AudioSourceCurveType)0)); } } else { val2.rolloffMode = (AudioRolloffMode)0; val2.minDistance = 2f; val2.maxDistance = 40f; } return val2; } } }