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

◆ GetAlpha()

Color Terraria.Dust.GetAlpha ( Color newColor)
inline

Definition at line 2357 of file Dust.cs.

2358 {
2359 float num = (float)(255 - alpha) / 255f;
2360 switch (type)
2361 {
2362 case 323:
2363 return Color.White;
2364 case 308:
2365 case 309:
2366 return new Color(225, 200, 250, 190);
2367 case 299:
2368 case 300:
2369 case 301:
2370 case 305:
2371 {
2372 Color color = default(Color);
2373 return type switch
2374 {
2375 299 => new Color(50, 255, 50, 200),
2376 300 => new Color(50, 200, 255, 255),
2377 301 => new Color(255, 50, 125, 200),
2378 305 => new Color(200, 50, 200, 200),
2379 _ => new Color(255, 150, 150, 200),
2380 };
2381 }
2382 default:
2383 {
2384 if (type == 304)
2385 {
2386 return Color.White * num;
2387 }
2388 if (type == 306)
2389 {
2390 return this.color * num;
2391 }
2392 if (type == 292)
2393 {
2394 return Color.White;
2395 }
2396 if (type == 259)
2397 {
2398 return new Color(230, 230, 230, 230);
2399 }
2400 if (type == 261)
2401 {
2402 return new Color(230, 230, 230, 115);
2403 }
2404 if (type == 254 || type == 255)
2405 {
2406 return new Color(255, 255, 255, 0);
2407 }
2408 if (type == 258)
2409 {
2410 return new Color(150, 50, 50, 0);
2411 }
2412 if (type == 263 || type == 264)
2413 {
2414 return new Color(this.color.R / 2 + 127, this.color.G + 127, this.color.B + 127, this.color.A / 8) * 0.5f;
2415 }
2416 if (type == 235)
2417 {
2418 return new Color(255, 255, 255, 0);
2419 }
2420 if (((type >= 86 && type <= 91) || type == 262 || type == 286) && !noLight)
2421 {
2422 return new Color(255, 255, 255, 0);
2423 }
2424 if (type == 213 || type == 260)
2425 {
2426 int num2 = (int)(scale / 2.5f * 255f);
2427 return new Color(num2, num2, num2, num2);
2428 }
2429 if (type == 64 && alpha == 255 && noLight)
2430 {
2431 return new Color(255, 255, 255, 0);
2432 }
2433 if (type == 197)
2434 {
2435 return new Color(250, 250, 250, 150);
2436 }
2437 if ((type >= 110 && type <= 114) || type == 311 || type == 312 || type == 313)
2438 {
2439 return new Color(200, 200, 200, 0);
2440 }
2441 if (type == 204)
2442 {
2443 return new Color(255, 255, 255, 0);
2444 }
2445 if (type == 181)
2446 {
2447 return new Color(200, 200, 200, 0);
2448 }
2449 if (type == 182 || type == 206)
2450 {
2451 return new Color(255, 255, 255, 0);
2452 }
2453 if (type == 159)
2454 {
2455 return new Color(250, 250, 250, 50);
2456 }
2457 if (type == 163 || type == 205)
2458 {
2459 return new Color(250, 250, 250, 0);
2460 }
2461 if (type == 170)
2462 {
2463 return new Color(200, 200, 200, 100);
2464 }
2465 if (type == 180)
2466 {
2467 return new Color(200, 200, 200, 0);
2468 }
2469 if (type == 175)
2470 {
2471 return new Color(200, 200, 200, 0);
2472 }
2473 if (type == 183)
2474 {
2475 return new Color(50, 0, 0, 0);
2476 }
2477 if (type == 172)
2478 {
2479 return new Color(250, 250, 250, 150);
2480 }
2481 if (type == 160 || type == 162 || type == 164 || type == 173)
2482 {
2483 int num3 = (int)(250f * scale);
2484 return new Color(num3, num3, num3, 0);
2485 }
2486 if (type == 92 || type == 106 || type == 107)
2487 {
2488 return new Color(255, 255, 255, 0);
2489 }
2490 if (type == 185)
2491 {
2492 return new Color(200, 200, 255, 125);
2493 }
2494 if (type == 127 || type == 187)
2495 {
2496 return new Color(newColor.R, newColor.G, newColor.B, 25);
2497 }
2498 if (type == 156 || type == 230 || type == 234)
2499 {
2500 return new Color(255, 255, 255, 0);
2501 }
2502 if (type == 270)
2503 {
2504 return new Color(newColor.R / 2 + 127, newColor.G / 2 + 127, newColor.B / 2 + 127, 25);
2505 }
2506 if (type == 271)
2507 {
2508 return new Color(newColor.R / 2 + 127, newColor.G / 2 + 127, newColor.B / 2 + 127, 127);
2509 }
2510 if (type == 6 || type == 242 || type == 174 || type == 135 || type == 75 || type == 20 || type == 21 || type == 231 || type == 169 || (type >= 130 && type <= 134) || type == 158 || type == 293 || type == 294 || type == 295 || type == 296 || type == 297 || type == 298 || type == 307 || type == 310)
2511 {
2512 return new Color(newColor.R, newColor.G, newColor.B, 25);
2513 }
2514 if (type == 278)
2515 {
2516 Color result = new Color(newColor.ToVector3() * this.color.ToVector3());
2517 result.A = 25;
2518 return result;
2519 }
2520 if (type >= 219 && type <= 223)
2521 {
2522 newColor = Color.Lerp(newColor, Color.White, 0.5f);
2523 return new Color(newColor.R, newColor.G, newColor.B, 25);
2524 }
2525 if (type == 226 || type == 272)
2526 {
2527 newColor = Color.Lerp(newColor, Color.White, 0.8f);
2528 return new Color(newColor.R, newColor.G, newColor.B, 25);
2529 }
2530 if (type == 228)
2531 {
2532 newColor = Color.Lerp(newColor, Color.White, 0.8f);
2533 return new Color(newColor.R, newColor.G, newColor.B, 25);
2534 }
2535 if (type == 279)
2536 {
2537 int a = newColor.A;
2538 newColor = Color.Lerp(newColor, Color.White, 0.8f);
2539 return new Color(newColor.R, newColor.G, newColor.B, a) * MathHelper.Min(scale, 1f);
2540 }
2541 if (type == 229 || type == 269)
2542 {
2543 newColor = Color.Lerp(newColor, Color.White, 0.6f);
2544 return new Color(newColor.R, newColor.G, newColor.B, 25);
2545 }
2546 if ((type == 68 || type == 70) && noGravity)
2547 {
2548 return new Color(255, 255, 255, 0);
2549 }
2550 int num6;
2551 int num5;
2552 int num4;
2553 if (type == 157)
2554 {
2555 num6 = (num5 = (num4 = 255));
2556 float num7 = (float)(int)Main.mouseTextColor / 100f - 1.6f;
2557 num6 = (int)((float)num6 * num7);
2558 num5 = (int)((float)num5 * num7);
2559 num4 = (int)((float)num4 * num7);
2560 int a2 = (int)(100f * num7);
2561 num6 += 50;
2562 if (num6 > 255)
2563 {
2564 num6 = 255;
2565 }
2566 num5 += 50;
2567 if (num5 > 255)
2568 {
2569 num5 = 255;
2570 }
2571 num4 += 50;
2572 if (num4 > 255)
2573 {
2574 num4 = 255;
2575 }
2576 return new Color(num6, num5, num4, a2);
2577 }
2578 if (type == 284)
2579 {
2580 Color result2 = new Color(newColor.ToVector4() * this.color.ToVector4());
2581 result2.A = this.color.A;
2582 return result2;
2583 }
2584 if (type == 15 || type == 274 || type == 20 || type == 21 || type == 29 || type == 35 || type == 41 || type == 44 || type == 27 || type == 45 || type == 55 || type == 56 || type == 57 || type == 58 || type == 73 || type == 74)
2585 {
2586 num = (num + 3f) / 4f;
2587 }
2588 else if (type == 43)
2589 {
2590 num = (num + 9f) / 10f;
2591 }
2592 else
2593 {
2594 if (type >= 244 && type <= 247)
2595 {
2596 return new Color(255, 255, 255, 0);
2597 }
2598 if (type == 66)
2599 {
2600 return new Color(newColor.R, newColor.G, newColor.B, 0);
2601 }
2602 if (type == 267)
2603 {
2604 return new Color(this.color.R, this.color.G, this.color.B, 0);
2605 }
2606 if (type == 71)
2607 {
2608 return new Color(200, 200, 200, 0);
2609 }
2610 if (type == 72)
2611 {
2612 return new Color(200, 200, 200, 200);
2613 }
2614 }
2615 num6 = (int)((float)(int)newColor.R * num);
2616 num5 = (int)((float)(int)newColor.G * num);
2617 num4 = (int)((float)(int)newColor.B * num);
2618 int num8 = newColor.A - alpha;
2619 if (num8 < 0)
2620 {
2621 num8 = 0;
2622 }
2623 if (num8 > 255)
2624 {
2625 num8 = 255;
2626 }
2627 return new Color(num6, num5, num4, num8);
2628 }
2629 }
2630 }
static float Min(float value1, float value2)
Definition MathHelper.cs:36
bool noGravity
Definition Dust.cs:26
int type
Definition Dust.cs:38
int alpha
Definition Dust.cs:42
bool noLight
Definition Dust.cs:32
float scale
Definition Dust.cs:28
Color color
Definition Dust.cs:40
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491

References Microsoft.Xna.Framework.Color.A, Terraria.Dust.alpha, Microsoft.Xna.Framework.Color.B, Terraria.Dust.color, Microsoft.Xna.Framework.Color.G, Microsoft.Xna.Framework.Color.Lerp(), Microsoft.Xna.Framework.MathHelper.Min(), Terraria.Dust.noGravity, Terraria.Dust.noLight, Microsoft.Xna.Framework.Color.R, Terraria.Dust.scale, Microsoft.Xna.Framework.Color.ToVector3(), Microsoft.Xna.Framework.Color.ToVector4(), Terraria.Dust.type, and Microsoft.Xna.Framework.Color.White.