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

◆ Step_PlanterBox()

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

Definition at line 405 of file SmartCursorHelper.cs.

406 {
407 if (providedInfo.item.createTile != 380 || focusedX != -1 || focusedY != -1)
408 {
409 return;
410 }
411 _targets.Clear();
412 bool flag = false;
413 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active() && Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].type == 380)
414 {
415 flag = true;
416 }
417 if (!flag)
418 {
419 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
420 {
421 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
422 {
423 Tile tile = Main.tile[i, j];
424 if (tile.active() && tile.type == 380)
425 {
426 if (!Main.tile[i - 1, j].active() || Main.tileCut[Main.tile[i - 1, j].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i - 1, j].type])
427 {
428 _targets.Add(new Tuple<int, int>(i - 1, j));
429 }
430 if (!Main.tile[i + 1, j].active() || Main.tileCut[Main.tile[i + 1, j].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i + 1, j].type])
431 {
432 _targets.Add(new Tuple<int, int>(i + 1, j));
433 }
434 }
435 }
436 }
437 }
438 if (_targets.Count > 0)
439 {
440 float num = -1f;
442 for (int k = 0; k < _targets.Count; k++)
443 {
444 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
445 if (num == -1f || num2 < num)
446 {
447 num = num2;
448 tuple = _targets[k];
449 }
450 }
451 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY) && num != -1f)
452 {
453 focusedX = tuple.Item1;
454 focusedY = tuple.Item2;
455 }
456 }
457 _targets.Clear();
458 }
static List< Tuple< int, int > > _targets
static bool[] BreakableWhenPlacing
Definition TileID.cs:277
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.GameContent.SmartCursorHelper._targets, Terraria.Tile.active(), Terraria.ID.TileID.Sets.BreakableWhenPlacing, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Collision.InTileBounds(), Terraria.Main.tile, and Terraria.Main.tileCut.

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