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

◆ SlopeCollision()

static Vector4 Terraria.Collision.SlopeCollision ( Vector2 Position,
Vector2 Velocity,
int Width,
int Height,
float gravity = 0f,
bool fall = false )
inlinestatic

Definition at line 1976 of file Collision.cs.

1977 {
1978 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
1979 //IL_001a: Unknown result type (might be due to invalid IL or missing references)
1980 //IL_0027: Unknown result type (might be due to invalid IL or missing references)
1981 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
1982 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
1983 //IL_002a: Unknown result type (might be due to invalid IL or missing references)
1984 //IL_002c: Unknown result type (might be due to invalid IL or missing references)
1985 //IL_002d: Unknown result type (might be due to invalid IL or missing references)
1986 //IL_002f: Unknown result type (might be due to invalid IL or missing references)
1987 //IL_003e: Unknown result type (might be due to invalid IL or missing references)
1988 //IL_0052: Unknown result type (might be due to invalid IL or missing references)
1989 //IL_0063: Unknown result type (might be due to invalid IL or missing references)
1990 //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
1991 //IL_06ba: Unknown result type (might be due to invalid IL or missing references)
1992 //IL_06bb: Unknown result type (might be due to invalid IL or missing references)
1993 //IL_06bd: Unknown result type (might be due to invalid IL or missing references)
1994 //IL_06be: Unknown result type (might be due to invalid IL or missing references)
1995 //IL_06c3: Unknown result type (might be due to invalid IL or missing references)
1996 //IL_06c5: Unknown result type (might be due to invalid IL or missing references)
1997 //IL_06cc: Unknown result type (might be due to invalid IL or missing references)
1998 //IL_06d1: Unknown result type (might be due to invalid IL or missing references)
1999 //IL_06d3: Unknown result type (might be due to invalid IL or missing references)
2000 //IL_06da: Unknown result type (might be due to invalid IL or missing references)
2001 //IL_0753: Unknown result type (might be due to invalid IL or missing references)
2002 //IL_075a: Unknown result type (might be due to invalid IL or missing references)
2003 //IL_06e3: Unknown result type (might be due to invalid IL or missing references)
2004 //IL_06ea: Unknown result type (might be due to invalid IL or missing references)
2005 //IL_06f6: Unknown result type (might be due to invalid IL or missing references)
2006 //IL_06fc: Unknown result type (might be due to invalid IL or missing references)
2007 //IL_07cb: Unknown result type (might be due to invalid IL or missing references)
2008 //IL_07cd: Unknown result type (might be due to invalid IL or missing references)
2009 //IL_07d4: Unknown result type (might be due to invalid IL or missing references)
2010 //IL_07db: Unknown result type (might be due to invalid IL or missing references)
2011 //IL_0763: Unknown result type (might be due to invalid IL or missing references)
2012 //IL_076a: Unknown result type (might be due to invalid IL or missing references)
2013 //IL_0776: Unknown result type (might be due to invalid IL or missing references)
2014 //IL_077c: Unknown result type (might be due to invalid IL or missing references)
2015 //IL_0710: Unknown result type (might be due to invalid IL or missing references)
2016 //IL_0790: Unknown result type (might be due to invalid IL or missing references)
2017 //IL_0725: Unknown result type (might be due to invalid IL or missing references)
2018 //IL_07a5: Unknown result type (might be due to invalid IL or missing references)
2019 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
2020 //IL_01d6: Unknown result type (might be due to invalid IL or missing references)
2021 //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
2022 //IL_01e8: Unknown result type (might be due to invalid IL or missing references)
2023 //IL_01fa: Unknown result type (might be due to invalid IL or missing references)
2024 //IL_0203: Unknown result type (might be due to invalid IL or missing references)
2025 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
2026 //IL_0215: Unknown result type (might be due to invalid IL or missing references)
2027 //IL_024b: Unknown result type (might be due to invalid IL or missing references)
2028 //IL_025b: Unknown result type (might be due to invalid IL or missing references)
2029 //IL_0364: Unknown result type (might be due to invalid IL or missing references)
2030 //IL_036d: Unknown result type (might be due to invalid IL or missing references)
2031 //IL_026c: Unknown result type (might be due to invalid IL or missing references)
2032 //IL_027a: Unknown result type (might be due to invalid IL or missing references)
2033 //IL_0379: Unknown result type (might be due to invalid IL or missing references)
2034 //IL_037f: Unknown result type (might be due to invalid IL or missing references)
2035 //IL_0391: Unknown result type (might be due to invalid IL or missing references)
2036 //IL_039a: Unknown result type (might be due to invalid IL or missing references)
2037 //IL_02af: Unknown result type (might be due to invalid IL or missing references)
2038 //IL_03a6: Unknown result type (might be due to invalid IL or missing references)
2039 //IL_03ac: Unknown result type (might be due to invalid IL or missing references)
2040 //IL_02d6: Unknown result type (might be due to invalid IL or missing references)
2041 //IL_02e3: Unknown result type (might be due to invalid IL or missing references)
2042 //IL_03d7: Unknown result type (might be due to invalid IL or missing references)
2043 //IL_03dd: Unknown result type (might be due to invalid IL or missing references)
2044 //IL_03ec: Unknown result type (might be due to invalid IL or missing references)
2045 //IL_03f9: Unknown result type (might be due to invalid IL or missing references)
2046 //IL_048a: Unknown result type (might be due to invalid IL or missing references)
2047 //IL_0490: Unknown result type (might be due to invalid IL or missing references)
2048 //IL_040e: Unknown result type (might be due to invalid IL or missing references)
2049 //IL_0414: Unknown result type (might be due to invalid IL or missing references)
2050 //IL_04e8: Unknown result type (might be due to invalid IL or missing references)
2051 //IL_04ee: Unknown result type (might be due to invalid IL or missing references)
2052 //IL_0499: Unknown result type (might be due to invalid IL or missing references)
2053 //IL_04a8: Unknown result type (might be due to invalid IL or missing references)
2054 //IL_0429: Unknown result type (might be due to invalid IL or missing references)
2055 //IL_0436: Unknown result type (might be due to invalid IL or missing references)
2056 //IL_0442: Unknown result type (might be due to invalid IL or missing references)
2057 //IL_04fd: Unknown result type (might be due to invalid IL or missing references)
2058 //IL_050a: Unknown result type (might be due to invalid IL or missing references)
2059 //IL_04bc: Unknown result type (might be due to invalid IL or missing references)
2060 //IL_0453: Unknown result type (might be due to invalid IL or missing references)
2061 //IL_0461: Unknown result type (might be due to invalid IL or missing references)
2062 //IL_0469: Unknown result type (might be due to invalid IL or missing references)
2063 //IL_0522: Unknown result type (might be due to invalid IL or missing references)
2064 //IL_052b: Unknown result type (might be due to invalid IL or missing references)
2065 //IL_0628: Unknown result type (might be due to invalid IL or missing references)
2066 //IL_0634: Unknown result type (might be due to invalid IL or missing references)
2067 //IL_05f8: Unknown result type (might be due to invalid IL or missing references)
2068 //IL_0607: Unknown result type (might be due to invalid IL or missing references)
2069 //IL_0613: Unknown result type (might be due to invalid IL or missing references)
2070 //IL_053a: Unknown result type (might be due to invalid IL or missing references)
2071 //IL_0541: Unknown result type (might be due to invalid IL or missing references)
2072 //IL_0550: Unknown result type (might be due to invalid IL or missing references)
2073 //IL_0682: Unknown result type (might be due to invalid IL or missing references)
2074 //IL_059e: Unknown result type (might be due to invalid IL or missing references)
2075 //IL_05ac: Unknown result type (might be due to invalid IL or missing references)
2076 //IL_05b4: Unknown result type (might be due to invalid IL or missing references)
2077 stair = false;
2078 stairFall = false;
2079 bool[] array = new bool[5];
2080 float y = Position.Y;
2081 float y2 = Position.Y;
2082 sloping = false;
2083 Vector2 vector2 = Position;
2084 Vector2 vector3 = Velocity;
2085 int value5 = (int)(Position.X / 16f) - 1;
2086 int value2 = (int)((Position.X + (float)Width) / 16f) + 2;
2087 int value3 = (int)(Position.Y / 16f) - 1;
2088 int value4 = (int)((Position.Y + (float)Height) / 16f) + 2;
2089 int num19 = Utils.Clamp(value5, 0, Main.maxTilesX - 1);
2090 value2 = Utils.Clamp(value2, 0, Main.maxTilesX - 1);
2091 value3 = Utils.Clamp(value3, 0, Main.maxTilesY - 1);
2092 value4 = Utils.Clamp(value4, 0, Main.maxTilesY - 1);
2093 Vector2 vector4 = default(Vector2);
2094 for (int i = num19; i < value2; i++)
2095 {
2096 for (int j = value3; j < value4; j++)
2097 {
2098 if (Main.tile[i, j] == null || !Main.tile[i, j].active() || Main.tile[i, j].inActive() || (!Main.tileSolid[Main.tile[i, j].type] && (!Main.tileSolidTop[Main.tile[i, j].type] || Main.tile[i, j].frameY != 0)))
2099 {
2100 continue;
2101 }
2102 vector4.X = i * 16;
2103 vector4.Y = j * 16;
2104 int num11 = 16;
2105 if (Main.tile[i, j].halfBrick())
2106 {
2107 vector4.Y += 8f;
2108 num11 -= 8;
2109 }
2110 if (!(Position.X + (float)Width > vector4.X) || !(Position.X < vector4.X + 16f) || !(Position.Y + (float)Height > vector4.Y) || !(Position.Y < vector4.Y + (float)num11))
2111 {
2112 continue;
2113 }
2114 bool flag = true;
2115 if (TileID.Sets.Platforms[Main.tile[i, j].type])
2116 {
2117 if (Velocity.Y < 0f)
2118 {
2119 flag = false;
2120 }
2121 if (Position.Y + (float)Height < (float)(j * 16) || Position.Y + (float)Height - (1f + Math.Abs(Velocity.X)) > (float)(j * 16 + 16))
2122 {
2123 flag = false;
2124 }
2125 if (((Main.tile[i, j].slope() == 1 && Velocity.X >= 0f) || (Main.tile[i, j].slope() == 2 && Velocity.X <= 0f)) && (Position.Y + (float)Height) / 16f - 1f == (float)j)
2126 {
2127 flag = false;
2128 }
2129 }
2130 if (!flag)
2131 {
2132 continue;
2133 }
2134 bool flag2 = false;
2135 if (fall && TileID.Sets.Platforms[Main.tile[i, j].type])
2136 {
2137 flag2 = true;
2138 }
2139 int num12 = Main.tile[i, j].slope();
2140 vector4.X = i * 16;
2141 vector4.Y = j * 16;
2142 if (!(Position.X + (float)Width > vector4.X) || !(Position.X < vector4.X + 16f) || !(Position.Y + (float)Height > vector4.Y) || !(Position.Y < vector4.Y + 16f))
2143 {
2144 continue;
2145 }
2146 float num13 = 0f;
2147 if (num12 == 3 || num12 == 4)
2148 {
2149 if (num12 == 3)
2150 {
2151 num13 = Position.X - vector4.X;
2152 }
2153 if (num12 == 4)
2154 {
2155 num13 = vector4.X + 16f - (Position.X + (float)Width);
2156 }
2157 if (num13 >= 0f)
2158 {
2159 if (Position.Y <= vector4.Y + 16f - num13)
2160 {
2161 float num14 = vector4.Y + 16f - Position.Y - num13;
2162 if (Position.Y + num14 > y2)
2163 {
2164 vector2.Y = Position.Y + num14;
2165 y2 = vector2.Y;
2166 if (vector3.Y < 0.0101f)
2167 {
2168 vector3.Y = 0.0101f;
2169 }
2170 array[num12] = true;
2171 }
2172 }
2173 }
2174 else if (Position.Y > vector4.Y)
2175 {
2176 float num15 = vector4.Y + 16f;
2177 if (vector2.Y < num15)
2178 {
2179 vector2.Y = num15;
2180 if (vector3.Y < 0.0101f)
2181 {
2182 vector3.Y = 0.0101f;
2183 }
2184 }
2185 }
2186 }
2187 if (num12 != 1 && num12 != 2)
2188 {
2189 continue;
2190 }
2191 if (num12 == 1)
2192 {
2193 num13 = Position.X - vector4.X;
2194 }
2195 if (num12 == 2)
2196 {
2197 num13 = vector4.X + 16f - (Position.X + (float)Width);
2198 }
2199 if (num13 >= 0f)
2200 {
2201 if (!(Position.Y + (float)Height >= vector4.Y + num13))
2202 {
2203 continue;
2204 }
2205 float num16 = vector4.Y - (Position.Y + (float)Height) + num13;
2206 if (!(Position.Y + num16 < y))
2207 {
2208 continue;
2209 }
2210 if (flag2)
2211 {
2212 stairFall = true;
2213 continue;
2214 }
2215 if (TileID.Sets.Platforms[Main.tile[i, j].type])
2216 {
2217 stair = true;
2218 }
2219 else
2220 {
2221 stair = false;
2222 }
2223 vector2.Y = Position.Y + num16;
2224 y = vector2.Y;
2225 if (vector3.Y > 0f)
2226 {
2227 vector3.Y = 0f;
2228 }
2229 array[num12] = true;
2230 continue;
2231 }
2232 if (TileID.Sets.Platforms[Main.tile[i, j].type] && !(Position.Y + (float)Height - 4f - Math.Abs(Velocity.X) <= vector4.Y))
2233 {
2234 if (flag2)
2235 {
2236 stairFall = true;
2237 }
2238 continue;
2239 }
2240 float num17 = vector4.Y - (float)Height;
2241 if (!(vector2.Y > num17))
2242 {
2243 continue;
2244 }
2245 if (flag2)
2246 {
2247 stairFall = true;
2248 continue;
2249 }
2250 if (TileID.Sets.Platforms[Main.tile[i, j].type])
2251 {
2252 stair = true;
2253 }
2254 else
2255 {
2256 stair = false;
2257 }
2258 vector2.Y = num17;
2259 if (vector3.Y > 0f)
2260 {
2261 vector3.Y = 0f;
2262 }
2263 }
2264 }
2265 Vector2 velocity = vector2 - Position;
2266 Vector2 vector5 = TileCollision(Position, velocity, Width, Height);
2267 if (vector5.Y > velocity.Y)
2268 {
2269 float num18 = velocity.Y - vector5.Y;
2270 vector2.Y = Position.Y + vector5.Y;
2271 if (array[1])
2272 {
2273 vector2.X = Position.X - num18;
2274 }
2275 if (array[2])
2276 {
2277 vector2.X = Position.X + num18;
2278 }
2279 vector3.X = 0f;
2280 vector3.Y = 0f;
2281 up = false;
2282 }
2283 else if (vector5.Y < velocity.Y)
2284 {
2285 float num10 = vector5.Y - velocity.Y;
2286 vector2.Y = Position.Y + vector5.Y;
2287 if (array[3])
2288 {
2289 vector2.X = Position.X - num10;
2290 }
2291 if (array[4])
2292 {
2293 vector2.X = Position.X + num10;
2294 }
2295 vector3.X = 0f;
2296 vector3.Y = 0f;
2297 }
2298 return new Vector4(vector2, vector3.X, vector3.Y);
2299 }
static bool stair
Definition Collision.cs:20
static bool up
Definition Collision.cs:32
static bool stairFall
Definition Collision.cs:22
static bool sloping
Definition Collision.cs:28
static Vector2 TileCollision(Vector2 Position, Vector2 Velocity, int Width, int Height, bool fallThrough=false, bool fall2=false, int gravDir=1)
static bool[] Platforms
Definition TileID.cs:219

References Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.ID.TileID.Sets.Platforms, Terraria.Collision.sloping, Terraria.Collision.stair, Terraria.Collision.stairFall, Terraria.Main.tile, Terraria.Collision.TileCollision(), Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and Terraria.Collision.up.

Referenced by Terraria.Player.CheckForGoodTeleportationSpot(), Terraria.NPC.Collision_MoveSlopesAndStairFall(), Terraria.NPC.Collision_MoveSnailOnSlopes(), Terraria.Collision.FindCollisionTile(), Terraria.Gore.Gore_UpdateLeaf(), Terraria.Projectile.HandleMovement(), Terraria.Collision.IsClearSpotTest(), Terraria.Item.MoveInWorld(), Terraria.Player.SlopingCollision(), Terraria.Gore.Update(), and Terraria.Projectile.UpdatePosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: