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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using BingBongToMochi;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TalkingBingBong;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("plswork")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("plswork")]
[assembly: AssemblyTitle("MyPlugin1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace TalkingBingBong
{
[HarmonyPatch(typeof(Action_AskBingBong), "AskRoutine", new Type[]
{
typeof(int),
typeof(bool)
})]
public static class Patch_AskRoutine
{
[Serializable]
public class BenResponse
{
public string subtitle;
public AudioClip sfx;
}
[CompilerGenerated]
private sealed class <BenSubtitleRoutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Action_AskBingBong __instance;
public string subtitle;
private float <t>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BenSubtitleRoutine>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.19f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Component)__instance.subtitles).gameObject.SetActive(true);
((TMP_Text)__instance.subtitles).text = subtitle;
<t>5__1 = 0f;
break;
case 2:
<>1__state = -1;
break;
}
if ((double)<t>5__1 < 1.7999999523162842)
{
<t>5__1 += Time.deltaTime;
((TMP_Text)__instance.subtitles).alpha = Mathf.Clamp01(<t>5__1 * 12f);
__instance.subtitles.transform.localScale = Vector3.one * __instance.scaleCurve.Evaluate(Vector3.Distance(__instance.subtitles.transform.position, ((Component)MainCamera.instance).transform.position));
__instance.subtitles.transform.forward = ((Component)MainCamera.instance).transform.forward;
<>2__current = null;
<>1__state = 2;
return true;
}
((Component)__instance.subtitles).gameObject.SetActive(false);
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();
}
}
[CompilerGenerated]
private sealed class <InitResponses>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InitResponses>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
Plugin.Log.LogInfo((object)"Initialising Ben Responses...");
benResponses = new BenResponse[4];
<>2__current = LoadClip("Saymyname.ogg", delegate(AudioClip clip)
{
benResponses[0] = new BenResponse
{
subtitle = "My name is Salad!",
sfx = clip
};
});
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
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();
}
}
[CompilerGenerated]
private sealed class <LoadClip>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string filename;
public Action<AudioClip> onLoaded;
private string <uri>5__1;
private UnityWebRequest <www>5__2;
private AudioClip <content>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadClip>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<uri>5__1 = null;
<www>5__2 = null;
<content>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Invalid comparison between Unknown and I4
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<uri>5__1 = new Uri(Path.Combine(Plugin.directory, filename)).AbsoluteUri;
<www>5__2 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__1, (AudioType)14);
Plugin.Log.LogInfo((object)Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filename));
<>2__current = <www>5__2.SendWebRequest();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((int)<www>5__2.result != 1)
{
Plugin.Log.LogError((object)("Failed to load " + filename + ": " + <www>5__2.error));
onLoaded(null);
}
else
{
<content>5__3 = DownloadHandlerAudioClip.GetContent(<www>5__2);
Plugin.Log.LogInfo((object)(filename + " is loaded!"));
onLoaded(<content>5__3);
<content>5__3 = null;
}
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();
}
}
[CompilerGenerated]
private sealed class <MyAskBenRoutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Action_AskBingBong __instance;
public int index;
private BenResponse <selected>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MyAskBenRoutine>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<selected>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<selected>5__1 = benResponses[0];
Plugin.Log.LogInfo((object)("TalkingBingBong has said: " + <selected>5__1.subtitle));
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
__instance.source.PlayOneShot(<selected>5__1.sfx);
<>2__current = BenSubtitleRoutine(__instance, <selected>5__1.subtitle);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
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 BenResponse[] benResponses;
[IteratorStateMachine(typeof(<InitResponses>d__1))]
public static IEnumerator InitResponses()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitResponses>d__1(0);
}
[IteratorStateMachine(typeof(<LoadClip>d__2))]
public static IEnumerator LoadClip(string filename, Action<AudioClip> onLoaded)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadClip>d__2(0)
{
filename = filename,
onLoaded = onLoaded
};
}
public static bool Prefix(Action_AskBingBong __instance, int index, bool spamming, ref IEnumerator __result)
{
Plugin.Log.LogInfo((object)"Asking BingBong...");
__result = MyAskBenRoutine(__instance, index % 4);
return false;
}
[IteratorStateMachine(typeof(<MyAskBenRoutine>d__4))]
public static IEnumerator MyAskBenRoutine(Action_AskBingBong __instance, int index)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MyAskBenRoutine>d__4(0)
{
__instance = __instance,
index = index
};
}
[IteratorStateMachine(typeof(<BenSubtitleRoutine>d__5))]
private static IEnumerator BenSubtitleRoutine(Action_AskBingBong __instance, string subtitle)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BenSubtitleRoutine>d__5(0)
{
__instance = __instance,
subtitle = subtitle
};
}
}
}
namespace BingBongToMochi
{
[HarmonyPatch(typeof(Item))]
public class ItemPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Item_Start(Item __instance)
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Invalid comparison between Unknown and I4
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Invalid comparison between Unknown and I4
if (!((Object)__instance).name.Contains("BingBong"))
{
return;
}
MeshRenderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Renderer val = (Renderer)(object)componentsInChildren[i];
val.enabled = false;
}
Collider[] componentsInChildren2 = ((Component)__instance).gameObject.GetComponentsInChildren<Collider>();
for (int j = 0; j < componentsInChildren2.Length; j++)
{
Object val2 = (Object)(object)componentsInChildren2[j];
Object.Destroy(val2);
}
GameObject val3 = Object.Instantiate<GameObject>(Plugin.MochiPrefab, ((Component)__instance).gameObject.transform);
((Renderer)val3.GetComponent<MeshRenderer>()).materials[0].shader = Shader.Find("Universal Render Pipeline/Lit");
float num = (float)(1.0 - (double)__instance.GetData<IntItemData>((DataEntryKey)1).Value * 0.20000000298023224);
((Renderer)val3.GetComponent<MeshRenderer>()).materials[0].SetColor("_BaseColor", new Color(Mathf.Clamp01(num + 0.2f), num, num));
val3.transform.localPosition = new Vector3(-0.15f, 0.05f, 0f);
val3.transform.localRotation = Quaternion.Euler(-98f, 90f, 0f);
val3.transform.localScale = new Vector3(20f, 20f, 20f);
__instance.colliders = ((Component)__instance).gameObject.GetComponentsInChildren<Collider>();
Plugin.Log.LogInfo((object)("Colliders: " + __instance.colliders.Length));
if ((int)__instance.itemState == 2)
{
(byte, BackpackReference) value = __instance.backpackReference.Value;
if (((BackpackReference)(ref value.Item2)).IsOnMyBack())
{
MeshRenderer[] componentsInChildren3 = ((Component)__instance).gameObject.GetComponentsInChildren<MeshRenderer>();
for (int k = 0; k < componentsInChildren3.Length; k++)
{
Renderer val4 = (Renderer)(object)componentsInChildren3[k];
val4.enabled = false;
}
}
}
if ((int)__instance.itemState == 2)
{
Collider[] componentsInChildren4 = ((Component)__instance).gameObject.GetComponentsInChildren<Collider>();
foreach (Collider val5 in componentsInChildren4)
{
val5.enabled = false;
}
}
}
[HarmonyPatch(typeof(ItemUIData), "GetIcon")]
[HarmonyPostfix]
public static void Item_GetIcon(ItemUIData __instance, ref Texture2D __result)
{
Plugin.Log.LogInfo((object)("Getting item name:" + __instance.itemName));
if (__instance.itemName == "Bing Bong")
{
__result = Plugin.MochiTexture;
}
}
[HarmonyPatch(typeof(ItemCooking), "UpdateCookedBehavior")]
[HarmonyPostfix]
public static void Item_SetCookedAmount(ItemCooking __instance)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
if (((Object)((ItemComponent)__instance).item).name.Contains("BingBong"))
{
float num = (float)(1.0 - (double)((ItemComponent)__instance).item.GetData<IntItemData>((DataEntryKey)1).Value * 0.20000000298023224);
MeshRenderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Renderer val = (Renderer)(object)componentsInChildren[i];
val.materials[0].SetColor("_BaseColor", new Color(Mathf.Clamp01(num + 0.2f), num, num));
}
}
}
[HarmonyPatch("GetName")]
[HarmonyPostfix]
public static void Item_Name(Item __instance, ref string __result)
{
__result = (((Object)__instance).name.Contains("BingBong") ? "SALAD" : __result);
}
[HarmonyPatch("HideRenderers")]
[HarmonyPostfix]
public static void Item_HideRendered(Item __instance)
{
Plugin.Log.LogInfo((object)("Hiding rendered item:" + ((Object)__instance).name));
if (((Object)__instance).name.Contains("BingBong"))
{
MeshRenderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Renderer val = (Renderer)(object)componentsInChildren[i];
val.enabled = false;
}
}
}
}
[BepInPlugin("com.github.FelineEntity.BingBingToMochi", "BingBongToMochi", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
internal static Harmony Harmony = new Harmony("com.github.FelineEntity.BingBingToMochi");
public const string Id = "com.github.FelineEntity.BingBingToMochi";
internal static ManualLogSource Log { get; private set; } = null;
internal static Plugin Instance { get; private set; } = null;
internal static AssetBundle Bundle { get; private set; } = null;
internal static GameObject MochiPrefab { get; private set; } = null;
internal static Material MochiMaterial { get; private set; } = null;
internal static Texture2D MochiTexture { get; private set; } = null;
public static string Name => "BingBongToSALAD";
internal static string directory => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
Harmony.PatchAll(Assembly.GetExecutingAssembly());
((MonoBehaviour)this).StartCoroutine(Patch_AskRoutine.InitResponses());
LoadAssets();
}
private void LoadAssets()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mochipeak"));
MochiPrefab = Bundle.LoadAsset<GameObject>("Assets/Models/Mochi/mochiThrowablePrefab.prefab");
MochiMaterial = Bundle.LoadAsset<Material>("Assets/Models/Mochi/Mochi.mat");
MochiTexture = Bundle.LoadAsset<Texture2D>("Assets/Models/Mochi/mochistand.png");
if ((Object)MochiPrefab == (Object)null)
{
Log.LogInfo((object)"Mochi prefab loading failed. :(");
return;
}
Log.LogInfo((object)"Mochi prefab loaded successfully!");
Object.Instantiate<GameObject>(MochiPrefab);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}