using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: AssemblyCompany("ScoutCookiesRandomizer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Randomizes thick mints/vanilla wafers")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ScoutCookiesRandomizer")] [assembly: AssemblyTitle("ScoutCookiesRandomizer")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ScoutCookiesRandomizer { internal class CookieSkinner : MonoBehaviour { internal static bool vanilla; internal static Material mVanillaWafers; internal static Texture2D scoutCookies; internal static Texture2D scoutCookiesVanilla; private void Start() { if (!vanilla) { return; } if ((Object)(object)mVanillaWafers == (Object)null || (Object)(object)scoutCookiesVanilla == (Object)null) { Plugin.Log.LogError((object)("Failed to initialize CookieSkinner for object \"" + ((Object)this).name + "\"")); ((Behaviour)this).enabled = false; return; } MeshRenderer component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).material = mVanillaWafers; Plugin.Log.LogDebug((object)("Replaced material for \"" + ((Object)this).name + "\"")); } } } [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(Pretitle), "Start")] [HarmonyPostfix] private static void Pretitle_Post_Start() { int num = 0; Item[] array = Resources.FindObjectsOfTypeAll(); foreach (Item val in array) { if (!((Object)val).name.StartsWith("ScoutCookies")) { continue; } if (((Object)val).name == "ScoutCookies_Vanilla") { Transform transform = ((Component)val).transform; object mVanillaWafers; if (transform == null) { mVanillaWafers = null; } else { Transform obj = transform.Find("thick mints"); if (obj == null) { mVanillaWafers = null; } else { MeshRenderer component = ((Component)obj).GetComponent(); mVanillaWafers = ((component != null) ? ((Renderer)component).sharedMaterial : null); } } CookieSkinner.mVanillaWafers = (Material)mVanillaWafers; if ((Object)(object)CookieSkinner.mVanillaWafers != (Object)null) { num++; Plugin.Log.LogDebug((object)("Cached material \"" + ((Object)CookieSkinner.mVanillaWafers).name + "\"")); } CookieSkinner.scoutCookiesVanilla = val.UIData?.icon; if ((Object)(object)CookieSkinner.scoutCookiesVanilla != (Object)null) { num++; Plugin.Log.LogDebug((object)$"Cached sprite \"{CookieSkinner.scoutCookiesVanilla}\""); } } else { CookieSkinner.scoutCookies = val.UIData?.icon; if ((Object)(object)CookieSkinner.scoutCookies != (Object)null) { num++; Plugin.Log.LogDebug((object)$"Cached sprite \"{CookieSkinner.scoutCookies}\""); } Transform transform2 = ((Component)val).transform; Transform val2 = ((transform2 != null) ? transform2.Find("thick mints") : null); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.AddComponent(); num++; Plugin.Log.LogDebug((object)("Hooked prefab \"" + ((Object)((Component)val).gameObject).name + "\"")); } } } if (num < 4) { Plugin.Log.LogError((object)$"Failed to complete start-up tasks ({num}/4)"); } } [HarmonyPatch(typeof(ItemUIData), "GetIcon")] [HarmonyPrefix] private static bool Item_ItemUIData_Pre_GetIcon(ItemUIData __instance, ref Texture2D __result) { if ((Object)(object)CookieSkinner.scoutCookies != (Object)null && (Object)(object)__instance.icon == (Object)(object)CookieSkinner.scoutCookies && CookieSkinner.vanilla && (Object)(object)CookieSkinner.scoutCookiesVanilla != (Object)null) { __result = CookieSkinner.scoutCookiesVanilla; return false; } return true; } } [BepInPlugin("butterystancakes.peak.scoutcookiesrandomizer", "Scout Cookies Randomizer", "1.0.0")] public class Plugin : BaseUnityPlugin { internal const string PLUGIN_GUID = "butterystancakes.peak.scoutcookiesrandomizer"; internal const string PLUGIN_NAME = "Scout Cookies Randomizer"; internal const string PLUGIN_VERSION = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("butterystancakes.peak.scoutcookiesrandomizer").PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogInfo((object)"Scout Cookies Randomizer v1.0.0 loaded"); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name.ToLower().StartsWith("level")) { Random random = new Random(BitConverter.ToInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Application.version + ((Scene)(ref scene)).name)))); random.NextDouble(); CookieSkinner.vanilla = random.NextDouble() >= 0.5; Log.LogDebug((object)("Cookies: " + (CookieSkinner.vanilla ? "Vanilla Wafers" : "Thick Mints") + " (\"" + ((Scene)(ref scene)).name + "\" - v" + Application.version + ")")); } } } public static class PluginInfo { public const string PLUGIN_GUID = "ScoutCookiesRandomizer"; public const string PLUGIN_NAME = "ScoutCookiesRandomizer"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }