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

◆ GetNPCLocation()

static bool Terraria.NPC.GetNPCLocation ( int i,
bool seekHead,
bool averageDirection,
out int index,
out Vector2 pos )
inlinestatic

Definition at line 13593 of file NPC.cs.

13594 {
13595 //IL_0379: Unknown result type (might be due to invalid IL or missing references)
13596 //IL_037e: Unknown result type (might be due to invalid IL or missing references)
13597 //IL_0256: Unknown result type (might be due to invalid IL or missing references)
13598 //IL_025b: Unknown result type (might be due to invalid IL or missing references)
13599 //IL_0274: Unknown result type (might be due to invalid IL or missing references)
13600 //IL_0279: Unknown result type (might be due to invalid IL or missing references)
13601 //IL_0243: Unknown result type (might be due to invalid IL or missing references)
13602 //IL_0248: Unknown result type (might be due to invalid IL or missing references)
13603 //IL_0361: Unknown result type (might be due to invalid IL or missing references)
13604 //IL_0366: Unknown result type (might be due to invalid IL or missing references)
13605 //IL_0333: Unknown result type (might be due to invalid IL or missing references)
13606 //IL_033c: Unknown result type (might be due to invalid IL or missing references)
13607 //IL_0341: Unknown result type (might be due to invalid IL or missing references)
13608 //IL_0346: Unknown result type (might be due to invalid IL or missing references)
13609 //IL_0349: Unknown result type (might be due to invalid IL or missing references)
13610 //IL_034f: Unknown result type (might be due to invalid IL or missing references)
13611 //IL_0354: Unknown result type (might be due to invalid IL or missing references)
13612 //IL_0323: Unknown result type (might be due to invalid IL or missing references)
13613 //IL_0328: Unknown result type (might be due to invalid IL or missing references)
13614 //IL_02b4: Unknown result type (might be due to invalid IL or missing references)
13615 //IL_02a1: Unknown result type (might be due to invalid IL or missing references)
13616 int num = Main.npc[i].type;
13617 int num2 = -1;
13618 int num3 = -1;
13619 switch (num)
13620 {
13621 case 13:
13622 num3 = 15;
13623 num2 = 0;
13624 break;
13625 case 14:
13626 case 15:
13627 num3 = 13;
13628 num2 = 1;
13629 break;
13630 case 134:
13631 num3 = 136;
13632 num2 = 0;
13633 break;
13634 case 135:
13635 case 136:
13636 num3 = 134;
13637 num2 = 1;
13638 break;
13639 case 454:
13640 num3 = 459;
13641 num2 = 0;
13642 break;
13643 case 455:
13644 case 456:
13645 case 457:
13646 case 458:
13647 case 459:
13648 num3 = 454;
13649 num2 = 1;
13650 break;
13651 case 98:
13652 num3 = 100;
13653 num2 = 0;
13654 break;
13655 case 99:
13656 case 100:
13657 num3 = 98;
13658 num2 = 1;
13659 break;
13660 case 39:
13661 num3 = 41;
13662 num2 = 0;
13663 break;
13664 case 40:
13665 case 41:
13666 num3 = 39;
13667 num2 = 1;
13668 break;
13669 case 510:
13670 num3 = 512;
13671 num2 = 0;
13672 break;
13673 case 511:
13674 case 512:
13675 num3 = 510;
13676 num2 = 1;
13677 break;
13678 case 621:
13679 num3 = 623;
13680 num2 = 0;
13681 break;
13682 case 622:
13683 case 623:
13684 num3 = 621;
13685 num2 = 1;
13686 break;
13687 case 513:
13688 num3 = 515;
13689 num2 = 0;
13690 break;
13691 case 514:
13692 case 515:
13693 num3 = 513;
13694 num2 = 1;
13695 break;
13696 case 87:
13697 num3 = 92;
13698 num2 = 0;
13699 break;
13700 case 88:
13701 case 89:
13702 case 90:
13703 case 91:
13704 case 92:
13705 num3 = 87;
13706 num2 = 1;
13707 break;
13708 case 117:
13709 num3 = 119;
13710 num2 = 0;
13711 break;
13712 case 118:
13713 case 119:
13714 num3 = 117;
13715 num2 = 1;
13716 break;
13717 case 7:
13718 num3 = 9;
13719 num2 = 0;
13720 break;
13721 case 8:
13722 case 9:
13723 num3 = 7;
13724 num2 = 1;
13725 break;
13726 case 95:
13727 num3 = 97;
13728 num2 = 0;
13729 break;
13730 case 96:
13731 case 97:
13732 num3 = 95;
13733 num2 = 1;
13734 break;
13735 case 10:
13736 num3 = 12;
13737 num2 = 0;
13738 break;
13739 case 11:
13740 case 12:
13741 num3 = 10;
13742 num2 = 1;
13743 break;
13744 }
13745 if (num2 != -1)
13746 {
13747 if (seekHead && num2 == 1)
13748 {
13749 index = -1;
13750 pos = Vector2.Zero;
13751 return false;
13752 }
13753 Vector2 center = Main.npc[i].Center;
13754 int num4 = -1;
13755 float num5 = -1f;
13756 int num6 = -1;
13757 Vector2 center2 = Main.player[Main.myPlayer].Center;
13758 int num7 = (int)Main.npc[i].ai[num2];
13759 int num8 = 0;
13760 while (num7 >= 0 && num7 < 200 && ++num8 < 100 && Main.npc[num7].active)
13761 {
13762 if (!averageDirection && (num6 == -1 || Main.npc[num7].Distance(center2) < num5))
13763 {
13764 num5 = Main.npc[num7].Distance(center2);
13765 num6 = num7;
13766 }
13767 if (Main.npc[num7].type == num3)
13768 {
13769 num4 = num7;
13770 break;
13771 }
13772 num7 = (int)Main.npc[num7].ai[num2];
13773 }
13774 if (num4 >= 0)
13775 {
13776 if (!averageDirection)
13777 {
13778 pos = Main.npc[num6].Center;
13779 index = num6;
13780 }
13781 else
13782 {
13783 center += Main.npc[num4].Center;
13784 pos = center / 2f;
13785 index = num4;
13786 }
13787 return true;
13788 }
13789 pos = Vector2.Zero;
13790 index = -1;
13791 return false;
13792 }
13793 pos = Main.npc[i].Center;
13794 index = i;
13795 return true;
13796 }

References Terraria.Main.myPlayer, Terraria.Main.npc, and Terraria.Main.player.

Referenced by Terraria.GameInput.LockOnHelper.Draw(), and Terraria.Main.DrawInterface_14_EntityHealthBars().

+ Here is the caller graph for this function: