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

◆ Step_Walls()

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

Definition at line 1077 of file SmartCursorHelper.cs.

1078 {
1079 int width = providedInfo.player.width;
1080 int height = providedInfo.player.height;
1081 if (providedInfo.item.createWall <= 0 || focusedX != -1 || focusedY != -1)
1082 {
1083 return;
1084 }
1085 _targets.Clear();
1086 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1087 {
1088 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1089 {
1090 Tile tile = Main.tile[i, j];
1091 if (tile.wall == 0 && (!tile.active() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]) && Collision.CanHitWithCheck(providedInfo.position, width, height, new Vector2(i, j) * 16f, 16, 16, DelegateMethods.NotDoorStand))
1092 {
1093 bool flag = false;
1094 if (Main.tile[i - 1, j].active() || Main.tile[i - 1, j].wall > 0)
1095 {
1096 flag = true;
1097 }
1098 if (Main.tile[i + 1, j].active() || Main.tile[i + 1, j].wall > 0)
1099 {
1100 flag = true;
1101 }
1102 if (Main.tile[i, j - 1].active() || Main.tile[i, j - 1].wall > 0)
1103 {
1104 flag = true;
1105 }
1106 if (Main.tile[i, j + 1].active() || Main.tile[i, j + 1].wall > 0)
1107 {
1108 flag = true;
1109 }
1110 if (WorldGen.IsOpenDoorAnchorFrame(i, j))
1111 {
1112 flag = false;
1113 }
1114 if (flag)
1115 {
1116 _targets.Add(new Tuple<int, int>(i, j));
1117 }
1118 }
1119 }
1120 }
1121 if (_targets.Count > 0)
1122 {
1123 float num = -1f;
1125 for (int k = 0; k < _targets.Count; k++)
1126 {
1127 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1128 if (num == -1f || num2 < num)
1129 {
1130 num = num2;
1131 tuple = _targets[k];
1132 }
1133 }
1134 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1135 {
1136 focusedX = tuple.Item1;
1137 focusedY = tuple.Item2;
1138 }
1139 }
1140 _targets.Clear();
1141 }
static List< Tuple< int, int > > _targets
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.GameContent.SmartCursorHelper._targets, Terraria.Tile.active(), Terraria.Collision.CanHitWithCheck(), Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Collision.InTileBounds(), Terraria.WorldGen.IsOpenDoorAnchorFrame(), Terraria.DelegateMethods.NotDoorStand(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, Terraria.Tile.type, and Terraria.Tile.wall.

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