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

◆ AI_116_WaterStriders()

void Terraria.NPC.AI_116_WaterStriders ( )
inlineprivate

Definition at line 49579 of file NPC.cs.

49580 {
49581 //IL_0003: Unknown result type (might be due to invalid IL or missing references)
49582 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
49583 //IL_001a: Unknown result type (might be due to invalid IL or missing references)
49584 //IL_002d: Unknown result type (might be due to invalid IL or missing references)
49585 bool flag = false;
49586 if (Collision.GetWaterLine(base.Center.ToTileCoordinates(), out var waterLineHeight))
49587 {
49588 float num = base.Bottom.Y - 1f;
49589 if (base.Center.Y > waterLineHeight)
49590 {
49591 velocity.Y -= 0.8f;
49592 if (velocity.Y < -4f)
49593 {
49594 velocity.Y = -4f;
49595 }
49596 if (num + velocity.Y < waterLineHeight)
49597 {
49598 velocity.Y = waterLineHeight - num;
49599 }
49600 }
49601 else
49602 {
49603 velocity.Y = MathHelper.Min(velocity.Y, waterLineHeight - num);
49604 flag = true;
49605 }
49606 }
49607 else if (wet)
49608 {
49609 velocity.Y -= 0.2f;
49610 }
49611 if ((int)ai[0] != 0)
49612 {
49613 return;
49614 }
49615 ai[1] += 1f;
49616 velocity.X *= 0.9f;
49617 if (velocity.Y == 0f)
49618 {
49619 velocity.X *= 0.6f;
49620 }
49621 bool flag2 = wet || flag;
49622 bool flag3 = flag2 || velocity.Y == 0f;
49623 int num2 = Main.rand.Next(120, 241);
49624 if (!flag2)
49625 {
49626 num2 = Main.rand.Next(60, 241);
49627 }
49628 if (!flag3 || !(ai[1] >= (float)num2))
49629 {
49630 return;
49631 }
49632 ai[1] = 0f;
49633 velocity.X = Main.rand.NextFloatDirection() * 5f;
49634 netUpdate = true;
49635 if (!flag2)
49636 {
49637 if (velocity.Y == 0f)
49638 {
49639 velocity.Y = -2f;
49640 }
49641 ai[1] = 60f;
49642 }
49643 }
bool wet
The Entity is currently in water. Projectile: Affects movement speed and some projectiles die when ...
Definition Entity.cs:57
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
bool netUpdate
Definition NPC.cs:1130

References Terraria.NPC.ai, Terraria.Collision.GetWaterLine(), Terraria.NPC.netUpdate, Terraria.Main.rand, Terraria.Entity.velocity, and Terraria.Entity.wet.

Referenced by Terraria.NPC.VanillaAI_Inner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: