コード例 #1
0
        /// <summary>
        /// Process an asset and register it for further reprocessing in the future.
        /// Apply any mod-related changes to the asset based on the existing mod asset meta map.
        /// </summary>
        /// <param name="asset">The asset to process.</param>
        /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param>
        /// <returns>The processed asset.</returns>
        public static object Process(object asset, string assetNameFull)
        {
            string assetName = assetNameFull;

            if (string.IsNullOrEmpty(PathContentOrig) && !string.IsNullOrEmpty(ModManager.PathGame))
            {
                PathContentOrig = Path.Combine(ModManager.PathGame, "Content");
            }
            if (!string.IsNullOrEmpty(PathContentOrig) && assetName.StartsWith(PathContentOrig))
            {
                assetName = assetName.Substring(PathContentOrig.Length + 1);
            }

            int loadedIndex = LoadedAssetPaths.IndexOf(assetName);

            if (loadedIndex == -1)
            {
                LoadedAssetPaths.Add(assetName);
                LoadedAssetFullPaths.Add(assetNameFull);
                LoadedAssets.Add(new WeakReference(asset));
            }
            else
            {
                LoadedAssets[loadedIndex] = new WeakReference(asset);
            }

            return(OnProcess?.InvokePassing(asset, assetNameFull) ?? asset);
        }
コード例 #2
0
            /// <summary>
            /// Process an asset and register it for further reprocessing in the future.
            /// Apply any mod-related changes to the asset based on the existing mod asset meta map.
            /// </summary>
            /// <param name="asset">The asset to process.</param>
            /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param>
            /// <returns>The processed asset.</returns>
            public static object Process(object asset, string assetNameFull)
            {
                if (DumpOnLoad)
                {
                    Dump(assetNameFull, asset);
                }

                string assetName = assetNameFull;

                if (assetName.StartsWith(PathContentOrig))
                {
                    assetName = assetName.Substring(PathContentOrig.Length + 1);
                }

                int loadedIndex = LoadedAssetPaths.IndexOf(assetName);

                if (loadedIndex == -1)
                {
                    LoadedAssetPaths.Add(assetName);
                    LoadedAssetFullPaths.Add(assetNameFull);
                    LoadedAssets.Add(new WeakReference(asset));
                }
                else
                {
                    LoadedAssets[loadedIndex] = new WeakReference(asset);
                }

                if (asset is Atlas)
                {
                    Atlas    atlas = asset as Atlas;
                    ModAsset mapping;

                    mapping = Get(assetName + "LQ", true);
                    if (mapping != null && mapping.AssetType == typeof(AssetTypeDirectory))
                    {
                        atlas.Ingest(mapping);
                    }

                    mapping = Get(assetName, true);
                    if (mapping != null && mapping.AssetType == typeof(AssetTypeDirectory))
                    {
                        atlas.Ingest(mapping);
                    }

                    return(asset);
                }

                return(OnProcess?.InvokePassing(asset, assetNameFull) ?? asset);
            }