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

◆ GetAlpha()

Color Terraria.NPC.GetAlpha ( Color newColor)
inline

Definition at line 90103 of file NPC.cs.

90104 {
90106 {
90108 }
90109 float num = (float)(255 - alpha) / 255f;
90110 int num2 = (int)((float)(int)newColor.R * num);
90111 int num3 = (int)((float)(int)newColor.G * num);
90112 int num4 = (int)((float)(int)newColor.B * num);
90113 int num5 = newColor.A - alpha;
90114 if (type == 402)
90115 {
90116 return new Color(255, 255, 255, 255);
90117 }
90118 if (type == 484)
90119 {
90120 return new Color(250, 250, 250, 200);
90121 }
90122 if (type >= 542 && type <= 545 && num2 + num3 + num4 > 10 && num2 + num3 + num4 >= 60)
90123 {
90124 num2 *= 2;
90125 num3 *= 2;
90126 num4 *= 2;
90127 if (num2 > 255)
90128 {
90129 num2 = 255;
90130 }
90131 if (num3 > 255)
90132 {
90133 num3 = 255;
90134 }
90135 if (num4 > 255)
90136 {
90137 num4 = 255;
90138 }
90139 }
90140 if (type == 681)
90141 {
90142 return Color.Lerp(newColor, Color.White, 0.4f) * Opacity;
90143 }
90144 if (type == 683 || type == 687)
90145 {
90146 float num6 = Utils.Remap(Utils.WrappedLerp(0.75f, 1f, (float)Main.timeForVisualEffects % 120f / 120f), 0f, 1f, 0.5f, 1f);
90147 Color result = Color.Lerp(newColor, new Color(255, 255, 100), 0.4f * num6) * Opacity;
90148 if (result.B < num4)
90149 {
90150 result.B = (byte)num4;
90151 }
90152 return result;
90153 }
90154 if (type == 658 || type == 659 || type == 660)
90155 {
90156 return Color.Lerp(newColor, Color.White, 0.4f) * Opacity;
90157 }
90158 if (type == 662)
90159 {
90161 color.A /= 4;
90162 return color * Opacity;
90163 }
90164 if ((type >= 454 && type <= 459) || type == 521)
90165 {
90167 newColor.A = 150;
90168 newColor *= (float)num5 / 255f;
90169 return newColor;
90170 }
90171 if (type == 636)
90172 {
90174 return newColor * Opacity;
90175 }
90176 if (type == 440)
90177 {
90178 byte b = 180;
90179 if (Main.expertMode)
90180 {
90181 b = 210;
90182 }
90183 b = (byte)((float)(int)b * num);
90184 return new Color(b, b, b, b);
90185 }
90186 if (type == 583 || type == 584 || type == 585)
90187 {
90189 return newColor;
90190 }
90191 if (type == 516)
90192 {
90193 return new Color(alpha, alpha, alpha, alpha);
90194 }
90195 if (type == 522)
90196 {
90197 return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
90198 }
90199 if (type == 523)
90200 {
90201 return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
90202 }
90203 if (type == 395 || type == 519)
90204 {
90206 return newColor;
90207 }
90208 if (type == 370 && ai[0] != -1f && ai[0] < 9f)
90209 {
90210 float num7 = MathHelper.Lerp(num, 1f, 0.25f);
90211 if (num7 > 1f)
90212 {
90213 num7 = 1f;
90214 }
90215 num4 = (int)((float)(int)newColor.B * num7);
90216 }
90217 if (type == 30 || type == 665)
90218 {
90219 return new Color(250, 250, 250, 100);
90220 }
90221 if (!IsABestiaryIconDummy && (type == 25 || type == 30 || type == 665 || type == 59 || type == 60))
90222 {
90223 return new Color(200, 200, 200, 0);
90224 }
90225 if (type == 360)
90226 {
90227 num2 = newColor.R;
90228 num3 = newColor.G;
90229 num4 = newColor.B;
90230 if (num2 < 75)
90231 {
90232 num2 = 75;
90233 }
90234 if (num3 < 175)
90235 {
90236 num3 = 175;
90237 }
90238 if (num4 < 255)
90239 {
90240 num4 = 255;
90241 }
90242 return new Color(num2, num3, num4, 255);
90243 }
90244 if (type == 655)
90245 {
90246 num2 = newColor.R;
90247 num3 = newColor.G;
90248 num4 = newColor.B;
90249 if (num2 < 255)
90250 {
90251 num2 = 255;
90252 }
90253 if (num3 < 100)
90254 {
90255 num3 = 100;
90256 }
90257 if (num4 < 50)
90258 {
90259 num4 = 50;
90260 }
90261 return new Color(num2, num3, num4, 255);
90262 }
90263 if (type == 352)
90264 {
90265 return new Color(255, 255, 255, 200);
90266 }
90267 if (type == 72)
90268 {
90269 num2 = newColor.R;
90270 num3 = newColor.G;
90271 num4 = newColor.B;
90272 }
90273 else
90274 {
90275 if (type == 288)
90276 {
90277 return new Color(200, 200, 200, 0);
90278 }
90279 if (type == 289)
90280 {
90281 return new Color(250, 250, 250, 50);
90282 }
90283 if (type >= 254 && type <= 261)
90284 {
90285 num4 = 255;
90286 if (num2 < 100)
90287 {
90288 num2 = 100;
90289 }
90290 if (num3 < 150)
90291 {
90292 num3 = 150;
90293 }
90294 }
90295 else if (type == 374 || type == 634 || type == 635)
90296 {
90297 num4 = 255;
90298 if (num2 < 100)
90299 {
90300 num2 = 100;
90301 }
90302 if (num3 < 150)
90303 {
90304 num3 = 150;
90305 }
90306 }
90307 else
90308 {
90309 if (type == 549)
90310 {
90312 newColor *= (float)num5 / 255f;
90313 return newColor;
90314 }
90315 if (type == 64 || type == 63 || type == 75 || type == 103 || type == 400)
90316 {
90317 num2 = (int)((double)(int)newColor.R * 1.5);
90318 num3 = (int)((double)(int)newColor.G * 1.5);
90319 num4 = (int)((double)(int)newColor.B * 1.5);
90320 if (num2 > 255)
90321 {
90322 num2 = 255;
90323 }
90324 if (num3 > 255)
90325 {
90326 num3 = 255;
90327 }
90328 if (num4 > 255)
90329 {
90330 num4 = 255;
90331 }
90332 }
90333 }
90334 }
90336 {
90337 num2 = (byte)((float)num2 * (1f - shimmerTransparency));
90338 num3 = (byte)((float)num3 * (1f - shimmerTransparency));
90339 num4 = (byte)((float)num4 * (1f - shimmerTransparency));
90340 num5 = (byte)((float)num5 * (1f - shimmerTransparency));
90341 }
90342 if (num5 < 0)
90343 {
90344 num5 = 0;
90345 }
90346 if (num5 > 255)
90347 {
90348 num5 = 255;
90349 }
90350 return new Color(num2, num3, num4, num5);
90351 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
float Opacity
Definition NPC.cs:810
bool CanApplyHunterPotionEffects()
Definition NPC.cs:87774
float[] ai
Definition NPC.cs:447
int type
Definition NPC.cs:445
int alpha
Definition NPC.cs:489
Color color
Definition NPC.cs:487
float shimmerTransparency
Definition NPC.cs:207
bool IsABestiaryIconDummy
Definition NPC.cs:33
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491

References Microsoft.Xna.Framework.Color.B, Microsoft.Xna.Framework.Graphics.Color, Microsoft.Xna.Framework.Color.Cyan, Terraria.Main.expertMode, Microsoft.Xna.Framework.Color.Lerp(), Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Utils.Remap(), Terraria.Main.timeForVisualEffects, System.type, Microsoft.Xna.Framework.Color.White, and Terraria.Utils.WrappedLerp().