using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; 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 System.Threading.Tasks; using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.Colors; using Archipelago.MultiClient.Net.Converters; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.MessageLog.Parts; using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BreakInfinity; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using TMPro; using Tweens; using Tweens.Core; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("UnfairFlipsAPMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+eb3f62bafd76662aa1768ee8a65f3bed619ba015")] [assembly: AssemblyProduct("UnfairFlipsAPMod")] [assembly: AssemblyTitle("UnfairFlipsAPMod")] [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.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] [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; } } } public static class Mathy { public static float Decay(float a, float b, float decay, float dt) { return b + (a - b) * Mathf.Exp((0f - decay) * dt); } public static Vector3 Decay(Vector3 a, Vector3 b, float decay, float dt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) return b + (a - b) * Mathf.Exp((0f - decay) * dt); } public static Vector2 Decay(Vector2 a, Vector2 b, float decay, float dt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) return b + (a - b) * Mathf.Exp((0f - decay) * dt); } public static Color Decay(Color a, Color b, float decay, float dt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) return b + (a - b) * Mathf.Exp((0f - decay) * dt); } public static float AngleBetween(Vector2 vector1, Vector2 vector2) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) return Mathf.Atan2((float)((double)vector1.x * (double)vector2.y - (double)vector2.x * (double)vector1.y), (float)((double)vector1.x * (double)vector2.x + (double)vector1.y * (double)vector2.y)) * (180f / MathF.PI); } public static string CentsToDollarString(BigDouble totalCents) { BigDouble bigDouble = (totalCents / 100).Floor(); BigDouble bigDouble2 = (totalCents - bigDouble * 100).Round(); return (bigDouble < 10000) ? ("$" + bigDouble.ToString("F0") + "." + bigDouble2.ToString("F0").PadLeft(2, '0')) : ("$" + bigDouble.ToString("G4")); } public static string CentsToDollarString(int cents) { string text = (cents / 100).ToString(); string text2 = (cents % 100).ToString("D2"); return "$" + text + "." + text2; } } namespace BreakInfinity { public struct BigDouble : IFormattable, IComparable, IComparable, IEquatable { private static class BigNumber { public static string FormatBigDouble(BigDouble value, string format, IFormatProvider formatProvider) { if (IsNaN(value)) { return "NaN"; } if (value.Exponent >= long.MaxValue) { return (value.Mantissa > 0.0) ? "Infinity" : "-Infinity"; } int digits; char c = ParseFormatSpecifier(format, out digits); switch (c) { case 'G': case 'R': return FormatGeneral(value, digits); case 'E': return FormatExponential(value, digits); case 'F': return FormatFixed(value, digits); default: throw new FormatException($"Unknown string format '{c}'"); } } private static char ParseFormatSpecifier(string format, out int digits) { digits = -1; if (string.IsNullOrEmpty(format)) { return 'R'; } int num = 0; char c = format[num]; if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z')) { return '\0'; } num++; int num2 = -1; if (num < format.Length && format[num] >= '0' && format[num] <= '9') { num2 = format[num++] - 48; while (num < format.Length && format[num] >= '0' && format[num] <= '9') { num2 = num2 * 10 + (format[num++] - 48); if (num2 >= 10) { break; } } } if (num < format.Length && format[num] != 0) { return '\0'; } digits = num2; return c; } private static string FormatGeneral(BigDouble value, int places) { if (value.Exponent <= -9223372036854775807L || IsZero(value.Mantissa)) { return "0"; } string text = ((places > 0) ? $"G{places}" : "G"); if (value.Exponent < 21 && value.Exponent > -7) { return value.ToDouble().ToString(text, CultureInfo.InvariantCulture); } return value.Mantissa.ToString(text, CultureInfo.InvariantCulture) + "E" + ((value.Exponent >= 0) ? "+" : "") + value.Exponent.ToString(CultureInfo.InvariantCulture); } private static string ToFixed(double value, int places) { return value.ToString($"F{places}", CultureInfo.InvariantCulture); } private static string FormatExponential(BigDouble value, int places) { if (value.Exponent <= -9223372036854775807L || IsZero(value.Mantissa)) { return "0" + ((places > 0) ? ".".PadRight(places + 1, '0') : "") + "E+0"; } int num = ((places >= 0) ? places : 17) + 1; int num2 = (int)Math.Ceiling(Math.Log10(Math.Abs(value.Mantissa))); double value2 = Math.Round(value.Mantissa * Math.Pow(10.0, num - num2)) * Math.Pow(10.0, num2 - num); string text = ToFixed(value2, Math.Max(num - num2, 0)); if (text != "0" && places < 0) { text = text.TrimEnd('0', '.'); } return text + "E" + ((value.Exponent >= 0) ? "+" : "") + value.Exponent; } private static string FormatFixed(BigDouble value, int places) { if (places < 0) { places = 17; } if (value.Exponent <= -9223372036854775807L || IsZero(value.Mantissa)) { return "0" + ((places > 0) ? ".".PadRight(places + 1, '0') : ""); } if (value.Exponent >= 17) { return value.Mantissa.ToString(CultureInfo.InvariantCulture).Replace(".", "").PadRight((int)value.Exponent + 1, '0') + ((places > 0) ? ".".PadRight(places + 1, '0') : ""); } return ToFixed(value.ToDouble(), places); } } private static class PowersOf10 { private const long IndexOf0 = 323L; private static double[] Powers { get; } static PowersOf10() { Powers = new double[632]; int num = 0; for (int i = 0; i < Powers.Length; i++) { Powers[num++] = double.Parse("1e" + ((long)i - 323L), CultureInfo.InvariantCulture); } } public static double Lookup(long power) { return Powers[323 + power]; } } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct PrivateConstructorArg { } public const double Tolerance = 1E-18; private const int MaxSignificantDigits = 17; private const long ExpLimit = long.MaxValue; private const long DoubleExpMax = 308L; private const long DoubleExpMin = -324L; private double mantissa; private long exponent; public static BigDouble Zero = FromMantissaExponentNoNormalize(0.0, 0L); public static BigDouble One = FromMantissaExponentNoNormalize(1.0, 0L); public static BigDouble NaN = FromMantissaExponentNoNormalize(double.NaN, long.MinValue); public static BigDouble PositiveInfinity = FromMantissaExponentNoNormalize(double.PositiveInfinity, 0L); public static BigDouble NegativeInfinity = FromMantissaExponentNoNormalize(double.NegativeInfinity, 0L); public double Mantissa => mantissa; public long Exponent => exponent; private BigDouble(double mantissa, long exponent, PrivateConstructorArg _) { this.mantissa = mantissa; this.exponent = exponent; } public BigDouble(double mantissa, long exponent) { this = Normalize(mantissa, exponent); } public BigDouble(BigDouble other) { mantissa = other.mantissa; exponent = other.exponent; } public BigDouble(double value) { if (double.IsNaN(value)) { this = NaN; } else if (double.IsPositiveInfinity(value)) { this = PositiveInfinity; } else if (double.IsNegativeInfinity(value)) { this = NegativeInfinity; } else if (IsZero(value)) { this = Zero; } else { this = Normalize(value, 0L); } } public static BigDouble Normalize(double mantissa, long exponent) { if ((mantissa >= 1.0 && mantissa < 10.0) || !IsFinite(mantissa)) { return FromMantissaExponentNoNormalize(mantissa, exponent); } if (IsZero(mantissa)) { return Zero; } long num = (long)Math.Floor(Math.Log10(Math.Abs(mantissa))); mantissa = ((num != -324) ? (mantissa / PowersOf10.Lookup(num)) : (mantissa * 10.0 / 1E-323)); return FromMantissaExponentNoNormalize(mantissa, exponent + num); } public static BigDouble FromMantissaExponentNoNormalize(double mantissa, long exponent) { return new BigDouble(mantissa, exponent, default(PrivateConstructorArg)); } public static bool IsNaN(BigDouble value) { return double.IsNaN(value.Mantissa); } public static bool IsPositiveInfinity(BigDouble value) { return double.IsPositiveInfinity(value.Mantissa); } public static bool IsNegativeInfinity(BigDouble value) { return double.IsNegativeInfinity(value.Mantissa); } public static bool IsInfinity(BigDouble value) { return double.IsInfinity(value.Mantissa); } public static BigDouble Parse(string value) { if (value.IndexOf('e') != -1) { string[] array = value.Split('e'); double num = double.Parse(array[0], CultureInfo.InvariantCulture); long num2 = long.Parse(array[1], CultureInfo.InvariantCulture); return Normalize(num, num2); } if (value == "NaN") { return NaN; } BigDouble bigDouble = new BigDouble(double.Parse(value, CultureInfo.InvariantCulture)); if (IsNaN(bigDouble)) { throw new Exception("Invalid argument: " + value); } return bigDouble; } public double ToDouble() { if (IsNaN(this)) { return double.NaN; } if (Exponent > 308) { return (Mantissa > 0.0) ? double.PositiveInfinity : double.NegativeInfinity; } if (Exponent < -324) { return 0.0; } if (Exponent == -324) { return (Mantissa > 0.0) ? double.Epsilon : (-5E-324); } double num = Mantissa * PowersOf10.Lookup(Exponent); if (!IsFinite(num) || Exponent < 0) { return num; } double num2 = Math.Round(num); if (Math.Abs(num2 - num) < 1E-10) { return num2; } return num; } public override string ToString() { return BigNumber.FormatBigDouble(this, null, null); } public string ToString(string format) { return BigNumber.FormatBigDouble(this, format, null); } public string ToString(string format, IFormatProvider formatProvider) { return BigNumber.FormatBigDouble(this, format, formatProvider); } public static BigDouble Abs(BigDouble value) { return FromMantissaExponentNoNormalize(Math.Abs(value.Mantissa), value.Exponent); } public static BigDouble Negate(BigDouble value) { return FromMantissaExponentNoNormalize(0.0 - value.Mantissa, value.Exponent); } public static int Sign(BigDouble value) { return Math.Sign(value.Mantissa); } public static BigDouble Round(BigDouble value) { if (IsNaN(value)) { return value; } if (value.Exponent < -1) { return Zero; } if (value.Exponent < 17) { return new BigDouble(Math.Round(value.ToDouble())); } return value; } public static BigDouble Round(BigDouble value, MidpointRounding mode) { if (IsNaN(value)) { return value; } if (value.Exponent < -1) { return Zero; } if (value.Exponent < 17) { return new BigDouble(Math.Round(value.ToDouble(), mode)); } return value; } public static BigDouble Floor(BigDouble value) { if (IsNaN(value)) { return value; } if (value.Exponent < -1) { return (Math.Sign(value.Mantissa) >= 0) ? Zero : (-One); } if (value.Exponent < 17) { return new BigDouble(Math.Floor(value.ToDouble())); } return value; } public static BigDouble Ceiling(BigDouble value) { if (IsNaN(value)) { return value; } if (value.Exponent < -1) { return (Math.Sign(value.Mantissa) > 0) ? One : Zero; } if (value.Exponent < 17) { return new BigDouble(Math.Ceiling(value.ToDouble())); } return value; } public static BigDouble Truncate(BigDouble value) { if (IsNaN(value)) { return value; } if (value.Exponent < 0) { return Zero; } if (value.Exponent < 17) { return new BigDouble(Math.Truncate(value.ToDouble())); } return value; } public static BigDouble Add(BigDouble left, BigDouble right) { if (IsZero(left.Mantissa)) { return right; } if (IsZero(right.Mantissa)) { return left; } if (IsNaN(left) || IsNaN(right) || IsInfinity(left) || IsInfinity(right)) { return left.Mantissa + right.Mantissa; } BigDouble result; BigDouble bigDouble; if (left.Exponent >= right.Exponent) { result = left; bigDouble = right; } else { result = right; bigDouble = left; } if (result.Exponent - bigDouble.Exponent > 17) { return result; } return Normalize(Math.Round(100000000000000.0 * result.Mantissa + 100000000000000.0 * bigDouble.Mantissa * PowersOf10.Lookup(bigDouble.Exponent - result.Exponent)), result.Exponent - 14); } public static BigDouble Subtract(BigDouble left, BigDouble right) { return left + -right; } public static BigDouble Multiply(BigDouble left, BigDouble right) { return Normalize(left.Mantissa * right.Mantissa, left.Exponent + right.Exponent); } public static BigDouble Divide(BigDouble left, BigDouble right) { return left * Reciprocate(right); } public static BigDouble Reciprocate(BigDouble value) { return Normalize(1.0 / value.Mantissa, -value.Exponent); } public static implicit operator BigDouble(double value) { return new BigDouble(value); } public static implicit operator BigDouble(int value) { return new BigDouble(value); } public static implicit operator BigDouble(long value) { return new BigDouble(value); } public static implicit operator BigDouble(float value) { return new BigDouble(value); } public static BigDouble operator -(BigDouble value) { return Negate(value); } public static BigDouble operator +(BigDouble left, BigDouble right) { return Add(left, right); } public static BigDouble operator -(BigDouble left, BigDouble right) { return Subtract(left, right); } public static BigDouble operator *(BigDouble left, BigDouble right) { return Multiply(left, right); } public static BigDouble operator /(BigDouble left, BigDouble right) { return Divide(left, right); } public static BigDouble operator ++(BigDouble value) { return value.Add(1); } public static BigDouble operator --(BigDouble value) { return value.Subtract(1); } public int CompareTo(object other) { if (other == null) { return 1; } if (other is BigDouble) { return CompareTo((BigDouble)other); } throw new ArgumentException("The parameter must be a BigDouble."); } public int CompareTo(BigDouble other) { if (IsZero(Mantissa) || IsZero(other.Mantissa) || IsNaN(this) || IsNaN(other) || IsInfinity(this) || IsInfinity(other)) { return Mantissa.CompareTo(other.Mantissa); } if (Mantissa > 0.0 && other.Mantissa < 0.0) { return 1; } if (Mantissa < 0.0 && other.Mantissa > 0.0) { return -1; } int num = Exponent.CompareTo(other.Exponent); return (num == 0) ? Mantissa.CompareTo(other.Mantissa) : ((Mantissa > 0.0) ? num : (-num)); } public override bool Equals(object other) { return other is BigDouble && Equals((BigDouble)other); } public override int GetHashCode() { return (Mantissa.GetHashCode() * 397) ^ Exponent.GetHashCode(); } public bool Equals(BigDouble other) { return !IsNaN(this) && !IsNaN(other) && (AreSameInfinity(this, other) || (Exponent == other.Exponent && AreEqual(Mantissa, other.Mantissa))); } public bool Equals(BigDouble other, double tolerance) { return !IsNaN(this) && !IsNaN(other) && (AreSameInfinity(this, other) || Abs(this - other) <= Max(Abs(this), Abs(other)) * tolerance); } private static bool AreSameInfinity(BigDouble first, BigDouble second) { return (IsPositiveInfinity(first) && IsPositiveInfinity(second)) || (IsNegativeInfinity(first) && IsNegativeInfinity(second)); } public static bool operator ==(BigDouble left, BigDouble right) { return left.Equals(right); } public static bool operator !=(BigDouble left, BigDouble right) { return !(left == right); } public static bool operator <(BigDouble a, BigDouble b) { if (IsNaN(a) || IsNaN(b)) { return false; } if (IsZero(a.Mantissa)) { return b.Mantissa > 0.0; } if (IsZero(b.Mantissa)) { return a.Mantissa < 0.0; } if (a.Exponent == b.Exponent) { return a.Mantissa < b.Mantissa; } if (a.Mantissa > 0.0) { return b.Mantissa > 0.0 && a.Exponent < b.Exponent; } return b.Mantissa > 0.0 || a.Exponent > b.Exponent; } public static bool operator <=(BigDouble a, BigDouble b) { if (IsNaN(a) || IsNaN(b)) { return false; } return !(a > b); } public static bool operator >(BigDouble a, BigDouble b) { if (IsNaN(a) || IsNaN(b)) { return false; } if (IsZero(a.Mantissa)) { return b.Mantissa < 0.0; } if (IsZero(b.Mantissa)) { return a.Mantissa > 0.0; } if (a.Exponent == b.Exponent) { return a.Mantissa > b.Mantissa; } if (a.Mantissa > 0.0) { return b.Mantissa < 0.0 || a.Exponent > b.Exponent; } return b.Mantissa < 0.0 && a.Exponent < b.Exponent; } public static bool operator >=(BigDouble a, BigDouble b) { if (IsNaN(a) || IsNaN(b)) { return false; } return !(a < b); } public static BigDouble Max(BigDouble left, BigDouble right) { if (IsNaN(left) || IsNaN(right)) { return NaN; } return (left > right) ? left : right; } public static BigDouble Min(BigDouble left, BigDouble right) { if (IsNaN(left) || IsNaN(right)) { return NaN; } return (left > right) ? right : left; } public static double AbsLog10(BigDouble value) { return (double)value.Exponent + Math.Log10(Math.Abs(value.Mantissa)); } public static double Log10(BigDouble value) { return (double)value.Exponent + Math.Log10(value.Mantissa); } public static double Log(BigDouble value, BigDouble @base) { return Log(value, @base.ToDouble()); } public static double Log(BigDouble value, double @base) { if (IsZero(@base)) { return double.NaN; } return 2.302585092994046 / Math.Log(@base) * Log10(value); } public static double Log2(BigDouble value) { return 3.321928094887362 * Log10(value); } public static double Ln(BigDouble value) { return 2.302585092994046 * Log10(value); } public static BigDouble Pow10(double power) { return IsInteger(power) ? Pow10((long)power) : Normalize(Math.Pow(10.0, power % 1.0), (long)Math.Truncate(power)); } public static BigDouble Pow10(long power) { return FromMantissaExponentNoNormalize(1.0, power); } public static BigDouble Pow(BigDouble value, BigDouble power) { return Pow(value, power.ToDouble()); } public static BigDouble Pow(BigDouble value, long power) { if (Is10(value)) { return Pow10(power); } double d = Math.Pow(value.Mantissa, power); if (double.IsInfinity(d)) { return Pow(Pow(value, 2L), (double)power / 2.0); } return Normalize(d, value.Exponent * power); } public static BigDouble Pow(BigDouble value, double power) { bool flag = IsInteger(power); if (value < 0 && !flag) { return NaN; } return (Is10(value) && flag) ? Pow10(power) : PowInternal(value, power); } private static bool Is10(BigDouble value) { return value.Exponent == 1 && value.Mantissa - 1.0 < double.Epsilon; } private static BigDouble PowInternal(BigDouble value, double other) { double num = (double)value.Exponent * other; double value2; if (IsInteger(num) && IsFinite(num) && Math.Abs(num) < 9.223372036854776E+18) { value2 = Math.Pow(value.Mantissa, other); if (IsFinite(value2)) { return Normalize(value2, (long)num); } } double num2 = Math.Truncate(num); double num3 = num - num2; value2 = Math.Pow(10.0, other * Math.Log10(value.Mantissa) + num3); if (IsFinite(value2)) { return Normalize(value2, (long)num2); } BigDouble bigDouble = Pow10(other * AbsLog10(value)); if (Sign(value) == -1 && AreEqual(other % 2.0, 1.0)) { return -bigDouble; } return bigDouble; } public static BigDouble Factorial(BigDouble value) { double num = value.ToDouble() + 1.0; return Pow(num / Math.E * Math.Sqrt(num * Math.Sinh(1.0 / num) + 1.0 / (810.0 * Math.Pow(num, 6.0))), num) * Math.Sqrt(Math.PI * 2.0 / num); } public static BigDouble Exp(BigDouble value) { return Pow(Math.E, value); } public static BigDouble Sqrt(BigDouble value) { if (value.Mantissa < 0.0) { return new BigDouble(double.NaN); } if (value.Exponent % 2 != 0) { return Normalize(Math.Sqrt(value.Mantissa) * 3.16227766016838, (long)Math.Floor((double)value.Exponent / 2.0)); } return Normalize(Math.Sqrt(value.Mantissa), (long)Math.Floor((double)value.Exponent / 2.0)); } public static BigDouble Cbrt(BigDouble value) { int num = 1; double num2 = value.Mantissa; if (num2 < 0.0) { num = -1; num2 = 0.0 - num2; } double num3 = (double)num * Math.Pow(num2, 1.0 / 3.0); long num4 = value.Exponent % 3; if (num4 == 1 || num4 == -1) { return Normalize(num3 * 2.154434690031884, (long)Math.Floor((double)value.Exponent / 3.0)); } if (num4 != 0) { return Normalize(num3 * 4.641588833612779, (long)Math.Floor((double)value.Exponent / 3.0)); } return Normalize(num3, (long)Math.Floor((double)value.Exponent / 3.0)); } public static BigDouble Sinh(BigDouble value) { return (Exp(value) - Exp(-value)) / 2; } public static BigDouble Cosh(BigDouble value) { return (Exp(value) + Exp(-value)) / 2; } public static BigDouble Tanh(BigDouble value) { return Sinh(value) / Cosh(value); } public static double Asinh(BigDouble value) { return Ln(value + Sqrt(Pow(value, 2L) + 1)); } public static double Acosh(BigDouble value) { return Ln(value + Sqrt(Pow(value, 2L) - 1)); } public static double Atanh(BigDouble value) { if (Abs(value) >= 1) { return double.NaN; } return Ln((value + 1) / (One - value)) / 2.0; } private static bool IsZero(double value) { return Math.Abs(value) < double.Epsilon; } private static bool AreEqual(double first, double second) { return Math.Abs(first - second) < 1E-18; } private static bool IsInteger(double value) { return IsZero(Math.Abs(value % 1.0)); } private static bool IsFinite(double value) { return !double.IsNaN(value) && !double.IsInfinity(value); } } public static class BigMath { private static readonly Random Random = new Random(); public static BigDouble RandomBigDouble(double absMaxExponent) { if (Random.NextDouble() * 20.0 < 1.0) { return BigDouble.Normalize(0.0, 0L); } double num = Random.NextDouble() * 10.0; if (Random.NextDouble() * 10.0 < 1.0) { num = Math.Round(num); } num *= (double)Math.Sign(Random.NextDouble() * 2.0 - 1.0); long exponent = (long)(Math.Floor(Random.NextDouble() * absMaxExponent * 2.0) - absMaxExponent); return BigDouble.Normalize(num, exponent); } public static BigDouble AffordGeometricSeries(BigDouble resourcesAvailable, BigDouble priceStart, BigDouble priceRatio, BigDouble currentOwned) { BigDouble bigDouble = priceStart * BigDouble.Pow(priceRatio, currentOwned); return BigDouble.Floor(BigDouble.Log10(resourcesAvailable / bigDouble * (priceRatio - 1) + 1) / BigDouble.Log10(priceRatio)); } public static BigDouble SumGeometricSeries(BigDouble numItems, BigDouble priceStart, BigDouble priceRatio, BigDouble currentOwned) { BigDouble bigDouble = priceStart * BigDouble.Pow(priceRatio, currentOwned); return bigDouble * (1 - BigDouble.Pow(priceRatio, numItems)) / (1 - priceRatio); } public static BigDouble AffordArithmeticSeries(BigDouble resourcesAvailable, BigDouble priceStart, BigDouble priceAdd, BigDouble currentOwned) { BigDouble bigDouble = priceStart + currentOwned * priceAdd; BigDouble bigDouble2 = bigDouble - priceAdd / 2; BigDouble bigDouble3 = BigDouble.Pow(bigDouble2, 2L); return BigDouble.Floor((BigDouble.Sqrt(bigDouble3 + priceAdd * resourcesAvailable * 2) - bigDouble2) / priceAdd); } public static BigDouble SumArithmeticSeries(BigDouble numItems, BigDouble priceStart, BigDouble priceAdd, BigDouble currentOwned) { BigDouble bigDouble = priceStart + currentOwned * priceAdd; return numItems / 2 * (2 * bigDouble + (numItems - 1) * priceAdd); } public static BigDouble EfficiencyOfPurchase(BigDouble cost, BigDouble currentRpS, BigDouble deltaRpS) { return cost / currentRpS + cost / deltaRpS; } } public static class BigDoubleExtensions { public static BigDouble Abs(this BigDouble value) { return BigDouble.Abs(value); } public static BigDouble Negate(this BigDouble value) { return BigDouble.Negate(value); } public static int Sign(this BigDouble value) { return BigDouble.Sign(value); } public static BigDouble Round(this BigDouble value) { return BigDouble.Round(value); } public static BigDouble Floor(this BigDouble value) { return BigDouble.Floor(value); } public static BigDouble Ceiling(this BigDouble value) { return BigDouble.Ceiling(value); } public static BigDouble Truncate(this BigDouble value) { return BigDouble.Truncate(value); } public static BigDouble Add(this BigDouble value, BigDouble other) { return BigDouble.Add(value, other); } public static BigDouble Subtract(this BigDouble value, BigDouble other) { return BigDouble.Subtract(value, other); } public static BigDouble Multiply(this BigDouble value, BigDouble other) { return BigDouble.Multiply(value, other); } public static BigDouble Divide(this BigDouble value, BigDouble other) { return BigDouble.Divide(value, other); } public static BigDouble Reciprocate(this BigDouble value) { return BigDouble.Reciprocate(value); } public static BigDouble Max(this BigDouble value, BigDouble other) { return BigDouble.Max(value, other); } public static BigDouble Min(this BigDouble value, BigDouble other) { return BigDouble.Min(value, other); } public static double AbsLog10(this BigDouble value) { return BigDouble.AbsLog10(value); } public static double Log10(this BigDouble value) { return BigDouble.Log10(value); } public static double Log(BigDouble value, BigDouble @base) { return BigDouble.Log(value, @base); } public static double Log(this BigDouble value, double @base) { return BigDouble.Log(value, @base); } public static double Log2(this BigDouble value) { return BigDouble.Log2(value); } public static double Ln(this BigDouble value) { return BigDouble.Ln(value); } public static BigDouble Exp(this BigDouble value) { return BigDouble.Exp(value); } public static BigDouble Sinh(this BigDouble value) { return BigDouble.Sinh(value); } public static BigDouble Cosh(this BigDouble value) { return BigDouble.Cosh(value); } public static BigDouble Tanh(this BigDouble value) { return BigDouble.Tanh(value); } public static double Asinh(this BigDouble value) { return BigDouble.Asinh(value); } public static double Acosh(this BigDouble value) { return BigDouble.Acosh(value); } public static double Atanh(this BigDouble value) { return BigDouble.Atanh(value); } public static BigDouble Pow(this BigDouble value, BigDouble power) { return BigDouble.Pow(value, power); } public static BigDouble Pow(this BigDouble value, long power) { return BigDouble.Pow(value, power); } public static BigDouble Pow(this BigDouble value, double power) { return BigDouble.Pow(value, power); } public static BigDouble Factorial(this BigDouble value) { return BigDouble.Factorial(value); } public static BigDouble Sqrt(this BigDouble value) { return BigDouble.Sqrt(value); } public static BigDouble Cbrt(this BigDouble value) { return BigDouble.Cbrt(value); } public static BigDouble Sqr(this BigDouble value) { return BigDouble.Pow(value, 2L); } } } namespace UnfairFlipsAPMod { public static class ArchipelagoConstants { public const float MaxHeadsChance = 0.95f; public const float MinFlipTime = 0.2f; public const float MaxFlipTime = 5f; public const float MaxComboMultiplier = 3.5f; public const float MinComboMultiplier = 1.2f; public const float MaxAutoFlipAddition = 5f; public const float MinAutoFlipAddition = 0.5f; public const int ShopLayers = 2; public static int[] CoinValues = new int[5] { 1, 5, 10, 25, 100 }; } public class ArchipelagoHandler : MonoBehaviour { private string seed; private readonly ConcurrentQueue locationsToCheck = new ConcurrentQueue(); private string lastDeath; private DateTime lastDeathLinkTime = DateTime.Now; private readonly Random random = new Random(); private string energyLinkKey; private readonly string[] deathMessages = new string[3] { "had a skill issue (died)", "RNGesus has smitten you on this day (died)", "You probably shouldn't go to the lottery... (died)" }; private const float ConnectTimeoutSeconds = 15f; private ArchipelagoSession Session { get; set; } private string Server { get; set; } private int Port { get; set; } private string Slot { get; set; } private string Password { get; set; } public bool IsConnected { get { ArchipelagoSession session = Session; return session != null && session.Socket.Connected; } } public bool IsConnecting { get; private set; } private MessageManager MessageManager => Object.FindObjectOfType(); public event Action OnConnected; public event Action OnConnectionFailed; public event Action OnDisconnected; private static string GetColorHex(PaletteColor? color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown if (1 == 0) { } string result = color switch { (PaletteColor)2L => "#EE0000", (PaletteColor)3L => "#00FF7F", (PaletteColor)7L => "#FAFAD2", (PaletteColor)4L => "#6495ED", (PaletteColor)6L => "#EE00EE", (PaletteColor)5L => "#00EEEE", (PaletteColor)1L => "#000000", (PaletteColor)0L => "#FFFFFF", (PaletteColor)8L => "#6D8BE8", (PaletteColor)9L => "#FA8072", (PaletteColor)10L => "#AF99EF", _ => "#FFFFFF", }; if (1 == 0) { } return result; } public void CreateSession(string server, int port, string slot, string password) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown Server = server; Port = port; Slot = slot; Password = password; Session = ArchipelagoSessionFactory.CreateSession(Server, Port); Session.MessageLog.OnMessageReceived += new MessageReceivedHandler(OnMessageReceived); Session.Socket.ErrorReceived += new ErrorReceivedHandler(OnError); Session.Socket.SocketClosed += new SocketClosedHandler(OnSocketClosed); Session.Socket.PacketReceived += new PacketReceivedHandler(PacketReceived); Session.Items.ItemReceived += new ItemReceivedHandler(ItemReceived); } private void OnDestroy() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown Session.MessageLog.OnMessageReceived -= new MessageReceivedHandler(OnMessageReceived); Session.Socket.ErrorReceived -= new ErrorReceivedHandler(OnError); Session.Socket.SocketClosed -= new SocketClosedHandler(OnSocketClosed); Session.Socket.PacketReceived -= new PacketReceivedHandler(PacketReceived); Session.Items.ItemReceived -= new ItemReceivedHandler(ItemReceived); } public void Connect() { if (IsConnecting) { Log.Warning("Connect requested while already connecting; ignoring."); } else { ((MonoBehaviour)this).StartCoroutine(ConnectRoutine()); } } private IEnumerator ConnectRoutine() { IsConnecting = true; try { Log.Message($"Logging in to {Server}:{Port} as {Slot}..."); Task connectTask = Session.ConnectAsync(); foreach (object item in WaitForTask(connectTask)) { yield return item; } if (!connectTask.IsCompleted) { Fail($"Connection to {Server}:{Port} timed out after {15f:0}s. " + "Check the hostname/port and that the server is online."); yield break; } if (connectTask.IsFaulted) { Fail($"Could not reach {Server}:{Port}: {Describe(connectTask.Exception)}"); yield break; } ArchipelagoHandler archipelagoHandler = this; RoomInfoPacket result = connectTask.Result; archipelagoHandler.seed = ((result != null) ? result.SeedName : null); Task loginTask = Session.LoginAsync("Unfair Flips", Slot, (ItemsHandlingFlags)7, new Version(0, 6, 7), Array.Empty(), (string)null, Password, true); foreach (object item2 in WaitForTask(loginTask)) { yield return item2; } if (!loginTask.IsCompleted) { Fail($"Login to {Server}:{Port} as {Slot} timed out after {15f:0}s."); yield break; } if (loginTask.IsFaulted) { Fail("Login failed: " + Describe(loginTask.Exception)); yield break; } LoginResult result2 = loginTask.Result; if (result2.Successful) { Log.Message($"Success! Connected to {Server}:{Port}"); LoginSuccessful successResult = (LoginSuccessful)result2; UnfairFlipsAPMod.SlotData = new SlotData(successResult.SlotData); if (seed != null) { UnfairFlipsAPMod.SaveDataHandler.GetSaveGame(seed, Slot); } Object.FindObjectOfType().SetPanelArrangement(2); UnfairFlipsAPMod.GameHandler.InitOnConnect(); ((MonoBehaviour)this).StartCoroutine(RunCheckQueue()); this.OnConnected?.Invoke(); } else { LoginFailure failure = (LoginFailure)result2; string errorMessage = Enumerable.Aggregate(seed: Enumerable.Aggregate(seed: $"Failed to connect to {Server}:{Port} as {Slot}:", source: failure.Errors, func: (string current, string error) => current + "\n " + error), source: failure.ErrorCodes, func: (string current, ConnectionRefusedError error) => current + $"\n {error}"); Fail(errorMessage); } } finally { IsConnecting = false; } } private static IEnumerable WaitForTask(Task task) { float elapsed = 0f; while (!task.IsCompleted && elapsed < 15f) { elapsed += Time.deltaTime; yield return null; } } private void Fail(string message) { Log.Error(message); this.OnConnectionFailed?.Invoke(message); } private static string Describe(Exception ex) { if (ex is AggregateException ex2) { ex = ex2.Flatten().InnerExceptions.FirstOrDefault() ?? ex2; } return ex?.Message ?? "unknown error"; } public void Disconnect() { if (Session != null) { ((MonoBehaviour)this).StopAllCoroutines(); Session.Socket.DisconnectAsync(); Session = null; Log.Message("Disconnected from Archipelago"); } } private void OnError(Exception ex, string message) { Log.Error("Socket error: " + message + " - " + ex.Message); } private void OnSocketClosed(string reason) { ((MonoBehaviour)this).StopAllCoroutines(); Log.Warning("Socket closed: " + reason); this.OnDisconnected?.Invoke(); } private void ItemReceived(ReceivedItemsHelper helper) { try { int valueOrDefault = (UnfairFlipsAPMod.SaveDataHandler?.SaveData?.ItemIndex).GetValueOrDefault(); while (helper.Any()) { ItemInfo item = helper.DequeueItem(); int num = helper.Index - 1; if (num >= valueOrDefault) { UnfairFlipsAPMod.ItemHandler.HandleItem(num, item); } } } catch (Exception arg) { Log.Error($"ItemReceived Error: {arg}"); throw; } } public void Release() { Session.SetGoalAchieved(); Session.SetClientState((ArchipelagoClientState)30); } public void CheckLocations(long[] ids) { ids.ToList().ForEach(delegate(long id) { locationsToCheck.Enqueue(id); }); } public void CheckLocation(long id) { if (!IsLocationChecked(id)) { locationsToCheck.Enqueue(id); } } private IEnumerator RunCheckQueue() { while (true) { if (locationsToCheck.TryDequeue(out var locationId)) { Session.Locations.CompleteLocationChecks(new long[1] { locationId }); Log.Message($"Sent location check: {locationId}"); } yield return (object)new WaitForSeconds(0.1f); } } public bool IsLocationChecked(long id) { return Session.Locations.AllLocationsChecked.Contains(id); } public int CountLocationsCheckedInRange(long start, long end) { return Session.Locations.AllLocationsChecked.Count((long loc) => loc >= start && loc < end); } public void UpdateTags(List tags) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown ConnectUpdatePacket val = new ConnectUpdatePacket { Tags = tags.ToArray(), ItemsHandling = (ItemsHandlingFlags)7 }; Session.Socket.SendPacket((ArchipelagoPacketBase)(object)val); } private void OnMessageReceived(LogMessage message) { if (((object)message).GetType().Name.Contains("Hint")) { try { PropertyInfo property = ((object)message).GetType().GetProperty("FindingPlayer"); PropertyInfo property2 = ((object)message).GetType().GetProperty("Item"); if (property != null && property2 != null) { object value = property.GetValue(message); object value2 = property2.GetValue(message); if (value != null && value2 != null) { PropertyInfo property3 = value.GetType().GetProperty("Slot"); PropertyInfo property4 = value2.GetType().GetProperty("Location"); if (property3 != null && property4 != null) { int num = Convert.ToInt32(property3.GetValue(value)); long num2 = Convert.ToInt64(property4.GetValue(value2)); if (num == Session.ConnectionInfo.Slot && num2 >= 512) { return; } } } } } catch (Exception) { } } if (message.Parts.Any((MessagePart x) => (int)x.Type == 1) && UnfairFlipsAPMod.FilterLog != null && UnfairFlipsAPMod.FilterLog.Value && !message.Parts.Any((MessagePart x) => x.Text.Contains(Session.Players.GetPlayerName(Session.ConnectionInfo.Slot)))) { return; } string message2; if (message.Parts.Length == 1) { message2 = message.Parts[0].Text; } else { StringBuilder stringBuilder = new StringBuilder(); MessagePart[] parts = message.Parts; foreach (MessagePart val in parts) { string colorHex = GetColorHex(val.PaletteColor); stringBuilder.Append("" + val.Text + ""); } message2 = stringBuilder.ToString(); } AddMessageToGameLog(message2); } public void AddMessageToGameLog(string message) { ((MonoBehaviour)this).StartCoroutine(AddMessageToGameLogRoutine(message)); } private IEnumerator AddMessageToGameLogRoutine(string message) { yield return null; MessageManager messageManager = MessageManager; if (messageManager != null) { messageManager.ShowMessage(message); } } private void PacketReceived(ArchipelagoPacketBase packet) { BouncePacket val = (BouncePacket)(object)((packet is BouncePacket) ? packet : null); if (val != null) { BouncePacketReceived(val); } } public void SendDeath() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown BouncePacket val = new BouncePacket(); DateTime now = DateTime.Now; if (now - lastDeathLinkTime < TimeSpan.FromSeconds(2.0)) { return; } val.Tags = new List(1) { "DeathLink" }; val.Data = new Dictionary { { "time", JToken.op_Implicit(UnixTimeConverter.ToUnixTimeStamp(now)) }, { "source", JToken.op_Implicit(Slot) }, { "cause", JToken.op_Implicit(Slot + " " + deathMessages[random.Next(deathMessages.Length)]) } }; if (val.Data.TryGetValue("source", out var value)) { string text = ((object)value)?.ToString() ?? "Unknown"; if (val.Data.TryGetValue("cause", out var value2)) { string text2 = ((object)value2)?.ToString() ?? "Unknown"; if (val.Data.TryGetValue("time", out var value3)) { string text3 = ((object)value3)?.ToString() ?? "Unknown"; } } } lastDeathLinkTime = now; Session.Socket.SendPacket((ArchipelagoPacketBase)(object)val); } private void BouncePacketReceived(BouncePacket packet) { if (UnfairFlipsAPMod.SlotData.DeathLink) { ProcessBouncePacket(packet, "DeathLink", ref lastDeath, delegate(string source, Dictionary data) { JToken value; string cause = (data.TryGetValue("cause", out value) ? ((object)value).ToString() : (source + " has died.")); HandleDeathLink(source, cause); }); } } private static void ProcessBouncePacket(BouncePacket packet, string tag, ref string lastTime, Action> handler) { if (!packet.Tags.Contains(tag) || !packet.Data.TryGetValue("time", out var value) || lastTime == ((object)value).ToString()) { return; } lastTime = ((object)value).ToString(); if (packet.Data.TryGetValue("source", out var value2)) { string arg = ((object)value2)?.ToString() ?? "Unknown"; if (packet.Data.TryGetValue("cause", out var value3)) { string text = ((object)value3)?.ToString() ?? "Unknown"; } handler(arg, packet.Data); } } private void HandleDeathLink(string source, string cause) { if (UnfairFlipsAPMod.SlotData.DeathLink) { AddMessageToGameLog(cause); if (!(source == Slot)) { UnfairFlipsAPMod.GameHandler.Kill(); } } } public ScoutedItemInfo TryScoutLocation(long locationId, bool createHint = false) { return Session.Locations.ScoutLocationsAsync(createHint, new long[1] { locationId })?.Result?.Values.First(); } public string GetPlayerName(int player) { return Session.Players.GetPlayerAlias(player) ?? $"Player {player}"; } public string GetLocationName(long locationId) { return Session.Locations.GetLocationNameFromId(locationId, (string)null) ?? $"Location {locationId}"; } public void DisplayItemCounts() { if (Session == null || !IsConnected) { AddMessageToGameLog("Not connected to Archipelago."); return; } ReadOnlyCollection allItemsReceived = Session.Items.AllItemsReceived; if (allItemsReceived.Count == 0) { AddMessageToGameLog("No items received yet."); return; } Dictionary dictionary = new Dictionary(); foreach (ItemInfo item in allItemsReceived) { string itemName = item.ItemName; bool flag; switch (itemName) { case "$": case "$$": case "$$$": flag = true; break; default: flag = false; break; } if (!flag) { if (dictionary.ContainsKey(itemName)) { dictionary[itemName]++; } else { dictionary[itemName] = 1; } } } AddMessageToGameLog("Upgrades Received:"); foreach (KeyValuePair item2 in dictionary.OrderByDescending((KeyValuePair x) => x.Value)) { AddMessageToGameLog($"{item2.Key}: {item2.Value}"); } } public void DisplayAutoFlipMsg() { AddMessageToGameLog($"Autoflip Time Is {UnfairFlipsAPMod.SaveDataHandler.SaveData.AutoFlipAddition:F} Seconds."); } public void DisplayResyncMsg() { AddMessageToGameLog("Resyncing items from Archipelago."); } } public class AutoFlipIconHandler { private static Sprite _autoFlipOnSprite; private static Sprite _autoFlipOffSprite; private static GameObject _autoFlipButtonObject; public static bool IsAutoFlipEnabled; public static bool IsVisible { get { return (Object)(object)_autoFlipButtonObject != (Object)null && _autoFlipButtonObject.activeSelf; } set { if ((Object)(object)_autoFlipButtonObject != (Object)null && _autoFlipButtonObject.activeSelf != value) { _autoFlipButtonObject.SetActive(value); } } } public static void CreateButton() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown GameObject gameObject = ((Component)Object.FindObjectOfType()).gameObject; Transform parent = gameObject.transform.parent; _autoFlipButtonObject = Object.Instantiate(gameObject, parent); ((Object)_autoFlipButtonObject).name = "AutoFlipButton"; Object.Destroy((Object)(object)_autoFlipButtonObject.GetComponent()); Image image = _autoFlipButtonObject.GetComponent(); string path = Path.Combine(UnfairFlipsAPMod.PluginDir, "AutoFlipIcon.png"); byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; _autoFlipOnSprite = Sprite.Create(val, new Rect(0f, 0f, 33f, 34f), new Vector2(0.5f, 0.5f), 100f); _autoFlipOffSprite = Sprite.Create(val, new Rect(34f, 0f, 34f, 34f), new Vector2(0.5f, 0.5f), 100f); image.sprite = _autoFlipOffSprite; image.preserveAspect = true; IsAutoFlipEnabled = false; _autoFlipButtonObject.transform.localPosition = new Vector3(250f, 400f, 0f); Button component = _autoFlipButtonObject.GetComponent