Beispiel #1
0
        public static void SaveUnlock(ICLIFlags flags, Unlock unlock, string path, string eventKey,
                                      Dictionary <string, ParsedArg> config,
                                      Dictionary <string, TagExpectedValue> tags, VoiceSet voiceSet, STUHero hero)
        {
            string rarity;

            if (tags != null)
            {
                if (unlock.STU.m_0B1BA7C1 == null)
                {
                    rarity             = unlock.Rarity.ToString();
                    tags["leagueTeam"] = new TagExpectedValue("none");
                }
                else
                {
                    TeamDefinition teamDef = new TeamDefinition(unlock.STU.m_0B1BA7C1);
                    tags["leagueTeam"] = new TagExpectedValue(teamDef.Abbreviation, // NY
                                                              teamDef.Location,     // New York
                                                              teamDef.Name,         // Excelsior
                                                              teamDef.FullName,     // New York Excelsior
                                                              (teamDef.Division == Enum_5A789F71.None && teamDef.Location == null) ? "none" : "*",
                                                              "*");                 // all

                    // nice file structure
                    rarity   = "";
                    eventKey = "League";
                }
                tags["rarity"] = new TagExpectedValue(unlock.Rarity.ToString());

                tags["special"] = new TagExpectedValue(unlock.Tag ?? "none");
            }
            else
            {
                rarity = ""; // for general unlocks
            }

            var eventMap = GetEventConfig();

            if (unlock.STU.m_BEE9BCDA != null)
            {
                var formalEventKey = unlock.STU.m_BEE9BCDA.FirstOrDefault(x => eventMap.ContainsKey(x));
                if (eventMap.ContainsKey(formalEventKey))
                {
                    eventKey = eventMap[formalEventKey] ?? eventKey;
                }
            }

            string thisPath = Path.Combine(path, unlock.Type.ToString(), eventKey ?? "Default", rarity, GetValidFilename(unlock.GetName()));

            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_SprayPaint)))
            {
                SprayAndIcon.Save(flags, thisPath, unlock);
            }
            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_AvatarPortrait)))
            {
                SprayAndIcon.Save(flags, thisPath, unlock);
            }

            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_POTGAnimation)))
            {
                AnimationItem.Save(flags, thisPath, unlock);
            }
            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_Emote)))
            {
                AnimationItem.Save(flags, thisPath, unlock);
            }
            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_Pose)))
            {
                AnimationItem.Save(flags, thisPath, unlock);
            }

            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_VoiceLine)))
            {
                VoiceLine.Save(flags, thisPath, unlock, voiceSet);
            }

            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_SkinTheme)))
            {
                SkinTheme.Save(flags, thisPath, unlock, hero);
            }

            if (ShouldDo(unlock, config, tags, typeof(STUUnlock_PortraitFrame)))
            {
                thisPath = Path.Combine(path, unlock.Type.ToString());
                PortraitFrame.Save(flags, thisPath, unlock);
            }
        }
Beispiel #2
0
        public void SaveUnlocksForHeroes(ICLIFlags flags, IEnumerable <KeyValuePair <ulong, STUHero> > heroes, string basePath, bool npc = false)
        {
            if (flags.Positionals.Length < 4)
            {
                QueryHelp(QueryTypes);
                return;
            }

            Dictionary <string, Dictionary <string, ParsedArg> > parsedTypes = ParseQuery(flags, QueryTypes, QueryNameOverrides);

            if (parsedTypes == null)
            {
                return;
            }

            foreach (KeyValuePair <ulong, STUHero> heroPair in heroes)
            {
                var    hero           = heroPair.Value;
                string heroNameActual = Hero.GetCleanName(hero);

                if (heroNameActual == null)
                {
                    continue;
                }

                Dictionary <string, ParsedArg> config = GetQuery(parsedTypes, heroNameActual.ToLowerInvariant(), "*", teResourceGUID.Index(heroPair.Key).ToString("X"));

                string heroFileName = GetValidFilename(heroNameActual);

                if (config.Count == 0)
                {
                    continue;
                }

                string heroPath = Path.Combine(basePath, RootDir, heroFileName);

                VoiceSet           voiceSet           = new VoiceSet(hero);
                ProgressionUnlocks progressionUnlocks = new ProgressionUnlocks(hero);
                if (progressionUnlocks.LevelUnlocks == null && !npc)
                {
                    continue;
                }
                if (progressionUnlocks.LootBoxesUnlocks != null && npc)
                {
                    continue;
                }

                Log($"Processing unlocks for {heroNameActual}");

                {
                    Combo.ComboInfo guiInfo = new Combo.ComboInfo();

                    foreach (STU_1A496D3C tex in hero.m_8203BFE1)
                    {
                        Combo.Find(guiInfo, tex.m_texture);
                        guiInfo.SetTextureName(tex.m_texture, teResourceGUID.AsString(tex.m_id));
                    }

                    var guiContext = new SaveLogic.Combo.SaveContext(guiInfo);
                    SaveLogic.Combo.SaveLooseTextures(flags, Path.Combine(heroPath, "GUI"), guiContext);
                    guiContext.Wait();
                }

                if (progressionUnlocks.OtherUnlocks != null)   // achievements and stuff
                {
                    Dictionary <string, TagExpectedValue> tags = new Dictionary <string, TagExpectedValue> {
                        { "event", new TagExpectedValue("base") }
                    };
                    SaveUnlocks(flags, progressionUnlocks.OtherUnlocks, heroPath, "Achievement", config, tags, voiceSet, hero);
                }

                if (npc)
                {
                    foreach (var skin in hero.m_skinThemes)
                    {
                        if (!config.ContainsKey("skin") || !config["skin"].ShouldDo(GetFileName(skin.m_5E9665E3)))
                        {
                            continue;
                        }

                        SkinTheme.Save(flags, Path.Combine(heroPath, UnlockType.Skin.ToString(), string.Empty, GetFileName(skin.m_5E9665E3)), skin, hero);
                    }
                    continue;
                }

                if (progressionUnlocks.LevelUnlocks != null)   // default unlocks
                {
                    Dictionary <string, TagExpectedValue> tags = new Dictionary <string, TagExpectedValue> {
                        { "event", new TagExpectedValue("base") }
                    };
                    foreach (LevelUnlocks levelUnlocks in progressionUnlocks.LevelUnlocks)
                    {
                        SaveUnlocks(flags, levelUnlocks.Unlocks, heroPath, "Default", config, tags, voiceSet, hero);
                    }
                }

                if (progressionUnlocks.LootBoxesUnlocks != null)
                {
                    foreach (LootBoxUnlocks lootBoxUnlocks in progressionUnlocks.LootBoxesUnlocks)
                    {
                        if (lootBoxUnlocks.Unlocks == null)
                        {
                            continue;
                        }
                        string lootboxName = LootBox.GetName(lootBoxUnlocks.LootBoxType);

                        var tags = new Dictionary <string, TagExpectedValue> {
                            { "event", new TagExpectedValue(LootBox.GetBasicName(lootBoxUnlocks.LootBoxType)) }
                        };

                        SaveUnlocks(flags, lootBoxUnlocks.Unlocks, heroPath, lootboxName, config, tags, voiceSet, hero);
                    }
                }

                SaveScratchDatabase();
            }
        }