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

◆ Step_Platforms()

static void Terraria.GameContent.SmartCursorHelper.Step_Platforms ( SmartCursorUsageInfo providedInfo,
ref int focusedX,
ref int focusedY )
inlinestaticprivate

Definition at line 1301 of file SmartCursorHelper.cs.

1302 {
1303 if (providedInfo.item.createTile < 0 || !TileID.Sets.Platforms[providedInfo.item.createTile] || focusedX != -1 || focusedY != -1)
1304 {
1305 return;
1306 }
1307 _targets.Clear();
1308 bool flag = false;
1309 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active() && TileID.Sets.Platforms[Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].type])
1310 {
1311 flag = true;
1312 }
1313 if (!flag)
1314 {
1315 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1316 {
1317 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1318 {
1319 Tile tile = Main.tile[i, j];
1320 if (tile.active() && TileID.Sets.Platforms[tile.type])
1321 {
1322 byte num = tile.slope();
1323 if (num != 2 && !Main.tile[i - 1, j - 1].active())
1324 {
1325 _targets.Add(new Tuple<int, int>(i - 1, j - 1));
1326 }
1327 if (!Main.tile[i - 1, j].active())
1328 {
1329 _targets.Add(new Tuple<int, int>(i - 1, j));
1330 }
1331 if (num != 1 && !Main.tile[i - 1, j + 1].active())
1332 {
1333 _targets.Add(new Tuple<int, int>(i - 1, j + 1));
1334 }
1335 if (num != 1 && !Main.tile[i + 1, j - 1].active())
1336 {
1337 _targets.Add(new Tuple<int, int>(i + 1, j - 1));
1338 }
1339 if (!Main.tile[i + 1, j].active())
1340 {
1341 _targets.Add(new Tuple<int, int>(i + 1, j));
1342 }
1343 if (num != 2 && !Main.tile[i + 1, j + 1].active())
1344 {
1345 _targets.Add(new Tuple<int, int>(i + 1, j + 1));
1346 }
1347 }
1348 if (!tile.active())
1349 {
1350 int num2 = 0;
1351 int num3 = 0;
1352 num2 = 0;
1353 num3 = 1;
1354 Tile tile2 = Main.tile[i + num2, j + num3];
1355 if (tile2.active() && Main.tileSolid[tile2.type] && !Main.tileSolidTop[tile2.type])
1356 {
1357 _targets.Add(new Tuple<int, int>(i, j));
1358 }
1359 num2 = -1;
1360 num3 = 0;
1361 tile2 = Main.tile[i + num2, j + num3];
1362 if (tile2.active() && Main.tileSolid[tile2.type] && !Main.tileSolidTop[tile2.type])
1363 {
1364 _targets.Add(new Tuple<int, int>(i, j));
1365 }
1366 num2 = 1;
1367 num3 = 0;
1368 tile2 = Main.tile[i + num2, j + num3];
1369 if (tile2.active() && Main.tileSolid[tile2.type] && !Main.tileSolidTop[tile2.type])
1370 {
1371 _targets.Add(new Tuple<int, int>(i, j));
1372 }
1373 }
1374 }
1375 }
1376 }
1377 if (_targets.Count > 0)
1378 {
1379 float num4 = -1f;
1381 for (int k = 0; k < _targets.Count; k++)
1382 {
1383 float num5 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1384 if (num4 == -1f || num5 < num4)
1385 {
1386 num4 = num5;
1387 tuple = _targets[k];
1388 }
1389 }
1390 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1391 {
1392 focusedX = tuple.Item1;
1393 focusedY = tuple.Item2;
1394 }
1395 }
1396 _targets.Clear();
1397 }
static List< Tuple< int, int > > _targets
static bool[] Platforms
Definition TileID.cs:163
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.GameContent.SmartCursorHelper._targets, Terraria.Tile.active(), Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Collision.InTileBounds(), Terraria.ID.TileID.Sets.Platforms, Terraria.Tile.slope(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and Terraria.Tile.type.

Referenced by Terraria.GameContent.SmartCursorHelper.SmartCursorLookup().