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

◆ StepDown()

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

Definition at line 3037 of file Collision.cs.

3038 {
3039 Vector2 vector = position;
3040 vector.X += velocity.X;
3041 vector.Y = (float)Math.Floor((vector.Y + (float)height) / 16f) * 16f - (float)height;
3042 bool flag = false;
3043 int num = (int)(vector.X / 16f);
3044 int num2 = (int)((vector.X + (float)width) / 16f);
3045 int num3 = (int)((vector.Y + (float)height + 4f) / 16f);
3046 int num4 = height / 16 + ((height % 16 != 0) ? 1 : 0);
3047 float num5 = (num3 + num4) * 16;
3048 float num6 = Main.bottomWorld / 16f - 42f;
3049 for (int i = num; i <= num2; i++)
3050 {
3051 for (int j = num3; j <= num3 + 1; j++)
3052 {
3053 if (!WorldGen.InWorld(i, j, 1))
3054 {
3055 continue;
3056 }
3057 if (Main.tile[i, j] == null)
3058 {
3059 Main.tile[i, j] = new Tile();
3060 }
3061 if (Main.tile[i, j - 1] == null)
3062 {
3063 Main.tile[i, j - 1] = new Tile();
3064 }
3065 if (waterWalk && Main.tile[i, j].liquid > 0 && Main.tile[i, j - 1].liquid == 0)
3066 {
3067 int num7 = Main.tile[i, j].liquid / 32 * 2 + 2;
3068 int num8 = j * 16 + 16 - num7;
3069 if (new Rectangle(i * 16, j * 16 - 17, 16, 16).Intersects(new Rectangle((int)position.X, (int)position.Y, width, height)) && (float)num8 < num5)
3070 {
3071 num5 = num8;
3072 }
3073 }
3074 if ((float)j >= num6 || (Main.tile[i, j].nactive() && (Main.tileSolid[Main.tile[i, j].type] || Main.tileSolidTop[Main.tile[i, j].type])))
3075 {
3076 int num9 = j * 16;
3077 if (Main.tile[i, j].halfBrick())
3078 {
3079 num9 += 8;
3080 }
3081 if (Utils.FloatIntersect(i * 16, j * 16 - 17, 16f, 16f, position.X, position.Y, width, height) && (float)num9 < num5)
3082 {
3083 num5 = num9;
3084 }
3085 }
3086 }
3087 }
3088 float num10 = num5 - (position.Y + (float)height);
3089 if (num10 > 7f && num10 < 17f && !flag)
3090 {
3091 stepSpeed = 1.5f;
3092 if (num10 > 9f)
3093 {
3094 stepSpeed = 2.5f;
3095 }
3096 gfxOffY += position.Y + (float)height - num5;
3097 position.Y = num5 - (float)height;
3098 }
3099 }
static double Floor(double d)

References Terraria.Utils.FloatIntersect(), System.Math.Floor(), Microsoft.Xna.Framework.Intersects, Terraria.WorldGen.InWorld(), Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, and Terraria.Main.tileSolidTop.

Referenced by Terraria.NPC.AI_007_TownEntities(), Terraria.Player.DryCollision(), and Terraria.Player.Update().