示例#1
0
        private void ConfirmPendingInfo()
        {
            List <int> truePendingID = new List <int>();
            int        nextID        = 0;

            for (int k = 0; k < pendingInfos.Count; k++)
            {
                while (nextID < infos.Count && infos[nextID] != null)
                {
                    nextID++;
                }
                if (nextID == infos.Count)
                {
                    infos.Add(pendingInfos[k]);
                }
                else
                {
                    infos[nextID] = pendingInfos[k];
                }
                truePendingID.Add(nextID);
            }
            ushort pendingType = (ushort)ModLoader.GetMod("ModLoader").TileType("PendingMysteryTile");
            ushort mysteryType = (ushort)ModLoader.GetMod("ModLoader").TileType("MysteryTile");

            for (int x = 0; x < Main.maxTilesX; x++)
            {
                for (int y = 0; y < Main.maxTilesY; y++)
                {
                    if (Main.tile[x, y].type == pendingType)
                    {
                        Tile             tile  = Main.tile[x, y];
                        MysteryTileFrame frame = new MysteryTileFrame(tile.frameX, tile.frameY);
                        frame       = new MysteryTileFrame(truePendingID[frame.FrameID]);
                        tile.type   = mysteryType;
                        tile.frameX = frame.FrameX;
                        tile.frameY = frame.FrameY;
                    }
                }
            }
        }
示例#2
0
        private void RestoreTiles(List <ushort> canRestore)
        {
            ushort mysteryType = (ushort)ModLoader.GetMod("ModLoader").TileType("MysteryTile");

            for (int x = 0; x < Main.maxTilesX; x++)
            {
                for (int y = 0; y < Main.maxTilesY; y++)
                {
                    if (Main.tile[x, y].type == mysteryType)
                    {
                        Tile             tile  = Main.tile[x, y];
                        MysteryTileFrame frame = new MysteryTileFrame(tile.frameX, tile.frameY);
                        int frameID            = frame.FrameID;
                        if (canRestore[frameID] > 0)
                        {
                            MysteryTileInfo info = infos[frameID];
                            tile.type   = canRestore[frameID];
                            tile.frameX = info.frameX;
                            tile.frameY = info.frameY;
                        }
                    }
                }
            }
        }
		private void RestoreTiles(List<ushort> canRestore)
		{
			ushort mysteryType = (ushort)ModLoader.GetMod("ModLoader").TileType("MysteryTile");
			for (int x = 0; x < Main.maxTilesX; x++)
			{
				for (int y = 0; y < Main.maxTilesY; y++)
				{
					if (Main.tile[x, y].type == mysteryType)
					{
						Tile tile = Main.tile[x, y];
						MysteryTileFrame frame = new MysteryTileFrame(tile.frameX, tile.frameY);
						int frameID = frame.FrameID;
						if (canRestore[frameID] > 0)
						{
							MysteryTileInfo info = infos[frameID];
							tile.type = canRestore[frameID];
							tile.frameX = info.frameX;
							tile.frameY = info.frameY;
						}
					}
				}
			}
		}
示例#4
0
		internal static void ReadModTile(ref int i, ref int j, TileTables tables, BinaryReader reader, ref bool nextModTile)
		{
			byte flags;
			flags = reader.ReadByte();
			Tile tile = Main.tile[i, j];
			if ((flags & 1) == 1)
			{
				tile.active(true);
				ushort saveType = reader.ReadUInt16();
				tile.type = tables.tiles[saveType];
				if (tables.frameImportant[saveType])
				{
					if ((flags & 2) == 2)
					{
						tile.frameX = reader.ReadInt16();
					}
					else
					{
						tile.frameX = reader.ReadByte();
					}
					if ((flags & 4) == 4)
					{
						tile.frameY = reader.ReadInt16();
					}
					else
					{
						tile.frameY = reader.ReadByte();
					}
				}
				else
				{
					tile.frameX = -1;
					tile.frameY = -1;
				}
				if (tile.type == ModLoader.GetMod("ModLoader").TileType("PendingMysteryTile")
					&& tables.tileNames.ContainsKey(saveType))
				{
					MysteryTileInfo info;
					if (tables.frameImportant[saveType])
					{
						info = new MysteryTileInfo(tables.tileModNames[saveType], tables.tileNames[saveType],
							tile.frameX, tile.frameY);
					}
					else
					{
						info = new MysteryTileInfo(tables.tileModNames[saveType], tables.tileNames[saveType]);
					}
					MysteryTilesWorld modWorld = (MysteryTilesWorld)ModLoader.GetMod("ModLoader").GetModWorld("MysteryTilesWorld");
					int pendingFrameID = modWorld.pendingInfos.IndexOf(info);
					if (pendingFrameID < 0)
					{
						pendingFrameID = modWorld.pendingInfos.Count;
						modWorld.pendingInfos.Add(info);
					}
					MysteryTileFrame pendingFrame = new MysteryTileFrame(pendingFrameID);
					tile.frameX = pendingFrame.FrameX;
					tile.frameY = pendingFrame.FrameY;
				}
				if ((flags & 8) == 8)
				{
					tile.color(reader.ReadByte());
				}
				WorldGen.tileCounts[tile.type] += j <= Main.worldSurface ? 5 : 1;
			}
			if ((flags & 16) == 16)
			{
				tile.wall = tables.walls[reader.ReadUInt16()];
				if ((flags & 32) == 32)
				{
					tile.wallColor(reader.ReadByte());
				}
			}
			if ((flags & 64) == 64)
			{
				byte sameCount = reader.ReadByte();
				for (byte k = 0; k < sameCount; k++)
				{
					NextTile(ref i, ref j);
					Main.tile[i, j].CopyFrom(tile);
					WorldGen.tileCounts[tile.type] += j <= Main.worldSurface ? 5 : 1;
				}
			}
			if ((flags & 128) == 128)
			{
				nextModTile = true;
			}
		}
		private void ConfirmPendingInfo()
		{
			List<int> truePendingID = new List<int>();
			int nextID = 0;
			for (int k = 0; k < pendingInfos.Count; k++)
			{
				while (nextID < infos.Count && infos[nextID] != null)
				{
					nextID++;
				}
				if (nextID == infos.Count)
				{
					infos.Add(pendingInfos[k]);
				}
				else
				{
					infos[nextID] = pendingInfos[k];
				}
				truePendingID.Add(nextID);
			}
			ushort pendingType = (ushort)ModLoader.GetMod("ModLoader").TileType("PendingMysteryTile");
			ushort mysteryType = (ushort)ModLoader.GetMod("ModLoader").TileType("MysteryTile");
			for (int x = 0; x < Main.maxTilesX; x++)
			{
				for (int y = 0; y < Main.maxTilesY; y++)
				{
					if (Main.tile[x, y].type == pendingType)
					{
						Tile tile = Main.tile[x, y];
						MysteryTileFrame frame = new MysteryTileFrame(tile.frameX, tile.frameY);
						frame = new MysteryTileFrame(truePendingID[frame.FrameID]);
						tile.type = mysteryType;
						tile.frameX = frame.FrameX;
						tile.frameY = frame.FrameY;
					}
				}
			}
		}