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

◆ FindSharpTearsSpot()

Point Terraria.Player.FindSharpTearsSpot ( Vector2 targetSpot)
inlineprivate

Definition at line 46731 of file Player.cs.

46732 {
46733 Point point = targetSpot.ToTileCoordinates();
46734 Vector2 center = base.Center;
46736 int samplesToTake = 3;
46737 float samplingWidth = 4f;
46739 float num = float.PositiveInfinity;
46740 for (int i = 0; i < samples.Length; i++)
46741 {
46742 if (samples[i] < num)
46743 {
46744 num = samples[i];
46745 }
46746 }
46747 targetSpot = center + vectorTowardsTarget.SafeNormalize(Vector2.Zero) * num;
46748 point = targetSpot.ToTileCoordinates();
46749 Rectangle value = new Rectangle(point.X, point.Y, 1, 1);
46750 value.Inflate(6, 16);
46751 Rectangle value2 = new Rectangle(0, 0, Main.maxTilesX, Main.maxTilesY);
46752 value2.Inflate(-40, -40);
46756 for (int j = value.Left; j <= value.Right; j++)
46757 {
46758 for (int k = value.Top; k <= value.Bottom; k++)
46759 {
46760 if (!WorldGen.SolidTile2(j, k))
46761 {
46762 continue;
46763 }
46764 Vector2 value3 = new Vector2(j * 16 + 8, k * 16 + 8);
46765 if (!(Vector2.Distance(targetSpot, value3) > 200f))
46766 {
46767 if (FindSharpTearsOpening(j, k, j > point.X, j < point.X, k > point.Y, k < point.Y))
46768 {
46769 list.Add(new Point(j, k));
46770 }
46771 else
46772 {
46773 list2.Add(new Point(j, k));
46774 }
46775 }
46776 }
46777 }
46778 if (list.Count == 0 && list2.Count == 0)
46779 {
46780 list.Add((base.Center.ToTileCoordinates().ToVector2() + Main.rand.NextVector2Square(-2f, 2f)).ToPoint());
46781 }
46783 if (list3.Count == 0)
46784 {
46785 list3 = list2;
46786 }
46787 int index = Main.rand.Next(list3.Count);
46788 return list3[index];
46789 }
void Add(TKey key, TValue value)
bool FindSharpTearsOpening(int x, int y, bool acceptLeft, bool acceptRight, bool acceptUp, bool acceptDown)
Definition Player.cs:46791
static Rectangle Intersect(Rectangle value1, Rectangle value2)
Definition Rectangle.cs:143
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), Terraria.Collision.AimingLaserScan(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, Microsoft.Xna.Framework.Vector2.Distance(), System.index, Microsoft.Xna.Framework.Rectangle.Intersect(), System.list, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.rand, Terraria.WorldGen.SolidTile2(), System.value, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Point.Y, and Microsoft.Xna.Framework.Vector2.Zero.