using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx.Logging; 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.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("HowToFish.ModKit")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5554268e42ae4803814c23b41e24d3c196693022")] [assembly: AssemblyProduct("HowToFish.ModKit")] [assembly: AssemblyTitle("How to Fish - Mod Kit runtime")] [assembly: AssemblyVersion("1.0.0.0")] [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 HowToFish.ModKit { public static class BundleLoader { private static readonly Dictionary Loaded = new Dictionary(StringComparer.OrdinalIgnoreCase); public static ManualLogSource Log { get; set; } public static string PluginDirectoryOf(object plugin) { return Path.GetDirectoryName(plugin.GetType().Assembly.Location); } public static AssetBundle Load(object plugin, string bundleFileName) { return LoadFrom(Path.Combine(PluginDirectoryOf(plugin), bundleFileName)); } public static AssetBundle LoadFrom(string fullPath) { string fullPath2 = Path.GetFullPath(fullPath); if (Loaded.TryGetValue(fullPath2, out var value) && (Object)(object)value != (Object)null) { return value; } if (!File.Exists(fullPath2)) { ManualLogSource log = Log; if (log != null) { log.LogError((object)("Asset bundle not found: " + fullPath2)); } return null; } AssetBundle val = AssetBundle.LoadFromFile(fullPath2); if ((Object)(object)val == (Object)null) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogError((object)("Failed to load asset bundle: " + fullPath2 + ". It was most likely built with a different Unity version than 6000.4.x.")); } return null; } Loaded[fullPath2] = val; ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)$"Loaded bundle {Path.GetFileName(fullPath2)} ({val.GetAllAssetNames().Length} assets)"); } return val; } public static T Asset(AssetBundle bundle, string name) where T : Object { if ((Object)(object)bundle == (Object)null) { return default(T); } T val = bundle.LoadAsset(name); if ((Object)(object)val == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogError((object)("Asset '" + name + "' of type " + typeof(T).Name + " not found in bundle. Available: " + string.Join(", ", bundle.GetAllAssetNames()))); } return default(T); } object obj = val; GameObject val2 = (GameObject)((obj is GameObject) ? obj : null); if (val2 != null) { ShaderFix.Apply(val2); } else { object obj2 = val; Material val3 = (Material)((obj2 is Material) ? obj2 : null); if (val3 != null) { ShaderFix.Apply(val3); } } return val; } public static GameObject Prefab(AssetBundle bundle, string name) { return BundleLoader.Asset(bundle, name); } public static void UnloadAll(bool unloadLoadedObjects = false) { foreach (AssetBundle value in Loaded.Values) { if ((Object)(object)value != (Object)null) { value.Unload(unloadLoadedObjects); } } Loaded.Clear(); } } public static class ShaderFix { private static readonly Dictionary Cache = new Dictionary(); public static bool Enabled = true; public static void Apply(GameObject root) { if (!Enabled || (Object)(object)root == (Object)null) { return; } Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material material in sharedMaterials) { Apply(material); } } } public static void Apply(Material material) { if (!Enabled || (Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null) { return; } string name = ((Object)material.shader).name; if (!Cache.TryGetValue(name, out var value)) { value = Shader.Find(name); Cache[name] = value; } if ((Object)(object)value == (Object)null) { ManualLogSource log = BundleLoader.Log; if (log != null) { log.LogWarning((object)("Shader '" + name + "' is not present in the game build; material '" + ((Object)material).name + "' will render incorrectly. Author it with a URP shader the game already uses (Universal Render Pipeline/Lit).")); } } else { int renderQueue = material.renderQueue; material.shader = value; material.renderQueue = renderQueue; } } } }