示例#1
0
        public static void PatchWeaponNames(Patch in_Patch, ISeed in_Seed, out List <Char> out_NewWeaponLetters)
        {
            const Int32 WEAPON_GET_LETTERS_ADDRESS       = 0x037E22;
            const Int32 WEAPON_GET_NAME_ADDRESS          = 0x037E2C;
            const Int32 WEAPON_GET_EXTENDED_NAME_ADDRESS = 0x037F5C;
            const Int32 WEAPON_GET_EXTENDED_NAME_INDEX   = 4;   // Quick Boomerang has an extended name
            const Int32 WEAPON_COUNT = 8;

            WeaponNameGenerator weaponNameGenerator = new WeaponNameGenerator(in_Seed);

            List <WeaponName> weaponNames = new List <WeaponName>();

            // Write in new weapon names
            for (Int32 weaponIndex = 0; weaponIndex < WEAPON_COUNT; ++weaponIndex)
            {
                // Each weapon get name is 14 bytes long with a 2 Byte header
                Int32 offsetAddress = WEAPON_GET_NAME_ADDRESS + (weaponIndex * 0x10);

                if (WEAPON_GET_EXTENDED_NAME_INDEX == weaponIndex)
                {
                    WeaponName weaponName = weaponNameGenerator.GenerateWeaponName(true);
                    weaponNames.Add(weaponName);

                    Int32 characterIndex = 0;
                    foreach (Char c in weaponName.Name)
                    {
                        in_Patch.Add(
                            offsetAddress + characterIndex,
                            c.AsPrintCharacter(),
                            String.Format("Weapon Name {0} Char #{1}: {2}", ((EDmgVsBoss.Offset)weaponIndex).Name, characterIndex, c.ToString()));

                        characterIndex++;
                    }

                    characterIndex = 0;
                    foreach (Char c in weaponName.ExtendedName)
                    {
                        in_Patch.Add(
                            WEAPON_GET_EXTENDED_NAME_ADDRESS + characterIndex,
                            c.AsPrintCharacter(),
                            String.Format("Extended Weapon Name {0} Char #{1}: {2}", ((EDmgVsBoss.Offset)weaponIndex).Name, characterIndex, c.ToString()));

                        characterIndex++;
                    }
                }
                else
                {
                    WeaponName weaponName = weaponNameGenerator.GenerateWeaponName(false);
                    weaponNames.Add(weaponName);

                    Int32 characterIndex = 0;
                    foreach (Char c in weaponName.Name)
                    {
                        in_Patch.Add(
                            offsetAddress + characterIndex,
                            c.AsPrintCharacter(),
                            String.Format("Weapon Name {0} Char #{1}: {2}", ((EDmgVsBoss.Offset)weaponIndex).Name, characterIndex, c.ToString()));

                        characterIndex++;
                    }
                }
            }

            // Get a list of the weapon letters
            List <Char> weaponLetters = weaponNames.Select(x => x.Letter).ToList();

            // Write in "Weapon Get" letters
            //
            // NOTE! There is not a space for buster because
            // there is never a "Weapon Get" for buster
            for (Int32 weaponLetterIndex = 0; weaponLetterIndex < weaponLetters.Count; ++weaponLetterIndex)
            {
                Char weaponLetter = weaponLetters[weaponLetterIndex];

                in_Patch.Add(
                    WEAPON_GET_LETTERS_ADDRESS + weaponLetterIndex,
                    weaponLetter.AsPrintCharacter(),
                    $"Weapon Get {((EDmgVsBoss.Offset)weaponLetterIndex).Name} Letter: {weaponLetter}");
            }

            // Pick a new weapon letter for buster
            weaponLetters.Insert(0, weaponNameGenerator.GetNextLetter(false));

            // Write in weapon pause menu letters
            for (Int32 weaponLetterIndex = 0; weaponLetterIndex < weaponLetters.Count; ++weaponLetterIndex)
            {
                Char weaponLetter = weaponLetters[weaponLetterIndex];

                // Write to pause menu
                in_Patch.Add(
                    PauseScreenWpnAddressByBossIndex[weaponLetterIndex],
                    weaponLetter.AsPauseScreenString(),
                    $"Pause menu weapon letter GFX for \'{weaponLetter}\'");
            }

            out_NewWeaponLetters = weaponLetters;
        }