Пример #1
0
        internal static void LoadTiles(TagCompound tag)
        {
            if (!tag.ContainsKey("data"))
            {
                return;
            }

            var tables = TileTables.Create();

            foreach (var tileTag in tag.GetList <TagCompound>("tileMap"))
            {
                ushort type    = (ushort)tileTag.GetShort("value");
                string modName = tileTag.GetString("mod");
                string name    = tileTag.GetString("name");
                tables.tiles[type] = ModContent.TryFind(modName, name, out ModTile tile) ? tile.Type : (ushort)0;
                if (tables.tiles[type] == 0)
                {
                    tables.tiles[type]        = ModContent.Find <ModTile>("ModLoader/PendingUnloadedTile").Type;
                    tables.tileModNames[type] = modName;
                    tables.tileNames[type]    = name;
                }
                tables.frameImportant[type] = tileTag.GetBool("framed");
            }
            foreach (var wallTag in tag.GetList <TagCompound>("wallMap"))
            {
                ushort type    = (ushort)wallTag.GetShort("value");
                string modName = wallTag.GetString("mod");
                string name    = wallTag.GetString("name");
                tables.walls[type] = ModContent.TryFind(modName, name, out ModWall wall) ? wall.Type : (ushort)0;
            }
            using (var memoryStream = new MemoryStream(tag.GetByteArray("data")))
                using (var reader = new BinaryReader(memoryStream))
                    ReadTileData(reader, tables);
            WorldIO.ValidateSigns();
        }
Пример #2
0
        //NOTE: LoadBasics can't be separated into LoadWalls() and LoadTiles() because of LoadLegacy.
        internal static void LoadBasics(TagCompound tag)
        {
            Tiles.LoadEntries(tag, out var tileEntriesLookup);
            Walls.LoadEntries(tag, out var wallEntriesLookup);

            if (!tag.ContainsKey("wallData"))
            {
                LoadLegacy(tag, tileEntriesLookup, wallEntriesLookup);
            }
            else
            {
                Tiles.LoadData(tag, tileEntriesLookup);
                Walls.LoadData(tag, wallEntriesLookup);
            }

            WorldIO.ValidateSigns();             //call this at end
        }
Пример #3
0
        internal static void LoadTiles(TagCompound tag)
        {
            if (!tag.ContainsKey("data"))
            {
                return;
            }

            var tables = TileTables.Create();

            foreach (var tileTag in tag.GetList <TagCompound>("tileMap"))
            {
                ushort type    = (ushort)tileTag.GetShort("value");
                string modName = tileTag.GetString("mod");
                string name    = tileTag.GetString("name");
                Mod    mod     = ModLoader.GetMod(modName);
                tables.tiles[type] = mod == null ? (ushort)0 : (ushort)mod.TileType(name);
                if (tables.tiles[type] == 0)
                {
                    tables.tiles[type]        = (ushort)ModContent.GetInstance <ModLoaderMod>().TileType("PendingMysteryTile");
                    tables.tileModNames[type] = modName;
                    tables.tileNames[type]    = name;
                }
                tables.frameImportant[type] = tileTag.GetBool("framed");
            }
            foreach (var wallTag in tag.GetList <TagCompound>("wallMap"))
            {
                ushort wall    = (ushort)wallTag.GetShort("value");
                string modName = wallTag.GetString("mod");
                string name    = wallTag.GetString("name");
                Mod    mod     = ModLoader.GetMod(modName);
                tables.walls[wall] = mod == null ? (ushort)0 : (ushort)mod.WallType(name);
            }
            using (var memoryStream = new MemoryStream(tag.GetByteArray("data")))
                using (var reader = new BinaryReader(memoryStream))
                    ReadTileData(reader, tables);
            WorldIO.ValidateSigns();
        }