Ejemplo n.º 1
0
        public static void GenerateTileMapping()
        {
            const int baseAddress      = 0xabcc;
            const int nameBaseAddress  = 0x9584;
            const int nameSize         = 5;
            const int shapeBaseAddress = 0x764c;
            const int shapeSize        = 22;

            var importSettings = FindOrCreateAssetAtPath <ImportSettings>(ImportSettingsPath);

            UnpackCode();

            importSettings.tileDescriptions = new List <TileDescription>();
            for (int i = 0; i < 0xf7; i++)
            {
                var tileDescription = new TileDescription();
                int structAddress   = baseAddress + i * 14;

                tileDescription.orientation    = unpackedCode[structAddress + 3] & 0x03;
                tileDescription.otherPartIndex = unpackedCode[structAddress + 8];
                tileDescription.materialIndex  = unpackedCode[structAddress + 9];

                int sizeFlags = unpackedCode[structAddress + 11];
                tileDescription.xSize = (sizeFlags & 2) == 0 ? 1 : 2;
                tileDescription.ySize = (sizeFlags & 1) == 0 ? 1 : 2;

                int    shapeAddress = unpackedCode[structAddress + 4] + unpackedCode[structAddress + 5] * 0x100;
                int    nameOffset   = (shapeAddress - shapeBaseAddress) * nameSize / shapeSize + nameBaseAddress;
                string meshName     = new ReadStream(unpackedCode, nameOffset).ReadFixedLengthString(4);
                if (!meshName.All(c => c > 0x20 && c < 0x80))
                {
                    meshName = "";
                }

                tileDescription.meshName = meshName;
                tileDescription.name     = string.Format("{0} ({1})", i, tileDescription.Displayname);

                importSettings.tileDescriptions.Add(tileDescription);
            }
        }