using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using DarkMachine.AI;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Teethiplier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Teethiplier")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("54e5eb0c-07e4-4b63-9f9e-38bbfea71f4e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 Teethiplier
{
[HarmonyPatch(typeof(DEN_Teeth), "OnEnable")]
public static class DEN_Teeth_OnEnable_Patch
{
private static void Postfix(DEN_Teeth __instance)
{
TeethVoiceManager teethVoiceManager = ((Component)__instance).gameObject.GetComponent<TeethVoiceManager>() ?? ((Component)__instance).gameObject.AddComponent<TeethVoiceManager>();
teethVoiceManager.PlayOneShot("appear");
}
}
[HarmonyPatch(typeof(DEN_Teeth), "OnDisable")]
public static class DEN_Teeth_OnDisable_Patch
{
private static void Postfix(DEN_Teeth __instance)
{
((Component)__instance).gameObject.GetComponent<TeethVoiceManager>()?.StopAll();
}
}
[HarmonyPatch(typeof(AIC_Teeth_Wander), "Enter")]
public static class AIC_Teeth_Wander_Enter_Patch
{
private static void Postfix(AIC_Teeth_Wander __instance)
{
TeethVoiceManager.Current?.StartLoop("wander");
}
}
[HarmonyPatch(typeof(AIC_Teeth_Chase), "Enter")]
public static class AIC_Teeth_Chase_Enter_Patch
{
private static void Postfix(AIC_Teeth_Chase __instance)
{
TeethVoiceManager.Current?.PlayOneShot("chasestart");
TeethVoiceManager.Current?.StartLoop("chase");
}
}
[HarmonyPatch(typeof(AIC_Teeth_Chase), "Exit")]
public static class AIC_Teeth_Chase_Exit_Patch
{
private static void Postfix(AIC_Teeth_Chase __instance)
{
TeethVoiceManager.Current?.StopLoop();
}
}
[HarmonyPatch(typeof(DEN_BasicNavigator), "OnKillPlayer")]
public static class DEN_BasicNavigator_OnKillPlayer_Patch
{
private static void Postfix(DEN_BasicNavigator __instance)
{
if (!((Object)(object)((Component)__instance).GetComponent<DEN_Teeth>() == (Object)null))
{
TeethVoiceManager.Current?.StopLoop();
TeethVoiceManager.Current?.PlayOneShot("kill");
}
}
}
[HarmonyPatch(typeof(AIC_Teeth_Burrow), "Enter")]
public static class AIC_Teeth_Burrow_Enter_Patch
{
private static void Postfix(AIC_Teeth_Burrow __instance)
{
TeethVoiceManager.Current?.StopLoop();
TeethVoiceManager.Current?.PlayOneShot("burrow");
}
}
[HarmonyPatch(typeof(AIC_Teeth_Retreat), "Enter")]
public static class AIC_Teeth_Retreat_Enter_Patch
{
private static void Postfix(AIC_Teeth_Retreat __instance)
{
TeethVoiceManager.Current?.StopLoop();
TeethVoiceManager.Current?.PlayOneShot("retreat");
}
}
[BepInPlugin("com.achelia.teethiplier", "Teethiplier", "1.0.0")]
public class TeethiplierPlugin : BaseUnityPlugin
{
public static readonly Dictionary<string, List<string>> Lines = new Dictionary<string, List<string>>
{
["appear"] = new List<string> { "appear_hello", "appear_helloeverybody" },
["wander"] = new List<string> { "wander_oneball", "wander_mimic" },
["chasestart"] = new List<string> { "chasestart_gotacrackingvoice", "chasestart_drugs" },
["chase"] = new List<string> { "chase_intheface", "chase_fuckmefuckyou" },
["burrow"] = new List<string> { "burrow_williamafton" },
["retreat"] = new List<string> { "retreat_motherfucker", "retreat_fuckyou", "retreat_mouse" },
["kill"] = new List<string> { "kill_biteof87", "kill_getrekt" }
};
public static readonly Dictionary<string, float> Volumes = new Dictionary<string, float>
{
["appear"] = 3f,
["wander"] = 3f,
["chasestart"] = 3f,
["chase"] = 3f,
["burrow"] = 3f,
["retreat"] = 3f,
["kill"] = 3f
};
public static TeethiplierPlugin Instance { get; private set; }
private void Awake()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
new Harmony("com.achelia.teethiplier").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Hello everybody, my name is Teethiplier and I am officially loaded.");
}
public AudioClip LoadClip(string key)
{
string text = "Teethiplier.clips." + key + ".wav";
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text);
if (stream == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find embedded resource: " + text));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return WavUtility.ToAudioClip(array, key);
}
}
public class TeethVoiceManager : MonoBehaviour
{
private AudioSource _source;
private Coroutine _loop;
private bool _firstAppearDone;
private bool _firstBurrowDone;
public static TeethVoiceManager Current { get; private set; }
private void Awake()
{
Current = this;
_source = ((Component)this).gameObject.AddComponent<AudioSource>();
_source.spatialBlend = 0f;
}
private void OnDestroy()
{
if ((Object)(object)Current == (Object)(object)this)
{
Current = null;
}
StopAll();
}
public void PlayOneShot(string state)
{
if (state == "appear" && !_firstAppearDone)
{
_firstAppearDone = true;
return;
}
if (state == "burrow" && !_firstBurrowDone)
{
_firstBurrowDone = true;
return;
}
AudioClip random = GetRandom(state);
if (!((Object)(object)random == (Object)null))
{
_source.volume = GetVolume(state);
_source.Stop();
_source.clip = random;
_source.Play();
}
}
public void StartLoop(string state)
{
StopLoop();
_loop = ((MonoBehaviour)this).StartCoroutine(Loop(state));
}
public void StopLoop()
{
if (_loop != null)
{
((MonoBehaviour)this).StopCoroutine(_loop);
_loop = null;
}
}
public void StopAll()
{
StopLoop();
AudioSource source = _source;
if (source != null)
{
source.Stop();
}
}
private IEnumerator Loop(string state)
{
while (true)
{
yield return (object)new WaitForSeconds(15f);
if (!_source.isPlaying)
{
AudioClip clip = GetRandom(state);
if ((Object)(object)clip != (Object)null)
{
_source.volume = GetVolume(state);
_source.clip = clip;
_source.Play();
}
}
}
}
private AudioClip GetRandom(string state)
{
if (!TeethiplierPlugin.Lines.TryGetValue(state, out var value) || value.Count == 0)
{
return null;
}
string key = value[Random.Range(0, value.Count)];
return TeethiplierPlugin.Instance.LoadClip(key);
}
private float GetVolume(string state)
{
float value;
return TeethiplierPlugin.Volumes.TryGetValue(state, out value) ? value : 3f;
}
}
public static class WavUtility
{
public static AudioClip ToAudioClip(byte[] wav, string name)
{
int num = wav[22] | (wav[23] << 8);
int num2 = wav[24] | (wav[25] << 8) | (wav[26] << 16) | (wav[27] << 24);
int num3 = wav[34] | (wav[35] << 8);
int i;
int num4;
for (i = 12; i + 8 < wav.Length; i += 8 + num4)
{
string text = Encoding.ASCII.GetString(wav, i, 4);
num4 = wav[i + 4] | (wav[i + 5] << 8) | (wav[i + 6] << 16) | (wav[i + 7] << 24);
if (text == "data")
{
i += 8;
break;
}
}
int num5 = (wav.Length - i) / (num3 / 8);
float[] array = new float[num5];
switch (num3)
{
case 16:
{
for (int k = 0; k < num5; k++)
{
short num6 = (short)(wav[i + k * 2] | (wav[i + k * 2 + 1] << 8));
array[k] = (float)num6 / 32768f;
}
break;
}
case 8:
{
for (int j = 0; j < num5; j++)
{
array[j] = (float)(wav[i + j] - 128) / 128f;
}
break;
}
}
AudioClip val = AudioClip.Create(name, num5 / num, num, num2, false);
val.SetData(array, 0);
return val;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}