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

◆ CheckTorch()

static void Terraria.WorldGen.CheckTorch ( int x,
int y )
inlinestatic

Definition at line 76174 of file WorldGen.cs.

76175 {
76176 for (int i = x - 1; i <= x + 1; i++)
76177 {
76178 for (int j = y - 1; j <= y + 1; j++)
76179 {
76180 if (Main.tile[i, j] == null)
76181 {
76182 return;
76183 }
76184 }
76185 }
76186 Tile tile = Main.tile[x, y];
76187 Tile tile2 = Main.tile[x, y - 1];
76188 Tile tile3 = Main.tile[x, y + 1];
76189 Tile tile4 = Main.tile[x - 1, y];
76190 Tile tile5 = Main.tile[x + 1, y];
76191 Tile tile6 = Main.tile[x - 1, y + 1];
76192 Tile tile7 = Main.tile[x + 1, y + 1];
76193 Tile tile8 = Main.tile[x - 1, y - 1];
76194 Tile tile9 = Main.tile[x + 1, y - 1];
76195 short num = 0;
76196 if (tile.frameX >= 66)
76197 {
76198 num = 66;
76199 }
76200 int num2 = -1;
76201 int num3 = -1;
76202 int num4 = -1;
76203 int tree = -1;
76204 int tree2 = -1;
76205 int tree3 = -1;
76206 int tree4 = -1;
76207 if (tile2 != null && tile2.active() && !tile2.bottomSlope())
76208 {
76209 _ = tile2.type;
76210 }
76211 if (tile3 != null && tile3.active() && ((TileID.Sets.Platforms[tile3.type] && TopEdgeCanBeAttachedTo(x, y + 1)) || (!tile3.halfBrick() && !tile3.topSlope())))
76212 {
76213 num2 = tile3.type;
76214 }
76215 if (tile4 != null && tile4.active() && (tile4.slope() == 0 || tile4.slope() % 2 != 1))
76216 {
76217 num3 = tile4.type;
76218 }
76219 if (tile5 != null && tile5.active() && (tile5.slope() == 0 || tile5.slope() % 2 != 0))
76220 {
76221 num4 = tile5.type;
76222 }
76223 if (tile6 != null && tile6.active())
76224 {
76225 tree = tile6.type;
76226 }
76227 if (tile7 != null && tile7.active())
76228 {
76229 tree2 = tile7.type;
76230 }
76231 if (tile8 != null && tile8.active())
76232 {
76233 tree3 = tile8.type;
76234 }
76235 if (tile9 != null && tile9.active())
76236 {
76237 tree4 = tile9.type;
76238 }
76239 if (num2 >= 0 && Main.tileSolid[num2] && (!Main.tileNoAttach[num2] || TileID.Sets.Platforms[num2]))
76240 {
76241 tile.frameX = num;
76242 }
76243 else if ((num3 >= 0 && Main.tileSolid[num3] && !Main.tileNoAttach[num3]) || (num3 >= 0 && TileID.Sets.IsBeam[num3]) || (IsTreeType(num3) && IsTreeType(tree3) && IsTreeType(tree)))
76244 {
76245 tile.frameX = (short)(22 + num);
76246 }
76247 else if ((num4 >= 0 && Main.tileSolid[num4] && !Main.tileNoAttach[num4]) || (num4 >= 0 && TileID.Sets.IsBeam[num4]) || (IsTreeType(num4) && IsTreeType(tree4) && IsTreeType(tree2)))
76248 {
76249 tile.frameX = (short)(44 + num);
76250 }
76251 else if (tile.wall > 0)
76252 {
76253 tile.frameX = num;
76254 }
76255 else
76256 {
76257 KillTile(x, y);
76258 }
76259 }
static bool[] IsBeam
Definition TileID.cs:161
static bool[] Platforms
Definition TileID.cs:163
static bool IsTreeType(int tree)
static bool TopEdgeCanBeAttachedTo(int i, int j)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)

References Terraria.Tile.frameX, Terraria.ID.TileID.Sets.IsBeam, Terraria.ID.TileID.Sets.Platforms, Terraria.Main.tile, Terraria.Main.tileNoAttach, Terraria.Main.tileSolid, and Terraria.Tile.wall.