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

◆ AI_116_WaterStriders()

void Terraria.NPC.AI_116_WaterStriders ( )
inlineprivate

Definition at line 40732 of file NPC.cs.

40733 {
40734 bool flag = false;
40735 if (Collision.GetWaterLine(base.Center.ToTileCoordinates(), out var waterLineHeight))
40736 {
40737 float num = base.Bottom.Y - 1f;
40738 if (base.Center.Y > waterLineHeight)
40739 {
40740 velocity.Y -= 0.8f;
40741 if (velocity.Y < -4f)
40742 {
40743 velocity.Y = -4f;
40744 }
40745 if (num + velocity.Y < waterLineHeight)
40746 {
40747 velocity.Y = waterLineHeight - num;
40748 }
40749 }
40750 else
40751 {
40752 velocity.Y = MathHelper.Min(velocity.Y, waterLineHeight - num);
40753 flag = true;
40754 }
40755 }
40756 else if (wet)
40757 {
40758 velocity.Y -= 0.2f;
40759 }
40760 if ((int)ai[0] != 0)
40761 {
40762 return;
40763 }
40764 ai[1] += 1f;
40765 velocity.X *= 0.9f;
40766 if (velocity.Y == 0f)
40767 {
40768 velocity.X *= 0.6f;
40769 }
40770 bool flag2 = wet || flag;
40771 bool flag3 = flag2 || velocity.Y == 0f;
40772 int num2 = Main.rand.Next(120, 241);
40773 if (!flag2)
40774 {
40775 num2 = Main.rand.Next(60, 241);
40776 }
40777 if (!flag3 || !(ai[1] >= (float)num2))
40778 {
40779 return;
40780 }
40781 ai[1] = 0f;
40782 velocity.X = Main.rand.NextFloatDirection() * 5f;
40783 netUpdate = true;
40784 if (!flag2)
40785 {
40786 if (velocity.Y == 0f)
40787 {
40788 velocity.Y = -2f;
40789 }
40790 ai[1] = 60f;
40791 }
40792 }
static float Min(float value1, float value2)
Definition MathHelper.cs:36
Vector2 velocity
Definition Entity.cs:16
float[] ai
Definition NPC.cs:447
bool netUpdate
Definition NPC.cs:507

References Terraria.NPC.ai, Terraria.Collision.GetWaterLine(), Microsoft.Xna.Framework.MathHelper.Min(), Terraria.NPC.netUpdate, Terraria.Main.rand, Terraria.Entity.velocity, Terraria.Entity.wet, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.NPC.AI().