Example #1
0
        public static bool LoadAssetPostHook(ref AssetBundleLoadAssetOperation __result, string assetBundleName, string assetName, Type type, string manifestAssetBundleName)
        {
            __result = ResourceRedirector.HandleAsset(assetBundleName, assetName, type, manifestAssetBundleName, ref __result);

            if (__result != null)
            {
                return(false);
            }

            return(true);
        }
        public static bool LoadAssetAsyncPreHook(ref AssetBundleLoadAssetOperation __result, ref string assetBundleName, ref string assetName, Type type, string manifestAssetBundleName)
        {
            __result = ResourceRedirector.HandleAsset(assetBundleName, assetName, type, manifestAssetBundleName, ref __result);

            //Redirect KK vanilla assets to EC vanilla assets
            if (__result == null && !ResourceRedirector.AssetBundleExists(assetBundleName) && assetBundleName.EndsWith(".unity3d") && assetBundleName.StartsWith("chara/"))
            {
                string temp = assetBundleName.Replace(".unity3d", "");
                if (temp.Length >= 2)
                {
                    temp = temp.Substring(temp.Length - 2, 2);
                    if (int.TryParse(temp, out _))
                    {
                        if (assetBundleName.StartsWith("chara/thumb/") && !assetBundleName.StartsWith($"chara/thumb/{temp}/"))
                        {
                            temp     = assetBundleName.Replace("chara/thumb/", $"chara/thumb/{temp}/");
                            __result = AssetBundleManager.LoadAssetAsync(temp, assetName, type, manifestAssetBundleName);
                            return(false);
                        }
                        else if (assetBundleName.StartsWith("chara/") && !assetBundleName.StartsWith($"chara/{temp}/"))
                        {
                            temp     = assetBundleName.Replace("chara/", $"chara/{temp}/");
                            __result = AssetBundleManager.LoadAssetAsync(temp, assetName, type, manifestAssetBundleName);
                            return(false);
                        }
                    }
                }
            }

            if (__result == null)
            {
                if (!ResourceRedirector.AssetBundleExists(assetBundleName))
                {
                    //An asset that does not exist is being requested from from an asset bundle that does not exist
                    //Redirect to an asset bundle the does exist so that the game does not attempt to open a non-existant file and cause errors
                    ResourceRedirector.Logger.Log(LogLevel.Debug, $"Asset {assetName} does not exist in asset bundle {assetBundleName}.");
                    assetBundleName = "chara/00/mt_ramp_00.unity3d";
                    assetName       = "dummy";
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static bool LoadAssetAsyncPreHook(ref AssetBundleLoadAssetOperation __result, ref string assetBundleName, ref string assetName, Type type, string manifestAssetBundleName)
        {
            __result = ResourceRedirector.HandleAsset(assetBundleName, assetName, type, manifestAssetBundleName, ref __result);

            if (__result == null)
            {
                if (!ResourceRedirector.AssetBundleExists(assetBundleName))
                {
                    //An asset that does not exist is being requested from from an asset bundle that does not exist
                    //Redirect to an asset bundle the does exist so that the game does not attempt to open a non-existant file and cause errors
                    ResourceRedirector.Logger.Log(LogLevel.Debug, $"Asset {assetName} does not exist in asset bundle {assetBundleName}.");
                    assetBundleName = "chara/mt_ramp_00.unity3d";
                    assetName       = "dummy";
                }
                return(true);
            }

            return(false);
        }
Example #4
0
        public static void LoadAssetAsyncPostHook(ref AssetBundleLoadAssetOperation __result, string assetBundleName, string assetName, Type type, string manifestAssetBundleName)
        {
            //BepInLogger.Log($"{assetBundleName} : {assetName} : {type.FullName} : {manifestAssetBundleName ?? ""}", true);

            __result = ResourceRedirector.HandleAsset(assetBundleName, assetName, type, manifestAssetBundleName, ref __result);
        }