コード例 #1
0
        private void AbilityToTank(Location loc)
        {
            // modify tileset
            Tileset ts;
            byte    bg1Val;

            int key = loc.Room | (loc.Area << 8);

            if (roomTilesets.TryGetValue(key, out byte tsNum))
            {
                ts     = new Tileset(rom, tsNum);
                bg1Val = ts.AddAbility(loc.NewItem);
                ts.Write(tsNum);
            }
            else
            {
                // get room header
                int headerOffset = rom.ReadPtr(Rom.AreaRoomEntryOffset + loc.Area * 4) + (loc.Room * 0x3C);
                tsNum = rom.Read8(headerOffset);

                ts     = new Tileset(rom, tsNum);
                bg1Val = ts.AddAbility(loc.NewItem);
                ts.Write(nextTilesetNum);

                rom.Write8(headerOffset, nextTilesetNum);
                nextTilesetNum++;
            }

            // write clipdata and BG1
            bool hidden = loc.IsHidden;

            rom.Write8(loc.ClipdataOffset, loc.NewItem.Clipdata(hidden));

            if (!hidden)
            {
                rom.Write8(loc.BG1Offset, bg1Val);
            }
        }