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

◆ PlotLine() [1/3]

static bool Terraria.Utils.PlotLine ( int x0,
int y0,
int x1,
int y1,
TileActionAttempt plot,
bool jump = true )
inlinestaticprivate

Definition at line 1576 of file Utils.cs.

1577 {
1578 if (x0 == x1 && y0 == y1)
1579 {
1580 return plot(x0, y0);
1581 }
1582 bool flag = Math.Abs(y1 - y0) > Math.Abs(x1 - x0);
1583 if (flag)
1584 {
1585 Swap(ref x0, ref y0);
1586 Swap(ref x1, ref y1);
1587 }
1588 int num = Math.Abs(x1 - x0);
1589 int num2 = Math.Abs(y1 - y0);
1590 int num3 = num / 2;
1591 int num4 = y0;
1592 int num5 = ((x0 < x1) ? 1 : (-1));
1593 int num6 = ((y0 < y1) ? 1 : (-1));
1594 for (int i = x0; i != x1; i += num5)
1595 {
1596 if (flag)
1597 {
1598 if (!plot(num4, i))
1599 {
1600 return false;
1601 }
1602 }
1603 else if (!plot(i, num4))
1604 {
1605 return false;
1606 }
1607 num3 -= num2;
1608 if (num3 >= 0)
1609 {
1610 continue;
1611 }
1612 num4 += num6;
1613 if (!jump)
1614 {
1615 if (flag)
1616 {
1617 if (!plot(num4, i))
1618 {
1619 return false;
1620 }
1621 }
1622 else if (!plot(i, num4))
1623 {
1624 return false;
1625 }
1626 }
1627 num3 += num;
1628 }
1629 return true;
1630 }
static double Abs(double value)

References System.Math.Abs(), and System.Text.RegularExpressions.i.