Terraria.Dust.NewDust C# (CSharp) Method

NewDust() public static method

public static NewDust ( Vector2 Position, int Width, int Height, int Type, float SpeedX = 0.0f, float SpeedY = 0.0f, int Alpha, Color newColor = default(Color), float Scale = 1f ) : int
Position Vector2
Width int
Height int
Type int
SpeedX float
SpeedY float
Alpha int
newColor Color
Scale float
return int
        public static int NewDust(Vector2 Position, int Width, int Height, int Type, float SpeedX = 0.0f, float SpeedY = 0.0f, int Alpha = 0, Color newColor = default(Color), float Scale = 1f)
        {
            if (Main.gameMenu)
                return 6000;
            if (Main.rand == null)
                Main.rand = new Random((int)DateTime.Now.Ticks);
            if (Main.gamePaused || WorldGen.gen || Main.netMode == 2)
                return 6000;
            int num1 = (int)(400.0 * (1.0 - (double)Dust.dCount));
            if (!new Rectangle((int)((double)Main.screenPosition.X - (double)num1), (int)((double)Main.screenPosition.Y - (double)num1), Main.screenWidth + num1 * 2, Main.screenHeight + num1 * 2).Intersects(new Rectangle((int)Position.X, (int)Position.Y, 10, 10)))
                return 6000;
            int num2 = 6000;
            for (int index = 0; index < 6000; ++index)
            {
                Dust dust = Main.dust[index];
                if (!dust.active)
                {
                    if ((double)index > (double)Main.numDust * 0.9)
                    {
                        if (Main.rand.Next(4) != 0)
                            return 5999;
                    }
                    else if ((double)index > (double)Main.numDust * 0.8)
                    {
                        if (Main.rand.Next(3) != 0)
                            return 5999;
                    }
                    else if ((double)index > (double)Main.numDust * 0.7)
                    {
                        if (Main.rand.Next(2) == 0)
                            return 5999;
                    }
                    else if ((double)index > (double)Main.numDust * 0.6)
                    {
                        if (Main.rand.Next(4) == 0)
                            return 5999;
                    }
                    else if ((double)index > (double)Main.numDust * 0.5)
                    {
                        if (Main.rand.Next(5) == 0)
                            return 5999;
                    }
                    else
                        Dust.dCount = 0.0f;
                    int num3 = Width;
                    int num4 = Height;
                    if (num3 < 5)
                        num3 = 5;
                    if (num4 < 5)
                        num4 = 5;
                    num2 = index;
                    dust.fadeIn = 0.0f;
                    dust.active = true;
                    dust.type = Type;
                    dust.noGravity = false;
                    dust.color = newColor;
                    dust.alpha = Alpha;
                    dust.position.X = (float)((double)Position.X + (double)Main.rand.Next(num3 - 4) + 4.0);
                    dust.position.Y = (float)((double)Position.Y + (double)Main.rand.Next(num4 - 4) + 4.0);
                    dust.velocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + SpeedX;
                    dust.velocity.Y = (float)Main.rand.Next(-20, 21) * 0.1f + SpeedY;
                    dust.frame.X = 10 * Type;
                    dust.frame.Y = 10 * Main.rand.Next(3);
                    dust.shader = (ArmorShaderData)null;
                    dust.customData = (object)null;
                    int num5 = Type;
                    while (num5 >= 100)
                    {
                        num5 -= 100;
                        dust.frame.X -= 1000;
                        dust.frame.Y += 30;
                    }
                    dust.frame.Width = 8;
                    dust.frame.Height = 8;
                    dust.rotation = 0.0f;
                    dust.scale = (float)(1.0 + (double)Main.rand.Next(-20, 21) * 0.00999999977648258);
                    dust.scale *= Scale;
                    dust.noLight = false;
                    dust.firstFrame = true;
                    if (dust.type == 228 || dust.type == 135 || (dust.type == 6 || dust.type == 242) || (dust.type == 75 || dust.type == 169 || dust.type == 29) || (dust.type >= 59 && dust.type <= 65 || dust.type == 158))
                    {
                        dust.velocity.Y = (float)Main.rand.Next(-10, 6) * 0.1f;
                        dust.velocity.X *= 0.3f;
                        dust.scale *= 0.7f;
                    }
                    if (dust.type == (int)sbyte.MaxValue || dust.type == 187)
                    {
                        dust.velocity *= 0.3f;
                        dust.scale *= 0.7f;
                    }
                    if (dust.type == 33 || dust.type == 52 || (dust.type == 266 || dust.type == 98) || (dust.type == 99 || dust.type == 100 || (dust.type == 101 || dust.type == 102)) || (dust.type == 103 || dust.type == 104 || dust.type == 105))
                    {
                        dust.alpha = 170;
                        dust.velocity *= 0.5f;
                        ++dust.velocity.Y;
                    }
                    if (dust.type == 41)
                        dust.velocity *= 0.0f;
                    if (dust.type == 80)
                        dust.alpha = 50;
                    if (dust.type == 34 || dust.type == 35 || dust.type == 152)
                    {
                        dust.velocity *= 0.1f;
                        dust.velocity.Y = -0.5f;
                        if (dust.type == 34 && !Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y - 8f), 4, 4))
                        {
                            dust.active = false;
                            break;
                        }
                        break;
                    }
                    break;
                }
            }
            return num2;
        }