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

◆ Step_Acorns()

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

Definition at line 1977 of file SmartCursorHelper.cs.

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 }
static List< Tuple< int, int > > _targets
static List< Tuple< int, int > > _toRemove
static bool[] BreakableWhenPlacing
Definition TileID.cs:277
static bool[] CommonSapling
Definition TileID.cs:103
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.GameContent.SmartCursorHelper._targets, Terraria.GameContent.SmartCursorHelper._toRemove, Terraria.Tile.active(), Terraria.ID.TileID.Sets.BreakableWhenPlacing, Terraria.ID.TileID.Sets.CommonSapling, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.WorldGen.EmptyTileCheck(), Terraria.Collision.InTileBounds(), Terraria.Tile.liquid, Terraria.WorldGen.SolidTile2(), Terraria.Main.tile, Terraria.Main.tileCut, and Terraria.Tile.type.

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