Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SmartCursorHelper.cs
Go to the documentation of this file.
1using System;
7using Terraria.ID;
8
10
12{
14 {
15 public Player player;
16
17 public Item item;
18
19 public Vector2 mouse;
20
22
24
25 public int screenTargetX;
26
27 public int screenTargetY;
28
29 public int reachableStartX;
30
31 public int reachableEndX;
32
33 public int reachableStartY;
34
35 public int reachableEndY;
36
37 public int paintLookup;
38
40 }
41
43
45
47
49
51
53
54 public static void SmartCursorLookup(Player player)
55 {
56 Main.SmartCursorShowing = false;
58 {
59 return;
60 }
62 {
63 player = player,
64 item = player.inventory[player.selectedItem],
65 mouse = Main.MouseWorld,
66 position = player.position,
67 Center = player.Center
68 };
69 _ = player.gravDir;
70 int tileTargetX = Player.tileTargetX;
71 int tileTargetY = Player.tileTargetY;
72 int tileRangeX = Player.tileRangeX;
73 int tileRangeY = Player.tileRangeY;
74 smartCursorUsageInfo.screenTargetX = Utils.Clamp(tileTargetX, 10, Main.maxTilesX - 10);
75 smartCursorUsageInfo.screenTargetY = Utils.Clamp(tileTargetY, 10, Main.maxTilesY - 10);
76 if (Main.tile[smartCursorUsageInfo.screenTargetX, smartCursorUsageInfo.screenTargetY] == null)
77 {
78 return;
79 }
82 int tileBoost = smartCursorUsageInfo.item.tileBoost;
83 smartCursorUsageInfo.reachableStartX = (int)(player.position.X / 16f) - tileRangeX - tileBoost + 1;
84 smartCursorUsageInfo.reachableEndX = (int)((player.position.X + (float)player.width) / 16f) + tileRangeX + tileBoost - 1;
85 smartCursorUsageInfo.reachableStartY = (int)(player.position.Y / 16f) - tileRangeY - tileBoost + 1;
86 smartCursorUsageInfo.reachableEndY = (int)((player.position.Y + (float)player.height) / 16f) + tileRangeY + tileBoost - 2;
87 smartCursorUsageInfo.reachableStartX = Utils.Clamp(smartCursorUsageInfo.reachableStartX, 10, Main.maxTilesX - 10);
88 smartCursorUsageInfo.reachableEndX = Utils.Clamp(smartCursorUsageInfo.reachableEndX, 10, Main.maxTilesX - 10);
89 smartCursorUsageInfo.reachableStartY = Utils.Clamp(smartCursorUsageInfo.reachableStartY, 10, Main.maxTilesY - 10);
90 smartCursorUsageInfo.reachableEndY = Utils.Clamp(smartCursorUsageInfo.reachableEndY, 10, Main.maxTilesY - 10);
91 if (!num || smartCursorUsageInfo.screenTargetX < smartCursorUsageInfo.reachableStartX || smartCursorUsageInfo.screenTargetX > smartCursorUsageInfo.reachableEndX || smartCursorUsageInfo.screenTargetY < smartCursorUsageInfo.reachableStartY || smartCursorUsageInfo.screenTargetY > smartCursorUsageInfo.reachableEndY)
92 {
93 _grappleTargets.Clear();
94 int[] grappling = player.grappling;
95 int grapCount = player.grapCount;
96 for (int i = 0; i < grapCount; i++)
97 {
98 Projectile obj = Main.projectile[grappling[i]];
99 int item = (int)obj.Center.X / 16;
100 int item2 = (int)obj.Center.Y / 16;
102 }
103 int fX = -1;
104 int fY = -1;
106 {
108 }
113 {
115 }
143 if (fX != -1 && fY != -1)
144 {
145 Main.SmartCursorX = (Player.tileTargetX = fX);
146 Main.SmartCursorY = (Player.tileTargetY = fY);
147 Main.SmartCursorShowing = true;
148 }
149 _grappleTargets.Clear();
150 }
151 }
152
154 {
155 _ = providedInfo.player.inventory;
156 paintLookup = 0;
157 coatingLookup = 0;
158 if (providedInfo.item.type == 1071 || providedInfo.item.type == 1543 || providedInfo.item.type == 1072 || providedInfo.item.type == 1544)
159 {
160 Item item = providedInfo.player.FindPaintOrCoating();
161 if (item != null)
162 {
163 coatingLookup = item.paintCoating;
164 paintLookup = item.paint;
165 }
166 }
167 }
168
170 {
171 bool result = false;
172 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active())
173 {
174 switch (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].type)
175 {
176 case 4:
177 case 10:
178 case 11:
179 case 13:
180 case 21:
181 case 29:
182 case 33:
183 case 49:
184 case 50:
185 case 55:
186 case 79:
187 case 85:
188 case 88:
189 case 97:
190 case 104:
191 case 125:
192 case 132:
193 case 136:
194 case 139:
195 case 144:
196 case 174:
197 case 207:
198 case 209:
199 case 212:
200 case 216:
201 case 219:
202 case 237:
203 case 287:
204 case 334:
205 case 335:
206 case 338:
207 case 354:
208 case 386:
209 case 387:
210 case 388:
211 case 389:
212 case 411:
213 case 425:
214 case 441:
215 case 463:
216 case 464:
217 case 467:
218 case 468:
219 case 491:
220 case 494:
221 case 510:
222 case 511:
223 case 573:
224 case 621:
225 case 642:
226 result = true;
227 break;
228 case 314:
229 if (providedInfo.player.gravDir == 1f)
230 {
231 result = true;
232 }
233 break;
234 }
235 }
236 return result;
237 }
238
240 {
241 if ((providedInfo.item.type != 213 && providedInfo.item.type != 5295) || focusedX != -1 || focusedY != -1)
242 {
243 return;
244 }
245 _targets.Clear();
246 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
247 {
248 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
249 {
250 Tile tile = Main.tile[i, j];
251 bool flag = !Main.tile[i - 1, j].active() || !Main.tile[i, j + 1].active() || !Main.tile[i + 1, j].active() || !Main.tile[i, j - 1].active();
252 bool flag2 = !Main.tile[i - 1, j - 1].active() || !Main.tile[i - 1, j + 1].active() || !Main.tile[i + 1, j + 1].active() || !Main.tile[i + 1, j - 1].active();
253 if (tile.active() && !tile.inActive() && tile.type == 0 && (flag || (tile.type == 0 && flag2)))
254 {
255 _targets.Add(new Tuple<int, int>(i, j));
256 }
257 }
258 }
259 if (_targets.Count > 0)
260 {
261 float num = -1f;
263 for (int k = 0; k < _targets.Count; k++)
264 {
265 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
266 if (num == -1f || num2 < num)
267 {
268 num = num2;
269 tuple = _targets[k];
270 }
271 }
272 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
273 {
274 focusedX = tuple.Item1;
275 focusedY = tuple.Item2;
276 }
277 }
278 _targets.Clear();
279 }
280
282 {
283 if (focusedX > -1 || focusedY > -1)
284 {
285 return;
286 }
287 int type = providedInfo.item.type;
289 {
290 return;
291 }
292 _targets.Clear();
293 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
294 {
295 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
296 {
297 Tile tile = Main.tile[i, j];
298 bool flag = !Main.tile[i - 1, j].active() || !Main.tile[i, j + 1].active() || !Main.tile[i + 1, j].active() || !Main.tile[i, j - 1].active();
299 bool flag2 = !Main.tile[i - 1, j - 1].active() || !Main.tile[i - 1, j + 1].active() || !Main.tile[i + 1, j + 1].active() || !Main.tile[i + 1, j - 1].active();
300 if (tile.active() && !tile.inActive() && (flag || flag2))
301 {
302 bool flag3 = false;
303 switch (type)
304 {
305 default:
306 flag3 = tile.type == 0;
307 break;
308 case 59:
309 case 2171:
310 flag3 = tile.type == 0 || tile.type == 59;
311 break;
312 case 194:
313 case 195:
314 flag3 = tile.type == 59;
315 break;
316 case 5214:
317 flag3 = tile.type == 57;
318 break;
319 }
320 if (flag3)
321 {
322 _targets.Add(new Tuple<int, int>(i, j));
323 }
324 }
325 }
326 }
327 if (_targets.Count > 0)
328 {
329 float num = -1f;
331 for (int k = 0; k < _targets.Count; k++)
332 {
333 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
334 if (num == -1f || num2 < num)
335 {
336 num = num2;
337 tuple = _targets[k];
338 }
339 }
340 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
341 {
342 focusedX = tuple.Item1;
343 focusedY = tuple.Item2;
344 }
345 }
346 _targets.Clear();
347 }
348
350 {
351 if (providedInfo.item.createTile != 78 || focusedX != -1 || focusedY != -1)
352 {
353 return;
354 }
355 _targets.Clear();
356 bool flag = false;
357 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active())
358 {
359 flag = true;
360 }
361 if (!Collision.InTileBounds(providedInfo.screenTargetX, providedInfo.screenTargetY, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
362 {
363 flag = true;
364 }
365 if (!flag)
366 {
367 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
368 {
369 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
370 {
371 Tile tile = Main.tile[i, j];
372 Tile tile2 = Main.tile[i, j + 1];
373 if ((!tile.active() || Main.tileCut[tile.type] || TileID.Sets.BreakableWhenPlacing[tile.type]) && tile2.nactive() && !tile2.halfBrick() && tile2.slope() == 0 && Main.tileSolid[tile2.type])
374 {
375 _targets.Add(new Tuple<int, int>(i, j));
376 }
377 }
378 }
379 }
380 if (_targets.Count > 0)
381 {
382 float num = -1f;
384 for (int k = 0; k < _targets.Count; k++)
385 {
386 if (Collision.EmptyTile(_targets[k].Item1, _targets[k].Item2, ignoreTiles: true))
387 {
388 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
389 if (num == -1f || num2 < num)
390 {
391 num = num2;
392 tuple = _targets[k];
393 }
394 }
395 }
396 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY) && num != -1f)
397 {
398 focusedX = tuple.Item1;
399 focusedY = tuple.Item2;
400 }
401 }
402 _targets.Clear();
403 }
404
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 }
459
461 {
462 if (providedInfo.item.createTile != 82 || focusedX != -1 || focusedY != -1)
463 {
464 return;
465 }
466 int placeStyle = providedInfo.item.placeStyle;
467 _targets.Clear();
468 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
469 {
470 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
471 {
472 Tile tile = Main.tile[i, j];
473 Tile tile2 = Main.tile[i, j + 1];
474 bool num = !tile.active() || TileID.Sets.BreakableWhenPlacing[tile.type] || (Main.tileCut[tile.type] && tile.type != 82 && tile.type != 83) || WorldGen.IsHarvestableHerbWithSeed(tile.type, tile.frameX / 18);
475 bool flag = tile2.nactive() && !tile2.halfBrick() && tile2.slope() == 0;
476 if (!num || !flag)
477 {
478 continue;
479 }
480 switch (placeStyle)
481 {
482 case 0:
483 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 2 && tile2.type != 477 && tile2.type != 109 && tile2.type != 492) || tile.liquid > 0)
484 {
485 continue;
486 }
487 break;
488 case 1:
489 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 60) || tile.liquid > 0)
490 {
491 continue;
492 }
493 break;
494 case 2:
495 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 0 && tile2.type != 59) || tile.liquid > 0)
496 {
497 continue;
498 }
499 break;
500 case 3:
501 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 203 && tile2.type != 199 && tile2.type != 23 && tile2.type != 25) || tile.liquid > 0)
502 {
503 continue;
504 }
505 break;
506 case 4:
507 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 53 && tile2.type != 116) || (tile.liquid > 0 && tile.lava()))
508 {
509 continue;
510 }
511 break;
512 case 5:
513 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 57 && tile2.type != 633) || (tile.liquid > 0 && !tile.lava()))
514 {
515 continue;
516 }
517 break;
518 case 6:
519 if ((tile2.type != 78 && tile2.type != 380 && tile2.type != 147 && tile2.type != 161 && tile2.type != 163 && tile2.type != 164 && tile2.type != 200) || (tile.liquid > 0 && tile.lava()))
520 {
521 continue;
522 }
523 break;
524 }
525 _targets.Add(new Tuple<int, int>(i, j));
526 }
527 }
528 if (_targets.Count > 0)
529 {
530 float num2 = -1f;
532 for (int k = 0; k < _targets.Count; k++)
533 {
534 float num3 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
535 if (num2 == -1f || num3 < num2)
536 {
537 num2 = num3;
538 tuple = _targets[k];
539 }
540 }
541 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
542 {
543 focusedX = tuple.Item1;
544 focusedY = tuple.Item2;
545 }
546 }
547 _targets.Clear();
548 }
549
551 {
552 if (providedInfo.item.type != 849 || focusedX != -1 || focusedY != -1)
553 {
554 return;
555 }
556 _targets.Clear();
557 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
558 {
559 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
560 {
561 Tile tile = Main.tile[i, j];
562 if ((tile.wire() || tile.wire2() || tile.wire3() || tile.wire4()) && !tile.actuator() && tile.active())
563 {
564 _targets.Add(new Tuple<int, int>(i, j));
565 }
566 }
567 }
568 if (_targets.Count > 0)
569 {
570 float num = -1f;
572 for (int k = 0; k < _targets.Count; k++)
573 {
574 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
575 if (num == -1f || num2 < num)
576 {
577 num = num2;
578 tuple = _targets[k];
579 }
580 }
581 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
582 {
583 focusedX = tuple.Item1;
584 focusedY = tuple.Item2;
585 }
586 }
587 _targets.Clear();
588 }
589
591 {
592 if (providedInfo.item.type != 205 || focusedX != -1 || focusedY != -1)
593 {
594 return;
595 }
596 _targets.Clear();
597 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
598 {
599 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
600 {
601 Tile tile = Main.tile[i, j];
602 if (tile.liquid <= 0)
603 {
604 continue;
605 }
606 int num = tile.liquidType();
607 int num2 = 0;
608 for (int k = i - 1; k <= i + 1; k++)
609 {
610 for (int l = j - 1; l <= j + 1; l++)
611 {
612 if (Main.tile[k, l].liquidType() == num)
613 {
614 num2 += Main.tile[k, l].liquid;
615 }
616 }
617 }
618 if (num2 > 100)
619 {
620 _targets.Add(new Tuple<int, int>(i, j));
621 }
622 }
623 }
624 if (_targets.Count > 0)
625 {
626 float num3 = -1f;
628 for (int m = 0; m < _targets.Count; m++)
629 {
630 float num4 = Vector2.Distance(new Vector2(_targets[m].Item1, _targets[m].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
631 if (num3 == -1f || num4 < num3)
632 {
633 num3 = num4;
634 tuple = _targets[m];
635 }
636 }
637 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
638 {
639 focusedX = tuple.Item1;
640 focusedY = tuple.Item2;
641 }
642 }
643 _targets.Clear();
644 }
645
647 {
648 if (!ItemID.Sets.IsPaintScraper[providedInfo.item.type] || focusedX != -1 || focusedY != -1)
649 {
650 return;
651 }
652 _targets.Clear();
653 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
654 {
655 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
656 {
657 Tile tile = Main.tile[i, j];
658 bool flag = false;
659 if (tile.active())
660 {
661 flag |= tile.color() > 0;
662 flag |= tile.type == 184;
663 flag |= tile.fullbrightBlock();
664 flag |= tile.invisibleBlock();
665 }
666 if (tile.wall > 0)
667 {
668 flag |= tile.wallColor() > 0;
669 flag |= tile.fullbrightWall();
670 flag |= tile.invisibleWall();
671 }
672 if (flag)
673 {
674 _targets.Add(new Tuple<int, int>(i, j));
675 }
676 }
677 }
678 if (_targets.Count > 0)
679 {
680 float num = -1f;
682 for (int k = 0; k < _targets.Count; k++)
683 {
684 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
685 if (num == -1f || num2 < num)
686 {
687 num = num2;
688 tuple = _targets[k];
689 }
690 }
691 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
692 {
693 focusedX = tuple.Item1;
694 focusedY = tuple.Item2;
695 }
696 }
697 _targets.Clear();
698 }
699
701 {
702 if ((providedInfo.item.type != 1071 && providedInfo.item.type != 1543) || (providedInfo.paintLookup == 0 && providedInfo.paintCoatingLookup == 0) || focusedX != -1 || focusedY != -1)
703 {
704 return;
705 }
706 _targets.Clear();
707 int paintLookup = providedInfo.paintLookup;
708 int paintCoatingLookup = providedInfo.paintCoatingLookup;
709 if (paintLookup != 0 || paintCoatingLookup != 0)
710 {
711 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
712 {
713 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
714 {
715 Tile tile = Main.tile[i, j];
716 if (tile.active() && (false | (paintLookup != 0 && tile.color() != paintLookup) | (paintCoatingLookup == 1 && !tile.fullbrightBlock()) | (paintCoatingLookup == 2 && !tile.invisibleBlock())))
717 {
718 _targets.Add(new Tuple<int, int>(i, j));
719 }
720 }
721 }
722 }
723 if (_targets.Count > 0)
724 {
725 float num = -1f;
727 for (int k = 0; k < _targets.Count; k++)
728 {
729 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
730 if (num == -1f || num2 < num)
731 {
732 num = num2;
733 tuple = _targets[k];
734 }
735 }
736 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
737 {
738 focusedX = tuple.Item1;
739 focusedY = tuple.Item2;
740 }
741 }
742 _targets.Clear();
743 }
744
746 {
747 if ((providedInfo.item.type != 1072 && providedInfo.item.type != 1544) || (providedInfo.paintLookup == 0 && providedInfo.paintCoatingLookup == 0) || focusedX != -1 || focusedY != -1)
748 {
749 return;
750 }
751 _targets.Clear();
752 int paintLookup = providedInfo.paintLookup;
753 int paintCoatingLookup = providedInfo.paintCoatingLookup;
754 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
755 {
756 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
757 {
758 Tile tile = Main.tile[i, j];
759 if (tile.wall > 0 && (!tile.active() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]) && (false | (paintLookup != 0 && tile.wallColor() != paintLookup) | (paintCoatingLookup == 1 && !tile.fullbrightWall()) | (paintCoatingLookup == 2 && !tile.invisibleWall())))
760 {
761 _targets.Add(new Tuple<int, int>(i, j));
762 }
763 }
764 }
765 if (_targets.Count > 0)
766 {
767 float num = -1f;
769 for (int k = 0; k < _targets.Count; k++)
770 {
771 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
772 if (num == -1f || num2 < num)
773 {
774 num = num2;
775 tuple = _targets[k];
776 }
777 }
778 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
779 {
780 focusedX = tuple.Item1;
781 focusedY = tuple.Item2;
782 }
783 }
784 _targets.Clear();
785 }
786
788 {
789 int type = providedInfo.item.type;
790 if (type < 0 || type >= ItemID.Count || !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] || focusedX != -1 || focusedY != -1)
791 {
792 return;
793 }
794 _targets.Clear();
795 bool flag = false;
796 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].active())
797 {
798 flag = true;
799 }
800 if (!Collision.InTileBounds(providedInfo.screenTargetX, providedInfo.screenTargetY, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
801 {
802 flag = true;
803 }
804 if (!flag)
805 {
806 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
807 {
808 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
809 {
810 Tile tile = Main.tile[i, j];
811 if (!tile.active() || Main.tileCut[tile.type] || TileID.Sets.BreakableWhenPlacing[tile.type])
812 {
813 bool flag2 = false;
814 if (Main.tile[i - 1, j].active() && Main.tileSolid[Main.tile[i - 1, j].type] && !Main.tileSolidTop[Main.tile[i - 1, j].type])
815 {
816 flag2 = true;
817 }
818 if (Main.tile[i + 1, j].active() && Main.tileSolid[Main.tile[i + 1, j].type] && !Main.tileSolidTop[Main.tile[i + 1, j].type])
819 {
820 flag2 = true;
821 }
822 if (Main.tile[i, j - 1].active() && Main.tileSolid[Main.tile[i, j - 1].type] && !Main.tileSolidTop[Main.tile[i, j - 1].type])
823 {
824 flag2 = true;
825 }
826 if (Main.tile[i, j + 1].active() && Main.tileSolid[Main.tile[i, j + 1].type] && !Main.tileSolidTop[Main.tile[i, j + 1].type])
827 {
828 flag2 = true;
829 }
830 if (flag2)
831 {
832 _targets.Add(new Tuple<int, int>(i, j));
833 }
834 }
835 }
836 }
837 }
838 if (_targets.Count > 0)
839 {
840 float num = -1f;
842 for (int k = 0; k < _targets.Count; k++)
843 {
844 if (Collision.EmptyTile(_targets[k].Item1, _targets[k].Item2))
845 {
846 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
847 if (num == -1f || num2 < num)
848 {
849 num = num2;
850 tuple = _targets[k];
851 }
852 }
853 }
854 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY) && num != -1f)
855 {
856 focusedX = tuple.Item1;
857 focusedY = tuple.Item2;
858 }
859 }
860 _targets.Clear();
861 }
862
864 {
865 if (providedInfo.item.createTile <= -1 || providedInfo.item.createTile >= TileID.Count || !TileID.Sets.Boulders[providedInfo.item.createTile] || focusedX != -1 || focusedY != -1)
866 {
867 return;
868 }
869 _targets.Clear();
870 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
871 {
872 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
873 {
874 Tile tile = Main.tile[i, j + 1];
875 Tile tile2 = Main.tile[i + 1, j + 1];
876 bool flag = true;
877 if (!tile2.nactive() || !tile.nactive())
878 {
879 flag = false;
880 }
881 if (tile2.slope() > 0 || tile.slope() > 0 || tile2.halfBrick() || tile.halfBrick())
882 {
883 flag = false;
884 }
885 if ((!Main.tileSolid[tile2.type] && !Main.tileTable[tile2.type]) || (!Main.tileSolid[tile.type] && !Main.tileTable[tile.type]))
886 {
887 flag = false;
888 }
889 if (Main.tileNoAttach[tile2.type] || Main.tileNoAttach[tile.type])
890 {
891 flag = false;
892 }
893 for (int k = i; k <= i + 1; k++)
894 {
895 for (int l = j - 1; l <= j; l++)
896 {
897 Tile tile3 = Main.tile[k, l];
898 if (tile3.active() && !Main.tileCut[tile3.type])
899 {
900 flag = false;
901 }
902 }
903 }
904 int x = i * 16;
905 int y = j * 16 - 16;
906 int width = 32;
907 int height = 32;
908 Rectangle value = new Rectangle(x, y, width, height);
909 for (int m = 0; m < 255; m++)
910 {
911 Player player = Main.player[m];
912 if (player.active && !player.dead && player.Hitbox.Intersects(value))
913 {
914 flag = false;
915 break;
916 }
917 }
918 if (flag)
919 {
920 _targets.Add(new Tuple<int, int>(i, j));
921 }
922 }
923 }
924 if (_targets.Count > 0)
925 {
926 float num = -1f;
928 for (int n = 0; n < _targets.Count; n++)
929 {
930 float num2 = Vector2.Distance(new Vector2(_targets[n].Item1, _targets[n].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
931 if (num == -1f || num2 < num)
932 {
933 num = num2;
934 tuple = _targets[n];
935 }
936 }
937 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
938 {
939 focusedX = tuple.Item1;
940 focusedY = tuple.Item2;
941 }
942 }
943 _targets.Clear();
944 }
945
947 {
948 if (providedInfo.item.createTile != 454 || focusedX != -1 || focusedY != -1)
949 {
950 return;
951 }
952 _targets.Clear();
953 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
954 {
955 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY && !((double)j > Main.worldSurface - 2.0); j++)
956 {
957 bool flag = true;
958 for (int k = i - 2; k <= i + 1; k++)
959 {
960 for (int l = j - 1; l <= j + 2; l++)
961 {
962 Tile tile = Main.tile[k, l];
963 if (l == j - 1)
964 {
965 if (!WorldGen.SolidTile(tile))
966 {
967 flag = false;
968 }
969 }
970 else if (tile.active() && (!Main.tileCut[tile.type] || tile.type == 454))
971 {
972 flag = false;
973 }
974 }
975 }
976 if (flag)
977 {
978 _targets.Add(new Tuple<int, int>(i, j));
979 }
980 }
981 }
982 if (_targets.Count > 0)
983 {
984 float num = -1f;
986 for (int m = 0; m < _targets.Count; m++)
987 {
988 float num2 = Vector2.Distance(new Vector2(_targets[m].Item1, _targets[m].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
989 if (num == -1f || num2 < num)
990 {
991 num = num2;
992 tuple = _targets[m];
993 }
994 }
995 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
996 {
997 focusedX = tuple.Item1;
998 focusedY = tuple.Item2;
999 }
1000 }
1001 _targets.Clear();
1002 }
1003
1005 {
1006 if (providedInfo.item.createTile != 254 || focusedX != -1 || focusedY != -1)
1007 {
1008 return;
1009 }
1010 _targets.Clear();
1011 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1012 {
1013 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1014 {
1015 Tile tile = Main.tile[i, j + 1];
1016 Tile tile2 = Main.tile[i + 1, j + 1];
1017 if ((double)j > Main.worldSurface - 2.0)
1018 {
1019 break;
1020 }
1021 bool flag = true;
1022 if (!tile2.active() || !tile.active())
1023 {
1024 flag = false;
1025 }
1026 if (tile2.slope() > 0 || tile.slope() > 0 || tile2.halfBrick() || tile.halfBrick())
1027 {
1028 flag = false;
1029 }
1030 if (tile2.type != 2 && tile2.type != 477 && tile2.type != 109 && tile2.type != 492)
1031 {
1032 flag = false;
1033 }
1034 if (tile.type != 2 && tile.type != 477 && tile.type != 109 && tile.type != 492)
1035 {
1036 flag = false;
1037 }
1038 for (int k = i; k <= i + 1; k++)
1039 {
1040 for (int l = j - 1; l <= j; l++)
1041 {
1042 Tile tile3 = Main.tile[k, l];
1043 if (tile3.active() && (tile3.type < 0 || tile3.type >= TileID.Count || Main.tileSolid[tile3.type] || !WorldGen.CanCutTile(k, l, TileCuttingContext.TilePlacement)))
1044 {
1045 flag = false;
1046 }
1047 }
1048 }
1049 if (flag)
1050 {
1051 _targets.Add(new Tuple<int, int>(i, j));
1052 }
1053 }
1054 }
1055 if (_targets.Count > 0)
1056 {
1057 float num = -1f;
1059 for (int m = 0; m < _targets.Count; m++)
1060 {
1061 float num2 = Vector2.Distance(new Vector2(_targets[m].Item1, _targets[m].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1062 if (num == -1f || num2 < num)
1063 {
1064 num = num2;
1065 tuple = _targets[m];
1066 }
1067 }
1068 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1069 {
1070 focusedX = tuple.Item1;
1071 focusedY = tuple.Item2;
1072 }
1073 }
1074 _targets.Clear();
1075 }
1076
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 }
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 }
1142
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 }
1300
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 }
1398
1400 {
1401 if (providedInfo.item.type != 510 || focusedX != -1 || focusedY != -1)
1402 {
1403 return;
1404 }
1405 _targets.Clear();
1406 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1407 {
1408 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1409 {
1410 Tile tile = Main.tile[i, j];
1411 if (tile.wire() || tile.wire2() || tile.wire3() || tile.wire4() || tile.actuator())
1412 {
1413 _targets.Add(new Tuple<int, int>(i, j));
1414 }
1415 }
1416 }
1417 if (_targets.Count > 0)
1418 {
1419 float num = -1f;
1421 for (int k = 0; k < _targets.Count; k++)
1422 {
1423 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1424 if (num == -1f || num2 < num)
1425 {
1426 num = num2;
1427 tuple = _targets[k];
1428 }
1429 }
1430 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1431 {
1432 focusedX = tuple.Item1;
1433 focusedY = tuple.Item2;
1434 }
1435 }
1436 _targets.Clear();
1437 }
1438
1440 {
1441 bool actuationRodLock = providedInfo.player.ActuationRodLock;
1442 bool actuationRodLockSetting = providedInfo.player.ActuationRodLockSetting;
1443 if (providedInfo.item.type != 3620 || focusedX != -1 || focusedY != -1)
1444 {
1445 return;
1446 }
1447 _targets.Clear();
1448 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1449 {
1450 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1451 {
1452 Tile tile = Main.tile[i, j];
1453 if (tile.active() && tile.actuator() && (!actuationRodLock || actuationRodLockSetting == tile.inActive()))
1454 {
1455 _targets.Add(new Tuple<int, int>(i, j));
1456 }
1457 }
1458 }
1459 if (_targets.Count > 0)
1460 {
1461 float num = -1f;
1463 for (int k = 0; k < _targets.Count; k++)
1464 {
1465 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1466 if (num == -1f || num2 < num)
1467 {
1468 num = num2;
1469 tuple = _targets[k];
1470 }
1471 }
1472 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1473 {
1474 focusedX = tuple.Item1;
1475 focusedY = tuple.Item2;
1476 }
1477 }
1478 _targets.Clear();
1479 }
1480
1482 {
1483 int width = providedInfo.player.width;
1484 int height = providedInfo.player.height;
1485 if (providedInfo.item.hammer > 0 && focusedX == -1 && focusedY == -1)
1486 {
1487 Vector2 vector = providedInfo.mouse - providedInfo.Center;
1488 int num = Math.Sign(vector.X);
1489 int num2 = Math.Sign(vector.Y);
1490 if (Math.Abs(vector.X) > Math.Abs(vector.Y) * 3f)
1491 {
1492 num2 = 0;
1493 providedInfo.mouse.Y = providedInfo.Center.Y;
1494 }
1495 if (Math.Abs(vector.Y) > Math.Abs(vector.X) * 3f)
1496 {
1497 num = 0;
1498 providedInfo.mouse.X = providedInfo.Center.X;
1499 }
1500 _ = (int)providedInfo.Center.X / 16;
1501 _ = (int)providedInfo.Center.Y / 16;
1502 _points.Clear();
1503 _endpoints.Clear();
1504 int num3 = 1;
1505 if (num2 == -1 && num != 0)
1506 {
1507 num3 = -1;
1508 }
1509 int num4 = (int)((providedInfo.position.X + (float)(width / 2) + (float)((width / 2 - 1) * num)) / 16f);
1510 int num5 = (int)(((double)providedInfo.position.Y + 0.1) / 16.0);
1511 if (num3 == -1)
1512 {
1513 num5 = (int)((providedInfo.position.Y + (float)height - 1f) / 16f);
1514 }
1515 int num6 = width / 16 + ((width % 16 != 0) ? 1 : 0);
1516 int num7 = height / 16 + ((height % 16 != 0) ? 1 : 0);
1517 if (num != 0)
1518 {
1519 for (int i = 0; i < num7; i++)
1520 {
1521 if (Main.tile[num4, num5 + i * num3] != null)
1522 {
1523 _points.Add(new Tuple<int, int>(num4, num5 + i * num3));
1524 }
1525 }
1526 }
1527 if (num2 != 0)
1528 {
1529 for (int j = 0; j < num6; j++)
1530 {
1531 if (Main.tile[(int)(providedInfo.position.X / 16f) + j, num5] != null)
1532 {
1533 _points.Add(new Tuple<int, int>((int)(providedInfo.position.X / 16f) + j, num5));
1534 }
1535 }
1536 }
1537 int num8 = (int)((providedInfo.mouse.X + (float)((width / 2 - 1) * num)) / 16f);
1538 int num9 = (int)(((double)providedInfo.mouse.Y + 0.1 - (double)(height / 2 + 1)) / 16.0);
1539 if (num3 == -1)
1540 {
1541 num9 = (int)((providedInfo.mouse.Y + (float)(height / 2) - 1f) / 16f);
1542 }
1543 if (providedInfo.player.gravDir == -1f && num2 == 0)
1544 {
1545 num9++;
1546 }
1547 if (num9 < 10)
1548 {
1549 num9 = 10;
1550 }
1551 if (num9 > Main.maxTilesY - 10)
1552 {
1553 num9 = Main.maxTilesY - 10;
1554 }
1555 int num10 = width / 16 + ((width % 16 != 0) ? 1 : 0);
1556 int num11 = height / 16 + ((height % 16 != 0) ? 1 : 0);
1557 if (num != 0)
1558 {
1559 for (int k = 0; k < num11; k++)
1560 {
1561 if (Main.tile[num8, num9 + k * num3] != null)
1562 {
1563 _endpoints.Add(new Tuple<int, int>(num8, num9 + k * num3));
1564 }
1565 }
1566 }
1567 if (num2 != 0)
1568 {
1569 for (int l = 0; l < num10; l++)
1570 {
1571 if (Main.tile[(int)((providedInfo.mouse.X - (float)(width / 2)) / 16f) + l, num9] != null)
1572 {
1573 _endpoints.Add(new Tuple<int, int>((int)((providedInfo.mouse.X - (float)(width / 2)) / 16f) + l, num9));
1574 }
1575 }
1576 }
1577 _targets.Clear();
1578 while (_points.Count > 0)
1579 {
1583 if (tuple3.Item1 == -1 || tuple3.Item2 == -1)
1584 {
1585 _points.Remove(tuple);
1586 _endpoints.Remove(tuple2);
1587 continue;
1588 }
1589 if (tuple3.Item1 != tuple2.Item1 || tuple3.Item2 != tuple2.Item2)
1590 {
1591 _targets.Add(tuple3);
1592 }
1593 _ = Main.tile[tuple3.Item1, tuple3.Item2];
1594 if (Collision.HitWallSubstep(tuple3.Item1, tuple3.Item2))
1595 {
1596 _targets.Add(tuple3);
1597 }
1598 _points.Remove(tuple);
1599 _endpoints.Remove(tuple2);
1600 }
1601 if (_targets.Count > 0)
1602 {
1603 float num12 = -1f;
1604 Tuple<int, int> tuple4 = null;
1605 for (int m = 0; m < _targets.Count; m++)
1606 {
1607 if (!Main.tile[_targets[m].Item1, _targets[m].Item2].active() || Main.tile[_targets[m].Item1, _targets[m].Item2].type != 26)
1608 {
1609 float num13 = Vector2.Distance(new Vector2(_targets[m].Item1, _targets[m].Item2) * 16f + Vector2.One * 8f, providedInfo.Center);
1610 if (num12 == -1f || num13 < num12)
1611 {
1612 num12 = num13;
1613 tuple4 = _targets[m];
1614 }
1615 }
1616 }
1617 if (tuple4 != null && Collision.InTileBounds(tuple4.Item1, tuple4.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1618 {
1619 providedInfo.player.poundRelease = false;
1620 focusedX = tuple4.Item1;
1621 focusedY = tuple4.Item2;
1622 }
1623 }
1624 _targets.Clear();
1625 _points.Clear();
1626 _endpoints.Clear();
1627 }
1628 if (providedInfo.item.hammer <= 0 || focusedX != -1 || focusedY != -1)
1629 {
1630 return;
1631 }
1632 _targets.Clear();
1633 for (int n = providedInfo.reachableStartX; n <= providedInfo.reachableEndX; n++)
1634 {
1635 for (int num14 = providedInfo.reachableStartY; num14 <= providedInfo.reachableEndY; num14++)
1636 {
1637 if (Main.tile[n, num14].wall > 0 && Collision.HitWallSubstep(n, num14))
1638 {
1639 _targets.Add(new Tuple<int, int>(n, num14));
1640 }
1641 }
1642 }
1643 if (_targets.Count > 0)
1644 {
1645 float num15 = -1f;
1646 Tuple<int, int> tuple5 = null;
1647 for (int num16 = 0; num16 < _targets.Count; num16++)
1648 {
1649 if (!Main.tile[_targets[num16].Item1, _targets[num16].Item2].active() || Main.tile[_targets[num16].Item1, _targets[num16].Item2].type != 26)
1650 {
1651 float num17 = Vector2.Distance(new Vector2(_targets[num16].Item1, _targets[num16].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1652 if (num15 == -1f || num17 < num15)
1653 {
1654 num15 = num17;
1656 }
1657 }
1658 }
1659 if (tuple5 != null && Collision.InTileBounds(tuple5.Item1, tuple5.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1660 {
1661 providedInfo.player.poundRelease = false;
1662 focusedX = tuple5.Item1;
1663 focusedY = tuple5.Item2;
1664 }
1665 }
1666 _targets.Clear();
1667 }
1668
1670 {
1671 if (providedInfo.item.type != 3625 || focusedX != -1 || focusedY != -1)
1672 {
1673 return;
1674 }
1675 _targets.Clear();
1678 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire())
1679 {
1681 }
1682 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire2())
1683 {
1685 }
1686 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire3())
1687 {
1689 }
1690 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire4())
1691 {
1693 }
1695 bool num = toolMode == multiToolMode;
1697 if (!num)
1698 {
1699 bool flag = toolMode.HasFlag(WiresUI.Settings.MultiToolMode.Red);
1700 bool flag2 = toolMode.HasFlag(WiresUI.Settings.MultiToolMode.Blue);
1701 bool flag3 = toolMode.HasFlag(WiresUI.Settings.MultiToolMode.Green);
1702 bool flag4 = toolMode.HasFlag(WiresUI.Settings.MultiToolMode.Yellow);
1703 bool flag5 = toolMode.HasFlag(WiresUI.Settings.MultiToolMode.Cutter);
1704 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1705 {
1706 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1707 {
1708 Tile tile = Main.tile[i, j];
1709 if (flag5)
1710 {
1711 if ((tile.wire() && flag) || (tile.wire2() && flag2) || (tile.wire3() && flag3) || (tile.wire4() && flag4))
1712 {
1713 _targets.Add(new Tuple<int, int>(i, j));
1714 }
1715 }
1716 else
1717 {
1718 if (!(tile.wire() && flag) && !(tile.wire2() && flag2) && !(tile.wire3() && flag3) && !(tile.wire4() && flag4))
1719 {
1720 continue;
1721 }
1722 if (flag)
1723 {
1724 if (!Main.tile[i - 1, j].wire())
1725 {
1726 _targets.Add(new Tuple<int, int>(i - 1, j));
1727 }
1728 if (!Main.tile[i + 1, j].wire())
1729 {
1730 _targets.Add(new Tuple<int, int>(i + 1, j));
1731 }
1732 if (!Main.tile[i, j - 1].wire())
1733 {
1734 _targets.Add(new Tuple<int, int>(i, j - 1));
1735 }
1736 if (!Main.tile[i, j + 1].wire())
1737 {
1738 _targets.Add(new Tuple<int, int>(i, j + 1));
1739 }
1740 }
1741 if (flag2)
1742 {
1743 if (!Main.tile[i - 1, j].wire2())
1744 {
1745 _targets.Add(new Tuple<int, int>(i - 1, j));
1746 }
1747 if (!Main.tile[i + 1, j].wire2())
1748 {
1749 _targets.Add(new Tuple<int, int>(i + 1, j));
1750 }
1751 if (!Main.tile[i, j - 1].wire2())
1752 {
1753 _targets.Add(new Tuple<int, int>(i, j - 1));
1754 }
1755 if (!Main.tile[i, j + 1].wire2())
1756 {
1757 _targets.Add(new Tuple<int, int>(i, j + 1));
1758 }
1759 }
1760 if (flag3)
1761 {
1762 if (!Main.tile[i - 1, j].wire3())
1763 {
1764 _targets.Add(new Tuple<int, int>(i - 1, j));
1765 }
1766 if (!Main.tile[i + 1, j].wire3())
1767 {
1768 _targets.Add(new Tuple<int, int>(i + 1, j));
1769 }
1770 if (!Main.tile[i, j - 1].wire3())
1771 {
1772 _targets.Add(new Tuple<int, int>(i, j - 1));
1773 }
1774 if (!Main.tile[i, j + 1].wire3())
1775 {
1776 _targets.Add(new Tuple<int, int>(i, j + 1));
1777 }
1778 }
1779 if (flag4)
1780 {
1781 if (!Main.tile[i - 1, j].wire4())
1782 {
1783 _targets.Add(new Tuple<int, int>(i - 1, j));
1784 }
1785 if (!Main.tile[i + 1, j].wire4())
1786 {
1787 _targets.Add(new Tuple<int, int>(i + 1, j));
1788 }
1789 if (!Main.tile[i, j - 1].wire4())
1790 {
1791 _targets.Add(new Tuple<int, int>(i, j - 1));
1792 }
1793 if (!Main.tile[i, j + 1].wire4())
1794 {
1795 _targets.Add(new Tuple<int, int>(i, j + 1));
1796 }
1797 }
1798 }
1799 }
1800 }
1801 }
1802 if (_targets.Count > 0)
1803 {
1804 float num2 = -1f;
1806 for (int k = 0; k < _targets.Count; k++)
1807 {
1808 float num3 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1809 if (num2 == -1f || num3 < num2)
1810 {
1811 num2 = num3;
1812 tuple = _targets[k];
1813 }
1814 }
1815 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1816 {
1817 focusedX = tuple.Item1;
1818 focusedY = tuple.Item2;
1819 }
1820 }
1821 _targets.Clear();
1822 }
1823
1825 {
1826 if ((providedInfo.item.type != 509 && providedInfo.item.type != 850 && providedInfo.item.type != 851 && providedInfo.item.type != 3612) || focusedX != -1 || focusedY != -1)
1827 {
1828 return;
1829 }
1830 _targets.Clear();
1831 int num = 0;
1832 if (providedInfo.item.type == 509)
1833 {
1834 num = 1;
1835 }
1836 if (providedInfo.item.type == 850)
1837 {
1838 num = 2;
1839 }
1840 if (providedInfo.item.type == 851)
1841 {
1842 num = 3;
1843 }
1844 if (providedInfo.item.type == 3612)
1845 {
1846 num = 4;
1847 }
1848 bool flag = false;
1849 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire() && num == 1)
1850 {
1851 flag = true;
1852 }
1853 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire2() && num == 2)
1854 {
1855 flag = true;
1856 }
1857 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire3() && num == 3)
1858 {
1859 flag = true;
1860 }
1861 if (Main.tile[providedInfo.screenTargetX, providedInfo.screenTargetY].wire4() && num == 4)
1862 {
1863 flag = true;
1864 }
1865 if (!flag)
1866 {
1867 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1868 {
1869 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1870 {
1871 Tile tile = Main.tile[i, j];
1872 if ((!tile.wire() || num != 1) && (!tile.wire2() || num != 2) && (!tile.wire3() || num != 3) && (!tile.wire4() || num != 4))
1873 {
1874 continue;
1875 }
1876 if (num == 1)
1877 {
1878 if (!Main.tile[i - 1, j].wire())
1879 {
1880 _targets.Add(new Tuple<int, int>(i - 1, j));
1881 }
1882 if (!Main.tile[i + 1, j].wire())
1883 {
1884 _targets.Add(new Tuple<int, int>(i + 1, j));
1885 }
1886 if (!Main.tile[i, j - 1].wire())
1887 {
1888 _targets.Add(new Tuple<int, int>(i, j - 1));
1889 }
1890 if (!Main.tile[i, j + 1].wire())
1891 {
1892 _targets.Add(new Tuple<int, int>(i, j + 1));
1893 }
1894 }
1895 if (num == 2)
1896 {
1897 if (!Main.tile[i - 1, j].wire2())
1898 {
1899 _targets.Add(new Tuple<int, int>(i - 1, j));
1900 }
1901 if (!Main.tile[i + 1, j].wire2())
1902 {
1903 _targets.Add(new Tuple<int, int>(i + 1, j));
1904 }
1905 if (!Main.tile[i, j - 1].wire2())
1906 {
1907 _targets.Add(new Tuple<int, int>(i, j - 1));
1908 }
1909 if (!Main.tile[i, j + 1].wire2())
1910 {
1911 _targets.Add(new Tuple<int, int>(i, j + 1));
1912 }
1913 }
1914 if (num == 3)
1915 {
1916 if (!Main.tile[i - 1, j].wire3())
1917 {
1918 _targets.Add(new Tuple<int, int>(i - 1, j));
1919 }
1920 if (!Main.tile[i + 1, j].wire3())
1921 {
1922 _targets.Add(new Tuple<int, int>(i + 1, j));
1923 }
1924 if (!Main.tile[i, j - 1].wire3())
1925 {
1926 _targets.Add(new Tuple<int, int>(i, j - 1));
1927 }
1928 if (!Main.tile[i, j + 1].wire3())
1929 {
1930 _targets.Add(new Tuple<int, int>(i, j + 1));
1931 }
1932 }
1933 if (num == 4)
1934 {
1935 if (!Main.tile[i - 1, j].wire4())
1936 {
1937 _targets.Add(new Tuple<int, int>(i - 1, j));
1938 }
1939 if (!Main.tile[i + 1, j].wire4())
1940 {
1941 _targets.Add(new Tuple<int, int>(i + 1, j));
1942 }
1943 if (!Main.tile[i, j - 1].wire4())
1944 {
1945 _targets.Add(new Tuple<int, int>(i, j - 1));
1946 }
1947 if (!Main.tile[i, j + 1].wire4())
1948 {
1949 _targets.Add(new Tuple<int, int>(i, j + 1));
1950 }
1951 }
1952 }
1953 }
1954 }
1955 if (_targets.Count > 0)
1956 {
1957 float num2 = -1f;
1959 for (int k = 0; k < _targets.Count; k++)
1960 {
1961 float num3 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
1962 if (num2 == -1f || num3 < num2)
1963 {
1964 num2 = num3;
1965 tuple = _targets[k];
1966 }
1967 }
1968 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
1969 {
1970 focusedX = tuple.Item1;
1971 focusedY = tuple.Item2;
1972 }
1973 }
1974 _targets.Clear();
1975 }
1976
1978 {
1979 if (providedInfo.item.type != 27 || focusedX != -1 || focusedY != -1 || providedInfo.reachableStartY <= 20)
1980 {
1981 return;
1982 }
1983 _targets.Clear();
1984 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
1985 {
1986 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
1987 {
1988 Tile tile = Main.tile[i, j];
1989 Tile tile2 = Main.tile[i, j - 1];
1990 Tile tile3 = Main.tile[i, j + 1];
1991 Tile tile4 = Main.tile[i - 1, j];
1992 Tile tile5 = Main.tile[i + 1, j];
1993 Tile tile6 = Main.tile[i - 2, j];
1994 Tile tile7 = Main.tile[i + 2, j];
1995 Tile tile8 = Main.tile[i - 3, j];
1996 Tile tile9 = Main.tile[i + 3, j];
1997 if ((tile.active() && !Main.tileCut[tile.type] && !TileID.Sets.BreakableWhenPlacing[tile.type]) || (tile2.active() && !Main.tileCut[tile2.type] && !TileID.Sets.BreakableWhenPlacing[tile2.type]) || (tile4.active() && TileID.Sets.CommonSapling[tile4.type]) || (tile5.active() && TileID.Sets.CommonSapling[tile5.type]) || (tile6.active() && TileID.Sets.CommonSapling[tile6.type]) || (tile7.active() && TileID.Sets.CommonSapling[tile7.type]) || (tile8.active() && TileID.Sets.CommonSapling[tile8.type]) || (tile9.active() && TileID.Sets.CommonSapling[tile9.type]) || !tile3.active() || !WorldGen.SolidTile2(tile3))
1998 {
1999 continue;
2000 }
2001 switch (tile3.type)
2002 {
2003 case 60:
2004 if (WorldGen.EmptyTileCheck(i - 2, i + 2, j - 20, j, 20))
2005 {
2006 _targets.Add(new Tuple<int, int>(i, j));
2007 }
2008 break;
2009 case 2:
2010 case 23:
2011 case 53:
2012 case 109:
2013 case 112:
2014 case 116:
2015 case 147:
2016 case 199:
2017 case 234:
2018 case 477:
2019 case 492:
2020 case 633:
2021 case 661:
2022 case 662:
2023 if (tile4.liquid == 0 && tile.liquid == 0 && tile5.liquid == 0 && WorldGen.EmptyTileCheck(i - 2, i + 2, j - 20, j, 20))
2024 {
2025 _targets.Add(new Tuple<int, int>(i, j));
2026 }
2027 break;
2028 }
2029 }
2030 }
2031 _toRemove.Clear();
2032 for (int k = 0; k < _targets.Count; k++)
2033 {
2034 bool flag = false;
2035 for (int l = -1; l < 2; l += 2)
2036 {
2037 Tile tile10 = Main.tile[_targets[k].Item1 + l, _targets[k].Item2 + 1];
2038 if (tile10.active())
2039 {
2040 switch (tile10.type)
2041 {
2042 case 2:
2043 case 23:
2044 case 53:
2045 case 60:
2046 case 109:
2047 case 112:
2048 case 116:
2049 case 147:
2050 case 199:
2051 case 234:
2052 case 477:
2053 case 492:
2054 case 633:
2055 case 661:
2056 case 662:
2057 flag = true;
2058 break;
2059 }
2060 }
2061 }
2062 if (!flag)
2063 {
2064 _toRemove.Add(_targets[k]);
2065 }
2066 }
2067 for (int m = 0; m < _toRemove.Count; m++)
2068 {
2069 _targets.Remove(_toRemove[m]);
2070 }
2071 _toRemove.Clear();
2072 if (_targets.Count > 0)
2073 {
2074 float num = -1f;
2076 for (int n = 0; n < _targets.Count; n++)
2077 {
2078 float num2 = Vector2.Distance(new Vector2(_targets[n].Item1, _targets[n].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
2079 if (num == -1f || num2 < num)
2080 {
2081 num = num2;
2082 tuple = _targets[n];
2083 }
2084 }
2085 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
2086 {
2087 focusedX = tuple.Item1;
2088 focusedY = tuple.Item2;
2089 }
2090 }
2091 _targets.Clear();
2092 }
2093
2095 {
2096 if (!WorldGen.GrowTreeSettings.Profiles.TryGetFromItemId(providedInfo.item.type, out var profile) || focusedX != -1 || focusedY != -1 || providedInfo.reachableStartY <= 20)
2097 {
2098 return;
2099 }
2100 _targets.Clear();
2101 for (int i = providedInfo.reachableStartX; i <= providedInfo.reachableEndX; i++)
2102 {
2103 for (int j = providedInfo.reachableStartY; j <= providedInfo.reachableEndY; j++)
2104 {
2105 Tile tile = Main.tile[i, j];
2106 Tile tile2 = Main.tile[i, j - 1];
2107 Tile tile3 = Main.tile[i, j + 1];
2108 Tile tile4 = Main.tile[i - 1, j];
2109 Tile tile5 = Main.tile[i + 1, j];
2110 Tile tile6 = Main.tile[i - 2, j];
2111 Tile tile7 = Main.tile[i + 2, j];
2112 Tile tile8 = Main.tile[i - 3, j];
2113 Tile tile9 = Main.tile[i + 3, j];
2114 if (profile.GroundTest(tile3.type) && (!tile.active() || Main.tileCut[tile.type] || TileID.Sets.BreakableWhenPlacing[tile.type]) && (!tile2.active() || Main.tileCut[tile2.type] || TileID.Sets.BreakableWhenPlacing[tile2.type]) && (!tile4.active() || !TileID.Sets.CommonSapling[tile4.type]) && (!tile5.active() || !TileID.Sets.CommonSapling[tile5.type]) && (!tile6.active() || !TileID.Sets.CommonSapling[tile6.type]) && (!tile7.active() || !TileID.Sets.CommonSapling[tile7.type]) && (!tile8.active() || !TileID.Sets.CommonSapling[tile8.type]) && (!tile9.active() || !TileID.Sets.CommonSapling[tile9.type]) && tile3.active() && WorldGen.SolidTile2(tile3) && tile4.liquid == 0 && tile.liquid == 0 && tile5.liquid == 0 && WorldGen.EmptyTileCheck(i - 2, i + 2, j - profile.TreeHeightMax, j, profile.SaplingTileType))
2115 {
2116 _targets.Add(new Tuple<int, int>(i, j));
2117 }
2118 }
2119 }
2120 _toRemove.Clear();
2121 for (int k = 0; k < _targets.Count; k++)
2122 {
2123 bool flag = false;
2124 for (int l = -1; l < 2; l += 2)
2125 {
2126 Tile tile10 = Main.tile[_targets[k].Item1 + l, _targets[k].Item2 + 1];
2127 if (tile10.active() && profile.GroundTest(tile10.type))
2128 {
2129 flag = true;
2130 }
2131 }
2132 if (!flag)
2133 {
2134 _toRemove.Add(_targets[k]);
2135 }
2136 }
2137 for (int m = 0; m < _toRemove.Count; m++)
2138 {
2139 _targets.Remove(_toRemove[m]);
2140 }
2141 _toRemove.Clear();
2142 if (_targets.Count > 0)
2143 {
2144 float num = -1f;
2146 for (int n = 0; n < _targets.Count; n++)
2147 {
2148 float num2 = Vector2.Distance(new Vector2(_targets[n].Item1, _targets[n].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
2149 if (num == -1f || num2 < num)
2150 {
2151 num = num2;
2152 tuple = _targets[n];
2153 }
2154 }
2155 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
2156 {
2157 focusedX = tuple.Item1;
2158 focusedY = tuple.Item2;
2159 }
2160 }
2161 _targets.Clear();
2162 }
2163
2165 {
2166 int reachableStartX = providedInfo.reachableStartX;
2167 int reachableStartY = providedInfo.reachableStartY;
2168 int reachableEndX = providedInfo.reachableEndX;
2169 int reachableEndY = providedInfo.reachableEndY;
2170 _ = providedInfo.screenTargetX;
2171 _ = providedInfo.screenTargetY;
2172 Vector2 mouse = providedInfo.mouse;
2173 Item item = providedInfo.item;
2174 if (fX != -1 || fY != -1 || PlayerInput.UsingGamepad)
2175 {
2176 return;
2177 }
2178 Point point = mouse.ToTileCoordinates();
2179 int x = point.X;
2180 int y = point.Y;
2181 if (Collision.InTileBounds(x, y, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2182 {
2183 Tile tile = Main.tile[x, y];
2184 bool flag = tile.active() && WorldGen.CanKillTile(x, y) && (!Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]);
2185 if (flag && Main.tileAxe[tile.type] && item.axe < 1)
2186 {
2187 flag = false;
2188 }
2189 if (flag && Main.tileHammer[tile.type] && item.hammer < 1)
2190 {
2191 flag = false;
2192 }
2193 if (flag && !Main.tileHammer[tile.type] && !Main.tileAxe[tile.type] && item.pick < 1)
2194 {
2195 flag = false;
2196 }
2197 if (flag)
2198 {
2199 fX = x;
2200 fY = y;
2201 }
2202 }
2203 }
2204
2206 {
2207 int reachableStartX = providedInfo.reachableStartX;
2208 int reachableStartY = providedInfo.reachableStartY;
2209 int reachableEndX = providedInfo.reachableEndX;
2210 int reachableEndY = providedInfo.reachableEndY;
2211 _ = providedInfo.screenTargetX;
2212 _ = providedInfo.screenTargetY;
2213 Item item = providedInfo.item;
2214 Vector2 mouse = providedInfo.mouse;
2215 if (item.pick <= 0 || fX != -1 || fY != -1)
2216 {
2217 return;
2218 }
2219 _targets.Clear();
2220 if (item.type != 1333 && item.type != 523)
2221 {
2222 _ = item.type != 4384;
2223 }
2224 else
2225 _ = 0;
2226 int num = 0;
2227 for (int i = reachableStartX; i <= reachableEndX; i++)
2228 {
2229 for (int j = reachableStartY; j <= reachableEndY; j++)
2230 {
2231 Tile tile = Main.tile[i, j];
2232 _ = Main.tile[i - 1, j];
2233 _ = Main.tile[i + 1, j];
2234 _ = Main.tile[i, j + 1];
2235 if (!tile.active())
2236 {
2237 continue;
2238 }
2240 if (num2 > 0)
2241 {
2242 if (num < num2)
2243 {
2244 num = num2;
2245 }
2246 _targets.Add(new Tuple<int, int>(i, j));
2247 }
2248 }
2249 }
2250 _targets2.Clear();
2251 foreach (Tuple<int, int> item2 in _targets2)
2252 {
2253 Tile tile2 = Main.tile[item2.Item1, item2.Item2];
2255 {
2256 _targets2.Add(item2);
2257 }
2258 }
2259 foreach (Tuple<int, int> item3 in _targets2)
2260 {
2261 _targets.Remove(item3);
2262 }
2263 if (_targets.Count > 0)
2264 {
2265 float num3 = -1f;
2267 for (int k = 0; k < _targets.Count; k++)
2268 {
2269 float num4 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, mouse);
2270 if (num3 == -1f || num4 < num3)
2271 {
2272 num3 = num4;
2273 tuple = _targets[k];
2274 }
2275 }
2276 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2277 {
2278 fX = tuple.Item1;
2279 fY = tuple.Item2;
2280 }
2281 }
2282 _targets.Clear();
2283 }
2284
2286 {
2287 int width = player.width;
2288 int height = player.height;
2289 int direction = player.direction;
2290 Vector2 center = player.Center;
2291 Vector2 position = player.position;
2292 float gravDir = player.gravDir;
2293 int whoAmI = player.whoAmI;
2294 if (providedInfo.item.pick <= 0 || focusedX != -1 || focusedY != -1)
2295 {
2296 return;
2297 }
2299 {
2300 Vector2 navigatorDirections = PlayerInput.Triggers.Current.GetNavigatorDirections();
2303 if (navigatorDirections == Vector2.Zero && gamepadThumbstickLeft.Length() < 0.05f && gamepadThumbstickRight.Length() < 0.05f)
2304 {
2305 providedInfo.mouse = center + new Vector2(direction * 1000, 0f);
2306 }
2307 }
2308 Vector2 vector = providedInfo.mouse - center;
2309 int num = Math.Sign(vector.X);
2310 int num2 = Math.Sign(vector.Y);
2311 if (Math.Abs(vector.X) > Math.Abs(vector.Y) * 3f)
2312 {
2313 num2 = 0;
2314 providedInfo.mouse.Y = center.Y;
2315 }
2316 if (Math.Abs(vector.Y) > Math.Abs(vector.X) * 3f)
2317 {
2318 num = 0;
2319 providedInfo.mouse.X = center.X;
2320 }
2321 _ = (int)center.X / 16;
2322 _ = (int)center.Y / 16;
2323 _points.Clear();
2324 _endpoints.Clear();
2325 int num3 = 1;
2326 if (num2 == -1 && num != 0)
2327 {
2328 num3 = -1;
2329 }
2330 int num4 = (int)((position.X + (float)(width / 2) + (float)((width / 2 - 1) * num)) / 16f);
2331 int num5 = (int)(((double)position.Y + 0.1) / 16.0);
2332 if (num3 == -1)
2333 {
2334 num5 = (int)((position.Y + (float)height - 1f) / 16f);
2335 }
2336 int num6 = width / 16 + ((width % 16 != 0) ? 1 : 0);
2337 int num7 = height / 16 + ((height % 16 != 0) ? 1 : 0);
2338 if (num != 0)
2339 {
2340 for (int i = 0; i < num7; i++)
2341 {
2342 if (Main.tile[num4, num5 + i * num3] != null)
2343 {
2344 _points.Add(new Tuple<int, int>(num4, num5 + i * num3));
2345 }
2346 }
2347 }
2348 if (num2 != 0)
2349 {
2350 for (int j = 0; j < num6; j++)
2351 {
2352 if (Main.tile[(int)(position.X / 16f) + j, num5] != null)
2353 {
2354 _points.Add(new Tuple<int, int>((int)(position.X / 16f) + j, num5));
2355 }
2356 }
2357 }
2358 int num8 = (int)((providedInfo.mouse.X + (float)((width / 2 - 1) * num)) / 16f);
2359 int num9 = (int)(((double)providedInfo.mouse.Y + 0.1 - (double)(height / 2 + 1)) / 16.0);
2360 if (num3 == -1)
2361 {
2362 num9 = (int)((providedInfo.mouse.Y + (float)(height / 2) - 1f) / 16f);
2363 }
2364 if (gravDir == -1f && num2 == 0)
2365 {
2366 num9++;
2367 }
2368 if (num9 < 10)
2369 {
2370 num9 = 10;
2371 }
2372 if (num9 > Main.maxTilesY - 10)
2373 {
2374 num9 = Main.maxTilesY - 10;
2375 }
2376 int num10 = width / 16 + ((width % 16 != 0) ? 1 : 0);
2377 int num11 = height / 16 + ((height % 16 != 0) ? 1 : 0);
2378 if (WorldGen.InWorld(num8, num9, 40))
2379 {
2380 if (num != 0)
2381 {
2382 for (int k = 0; k < num11; k++)
2383 {
2384 if (Main.tile[num8, num9 + k * num3] != null)
2385 {
2386 _endpoints.Add(new Tuple<int, int>(num8, num9 + k * num3));
2387 }
2388 }
2389 }
2390 if (num2 != 0)
2391 {
2392 for (int l = 0; l < num10; l++)
2393 {
2394 if (Main.tile[(int)((providedInfo.mouse.X - (float)(width / 2)) / 16f) + l, num9] != null)
2395 {
2396 _endpoints.Add(new Tuple<int, int>((int)((providedInfo.mouse.X - (float)(width / 2)) / 16f) + l, num9));
2397 }
2398 }
2399 }
2400 }
2401 _targets.Clear();
2402 while (_points.Count > 0 && _endpoints.Count > 0)
2403 {
2406 if (!Collision.TupleHitLine(tuple.Item1, tuple.Item2, tuple2.Item1, tuple2.Item2, num * (int)gravDir, -num2 * (int)gravDir, grappleTargets, out var col))
2407 {
2408 _points.Remove(tuple);
2409 _endpoints.Remove(tuple2);
2410 continue;
2411 }
2412 if (col.Item1 != tuple2.Item1 || col.Item2 != tuple2.Item2)
2413 {
2414 _targets.Add(col);
2415 }
2416 Tile tile = Main.tile[col.Item1, col.Item2];
2417 if (!tile.inActive() && tile.active() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type] && !grappleTargets.Contains(col))
2418 {
2419 _targets.Add(col);
2420 }
2421 _points.Remove(tuple);
2422 _endpoints.Remove(tuple2);
2423 }
2424 _toRemove.Clear();
2425 for (int m = 0; m < _targets.Count; m++)
2426 {
2427 if (!WorldGen.CanKillTile(_targets[m].Item1, _targets[m].Item2))
2428 {
2429 _toRemove.Add(_targets[m]);
2430 }
2431 }
2432 for (int n = 0; n < _toRemove.Count; n++)
2433 {
2434 _targets.Remove(_toRemove[n]);
2435 }
2436 _toRemove.Clear();
2437 if (_targets.Count > 0)
2438 {
2439 float num12 = -1f;
2442 if (Main.netMode == 1)
2443 {
2444 int num13 = 0;
2445 int num14 = 0;
2446 int num15 = 0;
2447 for (int num16 = 0; num16 < whoAmI; num16++)
2448 {
2450 if (player2.active && !player2.dead && player2.HeldItem.pick > 0 && player2.itemAnimation > 0)
2451 {
2452 if (player.Distance(player2.Center) <= 8f)
2453 {
2454 num13++;
2455 }
2456 if (player.Distance(player2.Center) <= 80f && Math.Abs(player2.Center.Y - center.Y) <= 12f)
2457 {
2458 num14++;
2459 }
2460 }
2461 }
2462 for (int num17 = whoAmI + 1; num17 < 255; num17++)
2463 {
2465 if (player3.active && !player3.dead && player3.HeldItem.pick > 0 && player3.itemAnimation > 0 && player.Distance(player3.Center) <= 8f)
2466 {
2467 num15++;
2468 }
2469 }
2470 if (num13 > 0)
2471 {
2472 if (num13 % 2 == 1)
2473 {
2474 value.X += 12f;
2475 }
2476 else
2477 {
2478 value.X -= 12f;
2479 }
2480 if (num14 % 2 == 1)
2481 {
2482 value.Y -= 12f;
2483 }
2484 }
2485 if (num15 > 0 && num13 == 0)
2486 {
2487 if (num15 % 2 == 1)
2488 {
2489 value.X -= 12f;
2490 }
2491 else
2492 {
2493 value.X += 12f;
2494 }
2495 }
2496 }
2497 for (int num18 = 0; num18 < _targets.Count; num18++)
2498 {
2499 float num19 = Vector2.Distance(new Vector2(_targets[num18].Item1, _targets[num18].Item2) * 16f + Vector2.One * 8f, value);
2500 if (num12 == -1f || num19 < num12)
2501 {
2502 num12 = num19;
2504 }
2505 }
2506 if (Collision.InTileBounds(tuple3.Item1, tuple3.Item2, providedInfo.reachableStartX, providedInfo.reachableStartY, providedInfo.reachableEndX, providedInfo.reachableEndY))
2507 {
2508 focusedX = tuple3.Item1;
2509 focusedY = tuple3.Item2;
2510 }
2511 }
2512 _points.Clear();
2513 _endpoints.Clear();
2514 _targets.Clear();
2515 }
2516
2517 private static void Step_Axe(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
2518 {
2519 int reachableStartX = providedInfo.reachableStartX;
2520 int reachableStartY = providedInfo.reachableStartY;
2521 int reachableEndX = providedInfo.reachableEndX;
2522 int reachableEndY = providedInfo.reachableEndY;
2523 _ = providedInfo.screenTargetX;
2524 _ = providedInfo.screenTargetY;
2525 if (providedInfo.item.axe <= 0 || fX != -1 || fY != -1)
2526 {
2527 return;
2528 }
2529 float num = -1f;
2530 for (int i = reachableStartX; i <= reachableEndX; i++)
2531 {
2532 for (int j = reachableStartY; j <= reachableEndY; j++)
2533 {
2534 if (!Main.tile[i, j].active())
2535 {
2536 continue;
2537 }
2538 Tile tile = Main.tile[i, j];
2540 {
2541 continue;
2542 }
2543 int num2 = i;
2544 int k = j;
2545 int type = tile.type;
2547 {
2548 if (Collision.InTileBounds(num2 + 1, k, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2549 {
2550 if (Main.tile[num2, k].frameY >= 198 && Main.tile[num2, k].frameX == 44)
2551 {
2552 num2++;
2553 }
2554 if (Main.tile[num2, k].frameX == 66 && Main.tile[num2, k].frameY <= 44)
2555 {
2556 num2++;
2557 }
2558 if (Main.tile[num2, k].frameX == 44 && Main.tile[num2, k].frameY >= 132 && Main.tile[num2, k].frameY <= 176)
2559 {
2560 num2++;
2561 }
2562 }
2563 if (Collision.InTileBounds(num2 - 1, k, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2564 {
2565 if (Main.tile[num2, k].frameY >= 198 && Main.tile[num2, k].frameX == 66)
2566 {
2567 num2--;
2568 }
2569 if (Main.tile[num2, k].frameX == 88 && Main.tile[num2, k].frameY >= 66 && Main.tile[num2, k].frameY <= 110)
2570 {
2571 num2--;
2572 }
2573 if (Main.tile[num2, k].frameX == 22 && Main.tile[num2, k].frameY >= 132 && Main.tile[num2, k].frameY <= 176)
2574 {
2575 num2--;
2576 }
2577 }
2578 for (; Main.tile[num2, k].active() && Main.tile[num2, k].type == type && Main.tile[num2, k + 1].type == type && Collision.InTileBounds(num2, k + 1, reachableStartX, reachableStartY, reachableEndX, reachableEndY); k++)
2579 {
2580 }
2581 }
2582 if (tile.type == 80)
2583 {
2584 if (Collision.InTileBounds(num2 + 1, k, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2585 {
2586 if (Main.tile[num2, k].frameX == 54)
2587 {
2588 num2++;
2589 }
2590 if (Main.tile[num2, k].frameX == 108 && Main.tile[num2, k].frameY == 36)
2591 {
2592 num2++;
2593 }
2594 }
2595 if (Collision.InTileBounds(num2 - 1, k, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2596 {
2597 if (Main.tile[num2, k].frameX == 36)
2598 {
2599 num2--;
2600 }
2601 if (Main.tile[num2, k].frameX == 108 && Main.tile[num2, k].frameY == 18)
2602 {
2603 num2--;
2604 }
2605 }
2606 for (; Main.tile[num2, k].active() && Main.tile[num2, k].type == 80 && Main.tile[num2, k + 1].type == 80 && Collision.InTileBounds(num2, k + 1, reachableStartX, reachableStartY, reachableEndX, reachableEndY); k++)
2607 {
2608 }
2609 }
2610 if (tile.type == 323 || tile.type == 72)
2611 {
2612 for (; Main.tile[num2, k].active() && ((Main.tile[num2, k].type == 323 && Main.tile[num2, k + 1].type == 323) || (Main.tile[num2, k].type == 72 && Main.tile[num2, k + 1].type == 72)) && Collision.InTileBounds(num2, k + 1, reachableStartX, reachableStartY, reachableEndX, reachableEndY); k++)
2613 {
2614 }
2615 }
2616 float num3 = Vector2.Distance(new Vector2(num2, k) * 16f + Vector2.One * 8f, providedInfo.mouse);
2617 if (num == -1f || num3 < num)
2618 {
2619 num = num3;
2620 fX = num2;
2621 fY = k;
2622 }
2623 }
2624 }
2625 }
2626
2628 {
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 }
2729
2730 private static void Step_Torch(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
2731 {
2732 int reachableStartX = providedInfo.reachableStartX;
2733 int reachableStartY = providedInfo.reachableStartY;
2734 int reachableEndX = providedInfo.reachableEndX;
2735 int reachableEndY = providedInfo.reachableEndY;
2736 _ = providedInfo.screenTargetX;
2737 _ = providedInfo.screenTargetY;
2738 if (providedInfo.item.createTile != 4 || fX != -1 || fY != -1)
2739 {
2740 return;
2741 }
2742 _targets.Clear();
2743 bool flag = providedInfo.item.type != 1333 && providedInfo.item.type != 523 && providedInfo.item.type != 4384;
2744 for (int i = reachableStartX; i <= reachableEndX; i++)
2745 {
2746 for (int j = reachableStartY; j <= reachableEndY; j++)
2747 {
2748 Tile tile = Main.tile[i, j];
2749 Tile tile2 = Main.tile[i - 1, j];
2750 Tile tile3 = Main.tile[i + 1, j];
2751 Tile tile4 = Main.tile[i, j + 1];
2752 if (tile.active() && !TileID.Sets.BreakableWhenPlacing[tile.type] && (!Main.tileCut[tile.type] || tile.type == 82 || tile.type == 83))
2753 {
2754 continue;
2755 }
2756 bool flag2 = false;
2757 for (int k = i - 8; k <= i + 8; k++)
2758 {
2759 for (int l = j - 8; l <= j + 8; l++)
2760 {
2761 if (Main.tile[k, l] != null && Main.tile[k, l].type == 4)
2762 {
2763 flag2 = true;
2764 break;
2765 }
2766 }
2767 if (flag2)
2768 {
2769 break;
2770 }
2771 }
2772 if (!flag2 && (!flag || tile.liquid <= 0) && (tile.wall > 0 || (tile2.active() && (tile2.slope() == 0 || tile2.slope() % 2 != 1) && ((Main.tileSolid[tile2.type] && !Main.tileNoAttach[tile2.type] && !Main.tileSolidTop[tile2.type] && !TileID.Sets.NotReallySolid[tile2.type]) || TileID.Sets.IsBeam[tile2.type] || (WorldGen.IsTreeType(tile2.type) && WorldGen.IsTreeType(Main.tile[i - 1, j - 1].type) && WorldGen.IsTreeType(Main.tile[i - 1, j + 1].type)))) || (tile3.active() && (tile3.slope() == 0 || tile3.slope() % 2 != 0) && ((Main.tileSolid[tile3.type] && !Main.tileNoAttach[tile3.type] && !Main.tileSolidTop[tile3.type] && !TileID.Sets.NotReallySolid[tile3.type]) || TileID.Sets.IsBeam[tile3.type] || (WorldGen.IsTreeType(tile3.type) && WorldGen.IsTreeType(Main.tile[i + 1, j - 1].type) && WorldGen.IsTreeType(Main.tile[i + 1, j + 1].type)))) || (tile4.active() && Main.tileSolid[tile4.type] && !Main.tileNoAttach[tile4.type] && (!Main.tileSolidTop[tile4.type] || (TileID.Sets.Platforms[tile4.type] && tile4.slope() == 0)) && !TileID.Sets.NotReallySolid[tile4.type] && !tile4.halfBrick() && tile4.slope() == 0)) && tile.type != 4)
2773 {
2774 _targets.Add(new Tuple<int, int>(i, j));
2775 }
2776 }
2777 }
2778 if (_targets.Count > 0)
2779 {
2780 float num = -1f;
2782 for (int m = 0; m < _targets.Count; m++)
2783 {
2784 float num2 = Vector2.Distance(new Vector2(_targets[m].Item1, _targets[m].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
2785 if (num == -1f || num2 < num)
2786 {
2787 num = num2;
2788 tuple = _targets[m];
2789 }
2790 }
2791 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2792 {
2793 fX = tuple.Item1;
2794 fY = tuple.Item2;
2795 }
2796 }
2797 _targets.Clear();
2798 }
2799
2801 {
2802 int reachableStartX = providedInfo.reachableStartX;
2803 int reachableStartY = providedInfo.reachableStartY;
2804 int reachableEndX = providedInfo.reachableEndX;
2805 int reachableEndY = providedInfo.reachableEndY;
2806 _ = providedInfo.screenTargetX;
2807 _ = providedInfo.screenTargetY;
2808 if (providedInfo.item.type != 4049 || fX != -1 || fY != -1)
2809 {
2810 return;
2811 }
2812 _targets.Clear();
2813 for (int i = reachableStartX; i <= reachableEndX; i++)
2814 {
2815 for (int j = reachableStartY; j <= reachableEndY; j++)
2816 {
2817 Tile tile = Main.tile[i, j];
2818 if (tile.active() && (tile.type == 2 || tile.type == 109))
2819 {
2820 _targets.Add(new Tuple<int, int>(i, j));
2821 }
2822 }
2823 }
2824 if (_targets.Count > 0)
2825 {
2826 float num = -1f;
2828 for (int k = 0; k < _targets.Count; k++)
2829 {
2830 float num2 = Vector2.Distance(new Vector2(_targets[k].Item1, _targets[k].Item2) * 16f + Vector2.One * 8f, providedInfo.mouse);
2831 if (num == -1f || num2 < num)
2832 {
2833 num = num2;
2834 tuple = _targets[k];
2835 }
2836 }
2837 if (Collision.InTileBounds(tuple.Item1, tuple.Item2, reachableStartX, reachableStartY, reachableEndX, reachableEndY))
2838 {
2839 fX = tuple.Item1;
2840 fY = tuple.Item2;
2841 }
2842 }
2843 _targets.Clear();
2844 }
2845}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static double Abs(double value)
static int Sign(decimal value)
Definition Math.cs:1202
static bool InTileBounds(int x, int y, int lx, int ly, int hx, int hy)
static bool CanHitWithCheck(Vector2 Position1, int Width1, int Height1, Vector2 Position2, int Width2, int Height2, Utils.TileActionAttempt check)
Definition Collision.cs:453
static bool EmptyTile(int i, int j, bool ignoreTiles=false)
static Tuple< int, int > TupleHitLineWall(int x1, int y1, int x2, int y2)
Definition Collision.cs:936
static bool TupleHitLine(int x1, int y1, int x2, int y2, int ignoreX, int ignoreY, List< Tuple< int, int > > ignoreTargets, out Tuple< int, int > col)
Definition Collision.cs:743
static bool HitWallSubstep(int x, int y)
static bool NotDoorStand(int x, int y)
Vector2 Center
Definition Entity.cs:43
float Distance(Vector2 Other)
Definition Entity.cs:187
Rectangle Hitbox
Definition Entity.cs:164
Vector2 position
Definition Entity.cs:14
static void Step_PaintRoller(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Boulders(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static List< Tuple< int, int > > _targets2
static void Step_Pigronata(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_BlocksLines(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void TryFindingPaintInplayerInventory(SmartCursorUsageInfo providedInfo, out int paintLookup, out int coatingLookup)
static List< Tuple< int, int > > _endpoints
static void Step_LawnMower(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
static void Step_Acorns(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_ColoredWrenches(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_MinecartTracks(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Torch(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
static void Step_MulticolorWrench(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_GrassSeeds(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_StaffOfRegrowth(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Pickaxe_MineShinies(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
static void Step_BlocksFilling(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
static void Step_WireCutter(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Actuators(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static List< Tuple< int, int > > _targets
static void Step_ForceCursorToAnyMinableThing(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
static List< Tuple< int, int > > _grappleTargets
static void Step_EmptyBuckets(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Walls(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Hammers(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_PaintScrapper(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_ClayPots(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static List< Tuple< int, int > > _points
static void Step_Axe(SmartCursorUsageInfo providedInfo, ref int fX, ref int fY)
static void Step_PaintBrush(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static bool IsHoveringOverAnInteractibleTileThatBlocksSmartCursor(SmartCursorUsageInfo providedInfo)
static void SmartCursorLookup(Player player)
static void Step_AlchemySeeds(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_ActuationRod(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static List< Tuple< int, int > > _toRemove
static void Step_Platforms(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_GemCorns(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_PumpkinSeeds(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_PlanterBox(SmartCursorUsageInfo providedInfo, ref int focusedX, ref int focusedY)
static void Step_Pickaxe_MineSolids(Player player, SmartCursorUsageInfo providedInfo, List< Tuple< int, int > > grappleTargets, ref int focusedX, ref int focusedY)
static TriggersPack Triggers
static Vector2 GamepadThumbstickLeft
static Vector2 GamepadThumbstickRight
static bool[] IsPaintScraper
Definition ItemID.cs:229
static bool[] GrassSeeds
Definition ItemID.cs:65
static readonly short Count
Definition ItemID.cs:12138
static bool[] IgnoreSmartCursorPriorityAxe
Definition TileID.cs:131
static bool[] Boulders
Definition TileID.cs:123
static bool[] BreakableWhenPlacing
Definition TileID.cs:277
static bool[] IsBeam
Definition TileID.cs:161
static int[] SmartCursorPickaxePriorityOverride
Definition TileID.cs:129
static bool[] CommonSapling
Definition TileID.cs:103
static bool[] NotReallySolid
Definition TileID.cs:257
static bool[] Platforms
Definition TileID.cs:163
static bool[] IsATreeTrunk
Definition TileID.cs:91
static readonly ushort Count
Definition TileID.cs:1698
static int maxTilesY
Definition Main.cs:1116
static bool[] tileSolidTop
Definition Main.cs:1469
static bool[] tileCut
Definition Main.cs:1433
static bool[] tileTable
Definition Main.cs:1459
static double worldSurface
Definition Main.cs:1272
static int netMode
Definition Main.cs:2095
static Vector2 MouseWorld
Definition Main.cs:2776
static bool[] tileHammer
Definition Main.cs:1453
static int maxTilesX
Definition Main.cs:1114
static bool[] tileSolid
Definition Main.cs:1471
static Tile[,] tile
Definition Main.cs:1675
static Projectile[] projectile
Definition Main.cs:1691
static bool SmartCursorIsUsed
Definition Main.cs:2855
static bool[] tileFrameImportant
Definition Main.cs:1495
static bool[] tileNoAttach
Definition Main.cs:1487
static Player[] player
Definition Main.cs:1803
static bool[] tileAxe
Definition Main.cs:1451
static int tileTargetY
Definition Player.cs:2085
static int tileRangeX
Definition Player.cs:2075
int[] grappling
Definition Player.cs:2305
static int tileTargetX
Definition Player.cs:2083
static int tileRangeY
Definition Player.cs:2077
Item[] inventory
Definition Player.cs:1257
byte color()
Definition Tile.cs:555
bool wire4()
Definition Tile.cs:413
bool wire3()
Definition Tile.cs:633
void liquidType(int liquidType)
Definition Tile.cs:233
bool nactive()
Definition Tile.cs:257
bool fullbrightWall()
Definition Tile.cs:694
bool invisibleWall()
Definition Tile.cs:521
byte liquid
Definition Tile.cs:12
bool inActive()
Definition Tile.cs:582
bool fullbrightBlock()
Definition Tile.cs:538
ushort type
Definition Tile.cs:8
short frameX
Definition Tile.cs:22
bool invisibleBlock()
Definition Tile.cs:504
bool active()
Definition Tile.cs:565
byte slope()
Definition Tile.cs:684
bool lava()
Definition Tile.cs:362
ushort wall
Definition Tile.cs:10
bool wire2()
Definition Tile.cs:616
byte wallColor()
Definition Tile.cs:352
bool actuator()
Definition Tile.cs:667
bool wire()
Definition Tile.cs:599
bool halfBrick()
Definition Tile.cs:650
static bool TryGetFromItemId(int itemType, out GrowTreeSettings profile)
Definition WorldGen.cs:729
static bool IsTreeType(int tree)
static bool SolidTile(Tile testTile)
static bool EmptyTileCheck(int startX, int endX, int startY, int endY, int ignoreID=-1)
static bool CanKillTile(int i, int j, SpecialKillTileContext context)
static bool SolidTile2(Tile testTile)
static bool IsOpenDoorAnchorFrame(int x, int y)
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816
static bool CanCutTile(int x, int y, TileCuttingContext context)
static bool IsHarvestableHerbWithSeed(int type, int style)
bool Intersects(Rectangle value)
Definition Rectangle.cs:129
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91