using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("VeryLethal")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VeryLethal")]
[assembly: AssemblyTitle("VeryLethal")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 very_lethal
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resource1
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("very_lethal.Resource1", typeof(Resource1).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static UnmanagedMemoryStream jester => ResourceManager.GetStream("jester", resourceCulture);
internal Resource1()
{
}
}
}
namespace VeryLethal
{
[BepInPlugin("com.scriptifid.verylethal", "VeryLethal", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <Init>d__3 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private string <cacheDir>5__1;
private string <outPath>5__2;
private Stream <s>5__3;
private FileStream <fs>5__4;
private string <uri>5__5;
private UnityWebRequest <uwr>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Init>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<cacheDir>5__1 = null;
<outPath>5__2 = null;
<s>5__3 = null;
<fs>5__4 = null;
<uri>5__5 = null;
<uwr>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Invalid comparison between Unknown and I4
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<cacheDir>5__1 = Path.Combine(Paths.BepInExRootPath, "cache", "jesterreplacer");
if (!Directory.Exists(<cacheDir>5__1))
{
Directory.CreateDirectory(<cacheDir>5__1);
}
<outPath>5__2 = Path.Combine(<cacheDir>5__1, "jester.ogg");
if (!File.Exists(<outPath>5__2))
{
<s>5__3 = Assembly.GetExecutingAssembly().GetManifestResourceStream("VeryLethal.Resources.jester.ogg");
try
{
if (<s>5__3 != null)
{
<fs>5__4 = File.Create(<outPath>5__2);
try
{
<s>5__3.CopyTo(<fs>5__4);
<fs>5__4.Flush();
}
finally
{
if (<fs>5__4 != null)
{
((IDisposable)<fs>5__4).Dispose();
}
}
<fs>5__4 = null;
}
}
finally
{
if (<s>5__3 != null)
{
((IDisposable)<s>5__3).Dispose();
}
}
<s>5__3 = null;
}
if (File.Exists(<outPath>5__2))
{
<uri>5__5 = "file://" + <outPath>5__2.Replace("\\", "/");
<uwr>5__6 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__5, (AudioType)14);
<>1__state = -3;
<>2__current = <uwr>5__6.SendWebRequest();
<>1__state = 1;
return true;
}
break;
case 1:
<>1__state = -3;
if ((int)<uwr>5__6.result == 1)
{
replacement = DownloadHandlerAudioClip.GetContent(<uwr>5__6);
((Object)replacement).name = "JesterReplacement";
}
<>m__Finally1();
<uri>5__5 = null;
<uwr>5__6 = null;
break;
}
new Harmony("com.scriptifid.verylethal").PatchAll();
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<uwr>5__6 != null)
{
((IDisposable)<uwr>5__6).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static Plugin Instance;
public static AudioClip replacement;
private void Awake()
{
Instance = this;
((MonoBehaviour)this).StartCoroutine(Init());
}
[IteratorStateMachine(typeof(<Init>d__3))]
private IEnumerator Init()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Init>d__3(0)
{
<>4__this = this
};
}
}
[HarmonyPatch(typeof(JesterAI), "Start")]
public static class Patch_JesterStart
{
[CompilerGenerated]
private sealed class <Replace>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public JesterAI j;
private FieldInfo <f>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Replace>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<f>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Plugin.replacement == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<f>5__1 = ((object)j).GetType().GetField("windupSFX", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (<f>5__1 != null && <f>5__1.FieldType == typeof(AudioClip))
{
<f>5__1.SetValue(j, Plugin.replacement);
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static void Postfix(JesterAI __instance)
{
((MonoBehaviour)Plugin.Instance).StartCoroutine(Replace(__instance));
}
[IteratorStateMachine(typeof(<Replace>d__1))]
private static IEnumerator Replace(JesterAI j)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Replace>d__1(0)
{
j = j
};
}
}
}