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

◆ AI_150_GolfClubHelper()

void Terraria.Projectile.AI_150_GolfClubHelper ( )
inlineprivate

Definition at line 42540 of file Projectile.cs.

42541 {
42542 Player player = Main.player[owner];
42543 if (!player.active)
42544 {
42545 Kill();
42546 return;
42547 }
42548 if (player.gravDir == -1f)
42549 {
42550 player.SetDummyItemTime(0);
42551 Kill();
42552 return;
42553 }
42554 bool flag = false;
42555 Rectangle rectangle = Utils.CenteredRectangle(player.Center, new Vector2(500f, 500f));
42556 for (int i = 0; i < 1000; i++)
42557 {
42558 Projectile projectile = Main.projectile[i];
42559 if (projectile.active && projectile.owner == Main.myPlayer && ProjectileID.Sets.IsAGolfBall[projectile.type] && rectangle.Contains(projectile.Center.ToPoint()))
42560 {
42561 flag = true;
42562 break;
42563 }
42564 }
42565 if (!flag && owner == Main.myPlayer && ai[0] == 0f)
42566 {
42567 player.TryPlacingAGolfBallNearANearbyTee(Main.player[owner].Center);
42568 }
42569 if (!player.channel && ai[0] == 0f)
42570 {
42571 SoundEngine.PlaySound(SoundID.Item1, player.Center);
42572 for (int j = 0; j < 1000; j++)
42573 {
42574 Projectile projectile2 = Main.projectile[j];
42575 Vector2 shotVector = Main.MouseWorld - projectile2.Center;
42577 {
42578 continue;
42579 }
42580 float num = Main.rand.NextFloatDirection();
42581 for (float num2 = 0f; num2 < 1f; num2 += 0.1f)
42582 {
42583 Dust dust = Dust.NewDustPerfect(projectile2.Center, 31, ((float)Math.PI * 2f * num2 + num).ToRotationVector2() * 0.8f, 127);
42584 dust.fadeIn = 0f;
42585 if (num2 % 0.2f == 0f)
42586 {
42587 dust.velocity *= 0.4f;
42588 }
42589 }
42591 if (owner == Main.myPlayer)
42592 {
42594 Vector2 vector = Vector2.Normalize(shotVector) * shotStrength.AbsoluteStrength;
42595 GolfHelper.HitGolfBall(projectile2, vector, shotStrength.RoughLandResistance);
42596 NetMessage.SendData(27, -1, -1, null, j);
42597 }
42598 }
42599 ai[0] = 1f;
42600 ai[1] = 0f;
42601 netUpdate = true;
42602 }
42603 if (ai[0] == 1f)
42604 {
42605 ai[1] += 1f;
42606 float num3 = player.HeldItem.useAnimation + 30;
42607 if (ai[1] >= num3)
42608 {
42609 Kill();
42610 return;
42611 }
42613 player.ChangeDir(direction);
42614 player.heldProj = whoAmI;
42615 int num4 = player.HeldItem.useAnimation - (int)ai[1];
42616 if (num4 < 2)
42617 {
42618 num4 = 2;
42619 }
42620 player.SetDummyItemTime(num4);
42621 }
42622 if (ai[0] != 0f)
42623 {
42624 return;
42625 }
42626 if (owner == Main.myPlayer)
42627 {
42628 Vector2 mouseWorld = Main.MouseWorld;
42629 if (mouseWorld != base.Center)
42630 {
42631 netUpdate = true;
42632 base.Center = mouseWorld;
42633 }
42634 if (Main.mouseRight && Main.mouseRightRelease)
42635 {
42636 Kill();
42637 player.mouseInterface = true;
42638 Main.blockMouse = true;
42639 player.SetItemTime(0);
42640 player.itemAnimation = 0;
42641 player.itemAnimationMax = 0;
42642 player.reuseDelay = 0;
42643 return;
42644 }
42645 }
42646 if (position != oldPosition)
42647 {
42648 if (base.Center.X - player.Center.X > 0f)
42649 {
42650 direction = 1;
42651 }
42652 else
42653 {
42654 direction = -1;
42655 }
42656 }
42658 player.ChangeDir(direction);
42659 player.heldProj = whoAmI;
42660 ai[1] += 1f;
42661 int num5 = player.HeldItem.useAnimation * 4;
42662 if (ai[1] > (float)(num5 * 3))
42663 {
42664 ai[1] = num5;
42665 }
42666 int num6 = player.HeldItem.useAnimation + Math.Min(num5, (int)ai[1]);
42667 if (num6 < 2)
42668 {
42669 num6 = 2;
42670 }
42671 player.SetDummyItemTime(num6);
42672 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 oldPosition
Definition Entity.cs:18
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static void HitGolfBall(Entity entity, Vector2 velocity, float roughLandResistance)
static bool ValidateShot(Entity golfBall, Player player, ref Vector2 shotVector)
static ShotStrength CalculateShotStrength(Vector2 shotVector, ClubProperties clubProperties)
static readonly LegacySoundStyle Item1
Definition SoundID.cs:416
static readonly LegacySoundStyle Item126
Definition SoundID.cs:666

References Terraria.Entity.active, Terraria.GameContent.Golf.GolfHelper.CalculateShotStrength(), Terraria.Entity.Center, Terraria.Utils.CenteredRectangle(), Terraria.Player.ChangeDir(), Terraria.Player.channel, System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), Terraria.Player.gravDir, Terraria.GameContent.Golf.GolfHelper.HitGolfBall(), Terraria.ID.ProjectileID.Sets.IsAGolfBall, Terraria.ID.SoundID.Item1, Terraria.ID.SoundID.Item126, System.Math.Min(), Terraria.Main.mouseRight, Terraria.Main.mouseRightRelease, Terraria.Main.MouseWorld, Terraria.Main.myPlayer, Terraria.Dust.NewDustPerfect(), Microsoft.Xna.Framework.Vector2.Normalize(), Terraria.Projectile.owner, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.projectile, Terraria.Main.rand, Terraria.NetMessage.SendData(), Terraria.Player.SetDummyItemTime(), Terraria.Player.SetItemTime(), Terraria.Player.TryPlacingAGolfBallNearANearbyTee(), Terraria.Projectile.type, Terraria.GameContent.Golf.GolfHelper.ValidateShot(), Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Zero.