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

◆ StepUp()

static void Terraria.Collision.StepUp ( ref Vector2 position,
ref Vector2 velocity,
int width,
int height,
ref float stepSpeed,
ref float gfxOffY,
int gravDir = 1,
bool holdsMatching = false,
int specialChecksMode = 0 )
inlinestatic

Definition at line 4216 of file Collision.cs.

4217 {
4218 //IL_0021: Unknown result type (might be due to invalid IL or missing references)
4219 //IL_0026: Unknown result type (might be due to invalid IL or missing references)
4220 //IL_0038: Unknown result type (might be due to invalid IL or missing references)
4221 //IL_0054: Unknown result type (might be due to invalid IL or missing references)
4222 //IL_0076: Unknown result type (might be due to invalid IL or missing references)
4223 //IL_05b4: Unknown result type (might be due to invalid IL or missing references)
4224 //IL_05c7: Unknown result type (might be due to invalid IL or missing references)
4225 //IL_06da: Unknown result type (might be due to invalid IL or missing references)
4226 //IL_0635: Unknown result type (might be due to invalid IL or missing references)
4227 //IL_06e5: Unknown result type (might be due to invalid IL or missing references)
4228 //IL_0641: Unknown result type (might be due to invalid IL or missing references)
4229 int num = 0;
4230 if (velocity.X < 0f)
4231 {
4232 num = -1;
4233 }
4234 if (velocity.X > 0f)
4235 {
4236 num = 1;
4237 }
4238 Vector2 vector = position;
4239 vector.X += velocity.X;
4240 int num2 = (int)((vector.X + (float)(width / 2) + (float)((width / 2 + 1) * num)) / 16f);
4241 int num3 = (int)(((double)vector.Y + 0.1) / 16.0);
4242 if (gravDir == 1)
4243 {
4244 num3 = (int)((vector.Y + (float)height - 1f) / 16f);
4245 }
4246 int num4 = height / 16 + ((height % 16 != 0) ? 1 : 0);
4247 bool flag = true;
4248 bool flag2 = true;
4249 if (Main.tile[num2, num3] == null)
4250 {
4251 return;
4252 }
4253 for (int i = 1; i < num4 + 2; i++)
4254 {
4255 if (!WorldGen.InWorld(num2, num3 - i * gravDir) || Main.tile[num2, num3 - i * gravDir] == null)
4256 {
4257 return;
4258 }
4259 }
4260 if (!WorldGen.InWorld(num2 - num, num3 - num4 * gravDir) || Main.tile[num2 - num, num3 - num4 * gravDir] == null)
4261 {
4262 return;
4263 }
4264 Tile tile;
4265 for (int j = 2; j < num4 + 1; j++)
4266 {
4267 if (!WorldGen.InWorld(num2, num3 - j * gravDir) || Main.tile[num2, num3 - j * gravDir] == null)
4268 {
4269 return;
4270 }
4271 tile = Main.tile[num2, num3 - j * gravDir];
4272 flag = flag && (!tile.nactive() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]);
4273 }
4274 tile = Main.tile[num2 - num, num3 - num4 * gravDir];
4275 flag2 = flag2 && (!tile.nactive() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]);
4276 bool flag3 = true;
4277 bool flag4 = true;
4278 bool flag5 = true;
4279 Tile tile2;
4280 if (gravDir == 1)
4281 {
4282 if (Main.tile[num2, num3 - gravDir] == null || Main.tile[num2, num3 - (num4 + 1) * gravDir] == null)
4283 {
4284 return;
4285 }
4286 tile = Main.tile[num2, num3 - gravDir];
4287 tile2 = Main.tile[num2, num3 - (num4 + 1) * gravDir];
4288 flag3 = flag3 && (!tile.nactive() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type] || (tile.slope() == 1 && position.X + (float)(width / 2) > (float)(num2 * 16)) || (tile.slope() == 2 && position.X + (float)(width / 2) < (float)(num2 * 16 + 16)) || (tile.halfBrick() && (!tile2.nactive() || !Main.tileSolid[tile2.type] || Main.tileSolidTop[tile2.type])));
4289 tile = Main.tile[num2, num3];
4290 tile2 = Main.tile[num2, num3 - 1];
4291 if (specialChecksMode == 1)
4292 {
4293 flag5 = !TileID.Sets.IgnoredByNpcStepUp[tile.type];
4294 }
4295 flag4 = flag4 && ((tile.nactive() && (!tile.topSlope() || (tile.slope() == 1 && position.X + (float)(width / 2) < (float)(num2 * 16)) || (tile.slope() == 2 && position.X + (float)(width / 2) > (float)(num2 * 16 + 16))) && (!tile.topSlope() || position.Y + (float)height > (float)(num3 * 16)) && ((Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type]) || (holdsMatching && ((Main.tileSolidTop[tile.type] && tile.frameY == 0) || TileID.Sets.Platforms[tile.type]) && (!Main.tileSolid[tile2.type] || !tile2.nactive()) && flag5))) || (tile2.halfBrick() && tile2.nactive()));
4296 flag4 &= !Main.tileSolidTop[tile.type] || !Main.tileSolidTop[tile2.type];
4297 }
4298 else
4299 {
4300 tile = Main.tile[num2, num3 - gravDir];
4301 tile2 = Main.tile[num2, num3 - (num4 + 1) * gravDir];
4302 flag3 = flag3 && (!tile.nactive() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type] || tile.slope() != 0 || (tile.halfBrick() && (!tile2.nactive() || !Main.tileSolid[tile2.type] || Main.tileSolidTop[tile2.type])));
4303 tile = Main.tile[num2, num3];
4304 tile2 = Main.tile[num2, num3 + 1];
4305 flag4 = flag4 && ((tile.nactive() && ((Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type]) || (holdsMatching && Main.tileSolidTop[tile.type] && tile.frameY == 0 && (!Main.tileSolid[tile2.type] || !tile2.nactive())))) || (tile2.halfBrick() && tile2.nactive()));
4306 }
4307 if (!((float)(num2 * 16) < vector.X + (float)width) || !((float)(num2 * 16 + 16) > vector.X))
4308 {
4309 return;
4310 }
4311 if (gravDir == 1)
4312 {
4313 if (!(flag4 && flag3 && flag && flag2))
4314 {
4315 return;
4316 }
4317 float num5 = num3 * 16;
4318 if (Main.tile[num2, num3 - 1].halfBrick())
4319 {
4320 num5 -= 8f;
4321 }
4322 else if (Main.tile[num2, num3].halfBrick())
4323 {
4324 num5 += 8f;
4325 }
4326 if (!(num5 < vector.Y + (float)height))
4327 {
4328 return;
4329 }
4330 float num6 = vector.Y + (float)height - num5;
4331 if ((double)num6 <= 16.1)
4332 {
4333 gfxOffY += position.Y + (float)height - num5;
4334 position.Y = num5 - (float)height;
4335 if (num6 < 9f)
4336 {
4337 stepSpeed = 1f;
4338 }
4339 else
4340 {
4341 stepSpeed = 2f;
4342 }
4343 }
4344 }
4345 else
4346 {
4347 if (!(flag4 && flag3 && flag && flag2) || Main.tile[num2, num3].bottomSlope() || TileID.Sets.Platforms[tile2.type])
4348 {
4349 return;
4350 }
4351 float num7 = num3 * 16 + 16;
4352 if (!(num7 > vector.Y))
4353 {
4354 return;
4355 }
4356 float num8 = num7 - vector.Y;
4357 if ((double)num8 <= 16.1)
4358 {
4359 gfxOffY -= num7 - position.Y;
4360 position.Y = num7;
4361 velocity.Y = 0f;
4362 if (num8 < 9f)
4363 {
4364 stepSpeed = 1f;
4365 }
4366 else
4367 {
4368 stepSpeed = 2f;
4369 }
4370 }
4371 }
4372 }
static bool[] IgnoredByNpcStepUp
Whether or not the tile will be ignored for automatic step up regarding town NPC collision....
Definition TileID.cs:416
static bool[] Platforms
Definition TileID.cs:219

References Terraria.Tile.halfBrick(), Terraria.ID.TileID.Sets.IgnoredByNpcStepUp, Terraria.WorldGen.InWorld(), Terraria.Tile.nactive(), Terraria.ID.TileID.Sets.Platforms, Terraria.Tile.slope(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and Terraria.Tile.type.

Referenced by Terraria.NPC.AI_007_TownEntities(), Terraria.Projectile.AI_026(), Terraria.Projectile.AI_067_FreakingPirates(), Terraria.NPC.AI_107_ImprovedWalkers(), Terraria.Player.DryCollision(), and Terraria.Player.Update().

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