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

◆ IsClearSpotTest()

static bool Terraria.Collision.IsClearSpotTest ( Vector2 position,
float testMagnitude,
int Width,
int Height,
bool fallThrough = false,
bool fall2 = false,
int gravDir = 1,
bool checkCardinals = true,
bool checkSlopes = false )
inlinestatic

Definition at line 2055 of file Collision.cs.

2056 {
2057 if (checkCardinals)
2058 {
2059 Vector2 vector = Vector2.UnitX * testMagnitude;
2060 if (TileCollision(position - vector, vector, Width, Height, fallThrough, fall2, gravDir) != vector)
2061 {
2062 return false;
2063 }
2064 vector = -Vector2.UnitX * testMagnitude;
2065 if (TileCollision(position - vector, vector, Width, Height, fallThrough, fall2, gravDir) != vector)
2066 {
2067 return false;
2068 }
2069 vector = Vector2.UnitY * testMagnitude;
2070 if (TileCollision(position - vector, vector, Width, Height, fallThrough, fall2, gravDir) != vector)
2071 {
2072 return false;
2073 }
2074 vector = -Vector2.UnitY * testMagnitude;
2075 if (TileCollision(position - vector, vector, Width, Height, fallThrough, fall2, gravDir) != vector)
2076 {
2077 return false;
2078 }
2079 }
2080 if (checkSlopes)
2081 {
2082 Vector2 vector = Vector2.UnitX * testMagnitude;
2083 Vector4 vector2 = new Vector4(position, testMagnitude, 0f);
2084 if (SlopeCollision(position, vector, Width, Height, gravDir, fallThrough) != vector2)
2085 {
2086 return false;
2087 }
2088 vector = -Vector2.UnitX * testMagnitude;
2089 vector2 = new Vector4(position, 0f - testMagnitude, 0f);
2090 if (SlopeCollision(position, vector, Width, Height, gravDir, fallThrough) != vector2)
2091 {
2092 return false;
2093 }
2094 vector = Vector2.UnitY * testMagnitude;
2095 vector2 = new Vector4(position, 0f, testMagnitude);
2096 if (SlopeCollision(position, vector, Width, Height, gravDir, fallThrough) != vector2)
2097 {
2098 return false;
2099 }
2100 vector = -Vector2.UnitY * testMagnitude;
2101 vector2 = new Vector4(position, 0f, 0f - testMagnitude);
2102 if (SlopeCollision(position, vector, Width, Height, gravDir, fallThrough) != vector2)
2103 {
2104 return false;
2105 }
2106 }
2107 return true;
2108 }
static Vector2 TileCollision(Vector2 Position, Vector2 Velocity, int Width, int Height, bool fallThrough=false, bool fall2=false, int gravDir=1)
static Vector4 SlopeCollision(Vector2 Position, Vector2 Velocity, int Width, int Height, float gravity=0f, bool fall=false)

References Terraria.Collision.SlopeCollision(), and Terraria.Collision.TileCollision().

Referenced by Terraria.Player.CanFitSpace(), and Terraria.Player.UpdateTouchingTiles().