using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
[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("BigWalkSpitMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BigWalkSpitMod")]
[assembly: AssemblyTitle("BigWalkSpitMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BigWalkSpitMod;
[BepInPlugin("com.username.bigwalk.spitmod", "Big Spitty", "1.0.0")]
public class BigSpitty : BasePlugin
{
public override void Load()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
ClassInjector.RegisterTypeInIl2Cpp<SpitUpdater>();
ClassInjector.RegisterTypeInIl2Cpp<SpitCollisionHandler>();
GameObject val = new GameObject("SpitModUpdater");
val.AddComponent<SpitUpdater>();
Object.DontDestroyOnLoad((Object)(object)val);
((BasePlugin)this).Log.LogInfo((object)"Big Spitty Ready! Multi-sound rotation active.");
}
}
public class SpitUpdater : MonoBehaviour
{
private float lastSpitTime = -10f;
private const float SPIT_COOLDOWN = 1f;
private AudioClip[] spitClips = (AudioClip[])(object)new AudioClip[3];
public SpitUpdater(IntPtr ptr)
: base(ptr)
{
}
public void Awake()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
LoadWaveFile(Path.Combine(directoryName, "spit1.wav"), 0);
LoadWaveFile(Path.Combine(directoryName, "spit2.wav"), 1);
LoadWaveFile(Path.Combine(directoryName, "spit3.wav"), 2);
}
public void Update()
{
if (Input.GetKeyDown((KeyCode)120) && Time.time >= lastSpitTime + 1f)
{
TriggerSpit();
lastSpitTime = Time.time;
}
}
private void TriggerSpit()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Expected O, but got Unknown
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
return;
}
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
val.transform.position = ((Component)main).transform.position + ((Component)main).transform.forward * 0.6f;
val.transform.localScale = new Vector3(0.12f, 0.12f, 0.12f);
MeshRenderer component = val.GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null)
{
Material val2 = new Material(Shader.Find("Sprites/Default"));
val2.color = new Color(0.8f, 0.9f, 1f, 1f);
((Renderer)component).material = val2;
((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
}
Rigidbody val3 = val.AddComponent<Rigidbody>();
if ((Object)(object)val3 != (Object)null)
{
Vector3 val4 = ((Component)main).transform.forward + new Vector3(0f, 0.2f, 0f);
val3.velocity = ((Vector3)(ref val4)).normalized * 12f;
val3.useGravity = true;
}
val.AddComponent<SpitCollisionHandler>();
int num = Random.Range(0, 3);
AudioClip val5 = spitClips[num];
if ((Object)(object)val5 == (Object)null)
{
val5 = spitClips[0] ?? spitClips[1] ?? spitClips[2];
}
if ((Object)(object)val5 != (Object)null)
{
GameObject val6 = new GameObject("SpitAudioNode");
val6.transform.position = ((Component)main).transform.position;
AudioSource val7 = val6.AddComponent<AudioSource>();
if ((Object)(object)val7 != (Object)null)
{
val7.clip = val5;
val7.volume = 0.15f;
val7.pitch = Random.Range(0.85f, 1.15f);
val7.Play();
}
Object.Destroy((Object)(object)val6, val5.length + 0.1f);
}
Object.Destroy((Object)(object)val, 5f);
}
private void LoadWaveFile(string fullPath, int slotIndex)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
if (!File.Exists(fullPath))
{
return;
}
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + fullPath, (AudioType)20);
UnityWebRequestAsyncOperation val = audioClip.SendWebRequest();
while (!((AsyncOperation)val).isDone)
{
Thread.Sleep(1);
}
if ((int)audioClip.result == 1)
{
AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
if ((Object)(object)content != (Object)null)
{
((Object)content).hideFlags = (HideFlags)61;
spitClips[slotIndex] = content;
}
}
}
}
public class SpitCollisionHandler : MonoBehaviour
{
public SpitCollisionHandler(IntPtr ptr)
: base(ptr)
{
}
public void OnCollisionEnter(Collision collision)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
val.transform.position = ((Component)this).transform.position;
val.transform.localScale = new Vector3(0.4f, 0.002f, 0.4f);
MeshRenderer component = val.GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null)
{
Material val2 = new Material(Shader.Find("Sprites/Default"));
val2.color = new Color(0.75f, 0.85f, 0.95f, 0.7f);
((Renderer)component).material = val2;
}
Collider component2 = val.GetComponent<Collider>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
}
Object.Destroy((Object)(object)val, 5f);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}