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

◆ Step_MinecartTracks()

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

Definition at line 1143 of file SmartCursorHelper.cs.

1144 {
1145 if ((providedInfo.item.type == 2340 || providedInfo.item.type == 2739) && focusedX == -1 && focusedY == -1)
1146 {
1147 _targets.Clear();
1148 Vector2 value = (Main.MouseWorld - providedInfo.Center).SafeNormalize(Vector2.UnitY);
1149 float num = Vector2.Dot(value, -Vector2.UnitY);
1150 bool flag = num >= 0.5f;
1151 bool flag2 = num <= -0.5f;
1152 float num2 = Vector2.Dot(value, Vector2.UnitX);
1153 bool flag3 = num2 >= 0.5f;
1154 bool flag4 = num2 <= -0.5f;
1155 bool flag5 = flag && flag4;
1156 bool flag6 = flag && flag3;
1157 bool flag7 = flag2 && flag4;
1158 bool flag8 = flag2 && flag3;
1159 if (flag5)
1160 {
1161 flag4 = false;
1162 }
1163 if (flag6)
1164 {
1165 flag3 = false;
1166 }
1167 if (flag7)
1168 {
1169 flag4 = false;
1170 }
1171 if (flag8)
1172 {
1173 flag3 = false;
1174 }
1175 bool flag9 = false;
1176 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active() && Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].type == 314)
1177 {
1178 flag9 = true;
1179 }
1180 if (!flag9)
1181 {
1182 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1183 {
1184 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1185 {
1186 Tile tile = Main.tile[i, j];
1187 if (tile.active() && tile.type == 314)
1188 {
1189 bool flag10 = Main.tile[i + 1, j + 1].active() && Main.tile[i + 1, j + 1].type == 314;
1190 bool flag11 = Main.tile[i + 1, j - 1].active() && Main.tile[i + 1, j - 1].type == 314;
1191 bool flag12 = Main.tile[i - 1, j + 1].active() && Main.tile[i - 1, j + 1].type == 314;
1192 bool flag13 = Main.tile[i - 1, j - 1].active() && Main.tile[i - 1, j - 1].type == 314;
1193 if (flag5 && (!Main.tile[i - 1, j - 1].active() || Main.tileCut[Main.tile[i - 1, j - 1].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i - 1, j - 1].type]) && !(!flag10 && flag11) && !flag12)
1194 {
1195 _targets.Add(new Tuple<int, int>(i - 1, j - 1));
1196 }
1197 if (flag4 && (!Main.tile[i - 1, j].active() || Main.tileCut[Main.tile[i - 1, j].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i - 1, j].type]))
1198 {
1199 _targets.Add(new Tuple<int, int>(i - 1, j));
1200 }
1201 if (flag7 && (!Main.tile[i - 1, j + 1].active() || Main.tileCut[Main.tile[i - 1, j + 1].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i - 1, j + 1].type]) && !(!flag11 && flag10) && !flag13)
1202 {
1203 _targets.Add(new Tuple<int, int>(i - 1, j + 1));
1204 }
1205 if (flag6 && (!Main.tile[i + 1, j - 1].active() || Main.tileCut[Main.tile[i + 1, j - 1].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i + 1, j - 1].type]) && !(!flag12 && flag13) && !flag10)
1206 {
1207 _targets.Add(new Tuple<int, int>(i + 1, j - 1));
1208 }
1209 if (flag3 && (!Main.tile[i + 1, j].active() || Main.tileCut[Main.tile[i + 1, j].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i + 1, j].type]))
1210 {
1211 _targets.Add(new Tuple<int, int>(i + 1, j));
1212 }
1213 if (flag8 && (!Main.tile[i + 1, j + 1].active() || Main.tileCut[Main.tile[i + 1, j + 1].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[i + 1, j + 1].type]) && !(!flag13 && flag12) && !flag11)
1214 {
1215 _targets.Add(new Tuple<int, int>(i + 1, j + 1));
1216 }
1217 }
1218 }
1219 }
1220 }
1221 if (_targets.Count > 0)
1222 {
1223 float num3 = -1f;
1225 for (int k = 0; k < _targets.Count; k++)
1226 {
1227 if ((!Main.tile[_targets[k].Item1, _targets[k].Item2 - 1].active() || Main.tile[_targets[k].Item1, _targets[k].Item2 - 1].type != 314) && (!Main.tile[_targets[k].Item1, _targets[k].Item2 + 1].active() || Main.tile[_targets[k].Item1, _targets[k].Item2 + 1].type != 314))
1228 {
1229 float num4 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1230 if (num3 == -1f || num4 < num3)
1231 {
1232 num3 = num4;
1233 tuple = _targets[k];
1234 }
1235 }
1236 }
1237 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY) && num3 != -1f)
1238 {
1239 focusedX = tuple.Item1;
1240 focusedY = tuple.Item2;
1241 }
1242 }
1243 _targets.Clear();
1244 }
1245 if (providedInfo.item.type != 2492 || focusedX != -1 || focusedY != -1)
1246 {
1247 return;
1248 }
1249 _targets.Clear();
1250 bool flag14 = false;
1251 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active() && Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].type == 314)
1252 {
1253 flag14 = true;
1254 }
1255 if (!flag14)
1256 {
1257 for (int l = providedInfo.reachableStartX; l <= providedInfo.reachableEndX; l++)
1258 {
1259 for (int m = providedInfo.reachableStartY; m <= providedInfo.reachableEndY; m++)
1260 {
1261 Tile tile2 = Main.tile[l, m];
1262 if (tile2.active() && tile2.type == 314)
1263 {
1264 if (!Main.tile[l - 1, m].active() || Main.tileCut[Main.tile[l - 1, m].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[l - 1, m].type])
1265 {
1266 _targets.Add(new Tuple<int, int>(l - 1, m));
1267 }
1268 if (!Main.tile[l + 1, m].active() || Main.tileCut[Main.tile[l + 1, m].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[l + 1, m].type])
1269 {
1270 _targets.Add(new Tuple<int, int>(l + 1, m));
1271 }
1272 }
1273 }
1274 }
1275 }
1276 if (_targets.Count > 0)
1277 {
1278 float num5 = -1f;
1280 for (int n = 0; n < _targets.Count; n++)
1281 {
1282 if ((!Main.tile[_targets[n].Item1, _targets[n].Item2 - 1].active() || Main.tile[_targets[n].Item1, _targets[n].Item2 - 1].type != 314) && (!Main.tile[_targets[n].Item1, _targets[n].Item2 + 1].active() || Main.tile[_targets[n].Item1, _targets[n].Item2 + 1].type != 314))
1283 {
1284 float num6 = Vector2.Distance(new Vector2(_targets[n].Item1, _targets[n].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1285 if (num5 == -1f || num6 < num5)
1286 {
1287 num5 = num6;
1288 tuple2 = _targets[n];
1289 }
1290 }
1291 }
1292 if (Collision.InTileBounds(tuple2.Item1, tuple2.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY) && num5 != -1f)
1293 {
1294 focusedX = tuple2.Item1;
1295 focusedY = tuple2.Item2;
1296 }
1297 }
1298 _targets.Clear();
1299 }
static List< Tuple< int, int > > _targets
static bool[] BreakableWhenPlacing
Definition TileID.cs:277
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121
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(), Microsoft.Xna.Framework.Vector2.Dot(), Terraria.Collision.InTileBounds(), Terraria.Main.tile, Terraria.Main.tileCut, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Vector2.UnitY, and System.value.

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