Ejemplo n.º 1
0
        private IStarterModel[] LoadStarters()
        {
            var commonStrings   = rom.GetCommonStrings();
            var mainExecutable  = rom.GetMainExecutable();
            var natureDiagnosis = rom.GetNatureDiagnosis();
            var fixedPokemon    = rom.GetFixedPokemon();

            var starters = new List <StarterModel>();

            foreach (var starter in natureDiagnosis.m_pokemonNatureAndTypeList)
            {
                var fixedPokemonSymbol = mainExecutable.StarterFixedPokemonMaps.FirstOrDefault(m => m.PokemonId == starter.m_nameLabel);
                if (fixedPokemonSymbol == default)
                {
                    // This isn't a usable starter
                    // The game WILL crash when loading the initial move set
                    continue;
                }

                var fixedPokemonEntry = fixedPokemon.Entries[(int)fixedPokemonSymbol.FixedPokemonId];
                starters.Add(new StarterModel(commonStrings)
                {
                    PokemonId = starter.m_nameLabel,
                    NatureDiagnosisMaleModelSymbol   = starter.m_symbolName,
                    NatureDiagnosisFemaleModelSymbol = starter.m_symbolNameFemale,
                    Move1        = fixedPokemonEntry.Move1,
                    Move2        = fixedPokemonEntry.Move2,
                    Move3        = fixedPokemonEntry.Move3,
                    Move4        = fixedPokemonEntry.Move4,
                    MaleNature   = starter.m_maleNature,
                    FemaleNature = starter.m_femaleNature
                });
            }
            return(starters.Cast <IStarterModel>().ToArray());
        }
Ejemplo n.º 2
0
        internal static IServiceProvider CreateRtdxRomServiceProvider(IRtdxRom rom)
        {
            IServiceProvider?serviceProvider = null;
            var services = new ServiceCollection();

            services
            .AddSingleton(_ => serviceProvider ?? throw new Exception("Failed to register IServiceProvider within itself"))
            .AddSingleton <IRtdxRom>(rom)
            .AddSingleton <ICommonStrings>(_ => rom.GetCommonStrings())
            .AddSingleton <ILuaGenerator, LuaGenerator>()
            .AddSingleton <ICSharpGenerator, CSharpGenerator>()
            .AddCustomScriptExpressionGeneratorsAsSingleton();

            serviceProvider = services.BuildServiceProvider();

            return(serviceProvider);
        }
Ejemplo n.º 3
0
        private IDungeonModel[] LoadDungeons()
        {
            var commonStrings  = rom.GetCommonStrings();
            var dungeonData    = rom.GetDungeonDataInfo();
            var dungeonExtra   = rom.GetDungeonExtra();
            var dungeonBalance = rom.GetDungeonBalance();

            var dungeons = new List <DungeonModel>();

            foreach (var dungeon in dungeonData.Entries)
            {
                dungeons.Add(new DungeonModel(commonStrings, dungeon.Value)
                {
                    Id      = dungeon.Key,
                    Extra   = dungeonExtra.Entries.GetValueOrDefault(dungeon.Key),
                    Balance = dungeonBalance.Entries[dungeon.Value.DungeonBalanceIndex]
                });
            }
            dungeons.Sort((d1, d2) => d1.Data.SortKey.CompareTo(d2.Data.SortKey));
            return(dungeons.ToArray());
        }