using System; 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 HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: AssemblyCompany("WK_Stamina_To_Hue")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WK Stamina To Hue")] [assembly: AssemblyTitle("WK_Stamina_To_Hue")] [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 WK_Stamina_To_Hue { [BepInPlugin("WK_Stamina_To_Hue", "WK Stamina To Hue", "1.0.0")] public class Phoeboi_S2H : BaseUnityPlugin { internal static ManualLogSource Logger; private Harmony _harmony; public static AssetBundle AB; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin WK_Stamina_To_Hue is loaded!"); Logger.LogInfo((object)"WK_Stamina_To_Hue credits - Phoeboi (also goes by alias Phoenix Indie)"); _harmony = new Harmony("Phoeboi WK Stamina To Hue"); _harmony.PatchAll(); Logger.LogInfo((object)"Phoeboi's WK Stamina To Hue (PWKS2H) Harmony Patches applied successfully."); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "pwks2h.bundle"); if (!File.Exists(text)) { Logger.LogError((object)("PWKS2H - Asset bundle not found at: " + text)); return; } Logger.LogInfo((object)("PWKS2H - Asset bundle found at: " + text)); Logger.LogInfo((object)"PWKS2H - Loading asset bundle pwks2h.bundle."); AB = AssetBundle.LoadFromFile(text); AB.LoadAllAssets(); } } public class HarmonyThing { [HarmonyPatch(typeof(Cosmetic_HandItem))] [HarmonyPatch("Initialize")] public static class Cosmetic_HandItem_Patch { [HarmonyPostfix] private static void PhoeFix(Cosmetic_HandItem __instance) { Debug.Log((object)("PWKS2H - Harmony Postfix on Initialize() initiated on " + __instance.cosmeticData.id + ".")); Material val = Resources.Load("Cosmetics/Materials/" + __instance.cosmeticData.globalMaterialBase); if (!((Object)(object)val == (Object)null) || !(__instance.cosmeticData.globalMaterialBase != "")) { return; } val = Phoeboi_S2H.AB.LoadAsset("assets/resources/cosmetics/materials/" + __instance.cosmeticData.globalMaterialBase + ".mat"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("PWKS2H - " + __instance.cosmeticData.globalMaterialBase + " not found in pwks2h.bundle.")); return; } Debug.Log((object)("PWKS2H - " + __instance.cosmeticData.globalMaterialBase + " found in pwks2h.bundle.")); Debug.Log((object)("PWKS2H - Adding " + __instance.cosmeticData.globalMaterialBase + " to materialDict.")); materialDictRef.Invoke(__instance).Add(__instance.cosmeticData.globalMaterialBase, Object.Instantiate(val)); Debug.Log((object)("PWKS2H - Applying " + __instance.cosmeticData.globalMaterialBase + " to globalMaterialSwap.")); globalMaterialSwapRef.Invoke(__instance.cosmeticData) = val; Debug.Log((object)("PWKS2H - Applying " + __instance.cosmeticData.globalMaterialBase + " to spawSprite materials (swapSprite loop).")); foreach (SwapSprite swapSprite in __instance.cosmeticData.swapSprites) { if (!string.IsNullOrEmpty(swapSprite.materialBase)) { Material val2 = Object.Instantiate(Phoeboi_S2H.AB.LoadAsset("assets/resources/cosmetics/materials/" + __instance.cosmeticData.globalMaterialBase + ".mat")); if ((Object)(object)val2 != (Object)null) { materialDictRef.Invoke(__instance).Add(swapSprite.materialBase, val2); } swapSpriteMatRef.Invoke(swapSprite) = val2; } } } } private static readonly FieldRef> materialDictRef = AccessTools.FieldRefAccess>("materialDict"); private static readonly FieldRef globalMaterialSwapRef = AccessTools.FieldRefAccess("globalMaterialSwap"); private static readonly FieldRef swapSpriteMatRef = AccessTools.FieldRefAccess("material"); } public static class MyPluginInfo { public const string PLUGIN_GUID = "WK_Stamina_To_Hue"; public const string PLUGIN_NAME = "WK Stamina To Hue"; public const string PLUGIN_VERSION = "1.0.0"; } }