Пример #1
0
        /// <summary>
        /// Gets the asset from a filesystem folder path.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static ArkAsset GetAssetFromFolderPath(string path, ArkInstall install)
        {
            //Get the fileinfo
            FileInfo info = new FileInfo(path);

            //Get the parent namespace
            ArkNamespace parent = ArkNamespace.GetNamespaceFromFolderPath(info.Directory.FullName, install);

            //Create object
            ArkAsset a = new ArkAsset
            {
                info         = info,
                filename     = path,
                parent       = parent,
                installation = install
            };

            //Get the name without the extension
            if (info.Name.Contains("."))
            {
                a.name      = info.Name.Substring(0, info.Name.LastIndexOf('.'));
                a.extension = info.Name.Substring(a.name.Length + 1);
            }
            else
            {
                a.name      = info.Name;
                a.extension = "";
            }

            //Set name
            a.fullName = parent.fullName + a.name;

            return(a);
        }
Пример #2
0
        /// <summary>
        /// Returns children assets
        /// </summary>
        /// <returns></returns>
        public List <ArkAsset> GetAssetChildren()
        {
            List <ArkAsset> children = new List <ArkAsset>();

            string[] paths = Directory.GetFiles(pathname);
            foreach (var p in paths)
            {
                children.Add(ArkAsset.GetAssetFromFolderPath(p, installation));
            }
            return(children);
        }
Пример #3
0
        /// <summary>
        /// Returns a named child asset. Does NOT include the extension and assumes it is a usasset
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ArkAsset GetAssetChildByName(string name)
        {
            //Get the pathname
            string path = pathname + name + ".uasset";

            //Make sure this exists
            if (!File.Exists(path))
            {
                throw new Exception("Could not get child file because it did not exist!");
            }

            //Get
            return(ArkAsset.GetAssetFromFolderPath(path, installation));
        }
Пример #4
0
        /// <summary>
        /// Extracts data and returns the package
        /// </summary>
        public Stream Run(UAssetCacheBlock cache, out string hash)
        {
            //Get pathnames that match this
            List <ArkAsset>[] files = DiscoveryService.DiscoverFiles(installation, this);

            //Load mod info if this is a mod. TODO

            //Load Primal Data for mod
            string              primalDataPathname = "/Game/PrimalEarth/CoreBlueprints/PrimalGameData_BP";
            ArkAsset            primalDataNs       = ArkAsset.GetAssetFromGame(primalDataPathname, installation);
            UAssetFileBlueprint primalData         = UAssetFileBlueprint.OpenFile(primalDataNs.filename, false, primalDataNs.name, this.installation.contentFolder);
            PropertyReader      primalDataReader   = new PropertyReader(primalData.GetFullProperties(cache));

            //Load all dino entries
            var dinoEntriesArray = primalDataReader.GetProperty <ArrayProperty>("DinoEntries");
            Dictionary <string, PropertyReader> dinoEntries = new Dictionary <string, PropertyReader>(); //Dino entries mapped by tag name

            foreach (var i in dinoEntriesArray.props)
            {
                var    ii  = ((ObjectProperty)i).GetReferencedFileBlueprint();
                var    iir = new PropertyReader(ii.GetFullProperties(cache));
                string tag = iir.GetPropertyStringOrName("DinoNameTag");
                if (!dinoEntries.ContainsKey(tag))
                {
                    dinoEntries.Add(tag, iir);
                }
                else
                {
                    dinoEntries[tag] = iir;
                }
            }

            //Import dinos
            var dinos = DinoExtractorService.ExtractDinos(cache, files[(int)ArkAssetType.Dino], patch, primalDataReader, dinoEntries);

            //Import items
            var items = ItemExtractorService.ExtractItems(cache, files[(int)ArkAssetType.InventoryItem], patch);

            Log.WriteSuccess("Export-Package-Run", $"Package {name}: Processed {dinos.Count} dinos, {items.Count} items");

            //Return the package
            return(CompilePackage(new Dictionary <string, object>
            {
                { "items.bson", items },
                { "dinos.bson", dinos }
            }, out hash));
        }