using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.UI; [assembly: AssemblyFileVersion("1.3.1")] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyProduct("RecyclePlus")] [assembly: AssemblyCompany("TastyChickenLegs")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("RecyclePlus")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [Embedded] internal sealed class <6ccf44e0-923d-45e9-af99-a839b6757a85>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <6ccf44e0-923d-45e9-af99-a839b6757a85>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <6ccf44e0-923d-45e9-af99-a839b6757a85>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [Embedded] [CompilerGenerated] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } [NullableContext(1)] [<6ccf44e0-923d-45e9-af99-a839b6757a85>Nullable(0)] internal sealed class ConfigurationManagerAttributes { public bool? ShowRangeAsPercent; public Action CustomDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func ObjToStr; public Func StrToObj; } [<6ccf44e0-923d-45e9-af99-a839b6757a85>Nullable(0)] [NullableContext(1)] public class WavUtility { private const int BlockSize_16Bit = 2; public static AudioClip ToAudioClip(string filePath) { if (!filePath.StartsWith(Application.persistentDataPath) && !filePath.StartsWith(Application.dataPath)) { Debug.LogWarning((object)"This only supports files that are stored using Unity's Application data path. \nTo load bundled resources use 'Resources.Load(\"filename\") typeof(AudioClip)' method. \nhttps://docs.unity3d.com/ScriptReference/Resources.Load.html"); return null; } return ToAudioClip(File.ReadAllBytes(filePath)); } public static AudioClip ToAudioClip(byte[] fileBytes, int offsetSamples = 0, string name = "wav") { int num = BitConverter.ToInt32(fileBytes, 16); FormatCode(BitConverter.ToUInt16(fileBytes, 20)); ushort num2 = BitConverter.ToUInt16(fileBytes, 22); int num3 = BitConverter.ToInt32(fileBytes, 24); ushort num4 = BitConverter.ToUInt16(fileBytes, 34); int num5 = 20 + num + 4; int dataSize = BitConverter.ToInt32(fileBytes, num5); float[] array = num4 switch { 8 => Convert8BitByteArrayToAudioClipData(fileBytes, num5, dataSize), 16 => Convert16BitByteArrayToAudioClipData(fileBytes, num5, dataSize), 24 => Convert24BitByteArrayToAudioClipData(fileBytes, num5, dataSize), 32 => Convert32BitByteArrayToAudioClipData(fileBytes, num5, dataSize), _ => throw new Exception(num4 + " bit depth is not supported."), }; AudioClip obj = AudioClip.Create(name, array.Length, (int)num2, num3, false); obj.SetData(array, 0); return obj; } private static float[] Convert8BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; float[] array = new float[num]; sbyte b = sbyte.MaxValue; for (int i = 0; i < num; i++) { array[i] = (float)(int)source[i] / (float)b; } return array; } private static float[] Convert16BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; int num2 = 2; int num3 = num / num2; float[] array = new float[num3]; short num4 = short.MaxValue; int num5 = 0; for (int i = 0; i < num3; i++) { num5 = i * num2 + headerOffset; array[i] = (float)BitConverter.ToInt16(source, num5) / (float)num4; } return array; } private static float[] Convert24BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; int num2 = 3; int num3 = num / num2; int num4 = int.MaxValue; float[] array = new float[num3]; byte[] array2 = new byte[4]; int num5 = 0; for (int i = 0; i < num3; i++) { num5 = i * num2 + headerOffset; Buffer.BlockCopy(source, num5, array2, 1, num2); array[i] = (float)BitConverter.ToInt32(array2, 0) / (float)num4; } return array; } private static float[] Convert32BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; int num2 = 4; int num3 = num / num2; int num4 = int.MaxValue; float[] array = new float[num3]; int num5 = 0; for (int i = 0; i < num3; i++) { num5 = i * num2 + headerOffset; array[i] = (float)BitConverter.ToInt32(source, num5) / (float)num4; } return array; } public static byte[] FromAudioClip(AudioClip audioClip) { string filepath; return FromAudioClip(audioClip, out filepath, saveAsFile: false); } public static byte[] FromAudioClip(AudioClip audioClip, out string filepath, bool saveAsFile = true, string dirname = "recordings") { MemoryStream stream = new MemoryStream(); ushort bitDepth = 16; int fileSize = audioClip.samples * audioClip.channels * 2 + 44; WriteFileHeader(ref stream, fileSize); WriteFileFormat(ref stream, audioClip.channels, audioClip.frequency, bitDepth); WriteFileData(ref stream, audioClip, bitDepth); byte[] array = stream.ToArray(); if (saveAsFile) { filepath = string.Format("{0}/{1}/{2}.{3}", Application.persistentDataPath, dirname, DateTime.UtcNow.ToString("yyMMdd-HHmmss-fff"), "wav"); Directory.CreateDirectory(Path.GetDirectoryName(filepath)); File.WriteAllBytes(filepath, array); } else { filepath = null; } stream.Dispose(); return array; } private static int WriteFileHeader(ref MemoryStream stream, int fileSize) { byte[] bytes = Encoding.ASCII.GetBytes("RIFF"); int num = 0 + WriteBytesToMemoryStream(ref stream, bytes, "ID"); int value = fileSize - 8; int num2 = num + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value), "CHUNK_SIZE"); byte[] bytes2 = Encoding.ASCII.GetBytes("WAVE"); return num2 + WriteBytesToMemoryStream(ref stream, bytes2, "FORMAT"); } private static int WriteFileFormat(ref MemoryStream stream, int channels, int sampleRate, ushort bitDepth) { byte[] bytes = Encoding.ASCII.GetBytes("fmt "); int num = 0 + WriteBytesToMemoryStream(ref stream, bytes, "FMT_ID"); int value = 16; int num2 = num + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value), "SUBCHUNK_SIZE"); ushort value2 = 1; int num3 = num2 + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value2), "AUDIO_FORMAT"); ushort value3 = Convert.ToUInt16(channels); int num4 = num3 + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value3), "CHANNELS") + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(sampleRate), "SAMPLE_RATE"); int value4 = sampleRate * channels * BytesPerSample(bitDepth); int num5 = num4 + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value4), "BYTE_RATE"); ushort value5 = Convert.ToUInt16(channels * BytesPerSample(bitDepth)); return num5 + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value5), "BLOCK_ALIGN") + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(bitDepth), "BITS_PER_SAMPLE"); } private static int WriteFileData(ref MemoryStream stream, AudioClip audioClip, ushort bitDepth) { float[] array = new float[audioClip.samples * audioClip.channels]; audioClip.GetData(array, 0); byte[] bytes = ConvertAudioClipDataToInt16ByteArray(array); byte[] bytes2 = Encoding.ASCII.GetBytes("data"); int num = 0 + WriteBytesToMemoryStream(ref stream, bytes2, "DATA_ID"); int value = Convert.ToInt32(audioClip.samples * audioClip.channels * 2); return num + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value), "SAMPLES") + WriteBytesToMemoryStream(ref stream, bytes, "DATA"); } private static byte[] ConvertAudioClipDataToInt16ByteArray(float[] data) { MemoryStream memoryStream = new MemoryStream(); int count = 2; short num = short.MaxValue; for (int i = 0; i < data.Length; i++) { memoryStream.Write(BitConverter.GetBytes(Convert.ToInt16(data[i] * (float)num)), 0, count); } byte[] result = memoryStream.ToArray(); memoryStream.Dispose(); return result; } private static int WriteBytesToMemoryStream(ref MemoryStream stream, byte[] bytes, string tag = "") { int num = bytes.Length; stream.Write(bytes, 0, num); return num; } public static ushort BitDepth(AudioClip audioClip) { return Convert.ToUInt16((float)(audioClip.samples * audioClip.channels) * audioClip.length / (float)audioClip.frequency); } private static int BytesPerSample(ushort bitDepth) { return bitDepth / 8; } private static int BlockSize(ushort bitDepth) { return bitDepth switch { 32 => 4, 16 => 2, 8 => 1, _ => throw new Exception(bitDepth + " bit depth is not supported."), }; } private static string FormatCode(ushort code) { switch (code) { case 1: return "PCM"; case 2: return "ADPCM"; case 3: return "IEEE"; case 7: return "μ-law"; case 65534: return "WaveFormatExtensable"; default: Debug.LogWarning((object)("Unknown wav code format:" + code)); return ""; } } } namespace RecyclePlus { [NullableContext(1)] [BepInPlugin("TastyChickenLegs.RecyclePlus", "RecyclePlus", "1.3.1")] [<6ccf44e0-923d-45e9-af99-a839b6757a85>Nullable(0)] public class RecyclePlusMain : BaseUnityPlugin { [NullableContext(0)] public enum Toggle { On = 1, Off = 0 } [NullableContext(0)] public enum SoundEffect { None, Sound1, Sound2, Sound3, Random } [NullableContext(0)] private class ConfigurationManagerAttributes { public bool? Browsable = false; } [<6ccf44e0-923d-45e9-af99-a839b6757a85>Nullable(0)] private class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } [<6ccf44e0-923d-45e9-af99-a839b6757a85>Nullable(0)] public class TrashButton : MonoBehaviour { private Canvas canvas; private GraphicRaycaster raycaster; private RectTransform rectTransform; private GameObject buttonGo; private void Awake() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { LogErr("InventoryGui.instance is null."); return; } if ((Object)(object)instance.m_player == (Object)null) { LogErr("InventoryGui.m_player is null."); return; } Transform transform = ((Component)instance.m_player).transform; RectTransform component = ((Component)this).GetComponent(); if ((Object)(object)component == (Object)null) { LogErr("Trash object does not contain a RectTransform."); return; } component.anchoredPosition -= new Vector2(0f, 78f); SetText(TrashLabel.Value); SetColor(TrashColor.Value); Transform val = ((Component)this).transform.Find("armor_icon"); if ((Object)(object)val == (Object)null) { LogErr("armor_icon not found!"); return; } Image component2 = ((Component)val).GetComponent(); if ((Object)(object)component2 == (Object)null) { LogErr("armor_icon does not contain an Image component!"); return; } component2.sprite = trashSprite; ((Component)this).transform.SetSiblingIndex(0); ((Object)((Component)((Component)this).transform).gameObject).name = "Trash"; buttonGo = new GameObject("ButtonCanvas"); rectTransform = buttonGo.AddComponent(); ((Component)rectTransform).transform.SetParent(((Component)((Component)this).transform).transform, true); rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = new Vector2(70f, 74f); canvas = buttonGo.AddComponent(); raycaster = buttonGo.AddComponent(); ((UnityEvent)buttonGo.AddComponent