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

◆ AI_170_FairyGlowstick()

void Terraria.Projectile.AI_170_FairyGlowstick ( )
inlineprivate

Definition at line 37629 of file Projectile.cs.

37630 {
37631 Point p = base.Center.ToTileCoordinates();
37632 Vector2 vector = p.ToVector2();
37633 int num = 10;
37635 int num2 = 0;
37636 float num3 = 3f;
37637 if (ai[1] == 1f)
37638 {
37640 rotation = 0f;
37641 velocity.X = 0f;
37642 ai[1] = 2f;
37643 }
37644 frameCounter++;
37645 if (frameCounter > 4)
37646 {
37647 frameCounter = 0;
37648 frame++;
37649 if (frame >= Main.projFrames[type])
37650 {
37651 frame = 0;
37652 }
37653 }
37654 if (velocity.Length() > 1f && timeLeft % 10 == 0)
37655 {
37656 for (int i = p.X - num; i < p.X + num + 1; i++)
37657 {
37658 for (int j = p.Y - num; j < p.Y + num + 1; j++)
37659 {
37660 if (WorldGen.SolidTile(i, j))
37661 {
37662 Vector2 v = vector - new Vector2(i, j);
37663 Vector2 vector2 = v.SafeNormalize(Vector2.Zero) * Math.Max((float)num - v.Length(), 0f);
37664 vector2 *= num3;
37665 zero += vector2;
37666 num2++;
37667 }
37668 }
37669 }
37670 if (num2 > 0)
37671 {
37672 zero /= (float)num2;
37673 }
37674 if (zero.Length() > 1f)
37675 {
37676 velocity = zero;
37677 }
37678 }
37679 velocity *= 0.95f;
37680 if (velocity.Length() < 1f)
37681 {
37683 netUpdate = true;
37684 }
37685 }
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static readonly LegacySoundStyle Item28
Definition SoundID.cs:470

References Terraria.ID.SoundID.Item28, Microsoft.Xna.Framework.Vector2.Length(), System.Math.Max(), Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.projFrames, Terraria.WorldGen.SolidTile(), System.type, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Point.Y, and Microsoft.Xna.Framework.Vector2.Zero.