Пример #1
0
        public void LoadBundleIndexes()
        {
            foreach (var indexPath in Directory.GetFiles(_basePath, "*" + _indexFileSuffix))
            {
                // get identifier (bundle name) from path
                var identifier = indexPath.Substring(
                    _basePath.Length,
                    indexPath.Length - _indexFileSuffix.Length - _basePath.Length
                    );

                // get asset bundle path
                var bundlePath = Path.Combine(_basePath, identifier);

                // parse bundle index
                var index = ContentBundleIndex.Parse(identifier, indexPath, bundlePath);
                _bundleIndexes.Add(index);

                // add items to the mapping dictionary
                foreach (var item in index.Items)
                {
                    if (_itemMapping.ContainsKey(item.Mountpoint))
                    {
                        Log.Instance.Warning("Found duplicate resource at path {0} loading bundle {1}, previous loaded from {2}",
                                             item.Mountpoint,
                                             identifier,
                                             _itemMapping[item.Mountpoint].Index.Identifier
                                             );
                    }

                    _itemMapping[item.Mountpoint] = item;
                }
            }
        }
 public static SpriteItem Parse(ContentBundleIndex index, XmlElement xmlItem)
 {
     return(new SpriteItem(
                index,
                xmlItem.Name,
                xmlItem.GetAttribute("mountpoint"),
                xmlItem.GetAttribute("asset")
                ));
 }
Пример #3
0
        public ContentItem(ContentBundleIndex index, string category, string mountpoint, string assetName)
        {
            Index      = index;
            Category   = category;
            Mountpoint = mountpoint;
            AssetName  = assetName;

            Debug.Assert(Category != null);
            Debug.Assert(Mountpoint != null);
            Debug.Assert(AssetName != null);
        }
        public static ContentBundleIndex Parse(string identifier, string xmlPath, string bundlePath)
        {
            var document = new XmlDocument();

            document.Load(xmlPath);

            var index    = new ContentBundleIndex(identifier, bundlePath);
            var xmlIndex = document.ChildNodes[0];

            Debug.Assert(xmlIndex != null);
            Debug.Assert(xmlIndex.Name == "index");

            foreach (var xmlItemNode in xmlIndex.ChildNodes)
            {
                var xmlItem = xmlItemNode as XmlElement;

                ContentItem item = null;
                // parse clothing items
                if (ClothingItem.IncludedTags.Contains(xmlItem.Name))
                {
                    item = ClothingItem.Parse(index, xmlItem);
                }
                else if (SpriteItem.IncludedTags.Contains(xmlItem.Name))
                {
                    item = SpriteItem.Parse(index, xmlItem);
                }
                else if (HairItem.IncludedTags.Contains(xmlItem.Name))
                {
                    item = HairItem.Parse(index, xmlItem);
                }

                // add item to the list
                if (item != null)
                {
                    index.Items.Add(item);
                }
                else
                {
                    Log.Instance.Error("Failed to parse content item with tag {0}", xmlItem.Name);
                }
            }

            return(index);
        }
        public static ClothingItem Parse(ContentBundleIndex index, XmlElement xmlItem)
        {
            ItemSex sex;

            switch (xmlItem.GetAttribute("sex"))
            {
            case "f":
                sex = ItemSex.Female;
                break;

            case "m":
                sex = ItemSex.Male;
                break;

            case "both":
                sex = ItemSex.Both;
                break;

            default:
                Log.Instance.Error("Invalid \"sex\" attribute value");
                return(null);
            }

            var material = xmlItem.HasAttribute("material") ? UInt32.Parse(xmlItem.GetAttribute("material")) : 0;

            string[] overrideShaders = new string[0];
            var      shader          = xmlItem.HasAttribute("overrideShader") ? xmlItem.GetAttribute("overrideShader") : null;

            if (shader != null)
            {
                overrideShaders = shader.Split(';');
            }

            return(new ClothingItem(
                       index,
                       xmlItem.GetAttribute("category"),
                       xmlItem.GetAttribute("mountpoint"),
                       xmlItem.GetAttribute("asset"),
                       sex,
                       overrideShaders,
                       xmlItem.GetAttribute("colorVar"),
                       material
                       ));
        }
        public static HairItem Parse(ContentBundleIndex index, XmlElement xmlItem)
        {
            // @TODO: code duplication with ClothingItem
            ItemSex sex;

            switch (xmlItem.GetAttribute("sex"))
            {
            case "f":
                sex = ItemSex.Female;
                break;

            case "m":
                sex = ItemSex.Male;
                break;

            case "both":
                sex = ItemSex.Both;
                break;

            default:
                Log.Instance.Error("Invalid \"sex\" attribute value");
                return(null);
            }

            string[] overrideShaders = new string[0];
            var      shader          = xmlItem.HasAttribute("overrideShader") ? xmlItem.GetAttribute("overrideShader") : null;

            if (shader != null)
            {
                overrideShaders = shader.Split(';');
            }

            return(new HairItem(
                       index,
                       xmlItem.GetAttribute("category"),
                       xmlItem.GetAttribute("mountpoint"),
                       xmlItem.GetAttribute("asset"),
                       sex,
                       overrideShaders
                       ));
        }
Пример #7
0
 public EquipItem(ContentBundleIndex index, string category, string mountpoint, string assetName, ItemSex sex, string[] overrideShaders)
     : base(index, category, mountpoint, assetName)
 {
     Sex             = sex;
     OverrideShaders = overrideShaders;
 }
 public ClothingItem(ContentBundleIndex index, string category, string mountpoint, string assetName, ItemSex sex, string[] overrideShaders, string colorVar, uint material)
     : base(index, category, mountpoint, assetName, sex, overrideShaders)
 {
     ColorVar = colorVar;
     Material = material;
 }
 public HairItem(ContentBundleIndex index, string category, string mountpoint, string assetName, ItemSex sex, string[] overrideShaders)
     : base(index, category, mountpoint, assetName, sex, overrideShaders)
 {
 }
 public SpriteItem(ContentBundleIndex index, string category, string mountpoint, string assetName) : base(index, category, mountpoint, assetName)
 {
 }