Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Place2x2()

static void Terraria.WorldGen.Place2x2 ( int x,
int y,
ushort type,
int style )
inlinestatic

Definition at line 42900 of file WorldGen.cs.

42901 {
42902 if (type == 95 || type == 126)
42903 {
42904 y++;
42905 }
42906 if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
42907 {
42908 return;
42909 }
42910 if (type == 172)
42911 {
42912 if (!CanPlaceSink(x, y, type, style))
42913 {
42914 return;
42915 }
42916 }
42917 else
42918 {
42919 for (int i = x - 1; i < x + 1; i++)
42920 {
42921 for (int j = y - 1; j < y + 1; j++)
42922 {
42923 Tile tileSafely = Framing.GetTileSafely(i, j);
42924 if (tileSafely.active() || (type == 98 && tileSafely.liquid > 0))
42925 {
42926 return;
42927 }
42928 }
42929 switch (type)
42930 {
42931 case 95:
42932 case 126:
42933 {
42934 Tile tileSafely = Framing.GetTileSafely(i, y - 2);
42935 if (!tileSafely.nactive() || !Main.tileSolid[tileSafely.type] || Main.tileSolidTop[tileSafely.type])
42936 {
42937 return;
42938 }
42939 break;
42940 }
42941 default:
42942 {
42943 Tile tileSafely = Framing.GetTileSafely(i, y + 1);
42944 if (!tileSafely.nactive() || (!SolidTile2(tileSafely) && !Main.tileTable[tileSafely.type]))
42945 {
42946 return;
42947 }
42948 break;
42949 }
42950 case 132:
42951 break;
42952 }
42953 }
42954 }
42955 if (type == 132)
42956 {
42957 bool flag = true;
42958 if (Main.tile[x - 1, y + 1] == null)
42959 {
42960 Main.tile[x - 1, y + 1] = new Tile();
42961 }
42962 if (Main.tile[x, y + 1] == null)
42963 {
42964 Main.tile[x, y + 1] = new Tile();
42965 }
42966 if (!Main.tile[x - 1, y + 1].nactive() || (!SolidTile2(x - 1, y + 1) && !Main.tileTable[Main.tile[x - 1, y + 1].type]))
42967 {
42968 flag = false;
42969 }
42970 if (!Main.tile[x, y + 1].nactive() || (!SolidTile2(x, y + 1) && !Main.tileTable[Main.tile[x, y + 1].type]))
42971 {
42972 flag = false;
42973 }
42974 if (!flag && (Main.tile[x - 1, y - 1].wall < 1 || Main.tile[x, y - 1].wall < 1 || Main.tile[x - 1, y].wall < 1 || Main.tile[x - 1, y].wall < 1))
42975 {
42976 return;
42977 }
42978 }
42979 x--;
42980 y--;
42981 int num = ((type == 172) ? 38 : 36);
42982 for (int k = 0; k < 2; k++)
42983 {
42984 for (int l = 0; l < 2; l++)
42985 {
42986 Tile tileSafely = Main.tile[x + k, y + l];
42987 tileSafely.active(active: true);
42988 tileSafely.frameX = (short)(k * 18);
42989 tileSafely.frameY = (short)(style * num + l * 18);
42990 tileSafely.type = type;
42991 }
42992 }
42993 }
static bool SolidTile2(Tile testTile)
static bool CanPlaceSink(int x, int y, ushort type, int style)

References Terraria.Framing.GetTileSafely(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, Terraria.Main.tileTable, and System.type.