protected override AssetInfo_Base CreateAssetInfoRaw(CapsResManifestItem item)
 {
     return(new AssetInfo_Scene()
     {
         ManiItem = item
     });
 }
 protected virtual AssetInfo_Base CreateAssetInfoRaw(CapsResManifestItem item)
 {
     return(new AssetInfo_Normal()
     {
         ManiItem = item
     });
 }
コード例 #3
0
 public static void MergeManifestNode(CapsResManifestNode mynode, CapsResManifestNode thnode, bool ignoreExt)
 {
     if (thnode.Children != null && thnode.Children.Count > 0)
     {
         if (mynode.Children == null)
         {
             mynode.Children = new SortedList <string, CapsResManifestNode>();
         }
         foreach (var kvpChild in thnode.Children)
         {
             var key = kvpChild.Key;
             if (ignoreExt && kvpChild.Value.Item != null)
             {
                 key = System.IO.Path.GetFileNameWithoutExtension(key);
             }
             CapsResManifestNode mychild;
             if (!mynode.Children.TryGetValue(key, out mychild))
             {
                 mychild = new CapsResManifestNode(mynode, key);
                 mynode.Children[key] = mychild;
             }
             if (kvpChild.Value.Item != null)
             {
                 CapsResManifestItem item;
                 item         = new CapsResManifestItem(mychild);
                 item.Type    = (int)CapsResManifestItemType.Redirect;
                 item.Ref     = kvpChild.Value.Item;
                 mychild.Item = item;
             }
             MergeManifestNode(mychild, kvpChild.Value, ignoreExt);
         }
     }
 }
コード例 #4
0
                public static string FormatBundleName(CapsResManifestItem item)
                {
                    var node  = item.Node;
                    var depth = node.GetDepth();

                    string[] parts = new string[depth];
                    for (int i = depth - 1; i >= 0; --i)
                    {
                        parts[i] = node.PPath;
                        node     = node.Parent;
                    }

                    var mod       = item.Manifest.MFlag;
                    var dist      = item.Manifest.DFlag;
                    var rootdepth = 2; // Assets/CapsRes/

                    if (depth > 2 && parts[1] == "Mods")
                    {
                        rootdepth += 2; // Assets/Mods/XXX/CapsRes/
                    }
                    else if (depth > 1 && parts[0] == "Packages")
                    {
                        rootdepth += 1; // Packages/xx.xx.xx/CapsRes/
                    }
                    if (!string.IsNullOrEmpty(dist))
                    {
                        rootdepth += 2; // .../dist/XXX/
                    }

                    System.Text.StringBuilder sbbundle = new System.Text.StringBuilder();
                    sbbundle.Append("m-");
                    sbbundle.Append((mod ?? "").ToLower());
                    sbbundle.Append("-d-");
                    sbbundle.Append((dist ?? "").ToLower());
                    sbbundle.Append("-");
                    for (int i = rootdepth; i < depth - 1; ++i)
                    {
                        if (i > rootdepth)
                        {
                            sbbundle.Append("-");
                        }
                        sbbundle.Append(parts[i].ToLower());
                    }
                    var filename = item.Node.PPath;

                    if (filename.EndsWith(".unity"))
                    {
                        var sceneName = parts[depth - 1];
                        sceneName = sceneName.Substring(0, sceneName.Length - ".unity".Length);
                        sbbundle.Append("-");
                        sbbundle.Append(sceneName.ToLower());
                        sbbundle.Append(".s");
                    }
                    else if (filename.EndsWith(".prefab"))
                    {
                        sbbundle.Append(".o");
                    }
                    sbbundle.Append(".ab");
                    return(sbbundle.ToString());
                }
                public override IAssetInfo CreateAssetInfo(CapsResManifestItem item)
                {
                    var ai = item.Attached as IAssetInfo;

                    if (ai == null)
                    {
                        AssetInfo_Base ain = CreateAssetInfoRaw(item);
                        item.Attached = ain;
                        ai            = ain;
                    }
                    return(ai);
                }
コード例 #6
0
            private static Object LoadAsset(CapsResManifestItem item, Type type)
            {
                var ai = CreateAssetInfo(item);

                if (ai != null)
                {
                    ai.Preload();
                    return(ai.Load(type));
                }
                else
                {
                    return(null);
                }
            }
コード例 #7
0
            public static IAssetInfo CreateAssetInfo(CapsResManifestItem item)
            {
                var             restype = item.Type;
                ITypedResLoader loader;

                if (TypedResLoaders != null && TypedResLoaders.TryGetValue(restype, out loader) && loader != null)
                {
                    return(loader.CreateAssetInfo(item));
                }
                else
                {
                    return(Instance_TypedResLoader_Normal.CreateAssetInfo(item));
                }
            }
                public override IAssetInfo CreateAssetInfo(CapsResManifestItem item)
                {
                    var ai = item.Attached as IAssetInfo;

                    if (ai == null)
                    {
                        AssetInfo_Redirect ain = new AssetInfo_Redirect()
                        {
                            ManiItem = item
                        };
                        item.Attached = ain;
                        ai            = ain;
                        var realitem = item.Ref;
                        if (realitem != null)
                        {
                            var air = ClientResLoader.CreateAssetInfo(realitem);
                            if (air != null)
                            {
                                ain.Real = air;
                            }
                        }
                    }
                    return(ai);
                }
コード例 #9
0
        public static CapsResManifest Load(CapsResOnDiskManifest ondisk)
        {
            if (ondisk == null)
            {
                return(null);
            }
            CapsResManifest rv = new CapsResManifest();

            rv.MFlag  = ondisk.MFlag;
            rv.DFlag  = ondisk.DFlag;
            rv.InMain = ondisk.InMain;

            if (ondisk.Assets != null && ondisk.Assets.Length > 0)
            {
                List <CapsResManifestNode> nodeStack = new List <CapsResManifestNode>();
                var parsedNodes = new CapsResManifestNode[ondisk.Assets.Length];
                for (int i = 0; i < ondisk.Assets.Length; ++i)
                {
                    var curDiskNode = ondisk.Assets[i];
                    var curlvl      = curDiskNode.Level;
                    if (nodeStack.Count > curlvl)
                    {
                        var removecnt = nodeStack.Count - curlvl;
                        nodeStack.RemoveRange(nodeStack.Count - removecnt, removecnt);
                    }
                    while (nodeStack.Count < curlvl)
                    {
                        // something goes wrong here.
                        nodeStack.Add(null);
                    }

                    CapsResManifestNode curNode;
                    if (curlvl == 0)
                    {
                        curNode = new CapsResManifestNode(rv);
                        rv.Root = curNode;
                        //curNode.PPath = curDiskNode.PPath;
                    }
                    else
                    {
                        var parNode = nodeStack[curlvl - 1];
                        var ppath   = curDiskNode.PPath;
                        curNode = new CapsResManifestNode(parNode, ppath);
                        if (parNode.Children == null)
                        {
                            parNode.Children = new SortedList <string, CapsResManifestNode>();
                        }
                        parNode.Children[ppath] = curNode;
                    }
                    nodeStack.Add(curNode);
                    parsedNodes[i] = curNode;

                    if (curDiskNode.Item != null && curDiskNode.Item.Type != 0)
                    {
                        var item = new CapsResManifestItem(curNode);
                        curNode.Item = item;
                        item.Type    = curDiskNode.Item.Type;
                        if (curDiskNode.Item.BRef > 0)
                        {
                            if (ondisk.Bundles != null && ondisk.Bundles.Length > curDiskNode.Item.BRef)
                            {
                                item.BRef = ondisk.Bundles[curDiskNode.Item.BRef];
                            }
                        }
                        if (curDiskNode.Item.ExInfo != null)
                        {
                            item.ExInfo = UnityEngine.Object.Instantiate <ScriptableObject>(curDiskNode.Item.ExInfo);
                        }
                    }
                }
                for (int i = 0; i < ondisk.Assets.Length; ++i)
                {
                    var curDiskNode = ondisk.Assets[i];
                    if (curDiskNode.Item != null && curDiskNode.Item.Type != 0 && curDiskNode.Item.Ref > 0)
                    {
                        parsedNodes[i].Item.Ref = parsedNodes[curDiskNode.Item.Ref].Item;
                    }
                }
            }

            rv.TrimExcess();

            return(rv);
        }
コード例 #10
0
 public abstract IAssetInfo CreateAssetInfo(CapsResManifestItem item);