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

◆ GetGrapplingForces()

void Terraria.Player.GetGrapplingForces ( Vector2 fromPosition,
out int? preferredPlayerDirectionToSet,
out float preferedPlayerVelocityX,
out float preferedPlayerVelocityY )
inlineprivate

Definition at line 21699 of file Player.cs.

21700 {
21701 float num = 0f;
21702 float num2 = 0f;
21704 int num3 = 0;
21705 for (int i = 0; i < grapCount; i++)
21706 {
21707 Projectile projectile = Main.projectile[grappling[i]];
21708 if (projectile.ai[0] != 2f || projectile.position.HasNaNs())
21709 {
21710 continue;
21711 }
21712 num += projectile.position.X + (float)(projectile.width / 2);
21713 num2 += projectile.position.Y + (float)(projectile.height / 2);
21714 num3++;
21715 if (projectile.type == 446)
21716 {
21717 Vector2 vector = new Vector2(controlRight.ToInt() - controlLeft.ToInt(), (float)(controlDown.ToInt() - controlUp.ToInt()) * gravDir);
21718 if (vector != Vector2.Zero)
21719 {
21720 vector.Normalize();
21721 }
21722 vector *= 100f;
21723 Vector2 vec = Vector2.Normalize(base.Center - projectile.Center + vector);
21724 if (vec.HasNaNs())
21725 {
21726 vec = -Vector2.UnitY;
21727 }
21728 float num4 = 200f;
21729 num += vec.X * num4;
21730 num2 += vec.Y * num4;
21731 }
21732 else if (projectile.type == 652)
21733 {
21734 Vector2 vector2 = new Vector2(controlRight.ToInt() - controlLeft.ToInt(), (float)(controlDown.ToInt() - controlUp.ToInt()) * gravDir).SafeNormalize(Vector2.Zero);
21735 Vector2 vector3 = projectile.Center - base.Center;
21736 Vector2 vector4 = vector3.SafeNormalize(Vector2.Zero);
21738 if (vector2 != Vector2.Zero)
21739 {
21741 }
21742 float num5 = 6f;
21743 if (Vector2.Dot(value, vector3) < 0f && vector3.Length() >= 600f)
21744 {
21745 num5 = 0f;
21746 }
21747 num += 0f - vector3.X + value.X * num5;
21748 num2 += 0f - vector3.Y + value.Y * num5;
21749 }
21750 else if (projectile.type == 865)
21751 {
21752 Vector2 vector5 = (projectile.rotation - (float)Math.PI / 2f).ToRotationVector2().SafeNormalize(Vector2.UnitY);
21753 Vector2 vector6 = -vector5 * 28f;
21754 num += vector6.X;
21755 num2 += vector6.Y;
21756 if (vector5.X != 0f)
21757 {
21759 }
21760 }
21761 }
21762 if (num3 == 0)
21763 {
21766 return;
21767 }
21768 float num6 = num / (float)num3;
21769 float num7 = num2 / (float)num3;
21774 float num9 = 11f;
21775 if (Main.projectile[grappling[0]].type == 315)
21776 {
21777 num9 = 14f;
21778 }
21779 if (Main.projectile[grappling[0]].type == 487)
21780 {
21781 num9 = 12f;
21782 }
21783 if (Main.projectile[grappling[0]].type >= 646 && Main.projectile[grappling[0]].type <= 649)
21784 {
21785 num9 = 16f;
21786 }
21787 float num10 = num8;
21788 num10 = ((!(num8 > num9)) ? 1f : (num9 / num8));
21791 }
static double Sqrt(double d)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
Vector2 velocity
Definition Entity.cs:16
bool controlRight
Definition Player.cs:1383
int[] grappling
Definition Player.cs:2305
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121

References Terraria.Projectile.ai, Terraria.Entity.Center, Microsoft.Xna.Framework.Vector2.Dot(), Terraria.Entity.height, Microsoft.Xna.Framework.Vector2.Normalize(), System.Math.PI, Terraria.Entity.position, Terraria.Main.projectile, System.Math.Sign(), System.Math.Sqrt(), Terraria.Projectile.type, Microsoft.Xna.Framework.Vector2.UnitY, System.value, Terraria.Entity.width, and Microsoft.Xna.Framework.Vector2.Zero.