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

◆ Step_ColoredWrenches()

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

Definition at line 1824 of file SmartCursorHelper.cs.

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 }
static List< Tuple< int, int > > _targets
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.GameContent.SmartCursorHelper._targets, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Collision.InTileBounds(), Terraria.Main.tile, Terraria.Tile.wire(), Terraria.Tile.wire2(), Terraria.Tile.wire3(), and Terraria.Tile.wire4().

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