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

◆ GetAlpha()

Color Terraria.NPC.GetAlpha ( Color newColor)
inline

Definition at line 110646 of file NPC.cs.

110647 {
110648 //IL_0010: Unknown result type (might be due to invalid IL or missing references)
110649 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
110650 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
110651 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
110652 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
110653 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
110654 //IL_0095: Unknown result type (might be due to invalid IL or missing references)
110655 //IL_00bc: Unknown result type (might be due to invalid IL or missing references)
110656 //IL_0137: Unknown result type (might be due to invalid IL or missing references)
110657 //IL_0138: Unknown result type (might be due to invalid IL or missing references)
110658 //IL_0142: Unknown result type (might be due to invalid IL or missing references)
110659 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
110660 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
110661 //IL_01ba: Unknown result type (might be due to invalid IL or missing references)
110662 //IL_01c7: Unknown result type (might be due to invalid IL or missing references)
110663 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
110664 //IL_01d7: Unknown result type (might be due to invalid IL or missing references)
110665 //IL_01ee: Unknown result type (might be due to invalid IL or missing references)
110666 //IL_0218: Unknown result type (might be due to invalid IL or missing references)
110667 //IL_0219: Unknown result type (might be due to invalid IL or missing references)
110668 //IL_0223: Unknown result type (might be due to invalid IL or missing references)
110669 //IL_022e: Unknown result type (might be due to invalid IL or missing references)
110670 //IL_0241: Unknown result type (might be due to invalid IL or missing references)
110671 //IL_0246: Unknown result type (might be due to invalid IL or missing references)
110672 //IL_0250: Unknown result type (might be due to invalid IL or missing references)
110673 //IL_0255: Unknown result type (might be due to invalid IL or missing references)
110674 //IL_0267: Unknown result type (might be due to invalid IL or missing references)
110675 //IL_026f: Unknown result type (might be due to invalid IL or missing references)
110676 //IL_029c: Unknown result type (might be due to invalid IL or missing references)
110677 //IL_029d: Unknown result type (might be due to invalid IL or missing references)
110678 //IL_02a7: Unknown result type (might be due to invalid IL or missing references)
110679 //IL_02ac: Unknown result type (might be due to invalid IL or missing references)
110680 //IL_02ba: Unknown result type (might be due to invalid IL or missing references)
110681 //IL_02c4: Unknown result type (might be due to invalid IL or missing references)
110682 //IL_02c9: Unknown result type (might be due to invalid IL or missing references)
110683 //IL_02cb: Unknown result type (might be due to invalid IL or missing references)
110684 //IL_02da: Unknown result type (might be due to invalid IL or missing references)
110685 //IL_02db: Unknown result type (might be due to invalid IL or missing references)
110686 //IL_02e5: Unknown result type (might be due to invalid IL or missing references)
110687 //IL_02ea: Unknown result type (might be due to invalid IL or missing references)
110688 //IL_02ec: Unknown result type (might be due to invalid IL or missing references)
110689 //IL_02f3: Unknown result type (might be due to invalid IL or missing references)
110690 //IL_0358: Unknown result type (might be due to invalid IL or missing references)
110691 //IL_0359: Unknown result type (might be due to invalid IL or missing references)
110692 //IL_0363: Unknown result type (might be due to invalid IL or missing references)
110693 //IL_0368: Unknown result type (might be due to invalid IL or missing references)
110694 //IL_036a: Unknown result type (might be due to invalid IL or missing references)
110695 //IL_032b: Unknown result type (might be due to invalid IL or missing references)
110696 //IL_0391: Unknown result type (might be due to invalid IL or missing references)
110697 //IL_03d4: Unknown result type (might be due to invalid IL or missing references)
110698 //IL_0417: Unknown result type (might be due to invalid IL or missing references)
110699 //IL_0437: Unknown result type (might be due to invalid IL or missing references)
110700 //IL_0438: Unknown result type (might be due to invalid IL or missing references)
110701 //IL_0442: Unknown result type (might be due to invalid IL or missing references)
110702 //IL_0447: Unknown result type (might be due to invalid IL or missing references)
110703 //IL_0449: Unknown result type (might be due to invalid IL or missing references)
110704 //IL_04ce: Unknown result type (might be due to invalid IL or missing references)
110705 //IL_0521: Unknown result type (might be due to invalid IL or missing references)
110706 //IL_05f8: Unknown result type (might be due to invalid IL or missing references)
110707 //IL_057c: Unknown result type (might be due to invalid IL or missing references)
110708 //IL_0643: Unknown result type (might be due to invalid IL or missing references)
110709 //IL_05d1: Unknown result type (might be due to invalid IL or missing references)
110710 //IL_0667: Unknown result type (might be due to invalid IL or missing references)
110711 //IL_0843: Unknown result type (might be due to invalid IL or missing references)
110712 //IL_0705: Unknown result type (might be due to invalid IL or missing references)
110713 //IL_0706: Unknown result type (might be due to invalid IL or missing references)
110714 //IL_0710: Unknown result type (might be due to invalid IL or missing references)
110715 //IL_0715: Unknown result type (might be due to invalid IL or missing references)
110716 //IL_0717: Unknown result type (might be due to invalid IL or missing references)
110717 //IL_0721: Unknown result type (might be due to invalid IL or missing references)
110718 //IL_0726: Unknown result type (might be due to invalid IL or missing references)
110719 //IL_0728: Unknown result type (might be due to invalid IL or missing references)
110721 {
110722 newColor = Color.White;
110723 }
110724 Color? val = NPCLoader.GetAlpha(this, newColor);
110725 if (val.HasValue)
110726 {
110727 return val.GetValueOrDefault();
110728 }
110729 float num = (float)(255 - alpha) / 255f;
110730 int num2 = (int)((float)(int)((Color)(ref newColor)).R * num);
110731 int num3 = (int)((float)(int)((Color)(ref newColor)).G * num);
110732 int num4 = (int)((float)(int)((Color)(ref newColor)).B * num);
110733 int num5 = ((Color)(ref newColor)).A - alpha;
110734 if (type == 402)
110735 {
110736 return new Color(255, 255, 255, 255);
110737 }
110738 if (type == 484)
110739 {
110740 return new Color(250, 250, 250, 200);
110741 }
110742 if (type >= 542 && type <= 545 && num2 + num3 + num4 > 10 && num2 + num3 + num4 >= 60)
110743 {
110744 num2 *= 2;
110745 num3 *= 2;
110746 num4 *= 2;
110747 if (num2 > 255)
110748 {
110749 num2 = 255;
110750 }
110751 if (num3 > 255)
110752 {
110753 num3 = 255;
110754 }
110755 if (num4 > 255)
110756 {
110757 num4 = 255;
110758 }
110759 }
110760 if (type == 681)
110761 {
110762 return Color.Lerp(newColor, Color.White, 0.4f) * Opacity;
110763 }
110764 if (type == 683 || type == 687)
110765 {
110766 float num6 = Utils.Remap(Utils.WrappedLerp(0.75f, 1f, (float)Main.timeForVisualEffects % 120f / 120f), 0f, 1f, 0.5f, 1f);
110767 Color result = Color.Lerp(newColor, new Color(255, 255, 100), 0.4f * num6) * Opacity;
110768 if (((Color)(ref result)).B < num4)
110769 {
110770 ((Color)(ref result)).B = (byte)num4;
110771 }
110772 return result;
110773 }
110774 if (type == 658 || type == 659 || type == 660)
110775 {
110776 return Color.Lerp(newColor, Color.White, 0.4f) * Opacity;
110777 }
110778 if (type == 662)
110779 {
110780 Color color = Color.Lerp(Color.White, Color.Cyan, 0.5f);
110781 ((Color)(ref color)).A = (byte)(((Color)(ref color)).A / 4);
110782 return color * Opacity;
110783 }
110784 if ((type >= 454 && type <= 459) || type == 521)
110785 {
110786 newColor = Color.Lerp(newColor, Color.White, 0.4f);
110787 ((Color)(ref newColor)).A = 150;
110788 newColor *= (float)num5 / 255f;
110789 return newColor;
110790 }
110791 if (type == 636)
110792 {
110793 newColor = Color.Lerp(newColor, Color.White, 0.25f);
110794 return newColor * Opacity;
110795 }
110796 if (type == 440)
110797 {
110798 byte b = 180;
110799 if (Main.expertMode)
110800 {
110801 b = 210;
110802 }
110803 b = (byte)((float)(int)b * num);
110804 return new Color((int)b, (int)b, (int)b, (int)b);
110805 }
110806 if (type == 583 || type == 584 || type == 585)
110807 {
110808 newColor = Color.Lerp(newColor, Color.White, 0.5f);
110809 return newColor;
110810 }
110811 if (type == 516)
110812 {
110813 return new Color(alpha, alpha, alpha, alpha);
110814 }
110815 if (type == 522)
110816 {
110817 return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
110818 }
110819 if (type == 523)
110820 {
110821 return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
110822 }
110823 if (type == 395 || type == 519)
110824 {
110825 newColor = Color.Lerp(newColor, Color.White, 0.4f);
110826 return newColor;
110827 }
110828 if (type == 370 && ai[0] != -1f && ai[0] < 9f)
110829 {
110830 float num7 = MathHelper.Lerp(num, 1f, 0.25f);
110831 if (num7 > 1f)
110832 {
110833 num7 = 1f;
110834 }
110835 num4 = (int)((float)(int)((Color)(ref newColor)).B * num7);
110836 }
110837 if (type == 30 || type == 665)
110838 {
110839 return new Color(250, 250, 250, 100);
110840 }
110841 if (!IsABestiaryIconDummy && (type == 25 || type == 30 || type == 665 || type == 59 || type == 60))
110842 {
110843 return new Color(200, 200, 200, 0);
110844 }
110845 if (type == 360)
110846 {
110847 num2 = ((Color)(ref newColor)).R;
110848 num3 = ((Color)(ref newColor)).G;
110849 num4 = ((Color)(ref newColor)).B;
110850 if (num2 < 75)
110851 {
110852 num2 = 75;
110853 }
110854 if (num3 < 175)
110855 {
110856 num3 = 175;
110857 }
110858 if (num4 < 255)
110859 {
110860 num4 = 255;
110861 }
110862 return new Color(num2, num3, num4, 255);
110863 }
110864 if (type == 655)
110865 {
110866 num2 = ((Color)(ref newColor)).R;
110867 num3 = ((Color)(ref newColor)).G;
110868 num4 = ((Color)(ref newColor)).B;
110869 if (num2 < 255)
110870 {
110871 num2 = 255;
110872 }
110873 if (num3 < 100)
110874 {
110875 num3 = 100;
110876 }
110877 if (num4 < 50)
110878 {
110879 num4 = 50;
110880 }
110881 return new Color(num2, num3, num4, 255);
110882 }
110883 if (type == 352)
110884 {
110885 return new Color(255, 255, 255, 200);
110886 }
110887 if (type == 72)
110888 {
110889 num2 = ((Color)(ref newColor)).R;
110890 num3 = ((Color)(ref newColor)).G;
110891 num4 = ((Color)(ref newColor)).B;
110892 }
110893 else
110894 {
110895 if (type == 288)
110896 {
110897 return new Color(200, 200, 200, 0);
110898 }
110899 if (type == 289)
110900 {
110901 return new Color(250, 250, 250, 50);
110902 }
110903 if (type >= 254 && type <= 261)
110904 {
110905 num4 = 255;
110906 if (num2 < 100)
110907 {
110908 num2 = 100;
110909 }
110910 if (num3 < 150)
110911 {
110912 num3 = 150;
110913 }
110914 }
110915 else if (type == 374 || type == 634 || type == 635)
110916 {
110917 num4 = 255;
110918 if (num2 < 100)
110919 {
110920 num2 = 100;
110921 }
110922 if (num3 < 150)
110923 {
110924 num3 = 150;
110925 }
110926 }
110927 else
110928 {
110929 if (type == 549)
110930 {
110931 newColor = Color.Lerp(newColor, Color.White, 0.4f);
110932 newColor *= (float)num5 / 255f;
110933 return newColor;
110934 }
110935 if (type == 64 || type == 63 || type == 75 || type == 103 || type == 400)
110936 {
110937 num2 = (int)((double)(int)((Color)(ref newColor)).R * 1.5);
110938 num3 = (int)((double)(int)((Color)(ref newColor)).G * 1.5);
110939 num4 = (int)((double)(int)((Color)(ref newColor)).B * 1.5);
110940 if (num2 > 255)
110941 {
110942 num2 = 255;
110943 }
110944 if (num3 > 255)
110945 {
110946 num3 = 255;
110947 }
110948 if (num4 > 255)
110949 {
110950 num4 = 255;
110951 }
110952 }
110953 }
110954 }
110956 {
110957 num2 = (byte)((float)num2 * (1f - shimmerTransparency));
110958 num3 = (byte)((float)num3 * (1f - shimmerTransparency));
110959 num4 = (byte)((float)num4 * (1f - shimmerTransparency));
110960 num5 = (byte)((float)num5 * (1f - shimmerTransparency));
110961 }
110962 if (num5 < 0)
110963 {
110964 num5 = 0;
110965 }
110966 if (num5 > 255)
110967 {
110968 num5 = 255;
110969 }
110970 return new Color(num2, num3, num4, num5);
110971 }
static ? Color GetAlpha(NPC npc, Color lightColor)
This serves as the central class from which NPC-related functions are carried out....
Definition NPCLoader.cs:26
float Opacity
Definition NPC.cs:1517
bool CanApplyHunterPotionEffects()
Definition NPC.cs:107881
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
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990
int alpha
0 is opaque, and 255 is transparent. Note that this is the opposite of how alpha is typically express...
Definition NPC.cs:1092
Color color
Definition NPC.cs:1085
float shimmerTransparency
Definition NPC.cs:643
bool IsABestiaryIconDummy
Definition NPC.cs:432

References Terraria.Main.expertMode, Terraria.ModLoader.NPCLoader.GetAlpha(), Terraria.Utils.Remap(), Terraria.Main.timeForVisualEffects, and Terraria.Utils.WrappedLerp().

+ Here is the call graph for this function: