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

◆ DrawNPCs()

void Terraria.Main.DrawNPCs ( bool behindTiles = false)
inlineprotected

Definition at line 21897 of file Main.cs.

21898 {
21899 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
21900 //IL_0095: Unknown result type (might be due to invalid IL or missing references)
21901 //IL_009a: Unknown result type (might be due to invalid IL or missing references)
21902 //IL_009f: Unknown result type (might be due to invalid IL or missing references)
21903 //IL_08a3: Unknown result type (might be due to invalid IL or missing references)
21904 //IL_08af: Unknown result type (might be due to invalid IL or missing references)
21905 //IL_08b4: Unknown result type (might be due to invalid IL or missing references)
21906 //IL_08b9: Unknown result type (might be due to invalid IL or missing references)
21907 //IL_087a: Unknown result type (might be due to invalid IL or missing references)
21908 //IL_03e6: Unknown result type (might be due to invalid IL or missing references)
21909 //IL_03f0: Unknown result type (might be due to invalid IL or missing references)
21910 //IL_0405: Unknown result type (might be due to invalid IL or missing references)
21911 //IL_040f: Unknown result type (might be due to invalid IL or missing references)
21912 //IL_066b: Unknown result type (might be due to invalid IL or missing references)
21913 //IL_0675: Unknown result type (might be due to invalid IL or missing references)
21914 //IL_0687: Unknown result type (might be due to invalid IL or missing references)
21915 //IL_0691: Unknown result type (might be due to invalid IL or missing references)
21916 //IL_0142: Unknown result type (might be due to invalid IL or missing references)
21917 //IL_0155: Unknown result type (might be due to invalid IL or missing references)
21918 //IL_017f: Unknown result type (might be due to invalid IL or missing references)
21919 //IL_0192: Unknown result type (might be due to invalid IL or missing references)
21920 //IL_01c2: Unknown result type (might be due to invalid IL or missing references)
21921 //IL_01ce: Unknown result type (might be due to invalid IL or missing references)
21922 //IL_04a1: Unknown result type (might be due to invalid IL or missing references)
21923 //IL_04ab: Unknown result type (might be due to invalid IL or missing references)
21924 //IL_04d6: Unknown result type (might be due to invalid IL or missing references)
21925 //IL_04e0: Unknown result type (might be due to invalid IL or missing references)
21926 //IL_0500: Unknown result type (might be due to invalid IL or missing references)
21927 //IL_050b: Unknown result type (might be due to invalid IL or missing references)
21928 //IL_0519: Unknown result type (might be due to invalid IL or missing references)
21929 //IL_051e: Unknown result type (might be due to invalid IL or missing references)
21930 //IL_052f: Unknown result type (might be due to invalid IL or missing references)
21931 //IL_0541: Unknown result type (might be due to invalid IL or missing references)
21932 //IL_0553: Unknown result type (might be due to invalid IL or missing references)
21933 //IL_0566: Unknown result type (might be due to invalid IL or missing references)
21934 //IL_0570: Unknown result type (might be due to invalid IL or missing references)
21935 //IL_0596: Unknown result type (might be due to invalid IL or missing references)
21936 //IL_0720: Unknown result type (might be due to invalid IL or missing references)
21937 //IL_072a: Unknown result type (might be due to invalid IL or missing references)
21938 //IL_074f: Unknown result type (might be due to invalid IL or missing references)
21939 //IL_0759: Unknown result type (might be due to invalid IL or missing references)
21940 //IL_0776: Unknown result type (might be due to invalid IL or missing references)
21941 //IL_0781: Unknown result type (might be due to invalid IL or missing references)
21942 //IL_078f: Unknown result type (might be due to invalid IL or missing references)
21943 //IL_0794: Unknown result type (might be due to invalid IL or missing references)
21944 //IL_07a5: Unknown result type (might be due to invalid IL or missing references)
21945 //IL_07b7: Unknown result type (might be due to invalid IL or missing references)
21946 //IL_07c9: Unknown result type (might be due to invalid IL or missing references)
21947 //IL_07dc: Unknown result type (might be due to invalid IL or missing references)
21948 //IL_07e6: Unknown result type (might be due to invalid IL or missing references)
21949 //IL_080c: Unknown result type (might be due to invalid IL or missing references)
21950 //IL_027d: Unknown result type (might be due to invalid IL or missing references)
21951 //IL_0289: Unknown result type (might be due to invalid IL or missing references)
21952 //IL_0293: Unknown result type (might be due to invalid IL or missing references)
21953 //IL_029e: Unknown result type (might be due to invalid IL or missing references)
21954 //IL_02ac: Unknown result type (might be due to invalid IL or missing references)
21955 //IL_02b1: Unknown result type (might be due to invalid IL or missing references)
21956 //IL_02c2: Unknown result type (might be due to invalid IL or missing references)
21957 //IL_02d4: Unknown result type (might be due to invalid IL or missing references)
21958 //IL_02e6: Unknown result type (might be due to invalid IL or missing references)
21959 //IL_0301: Unknown result type (might be due to invalid IL or missing references)
21960 //IL_030b: Unknown result type (might be due to invalid IL or missing references)
21961 //IL_0331: Unknown result type (might be due to invalid IL or missing references)
21962 bool flag = false;
21963 Rectangle rectangle = default(Rectangle);
21964 ((Rectangle)(ref rectangle))._002Ector((int)screenPosition.X - 800, (int)screenPosition.Y - 800, screenWidth + 1600, screenHeight + 1600);
21965 Vector2 vector = default(Vector2);
21966 Vector2 vector2 = default(Vector2);
21967 Vector2 vector3 = default(Vector2);
21968 for (int num = 199; num >= 0; num--)
21969 {
21970 try
21971 {
21972 if (npc[num].active && npc[num].type > 0 && !npc[num].hide)
21973 {
21974 NPC obj = npc[num];
21975 obj.position += npc[num].netOffset;
21976 if (npc[num].behindTiles == behindTiles)
21977 {
21978 if (npc[num].type == 125 || npc[num].type == 126)
21979 {
21980 if (!NPC.IsMechQueenUp && !flag)
21981 {
21982 flag = true;
21983 for (int i = 0; i < 200; i++)
21984 {
21985 if (!npc[i].active || num == i || (npc[i].type != 125 && npc[i].type != 126))
21986 {
21987 continue;
21988 }
21989 float scale = npc[i].scale;
21990 float x = npc[i].Center.X;
21991 float num10 = npc[i].Bottom.Y - (float)npc[i].height * 0.5f * scale;
21992 float x2 = npc[num].Center.X;
21993 float y = npc[num].Bottom.Y - (float)npc[num].height * 0.5f * scale;
21994 ((Vector2)(ref vector))._002Ector(x2, y);
21995 float num11 = x - vector.X;
21996 float num12 = num10 - vector.Y;
21997 float rotation = (float)Math.Atan2(num12, num11) - 1.57f;
21998 bool flag2 = true;
21999 float num13 = (float)Math.Sqrt(num11 * num11 + num12 * num12);
22000 if (num13 > 2000f)
22001 {
22002 flag2 = false;
22003 }
22004 float num14 = 40f * scale;
22005 while (flag2)
22006 {
22007 num13 = (float)Math.Sqrt(num11 * num11 + num12 * num12);
22008 if (num13 < num14)
22009 {
22010 flag2 = false;
22011 continue;
22012 }
22013 num13 = (float)TextureAssets.Chain12.Height() * scale / num13;
22014 num11 *= num13;
22015 num12 *= num13;
22016 vector.X += num11;
22017 vector.Y += num12;
22018 num11 = x - vector.X;
22019 num12 = num10 - vector.Y;
22020 Color color = Lighting.GetColor((int)vector.X / 16, (int)(vector.Y / 16f));
22021 spriteBatch.Draw(TextureAssets.Chain12.Value, new Vector2(vector.X - screenPosition.X, vector.Y - screenPosition.Y), (Rectangle?)new Rectangle(0, 0, TextureAssets.Chain12.Width(), TextureAssets.Chain12.Height()), color, rotation, new Vector2((float)TextureAssets.Chain12.Width() * 0.5f, (float)TextureAssets.Chain12.Height() * 0.5f), scale, (SpriteEffects)0, 0f);
22022 }
22023 }
22024 }
22025 }
22026 else if (npc[num].type == 263 && npc[num].aiStyle == 52 && NPC.plantBoss >= 0)
22027 {
22028 ((Vector2)(ref vector2))._002Ector(npc[num].position.X + (float)(npc[num].width / 2), npc[num].position.Y + (float)(npc[num].height / 2));
22029 float num15 = npc[NPC.plantBoss].Center.X - vector2.X;
22030 float num16 = npc[NPC.plantBoss].Center.Y - vector2.Y;
22031 float rotation2 = (float)Math.Atan2(num16, num15) - 1.57f;
22032 bool flag3 = true;
22033 while (flag3)
22034 {
22035 int num17 = 16;
22036 int num2 = 32;
22037 float num3 = (float)Math.Sqrt(num15 * num15 + num16 * num16);
22038 if (num3 < (float)num2)
22039 {
22040 num17 = (int)num3 - num2 + num17;
22041 flag3 = false;
22042 }
22043 num3 = (float)num17 / num3;
22044 num15 *= num3;
22045 num16 *= num3;
22046 vector2.X += num15;
22047 vector2.Y += num16;
22048 num15 = npc[NPC.plantBoss].Center.X - vector2.X + npc[NPC.plantBoss].netOffset.X;
22049 num16 = npc[NPC.plantBoss].Center.Y - vector2.Y + npc[NPC.plantBoss].netOffset.Y;
22050 Color color2 = Lighting.GetColor((int)vector2.X / 16, (int)(vector2.Y / 16f));
22051 spriteBatch.Draw(TextureAssets.Chain26.Value, new Vector2(vector2.X - screenPosition.X, vector2.Y - screenPosition.Y), (Rectangle?)new Rectangle(0, 0, TextureAssets.Chain26.Width(), num17), color2, rotation2, new Vector2((float)TextureAssets.Chain26.Width() * 0.5f, (float)TextureAssets.Chain26.Height() * 0.5f), 1f, (SpriteEffects)0, 0f);
22052 }
22053 }
22054 else if (npc[num].type == 264 && npc[num].aiStyle == 53 && NPC.plantBoss >= 0)
22055 {
22056 int num4 = NPC.plantBoss;
22057 if (npc[num].ai[3] > 0f)
22058 {
22059 num4 = (int)npc[num].ai[3] - 1;
22060 }
22061 ((Vector2)(ref vector3))._002Ector(npc[num].position.X + (float)(npc[num].width / 2), npc[num].position.Y + (float)(npc[num].height / 2));
22062 float num5 = npc[num4].Center.X - vector3.X;
22063 float num6 = npc[num4].Center.Y - vector3.Y;
22064 float rotation3 = (float)Math.Atan2(num6, num5) - 1.57f;
22065 bool flag4 = true;
22066 while (flag4)
22067 {
22068 int num7 = 16;
22069 int num8 = 32;
22070 float num9 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
22071 if (num9 < (float)num8)
22072 {
22073 num7 = (int)num9 - num8 + num7;
22074 flag4 = false;
22075 }
22076 num9 = (float)num7 / num9;
22077 num5 *= num9;
22078 num6 *= num9;
22079 vector3.X += num5;
22080 vector3.Y += num6;
22081 num5 = npc[num4].Center.X - vector3.X + npc[num4].netOffset.X;
22082 num6 = npc[num4].Center.Y - vector3.Y + npc[num4].netOffset.Y;
22083 Color color3 = Lighting.GetColor((int)vector3.X / 16, (int)(vector3.Y / 16f));
22084 spriteBatch.Draw(TextureAssets.Chain27.Value, new Vector2(vector3.X - screenPosition.X, vector3.Y - screenPosition.Y), (Rectangle?)new Rectangle(0, 0, TextureAssets.Chain27.Width(), num7), color3, rotation3, new Vector2((float)TextureAssets.Chain27.Width() * 0.5f, (float)TextureAssets.Chain27.Height() * 0.5f), 1f, (SpriteEffects)0, 0f);
22085 }
22086 }
22087 if (NPCID.Sets.MustAlwaysDraw[npc[num].type] || ((Rectangle)(ref rectangle)).Intersects(new Rectangle((int)npc[num].position.X, (int)npc[num].position.Y, npc[num].width, npc[num].height)))
22088 {
22090 DrawNPC(num, behindTiles);
22091 }
22092 }
22093 NPC obj2 = npc[num];
22094 obj2.position -= npc[num].netOffset;
22095 }
22096 }
22097 catch
22098 {
22099 npc[num].active = false;
22100 }
22101 }
22102 }
static Asset< Texture2D > Chain27
static Asset< Texture2D > Chain12
static Asset< Texture2D > Chain26
static bool[] MustAlwaysDraw
If true for a given NPC type (F:Terraria.NPC.type), then that NPC will always draw,...
Definition NPCID.cs:590
void DrawNPC(int iNPCIndex, bool behindTiles)
Definition Main.cs:22112
static SpriteBatch spriteBatch
Definition Main.cs:1043
static int screenHeight
Definition Main.cs:1870
static Vector2 screenPosition
The position of the top left corner of the screen in world coordinates. Modify in M:Terraria....
Definition Main.cs:1864
void DrawNPCCheckAlt(NPC n)
Definition Main.cs:22104
static NPC[] npc
Definition Main.cs:1830
static int screenWidth
Definition Main.cs:1868

References Terraria.GameContent.TextureAssets.Chain12, Terraria.GameContent.TextureAssets.Chain26, Terraria.GameContent.TextureAssets.Chain27, Terraria.Main.DrawNPC(), Terraria.Main.DrawNPCCheckAlt(), Terraria.Lighting.GetColor(), Terraria.NPC.IsMechQueenUp, Terraria.ID.NPCID.Sets.MustAlwaysDraw, Terraria.Main.npc, Terraria.NPC.plantBoss, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, and Terraria.Main.spriteBatch.

Referenced by Terraria.Main.DoDraw_DrawNPCsBehindTiles(), Terraria.Main.DoDraw_DrawNPCsOverTiles(), and Terraria.Main.DrawCapture().

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