示例#1
0
 public static async Task InitializeOffline(string directory)
 {
     Index = new PakIndex(directory, true, false, null);
     Index.UseKey(FGuid.Zero, await AuthSupplier.GetKeyAsync());
     foreach (var(guid, key) in await AuthSupplier.GetKeychainAsync())
     {
         Index.UseKey(guid, key);
     }
 }
示例#2
0
 private static bool unlockPakIndex(PakIndex pakIndex)
 {
     foreach (var keyStr in Secrets.PAKS_AES_KEY_STRINGS)
     {
         byte[] keyBytes;
         if (keyStr.StartsWith("0x"))
         {
             keyBytes = keyStr.Substring(2).ToBytesKey();
         }
         else
         {
             keyBytes = keyStr.ToBytesKey();
         }
         var count = pakIndex.UseKey(FGuid.Zero, keyBytes);
         if (count > 0)
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        private static Task <PakIndex?> loadPakIndex()
        {
            var tcs = new TaskCompletionSource <PakIndex?>();

            Task.Run(() =>
            {
                try
                {
                    var filter   = new PakFilter(new[] { "/dungeons/content" });
                    var pakIndex = new PakIndex(path: Constants.PAKS_FOLDER, cacheFiles: true, caseSensitive: false, filter: filter);
                    pakIndex.UseKey(BinaryHelper.ToBytesKey(Constants.PAKS_AES_KEY_STRING));
                    tcs.SetResult(pakIndex);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Could not load Minecraft Dungeons Paks: {e}");
                    tcs.SetResult(null);
                }
            });
            return(tcs.Task);
        }
示例#4
0
        public StoreItem ConvertItem(Entry entry)
        {
            var ret = new StoreItem();

            if (entry.MetaInfo != null)
            {
                foreach (var mi in entry.MetaInfo)
                {
                    switch (mi.Key)
                    {
                    case "EncryptionKey":
                        Index.UseKey(Convert.FromBase64String(mi.Value.Split(':', 3)[1]));
                        break;

                    case "BannerOverride":
                        ret.Banner = mi.Value.ToUpperInvariant();
                        break;
                    }
                }
            }

            var displayAssetPath = entry.DisplayAssetPath ?? "None";
            var _p = GetItemPath(entry.ItemGrants[0].TemplateID, out ret.Type);

            Console.WriteLine("Getting " + _p);
            var exp = Index.GetPackage(_p).GetExport <UObject>();

            foreach (var prop in exp)
            {
                switch (prop.Key)
                {
                case "Rarity":
                    if (ret.Rarity == Rarity.UNCOMMON)
                    {
                        ret.Rarity = GetRarity((EnumProperty)prop.Value);
                    }
                    break;

                case "DisplayName":
                    ret.Name = ((TextProperty)prop.Value).Value;
                    break;

                case "ShortDescription":
                    ret.ShortDescription = ((TextProperty)prop.Value).Value;
                    break;

                case "Description":
                    ret.Description = ((TextProperty)prop.Value).Value;
                    break;

                case "Series":
                    ret.Series = ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String.ToLowerInvariant();
                    break;

                case "DisplayAssetPath":
                    if (displayAssetPath == "None")
                    {
                        displayAssetPath = ((FSoftObjectPath)((StructProperty)prop.Value).Value).AssetPathName.String;
                    }
                    break;

                case "LargePreviewImage":
                    if (ret.StandardIcon == null)
                    {
                        ret.StandardIcon = ((SoftObjectProperty)prop.Value).Value.AssetPathName.String;
                    }
                    break;

                case "HeroDefinition":     // skin
                    foreach (var defProp in Index.GetPackage("/FortniteGame/Content/Athena/Heroes/" + ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String).GetExport <UObject>())
                    {
                        switch (defProp.Key)
                        {
                        case "LargePreviewImage":
                            ret.StandardIcon = ((SoftObjectProperty)defProp.Value).Value.AssetPathName.String;
                            break;
                        }
                    }
                    break;

                case "WeaponDefinition":     // pick
                    var path = "/FortniteGame/Content/Athena/Items/Weapons/" + ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String;
                    Console.WriteLine("getting pickaxe: " + path);
                    var uobj = Index.GetPackage("/FortniteGame/Content/Athena/Items/Weapons/" + ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String).GetExport <UObject>();
                    foreach (var defProp in uobj)
                    {
                        switch (defProp.Key)
                        {
                        case "LargePreviewImage":
                            ret.StandardIcon = ((SoftObjectProperty)defProp.Value).Value.AssetPathName.String;
                            break;
                        }
                    }
                    break;
                }
            }

            if (displayAssetPath != "None")
            {
                exp = Index.GetPackage(ConvertObjectPath(displayAssetPath)).GetExport <UObject>();
                foreach (var prop in exp)
                {
                    switch (prop.Key)
                    {
                    case "DisplayName":
                        ret.Name = ((TextProperty)prop.Value).Value;
                        break;

                    case "ShortDescription":
                        ret.ShortDescription = ((TextProperty)prop.Value).Value;
                        break;

                    case "Description":
                        ret.Description = ((TextProperty)prop.Value).Value;
                        break;

                    case "TileImage":
                    case "DetailsImage":
                        var ind = ((ObjectProperty)((UObject)((StructProperty)prop.Value).Value)["ResourceObject"]).Value;
                        if (string.IsNullOrWhiteSpace(ind.Resource.ObjectName.String))
                        {
                            throw new NotImplementedException("WRAPS NOT ADDED YET");

                            /*/ most likely an item wrap
                             * foreach (var mProp in (await Index.GetPackage("/FortniteGame/Content/UI/Foundation/Textures/Icons/Wraps/FeaturedMaterials/" + packageIndex.import).GetUObjectAsync()).properties)
                             * {
                             *  if (mProp.name == "TextureParameterValues")
                             *  {
                             *      ret.FeaturedIcon = ((FPackageIndex)((FStructFallback)((UScriptStruct)((UScriptArray)mProp.tag_data).data[0]).struct_type).properties[1].tag_data).outer_import;
                             *  }
                             * }*/
                        }
                        else
                        {
                            ret.FeaturedIcon = ind.Resource.OuterIndex.Resource.ObjectName.String;
                            if (ret.FeaturedIcon.Contains("MI_UI"))
                            {
                                // yikes but whatever lol
                                ret.FeaturedIcon = ((ObjectProperty)((UObject)((StructProperty)((ArrayProperty)Index.GetPackage(ConvertObjectPath(ret.FeaturedIcon)).GetExport <UObject>()["TextureParameterValues"]).Value[0]).Value)["ParameterValue"]).Value.Resource.OuterIndex.Resource.ObjectName.String;
                            }
                        }
                        break;
                    }
                }
                if (ret.Type == ItemType.ITEMWRAP)
                {
                    ret.StandardIcon = ret.FeaturedIcon;
                }
                ret.FeaturedIcon = ConvertObjectPath(ret.FeaturedIcon);
            }
            ret.StandardIcon = ConvertObjectPath(ret.StandardIcon);
            if (entry.Categories.Length != 0)
            {
                ret.FeaturedCategory = int.Parse(entry.Categories[0].Split(' ', 2)[1]);
            }
            ret.SortPriority = entry.SortPriority;

            switch (entry.OfferType)
            {
            case "DynamicBundle":
                int basePrice = 0;
                var items     = entry.BundleInfo.BundleItems;
                for (int i = 0; i < items.Length; i++)
                {
                    basePrice += items[i].RegularPrice;
                }
                DiscountedPrice price;
                ret.Price = price = new DiscountedPrice(basePrice + entry.BundleInfo.DiscountedBasePrice, basePrice);
                switch (entry.BundleInfo.DisplayType)
                {
                case "PercentOff":
                    ret.Banner = $"{(1 - ((float)price.Price / price.OriginalPrice)) * 100}% OFF";
                    break;

                case "AmountOff":
                    ret.Banner = $"{price.OriginalPrice - price.Price} V-BUCKS OFF";
                    break;
                }
                ret.Type = ItemType.BUNDLE;
                //ret.ShortDescription.Text.SourceString = $"{items.Length} ITEM BUNDLE"; // TODO: fix this please lmao
                break;

            case "StaticPrice":
            default:
                ret.Price = new StaticPrice(entry.Prices[0].FinalPrice);
                break;
            }
            return(ret);
        }