public void GetHeroes(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractFlags flags) { basePath = flags.OutputPath; } else { throw new Exception("no output path"); } foreach (ulong key in TrackedFiles[0x75]) { STUHero hero = GetInstance <STUHero>(key); if (hero == null) { continue; } Dictionary <string, HashSet <ItemInfo> > unlocks = ListHeroUnlocks.GetUnlocksForHero(hero.LootboxUnlocks); if (unlocks == null) { continue; } List <ItemInfo> skins = unlocks.SelectMany(x => x.Value.Where(y => y.Type == "Skin")).ToList(); List <ItemInfo> weaponSkins = unlocks.SelectMany(x => x.Value.Where(y => y.Type == "Weapon")).ToList(); foreach (ItemInfo skin in skins) { Skin.Save(flags, $"{basePath}\\HeroSkinDebug", hero, skin.Rarity, skin.Unlock as STUUnlock_Skin, weaponSkins, null, false); } } }
public void SaveUnlocksForHeroes(ICLIFlags flags, IEnumerable <STUHero> heroes, string basePath, bool npc = false) { if (flags.Positionals.Length < 4) { QueryHelp(QueryTypes); return; } Log("Initializing..."); Dictionary <string, Dictionary <string, ParsedArg> > parsedTypes = ParseQuery(flags, QueryTypes, QueryNameOverrides); if (parsedTypes == null) { return; } foreach (STUHero hero in heroes) { string heroNameActual = GetString(hero.Name); string heroFileName = GetValidFilename(heroNameActual); if (heroFileName == null) { continue; // heroFileName = "Unknown"; // heroNameActual = "Unknown"; } heroNameActual = heroNameActual.TrimEnd(' '); heroFileName = heroFileName.TrimEnd(' '); Dictionary <string, ParsedArg> config = new Dictionary <string, ParsedArg>(); foreach (string key in new [] { heroNameActual.ToLowerInvariant(), "*" }) { if (!parsedTypes.ContainsKey(key)) { continue; } foreach (KeyValuePair <string, ParsedArg> parsedArg in parsedTypes[key]) { if (config.ContainsKey(parsedArg.Key)) { config[parsedArg.Key] = config[parsedArg.Key].Combine(parsedArg.Value); } else { config[parsedArg.Key] = parsedArg.Value.Combine(null); // clone for safety } } } if (config.Count == 0) { continue; } var unlocks = GetInstance <STUHeroUnlocks>(hero.LootboxUnlocks); if (unlocks?.Unlocks == null && !npc) { continue; } if (unlocks?.LootboxUnlocks != null && npc) { continue; } Log($"Processing data for {heroNameActual}..."); List <ItemInfo> weaponSkins = ListHeroUnlocks.GetUnlocksForHero(hero.LootboxUnlocks)?.SelectMany(x => x.Value.Where(y => y.Type == "Weapon")).ToList(); // eww? var achievementUnlocks = GatherUnlocks(unlocks?.SystemUnlocks?.Unlocks?.Select(it => (ulong)it)).ToList(); foreach (ItemInfo itemInfo in achievementUnlocks) { if (itemInfo == null) { continue; } Dictionary <string, TagExpectedValue> tags = new Dictionary <string, TagExpectedValue> { { "event", new TagExpectedValue("base") } }; SaveItemInfo(itemInfo, basePath, heroFileName, flags, hero, "Achievement", config, tags, weaponSkins); } if (npc) { foreach (STUHeroSkin skin in hero.Skins) { if (config.ContainsKey("skin") && config["skin"].ShouldDo(GetFileName(skin.SkinOverride))) { Skin.Save(flags, $"{basePath}\\{RootDir}", hero, skin, false); } } continue; } foreach (var defaultUnlocks in unlocks.Unlocks) { var dUnlocks = GatherUnlocks(defaultUnlocks.Unlocks.Select(it => (ulong)it)).ToList(); foreach (ItemInfo itemInfo in dUnlocks) { Dictionary <string, TagExpectedValue> tags = new Dictionary <string, TagExpectedValue> { { "event", new TagExpectedValue("base") } }; SaveItemInfo(itemInfo, basePath, heroFileName, flags, hero, "Standard", config, tags, weaponSkins); } } foreach (var eventUnlocks in unlocks.LootboxUnlocks) { if (eventUnlocks?.Unlocks?.Unlocks == null) { continue; } var eventKey = ItemEvents.GetInstance().EventsNormal[(uint)eventUnlocks.Event]; var eUnlocks = eventUnlocks.Unlocks.Unlocks.Select(it => GatherUnlock(it)).ToList(); foreach (ItemInfo itemInfo in eUnlocks) { if (itemInfo == null) { continue; } Dictionary <string, TagExpectedValue> tags = new Dictionary <string, TagExpectedValue> { { "event", new TagExpectedValue(eventUnlocks.Event.ToString().ToLowerInvariant()) } }; SaveItemInfo(itemInfo, basePath, heroFileName, flags, hero, eventKey, config, tags, weaponSkins); } } Combo.ComboInfo guiInfo = new Combo.ComboInfo(); Combo.Find(guiInfo, hero.ImageResource1); Combo.Find(guiInfo, hero.ImageResource2); Combo.Find(guiInfo, hero.ImageResource3); Combo.Find(guiInfo, hero.ImageResource4); guiInfo.SetTextureName(hero.ImageResource1, "Icon"); guiInfo.SetTextureName(hero.ImageResource2, "Portrait"); guiInfo.SetTextureName(hero.ImageResource4, "Avatar"); guiInfo.SetTextureName(hero.SpectatorIcon, "SpectatorIcon"); SaveLogic.Combo.SaveLooseTextures(flags, Path.Combine(basePath, RootDir, heroFileName, "GUI"), guiInfo); } }