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

◆ Step_BlocksFilling()

static void Terraria.GameContent.SmartCursorHelper.Step_BlocksFilling ( SmartCursorUsageInfo providedInfo,
ref int fX,
ref int fY )
inlinestaticprivate

Definition at line 2627 of file SmartCursorHelper.cs.

2628 {
2629 if (!Player.SmartCursorSettings.SmartBlocksEnabled)
2630 {
2631 return;
2632 }
2633 int type = providedInfo.item.type;
2635 {
2636 return;
2637 }
2638 int reachableStartX = providedInfo.reachableStartX;
2639 int reachableStartY = providedInfo.reachableStartY;
2640 int reachableEndX = providedInfo.reachableEndX;
2641 int reachableEndY = providedInfo.reachableEndY;
2642 int screenTargetX = providedInfo.screenTargetX;
2643 int screenTargetY = providedInfo.screenTargetY;
2644 if (Player.SmartCursorSettings.SmartBlocksEnabled || providedInfo.item.createTile <= -1 || type == 213 || type == 5295 || ItemID.Sets.GrassSeeds[type] || !Main.tileSolid[providedInfo.item.createTile] || Main.tileSolidTop[providedInfo.item.createTile] || Main.tileFrameImportant[providedInfo.item.createTile] || fX != -1 || fY != -1)
2645 {
2646 return;
2647 }
2648 _targets.Clear();
2649 bool flag = false;
2650 if (Main.tile[screenTargetX, screenTargetY].active())
2651 {
2652 flag = true;
2653 }
2654 if (!Collision.InTileBounds(screenTargetX, screenTargetY, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2655 {
2656 flag = true;
2657 }
2658 if (!flag)
2659 {
2660 for (int i = reachableStartX; i <= reachableEndX; i++)
2661 {
2662 for (int j = reachableStartY; j <= reachableEndY; j++)
2663 {
2664 Tile tile = Main.tile[i, j];
2665 if (!tile.active() || Main.tileCut[tile.type] || TileID.Sets.BreakableWhenPlacing[tile.type])
2666 {
2667 int num = 0;
2668 if (Main.tile[i - 1, j].active() && Main.tileSolid[Main.tile[i - 1, j].type] && !Main.tileSolidTop[Main.tile[i - 1, j].type])
2669 {
2670 num++;
2671 }
2672 if (Main.tile[i + 1, j].active() && Main.tileSolid[Main.tile[i + 1, j].type] && !Main.tileSolidTop[Main.tile[i + 1, j].type])
2673 {
2674 num++;
2675 }
2676 if (Main.tile[i, j - 1].active() && Main.tileSolid[Main.tile[i, j - 1].type] && !Main.tileSolidTop[Main.tile[i, j - 1].type])
2677 {
2678 num++;
2679 }
2680 if (Main.tile[i, j + 1].active() && Main.tileSolid[Main.tile[i, j + 1].type] && !Main.tileSolidTop[Main.tile[i, j + 1].type])
2681 {
2682 num++;
2683 }
2684 if (num >= 2)
2685 {
2686 _targets.Add(new Tuple<int, int>(i, j));
2687 }
2688 }
2689 }
2690 }
2691 }
2692 if (_targets.Count > 0)
2693 {
2694 float num2 = -1f;
2695 float num3 = float.PositiveInfinity;
2697 for (int k = 0; k < _targets.Count; k++)
2698 {
2699 if (Collision.EmptyTile(_targets[k].Item1, _targets[k].Item2, ignoreTiles: true))
2700 {
2701 Vector2 vector = new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f - providedInfo.mouse;
2702 bool flag2 = false;
2703 float num4 = Math.Abs(vector.X);
2704 float num5 = vector.Length();
2705 if (num4 < num3)
2706 {
2707 flag2 = true;
2708 }
2709 if (num4 == num3 && (num2 == -1f || num5 < num2))
2710 {
2711 flag2 = true;
2712 }
2713 if (flag2)
2714 {
2715 num2 = num5;
2716 num3 = num4;
2717 tuple = _targets[k];
2718 }
2719 }
2720 }
2721 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, reachableStartX, reachableStartY, reachableEndX, reachableEndY) && num2 != -1f)
2722 {
2723 fX = tuple.Item1;
2724 fY = tuple.Item2;
2725 }
2726 }
2727 _targets.Clear();
2728 }
static double Abs(double value)
static List< Tuple< int, int > > _targets
static bool[] GrassSeeds
Definition ItemID.cs:65
static readonly short Count
Definition ItemID.cs:12138
static bool[] BreakableWhenPlacing
Definition TileID.cs:277

References Terraria.GameContent.SmartCursorHelper._targets, System.Math.Abs(), Terraria.Tile.active(), Terraria.ID.TileID.Sets.BreakableWhenPlacing, Terraria.ID.ItemID.Count, Terraria.Collision.EmptyTile(), Terraria.ID.ItemID.Sets.GrassSeeds, Terraria.Collision.InTileBounds(), Terraria.Player.SmartCursorSettings.SmartBlocksEnabled, Terraria.Main.tile, Terraria.Main.tileCut, Terraria.Main.tileFrameImportant, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, System.type, and Terraria.Tile.type.

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