using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; 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: AssemblyCompany("GWYFSlotCustomizer")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+16eabb6c25fb155a7ef90d0bf1a928b2551cf2be")] [assembly: AssemblyProduct("GWYFSlotCustomizer")] [assembly: AssemblyTitle("GWYFSlotCustomizer")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace GWYFSlotCustomizer { [HarmonyPatch(typeof(SlotReel), "Awake")] public static class PatchSlotReelAwake { private struct SlotSymbolReplacement { public int Index; public string DisplayName; public string FileName; public SlotSymbolReplacement(int index, string displayName, string fileName) { Index = index; DisplayName = displayName; FileName = fileName; } } private static readonly SlotSymbolReplacement[] Replacements = new SlotSymbolReplacement[4] { new SlotSymbolReplacement(0, "flower", "flower.png"), new SlotSymbolReplacement(1, "beetle", "beetle.png"), new SlotSymbolReplacement(2, "ankh", "ankh.png"), new SlotSymbolReplacement(3, "eye", "eye.png") }; private static void Postfix(SlotReel __instance) { if (__instance.atlas == null || __instance.atlas.Length == 0) { Plugin.Log.LogWarning((object)"SlotReel atlas is missing."); return; } string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); string text = Path.Combine(directoryName, "symbols"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); Plugin.Log.LogWarning((object)("Created symbols folder: " + text)); Plugin.Log.LogWarning((object)"Put flower.png, beetle.png, ankh.png or eye.png there to replace symbols."); return; } SlotSymbolReplacement[] replacements = Replacements; foreach (SlotSymbolReplacement replacement in replacements) { TryReplaceSymbol(__instance, text, replacement); } } private static void TryReplaceSymbol(SlotReel reel, string symbolsFolder, SlotSymbolReplacement replacement) { if (reel.atlas.Length <= replacement.Index) { Plugin.Log.LogWarning((object)$"Cannot replace {replacement.DisplayName}: atlas only has {reel.atlas.Length} symbols."); return; } string text = Path.Combine(symbolsFolder, replacement.FileName); if (!File.Exists(text)) { return; } Sprite val = reel.atlas[replacement.Index]; Sprite val2 = LoadSprite(text, replacement.DisplayName); if ((Object)(object)val2 == (Object)null) { return; } reel.atlas[replacement.Index] = val2; if (reel.symbols != null) { Image[] symbols = reel.symbols; foreach (Image val3 in symbols) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.sprite == (Object)(object)val) { val3.sprite = val2; } } } Plugin.Log.LogInfo((object)("Replaced " + replacement.DisplayName + ": " + ((Object)val).name + " -> " + ((Object)val2).name)); } private static Sprite? LoadSprite(string filePath, string displayName) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) try { byte[] array = File.ReadAllBytes(filePath); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { Plugin.Log.LogWarning((object)("Failed to load image: " + filePath)); return null; } ((Object)val).name = "GWYFSlotCustomizer_" + displayName + "_Texture"; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)val2).name = "GWYFSlotCustomizer_" + displayName + "_Sprite"; return val2; } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to replace {displayName}: {arg}"); return null; } } } [BepInPlugin("com.agonyz.gwyf.slotcustomizer", "GWYF Slot Customizer", "0.1.2")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.agonyz.gwyf.slotcustomizer"; public const string PluginName = "GWYF Slot Customizer"; public const string PluginVersion = "0.1.2"; internal static ManualLogSource Log; private readonly Harmony _harmony = new Harmony("com.agonyz.gwyf.slotcustomizer"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; _harmony.PatchAll(); Log.LogInfo((object)"GWYF Slot Customizer v0.1.2 loaded."); } private void OnDestroy() { _harmony.UnpatchSelf(); } } }