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

◆ TryBouncingBlocks()

void Terraria.Player.TryBouncingBlocks ( bool Falling)
inlineprivate

Definition at line 33032 of file Player.cs.

33033 {
33034 bool num = !wet && !shimmering && (velocity.Y >= 5f || velocity.Y <= -5f);
33035 bool flag = false;
33036 bool flag2 = false;
33037 float num2 = 1f;
33038 if (!num)
33039 {
33040 return;
33041 }
33042 bool flag3 = false;
33043 int num3 = 0;
33044 foreach (Point touchedTile in TouchedTiles)
33045 {
33046 Tile tile = Main.tile[touchedTile.X, touchedTile.Y];
33047 if (tile != null && tile.active() && tile.nactive() && (flag || Main.tileBouncy[tile.type]))
33048 {
33049 flag3 = true;
33050 num3 = touchedTile.Y;
33051 break;
33052 }
33053 }
33054 if (!flag3)
33055 {
33056 return;
33057 }
33058 velocity.Y *= -0.8f;
33059 if (controlJump)
33060 {
33061 velocity.Y = MathHelper.Clamp(velocity.Y, -13f, 13f);
33062 }
33063 position.Y = num3 * 16 - ((velocity.Y < 0f) ? height : (-16));
33064 FloorVisuals(Falling);
33065 if (flag2)
33066 {
33067 Vector2 vector = (fullRotation - (float)Math.PI / 2f).ToRotationVector2();
33068 if (vector.Y > 0f)
33069 {
33070 vector.Y *= -1f;
33071 }
33072 vector.Y = vector.Y * 0.5f + -0.5f;
33073 float num4 = 0f - vector.Y;
33074 if (num4 < 0f)
33075 {
33076 num4 = 0f;
33077 }
33078 float num5 = num4 * 1.5f + 1f;
33079 float value = Math.Abs(velocity.Y) * num5 * num2;
33080 value = MathHelper.Clamp(value, 2f, 16f);
33081 velocity = vector * value;
33082 float num6 = 20f;
33083 Vector2 vector2 = base.Center + (fullRotation + (float)Math.PI / 2f).ToRotationVector2() * num6;
33084 vector2 = base.Bottom;
33086 {
33087 PositionInWorld = vector2
33088 }, whoAmI);
33089 }
33090 velocity.Y = MathHelper.Clamp(velocity.Y, -20f, 20f);
33091 if (velocity.Y * gravDir < 0f)
33092 {
33093 fallStart = (int)position.Y / 16;
33094 }
33095 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static double Abs(double value)
const double PI
Definition Math.cs:16
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static void RequestParticleSpawn(bool clientOnly, ParticleOrchestraType type, ParticleOrchestraSettings settings, int? overrideInvokingPlayerIndex=null)
List< Point > TouchedTiles
Definition Player.cs:2563
void FloorVisuals(bool Falling)
Definition Player.cs:22756
float fullRotation
Definition Player.cs:1291

References System.Math.Abs(), Terraria.Tile.active(), Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.Tile.nactive(), System.Math.PI, Terraria.GameContent.Drawing.ParticleOrchestrator.RequestParticleSpawn(), Terraria.Main.tile, Terraria.Main.tileBouncy, Terraria.Tile.type, and System.value.