コード例 #1
0
        private static bool ShouldDo(Unlock unlock, Dictionary <string, ParsedArg> config,
                                     Dictionary <string, TagExpectedValue> tags, Type unlockType)
        {
            string type      = Unlock.GetTypeName(unlockType);
            string typeLower = type.ToLowerInvariant();

            if (config == null)
            {
                return(unlock.Type == type);
            }
            return(unlock.Type == type && config.ContainsKey(typeLower) &&
                   config[typeLower].ShouldDo(unlock.GetName(), tags));
        }
コード例 #2
0
        public void SaveUnlocksForHeroes(ICLIFlags flags, IEnumerable <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 (STUHero hero in heroes)
            {
                if (hero == null)
                {
                    continue;
                }
                string heroNameActual = GetString(hero.m_0EDCE350);

                if (heroNameActual == null)
                {
                    continue;
                }

                Dictionary <string, ParsedArg> config = GetQuery(parsedTypes, heroNameActual.ToLowerInvariant(), "*");

                heroNameActual = heroNameActual.TrimEnd(' ');
                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));
                    }

                    SaveLogic.Combo.SaveLooseTextures(flags, Path.Combine(heroPath, "GUI"), guiInfo);
                }

                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, Unlock.GetTypeName(typeof(STUUnlock_SkinTheme)),
                                                           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);
                    }
                }
            }
        }
コード例 #3
0
ファイル: UtilDynamicChoices.cs プロジェクト: ipud2/OWLib
        private static void ProcessHeroNames(DynamicChoicesContainer container)
        {
            var heroContainer = container.GetType(VALID_HERO_NAMES);
            var npcContainer  = container.GetType(VALID_NPC_NAMES);
            var owlTeams      = container.GetType(VALID_OWL_TEAMS);

            HashSet <string> handledTeams = new HashSet <string>();

            Dictionary <ulong, STUHero> heroes          = new Dictionary <ulong, STUHero>();
            Dictionary <string, int>    nameOccurrances = new Dictionary <string, int>();

            foreach (ulong heroGUID in Program.TrackedFiles[0x75])
            {
                var hero = STUHelper.GetInstance <STUHero>(heroGUID);
                if (hero == null)
                {
                    continue;
                }

                string heroNameActual = Hero.GetCleanName(hero);
                if (heroNameActual == null)
                {
                    continue;
                }

                heroes[heroGUID] = hero;
                if (nameOccurrances.TryGetValue(heroNameActual, out _))
                {
                    nameOccurrances[heroNameActual]++;
                }
                else
                {
                    nameOccurrances[heroNameActual] = 0;
                }
            }

            foreach (ulong heroGUID in Program.TrackedFiles[0x75])
            {
                if (!heroes.TryGetValue(heroGUID, out var hero))
                {
                    continue;
                }
                string heroNameActual = Hero.GetCleanName(hero);

                var doGuidName = nameOccurrances[heroNameActual] > 1;
                if (doGuidName)
                {
                    heroNameActual += $" ({teResourceGUID.Index(heroGUID):X})";
                }

                ProgressionUnlocks progressionUnlocks = new ProgressionUnlocks(hero);

                var choice = new DynamicChoice {
                    DisplayName = heroNameActual,
                    QueryName   = $"{teResourceGUID.Index(heroGUID):X}"
                };

                if (progressionUnlocks.LevelUnlocks == null)
                {
                    npcContainer.Choices.Add(choice);
                }
                else
                {
                    heroContainer.Choices.Add(choice);
                }

                foreach (var unlock in progressionUnlocks.IterateUnlocks())
                {
                    if (string.IsNullOrWhiteSpace(unlock.Name))
                    {
                        continue;
                    }

                    if (unlock.STU.m_0B1BA7C1 != null)
                    {
                        TeamDefinition teamDef = new TeamDefinition(unlock.STU.m_0B1BA7C1);
                        if (!(teamDef.Division == Enum_5A789F71.None && teamDef.Location == null))
                        {
                            if (handledTeams.Add(teamDef.FullName))
                            {
                                owlTeams.Choices.Add(new DynamicChoice {
                                    DisplayName = teamDef.FullName,
                                    QueryName   = teamDef.FullName
                                });
                            }
                            continue;
                        }
                    }

                    var key = "datatool.ux.valid_" + Unlock.GetTypeName(unlock.STU.GetType()).ToLowerInvariant() + "_names";

                    if (choice.Children == null)
                    {
                        choice.Children = new DynamicChoicesContainer();
                    }

                    var test = choice.Children.GetType(key);
                    test.Choices.Add(new DynamicChoice {
                        QueryName   = unlock.Name,
                        DisplayName = unlock.Name
                    });
                }
            }
        }