Exemplo n.º 1
0
        public override void MouseOver(int i, int j)
        {
            var tile = Main.tile[i, j];

            if (tile != null && tile.type == Type)
            {
                var frame = new UnloadedTileFrame(tile.frameX, tile.frameY);
                var info  = ModContent.GetInstance <UnloadedTilesWorld>().infos[frame.FrameID];

                if (info != null)
                {
                    Main.LocalPlayer.cursorItemIconEnabled = true;
                    Main.LocalPlayer.cursorItemIconID      = -1;
                    Main.LocalPlayer.cursorItemIconText    = $"{info.modName}: {info.name}";
                }
            }
        }
Exemplo n.º 2
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 == ModContent.Find <ModTile>("ModLoader/PendingUnloadedTile").Type &&
                    tables.tileNames.ContainsKey(saveType))
                {
                    UnloadedTileInfo info;
                    if (tables.frameImportant[saveType])
                    {
                        info = new UnloadedTileInfo(tables.tileModNames[saveType], tables.tileNames[saveType],
                                                    tile.frameX, tile.frameY);
                    }
                    else
                    {
                        info = new UnloadedTileInfo(tables.tileModNames[saveType], tables.tileNames[saveType]);
                    }
                    UnloadedTilesWorld modWorld = ModContent.GetInstance <UnloadedTilesWorld>();
                    int pendingFrameID          = modWorld.pendingInfos.IndexOf(info);
                    if (pendingFrameID < 0)
                    {
                        pendingFrameID = modWorld.pendingInfos.Count;
                        modWorld.pendingInfos.Add(info);
                    }
                    UnloadedTileFrame pendingFrame = new UnloadedTileFrame(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;
            }
        }