AddLight() 공개 정적인 메소드

public static AddLight ( Vector2 position, Vector3 rgb ) : void
position Vector2
rgb Vector3
리턴 void
예제 #1
0
        public void Update()
        {
            if (Main.netMode == 2 || !this.active)
            {
                return;
            }
            bool flag = this.type >= 1024 && this.type <= 1026;

            if (this.type >= 276 && this.type <= 282)
            {
                this.velocity.X *= 0.98f;
                this.velocity.Y *= 0.98f;
                if ((double)this.velocity.Y < (double)this.scale)
                {
                    this.velocity.Y += 0.05f;
                }
                if ((double)this.velocity.Y > 0.1)
                {
                    this.rotation = (double)this.velocity.X <= 0.0 ? this.rotation - 0.01f : this.rotation + 0.01f;
                }
            }
            if (this.type >= 570 && this.type <= 572)
            {
                this.scale = this.scale - 1f / 1000f;
                if ((double)this.scale <= 0.01)
                {
                    this.scale    = 0.01f;
                    Gore.goreTime = 0;
                }
                this.sticky   = false;
                this.rotation = this.velocity.X * 0.1f;
            }
            else if (this.type >= 706 && this.type <= 717 || this.type == 943)
            {
                this.alpha = (double)this.position.Y >= Main.worldSurface * 16.0 + 8.0 ? 100 : 0;
                int num1 = 4;
                this.frameCounter = (byte)((uint)this.frameCounter + 1U);
                if ((int)this.frame <= 4)
                {
                    int x = (int)((double)this.position.X / 16.0);
                    int y = (int)((double)this.position.Y / 16.0) - 1;
                    if (WorldGen.InWorld(x, y, 0) && !Main.tile[x, y].active())
                    {
                        this.active = false;
                    }
                    if ((int)this.frame == 0)
                    {
                        num1 = 24 + Main.rand.Next(256);
                    }
                    if ((int)this.frame == 1)
                    {
                        num1 = 24 + Main.rand.Next(256);
                    }
                    if ((int)this.frame == 2)
                    {
                        num1 = 24 + Main.rand.Next(256);
                    }
                    if ((int)this.frame == 3)
                    {
                        num1 = 24 + Main.rand.Next(96);
                    }
                    if ((int)this.frame == 5)
                    {
                        num1 = 16 + Main.rand.Next(64);
                    }
                    if (this.type == 716)
                    {
                        num1 *= 2;
                    }
                    if (this.type == 717)
                    {
                        num1 *= 4;
                    }
                    if (this.type == 943 && (int)this.frame < 6)
                    {
                        num1 = 4;
                    }
                    if ((int)this.frameCounter >= num1)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                        if ((int)this.frame == 5)
                        {
                            int index = Gore.NewGore(this.position, this.velocity, this.type, 1f);
                            Main.gore[index].frame     = (byte)9;
                            Main.gore[index].velocity *= 0.0f;
                        }
                        if (this.type == 943 && (int)this.frame > 4)
                        {
                            if (Main.rand.Next(2) == 0)
                            {
                                Gore gore = Main.gore[Gore.NewGore(this.position, this.velocity, this.type, this.scale)];
                                int  num2 = 0;
                                gore.frameCounter = (byte)num2;
                                int num3 = 7;
                                gore.frame = (byte)num3;
                                Vector2 vector2 = Vector2.UnitY * 1f;
                                gore.velocity = vector2;
                            }
                            if (Main.rand.Next(2) == 0)
                            {
                                Gore gore = Main.gore[Gore.NewGore(this.position, this.velocity, this.type, this.scale)];
                                int  num2 = 0;
                                gore.frameCounter = (byte)num2;
                                int num3 = 7;
                                gore.frame = (byte)num3;
                                Vector2 vector2 = Vector2.UnitY * 2f;
                                gore.velocity = vector2;
                            }
                        }
                    }
                }
                else if ((int)this.frame <= 6)
                {
                    int num2 = 8;
                    if (this.type == 716)
                    {
                        num2 *= 2;
                    }
                    if (this.type == 717)
                    {
                        num2 *= 3;
                    }
                    if ((int)this.frameCounter >= num2)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                        if ((int)this.frame == 7)
                        {
                            this.active = false;
                        }
                    }
                }
                else if ((int)this.frame <= 9)
                {
                    int num2 = 6;
                    if (this.type == 716)
                    {
                        num2             = (int)((double)num2 * 1.5);
                        this.velocity.Y += 0.175f;
                    }
                    else if (this.type == 717)
                    {
                        num2            *= 2;
                        this.velocity.Y += 0.15f;
                    }
                    else if (this.type == 943)
                    {
                        num2             = (int)((double)num2 * 1.5);
                        this.velocity.Y += 0.2f;
                    }
                    else
                    {
                        this.velocity.Y += 0.2f;
                    }
                    if ((double)this.velocity.Y < 0.5)
                    {
                        this.velocity.Y = 0.5f;
                    }
                    if ((double)this.velocity.Y > 12.0)
                    {
                        this.velocity.Y = 12f;
                    }
                    if ((int)this.frameCounter >= num2)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                    }
                    if ((int)this.frame > 9)
                    {
                        this.frame = (byte)7;
                    }
                }
                else
                {
                    if (this.type == 716)
                    {
                        num1 *= 2;
                    }
                    else if (this.type == 717)
                    {
                        num1 *= 6;
                    }
                    this.velocity.Y += 0.1f;
                    if ((int)this.frameCounter >= num1)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                    }
                    this.velocity = this.velocity * 0.0f;
                    if ((int)this.frame > 14)
                    {
                        this.active = false;
                    }
                }
            }
            else if (this.type == 11 || this.type == 12 || (this.type == 13 || this.type == 61) || (this.type == 62 || this.type == 63 || (this.type == 99 || this.type == 220)) || (this.type == 221 || this.type == 222 || this.type >= 375 && this.type <= 377 || (this.type >= 435 && this.type <= 437 || this.type >= 861 && this.type <= 862)))
            {
                this.velocity.Y *= 0.98f;
                this.velocity.X *= 0.98f;
                this.scale       = this.scale - 0.007f;
                if ((double)this.scale < 0.1)
                {
                    this.scale = 0.1f;
                    this.alpha = (int)byte.MaxValue;
                }
            }
            else if (this.type == 16 || this.type == 17)
            {
                this.velocity.Y *= 0.98f;
                this.velocity.X *= 0.98f;
                this.scale       = this.scale - 0.01f;
                if ((double)this.scale < 0.1)
                {
                    this.scale = 0.1f;
                    this.alpha = (int)byte.MaxValue;
                }
            }
            else if (this.type == 331)
            {
                this.alpha       = this.alpha + 5;
                this.velocity.Y *= 0.95f;
                this.velocity.X *= 0.95f;
                this.rotation    = this.velocity.X * 0.1f;
            }
            else if (GoreID.Sets.SpecialAI[this.type] == 3)
            {
                byte num1 = (byte)((uint)this.frameCounter + 1U);
                this.frameCounter = num1;
                if ((int)num1 >= 8 && (double)this.velocity.Y > 0.200000002980232)
                {
                    this.frameCounter = (byte)0;
                    int  num2 = (int)this.frame / 4;
                    byte num3 = (byte)((uint)this.frame + 1U);
                    this.frame = num3;
                    if ((int)num3 >= 4 + num2 * 4)
                    {
                        this.frame = (byte)(num2 * 4);
                    }
                }
            }
            else if (GoreID.Sets.SpecialAI[this.type] != 1 && GoreID.Sets.SpecialAI[this.type] != 2)
            {
                if (this.type >= 907 && this.type <= 909)
                {
                    this.rotation    = 0.0f;
                    this.velocity.X *= 0.98f;
                    if ((double)this.velocity.Y > 0.0 && (double)this.velocity.Y < 1.0 / 1000.0)
                    {
                        this.velocity.Y = (float)((double)Main.rand.NextFloat() * -3.0 - 0.5);
                    }
                    if ((double)this.velocity.Y > -1.0)
                    {
                        this.velocity.Y -= 0.1f;
                    }
                    if ((double)this.scale < 1.0)
                    {
                        this.scale = this.scale + 0.1f;
                    }
                    byte num1 = (byte)((uint)this.frameCounter + 1U);
                    this.frameCounter = num1;
                    if ((int)num1 >= 8)
                    {
                        this.frameCounter = (byte)0;
                        byte num2 = (byte)((uint)this.frame + 1U);
                        this.frame = num2;
                        if ((int)num2 >= 3)
                        {
                            this.frame = (byte)0;
                        }
                    }
                }
                else if (this.type < 411 || this.type > 430)
                {
                    this.velocity.Y += 0.2f;
                }
            }
            this.rotation = this.rotation + this.velocity.X * 0.1f;
            if (this.type >= 580 && this.type <= 582)
            {
                this.rotation    = 0.0f;
                this.velocity.X *= 0.95f;
            }
            if (GoreID.Sets.SpecialAI[this.type] == 2)
            {
                if (this.timeLeft < 60)
                {
                    this.alpha = this.alpha + Main.rand.Next(1, 7);
                }
                else if (this.alpha > 100)
                {
                    this.alpha = this.alpha - Main.rand.Next(1, 4);
                }
                if (this.alpha < 0)
                {
                    this.alpha = 0;
                }
                if (this.alpha > (int)byte.MaxValue)
                {
                    this.timeLeft = 0;
                }
                this.velocity.X = (float)(((double)this.velocity.X * 50.0 + (double)Main.windSpeed * 2.0 + (double)Main.rand.Next(-10, 11) * 0.100000001490116) / 51.0);
                float num1 = 0.0f;
                if ((double)this.velocity.X < 0.0)
                {
                    num1 = this.velocity.X * 0.2f;
                }
                this.velocity.Y = (float)(((double)this.velocity.Y * 50.0 - 0.349999994039536 + (double)num1 + (double)Main.rand.Next(-10, 11) * 0.200000002980232) / 51.0);
                this.rotation   = this.velocity.X * 0.6f;
                float num2 = -1f;
                if (Main.goreLoaded[this.type])
                {
                    Rectangle rectangle1 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale));
                    for (int index = 0; index < (int)byte.MaxValue; ++index)
                    {
                        if (Main.player[index].active && !Main.player[index].dead)
                        {
                            Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X, (int)Main.player[index].position.Y, Main.player[index].width, Main.player[index].height);
                            if (rectangle1.Intersects(rectangle2))
                            {
                                this.timeLeft = 0;
                                num2          = Main.player[index].velocity.Length();
                                break;
                            }
                        }
                    }
                }
                if (this.timeLeft > 0)
                {
                    if (Main.rand.Next(2) == 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    if (Main.rand.Next(50) == 0)
                    {
                        this.timeLeft = this.timeLeft - 5;
                    }
                    if (Main.rand.Next(100) == 0)
                    {
                        this.timeLeft = this.timeLeft - 10;
                    }
                }
                else
                {
                    this.alpha = (int)byte.MaxValue;
                    if (Main.goreLoaded[this.type] && (double)num2 != -1.0)
                    {
                        float num3 = (float)((double)Main.goreTexture[this.type].Width * (double)this.scale * 0.800000011920929);
                        float x    = this.position.X;
                        float y    = this.position.Y;
                        float num4 = (float)Main.goreTexture[this.type].Width * this.scale;
                        float num5 = (float)Main.goreTexture[this.type].Height * this.scale;
                        int   Type = 31;
                        for (int index1 = 0; (double)index1 < (double)num3; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(x, y), (int)num4, (int)num5, Type, 0.0f, 0.0f, 0, new Color(), 1f);
                            Main.dust[index2].velocity *= (float)((1.0 + (double)num2) / 3.0);
                            Main.dust[index2].noGravity = true;
                            Main.dust[index2].alpha     = 100;
                            Main.dust[index2].scale     = this.scale;
                        }
                    }
                }
            }
            if (this.type >= 411 && this.type <= 430)
            {
                this.alpha      = 50;
                this.velocity.X = (float)(((double)this.velocity.X * 50.0 + (double)Main.windSpeed * 2.0 + (double)Main.rand.Next(-10, 11) * 0.100000001490116) / 51.0);
                this.velocity.Y = (float)(((double)this.velocity.Y * 50.0 - 0.25 + (double)Main.rand.Next(-10, 11) * 0.200000002980232) / 51.0);
                this.rotation   = this.velocity.X * 0.3f;
                if (Main.goreLoaded[this.type])
                {
                    Rectangle rectangle1 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale));
                    for (int index = 0; index < (int)byte.MaxValue; ++index)
                    {
                        if (Main.player[index].active && !Main.player[index].dead)
                        {
                            Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X, (int)Main.player[index].position.Y, Main.player[index].width, Main.player[index].height);
                            if (rectangle1.Intersects(rectangle2))
                            {
                                this.timeLeft = 0;
                            }
                        }
                    }
                    if (Collision.SolidCollision(this.position, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale)))
                    {
                        this.timeLeft = 0;
                    }
                }
                if (this.timeLeft > 0)
                {
                    if (Main.rand.Next(2) == 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    if (Main.rand.Next(50) == 0)
                    {
                        this.timeLeft = this.timeLeft - 5;
                    }
                    if (Main.rand.Next(100) == 0)
                    {
                        this.timeLeft = this.timeLeft - 10;
                    }
                }
                else
                {
                    this.alpha = (int)byte.MaxValue;
                    if (Main.goreLoaded[this.type])
                    {
                        float num1 = (float)((double)Main.goreTexture[this.type].Width * (double)this.scale * 0.800000011920929);
                        float x    = this.position.X;
                        float y    = this.position.Y;
                        float num2 = (float)Main.goreTexture[this.type].Width * this.scale;
                        float num3 = (float)Main.goreTexture[this.type].Height * this.scale;
                        int   Type = 176;
                        if (this.type >= 416 && this.type <= 420)
                        {
                            Type = 177;
                        }
                        if (this.type >= 421 && this.type <= 425)
                        {
                            Type = 178;
                        }
                        if (this.type >= 426 && this.type <= 430)
                        {
                            Type = 179;
                        }
                        for (int index1 = 0; (double)index1 < (double)num1; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(x, y), (int)num2, (int)num3, Type, 0.0f, 0.0f, 0, new Color(), 1f);
                            Main.dust[index2].noGravity = true;
                            Main.dust[index2].alpha     = 100;
                            Main.dust[index2].scale     = this.scale;
                        }
                    }
                }
            }
            else if (GoreID.Sets.SpecialAI[this.type] != 3 && GoreID.Sets.SpecialAI[this.type] != 1)
            {
                if (this.type >= 706 && this.type <= 717 || this.type == 943)
                {
                    if (this.type == 716)
                    {
                        float num1 = 0.6f;
                        float num2 = (int)this.frame != 0 ? ((int)this.frame != 1 ? ((int)this.frame != 2 ? ((int)this.frame != 3 ? ((int)this.frame != 4 ? ((int)this.frame != 5 ? ((int)this.frame != 6 ? ((int)this.frame > 9 ? ((int)this.frame != 10 ? ((int)this.frame != 11 ? ((int)this.frame != 12 ? ((int)this.frame != 13 ? ((int)this.frame != 14 ? 0.0f : num1 * 0.1f) : num1 * 0.2f) : num1 * 0.3f) : num1 * 0.4f) : num1 * 0.5f) : num1 * 0.5f) : num1 * 0.2f) : num1 * 0.4f) : num1 * 0.5f) : num1 * 0.4f) : num1 * 0.3f) : num1 * 0.2f) : num1 * 0.1f;
                        Lighting.AddLight(this.position + new Vector2(8f, 8f), 1f * num2, 0.5f * num2, 0.1f * num2);
                    }
                    Vector2 velocity = this.velocity;
                    this.velocity = Collision.TileCollision(this.position, this.velocity, 16, 14, false, false, 1);
                    if (this.velocity != velocity)
                    {
                        if ((int)this.frame < 10)
                        {
                            this.frame        = (byte)10;
                            this.frameCounter = (byte)0;
                            if (this.type != 716 && this.type != 717 && this.type != 943)
                            {
                                Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, Main.rand.Next(2), 1f, 0.0f);
                            }
                        }
                    }
                    else if (Collision.WetCollision(this.position + this.velocity, 16, 14))
                    {
                        if ((int)this.frame < 10)
                        {
                            this.frame        = (byte)10;
                            this.frameCounter = (byte)0;
                            if (this.type != 716 && this.type != 717 && this.type != 943)
                            {
                                Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, 2, 1f, 0.0f);
                            }
                            ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(this.position + new Vector2(8f, 8f), 1f, RippleShape.Square, 0.0f);
                        }
                        int index1 = (int)((double)this.position.X + 8.0) / 16;
                        int index2 = (int)((double)this.position.Y + 14.0) / 16;
                        if (Main.tile[index1, index2] != null && (int)Main.tile[index1, index2].liquid > 0)
                        {
                            this.velocity   = this.velocity * 0.0f;
                            this.position.Y = (float)(index2 * 16 - (int)Main.tile[index1, index2].liquid / 16);
                        }
                    }
                }
                else if (this.sticky)
                {
                    int num1 = 32;
                    if (Main.goreLoaded[this.type])
                    {
                        num1 = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num1)
                        {
                            num1 = Main.goreTexture[this.type].Height;
                        }
                    }
                    if (flag)
                    {
                        num1 = 4;
                    }
                    int     num2     = (int)((double)num1 * 0.899999976158142);
                    Vector2 velocity = this.velocity;
                    this.velocity = Collision.TileCollision(this.position, this.velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1);
                    if ((double)this.velocity.Y == 0.0)
                    {
                        if (flag)
                        {
                            this.velocity.X *= 0.94f;
                        }
                        else
                        {
                            this.velocity.X *= 0.97f;
                        }
                        if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                        {
                            this.velocity.X = 0.0f;
                        }
                    }
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - GoreID.Sets.DisappearSpeed[this.type];
                    }
                    else
                    {
                        this.alpha = this.alpha + GoreID.Sets.DisappearSpeedAlpha[this.type];
                    }
                }
                else
                {
                    this.alpha = this.alpha + 2 * GoreID.Sets.DisappearSpeedAlpha[this.type];
                }
            }
            if (this.type >= 907 && this.type <= 909)
            {
                int num1 = 32;
                if (Main.goreLoaded[this.type])
                {
                    num1 = Main.goreTexture[this.type].Width;
                    if (Main.goreTexture[this.type].Height < num1)
                    {
                        num1 = Main.goreTexture[this.type].Height;
                    }
                }
                int     num2    = (int)((double)num1 * 0.899999976158142);
                Vector4 vector4 = Collision.SlopeCollision(this.position, this.velocity, num2, num2, 0.0f, true);
                this.position.X = vector4.X;
                this.position.Y = vector4.Y;
                this.velocity.X = vector4.Z;
                this.velocity.Y = vector4.W;
            }
            if (GoreID.Sets.SpecialAI[this.type] == 1)
            {
                if ((double)this.velocity.Y < 0.0)
                {
                    Vector2 Velocity = new Vector2(this.velocity.X, 0.6f);
                    int     num1     = 32;
                    if (Main.goreLoaded[this.type])
                    {
                        num1 = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num1)
                        {
                            num1 = Main.goreTexture[this.type].Height;
                        }
                    }
                    int     num2    = (int)((double)num1 * 0.899999976158142);
                    Vector2 vector2 = Collision.TileCollision(this.position, Velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1);
                    vector2.X *= 0.97f;
                    if ((double)vector2.X > -0.01 && (double)vector2.X < 0.01)
                    {
                        vector2.X = 0.0f;
                    }
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    else
                    {
                        this.alpha = this.alpha + 1;
                    }
                    this.velocity.X = vector2.X;
                }
                else
                {
                    this.velocity.Y += (float)Math.PI / 60f;
                    Vector2 Velocity = new Vector2(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).X * 2f, Math.Abs(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).Y) * 3f) * 2f;
                    int     num      = 32;
                    if (Main.goreLoaded[this.type])
                    {
                        num = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num)
                        {
                            num = Main.goreTexture[this.type].Height;
                        }
                    }
                    Vector2 vector2 = Velocity;
                    Vector2 v       = Collision.TileCollision(this.position, Velocity, (int)((double)num * (double)this.scale), (int)((double)num * (double)this.scale), false, false, 1);
                    if (v != vector2)
                    {
                        this.velocity.Y = -1f;
                    }
                    this.position = this.position + v;
                    this.rotation = v.ToRotation() + 3.141593f;
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    else
                    {
                        this.alpha = this.alpha + 1;
                    }
                }
            }
            else if (GoreID.Sets.SpecialAI[this.type] == 3)
            {
                if ((double)this.velocity.Y < 0.0)
                {
                    Vector2 Velocity = new Vector2(this.velocity.X, -0.2f);
                    int     num1     = 8;
                    if (Main.goreLoaded[this.type])
                    {
                        num1 = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num1)
                        {
                            num1 = Main.goreTexture[this.type].Height;
                        }
                    }
                    int     num2    = (int)((double)num1 * 0.899999976158142);
                    Vector2 vector2 = Collision.TileCollision(this.position, Velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1);
                    vector2.X *= 0.94f;
                    if ((double)vector2.X > -0.01 && (double)vector2.X < 0.01)
                    {
                        vector2.X = 0.0f;
                    }
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - GoreID.Sets.DisappearSpeed[this.type];
                    }
                    else
                    {
                        this.alpha = this.alpha + GoreID.Sets.DisappearSpeedAlpha[this.type];
                    }
                    this.velocity.X = vector2.X;
                }
                else
                {
                    this.velocity.Y += (float)Math.PI / 180f;
                    Vector2 Velocity = new Vector2(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).X * 1f, Math.Abs(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).Y) * 1f);
                    int     num      = 8;
                    if (Main.goreLoaded[this.type])
                    {
                        num = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num)
                        {
                            num = Main.goreTexture[this.type].Height;
                        }
                    }
                    Vector2 vector2 = Velocity;
                    Vector2 v       = Collision.TileCollision(this.position, Velocity, (int)((double)num * (double)this.scale), (int)((double)num * (double)this.scale), false, false, 1);
                    if (v != vector2)
                    {
                        this.velocity.Y = -1f;
                    }
                    this.position = this.position + v;
                    this.rotation = v.ToRotation() + 1.570796f;
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - GoreID.Sets.DisappearSpeed[this.type];
                    }
                    else
                    {
                        this.alpha = this.alpha + GoreID.Sets.DisappearSpeedAlpha[this.type];
                    }
                }
            }
            else
            {
                this.position = this.position + this.velocity;
            }
            if (this.alpha >= (int)byte.MaxValue)
            {
                this.active = false;
            }
            if ((double)this.light <= 0.0)
            {
                return;
            }
            float R = this.light * this.scale;
            float G = this.light * this.scale;
            float B = this.light * this.scale;

            if (this.type == 16)
            {
                B *= 0.3f;
                G *= 0.8f;
            }
            else if (this.type == 17)
            {
                G *= 0.6f;
                R *= 0.3f;
            }
            if (Main.goreLoaded[this.type])
            {
                Lighting.AddLight((int)(((double)this.position.X + (double)Main.goreTexture[this.type].Width * (double)this.scale / 2.0) / 16.0), (int)(((double)this.position.Y + (double)Main.goreTexture[this.type].Height * (double)this.scale / 2.0) / 16.0), R, G, B);
            }
            else
            {
                Lighting.AddLight((int)(((double)this.position.X + 32.0 * (double)this.scale / 2.0) / 16.0), (int)(((double)this.position.Y + 32.0 * (double)this.scale / 2.0) / 16.0), R, G, B);
            }
        }
예제 #2
0
        // Token: 0x060006E1 RID: 1761 RVA: 0x00347714 File Offset: 0x00345914
        private void DrawWaterfall(SpriteBatch spriteBatch, int Style = 0, float Alpha = 1f)
        {
            float num   = 0f;
            float num2  = 99999f;
            float num3  = 99999f;
            int   num4  = -1;
            int   num5  = -1;
            float num6  = 0f;
            float num7  = 99999f;
            float num8  = 99999f;
            int   num9  = -1;
            int   num10 = -1;
            int   i     = 0;

            while (i < this.currentMax)
            {
                int num11 = 0;
                int num12 = this.waterfalls[i].type;
                int num13 = this.waterfalls[i].x;
                int num14 = this.waterfalls[i].y;
                int num15 = 0;
                int num16 = 0;
                int num17 = 0;
                int num18 = 0;
                int num19 = 0;
                int num20 = 0;
                int num21 = 0;
                int num22;
                if (num12 == 1 || num12 == 14)
                {
                    if (!Main.drewLava && this.waterfalls[i].stopAtStep != 0)
                    {
                        num21 = 32 * this.slowFrame;
                        goto IL_459;
                    }
                }
                else
                {
                    if (num12 != 11 && num12 != 22)
                    {
                        if (num12 == 0)
                        {
                            num12 = Style;
                        }
                        else if (num12 == 2 && Main.drewLava)
                        {
                            goto IL_18C8;
                        }
                        num21 = 32 * this.regularFrame;
                        goto IL_459;
                    }
                    if (!Main.drewLava)
                    {
                        num22 = this.waterfallDist / 4;
                        if (num12 == 22)
                        {
                            num22 = this.waterfallDist / 2;
                        }
                        if (this.waterfalls[i].stopAtStep > num22)
                        {
                            this.waterfalls[i].stopAtStep = num22;
                        }
                        if (this.waterfalls[i].stopAtStep != 0 && (float)(num14 + num22) >= Main.screenPosition.Y / 16f && (float)num13 >= Main.screenPosition.X / 16f - 1f && (float)num13 <= (Main.screenPosition.X + (float)Main.screenWidth) / 16f + 1f)
                        {
                            int num23;
                            int num24;
                            if (num13 % 2 == 0)
                            {
                                num23 = this.rainFrameForeground + 3;
                                if (num23 > 7)
                                {
                                    num23 -= 8;
                                }
                                num24 = this.rainFrameBackground + 2;
                                if (num24 > 7)
                                {
                                    num24 -= 8;
                                }
                                if (num12 == 22)
                                {
                                    num23 = this.snowFrameForeground + 3;
                                    if (num23 > 7)
                                    {
                                        num23 -= 8;
                                    }
                                }
                            }
                            else
                            {
                                num23 = this.rainFrameForeground;
                                num24 = this.rainFrameBackground;
                                if (num12 == 22)
                                {
                                    num23 = this.snowFrameForeground;
                                }
                            }
                            Rectangle value  = new Rectangle(num24 * 18, 0, 16, 16);
                            Rectangle value2 = new Rectangle(num23 * 18, 0, 16, 16);
                            Vector2   origin = new Vector2(8f, 8f);
                            Vector2   position;
                            if (num14 % 2 == 0)
                            {
                                position = new Vector2((float)(num13 * 16 + 9), (float)(num14 * 16 + 8)) - Main.screenPosition;
                            }
                            else
                            {
                                position = new Vector2((float)(num13 * 16 + 8), (float)(num14 * 16 + 8)) - Main.screenPosition;
                            }
                            bool flag = false;
                            for (int j = 0; j < num22; j++)
                            {
                                Color arg_2C8_0 = Lighting.GetColor(num13, num14);
                                float num25     = 0.6f;
                                float num26     = 0.3f;
                                if (j > num22 - 8)
                                {
                                    float num27 = (float)(num22 - j) / 8f;
                                    num25 *= num27;
                                    num26 *= num27;
                                }
                                Color color  = arg_2C8_0 * num25;
                                Color color2 = arg_2C8_0 * num26;
                                if (num12 == 22)
                                {
                                    spriteBatch.Draw(this.waterfallTexture[22], position, new Rectangle?(value2), color, 0f, origin, 1f, SpriteEffects.None, 0f);
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[12], position, new Rectangle?(value), color2, 0f, origin, 1f, SpriteEffects.None, 0f);
                                    spriteBatch.Draw(this.waterfallTexture[11], position, new Rectangle?(value2), color, 0f, origin, 1f, SpriteEffects.None, 0f);
                                }
                                if (flag)
                                {
                                    break;
                                }
                                num14++;
                                Tile tile = Main.tile[num13, num14];
                                if (WorldGen.SolidTile(tile))
                                {
                                    flag = true;
                                }
                                if (tile.liquid > 0)
                                {
                                    int num28 = (int)(16f * ((float)tile.liquid / 255f)) & 254;
                                    if (num28 >= 15)
                                    {
                                        break;
                                    }
                                    value2.Height -= num28;
                                    value.Height  -= num28;
                                }
                                if (num14 % 2 == 0)
                                {
                                    position.X += 1f;
                                }
                                else
                                {
                                    position.X -= 1f;
                                }
                                position.Y += 16f;
                            }
                            this.waterfalls[i].stopAtStep = 0;
                        }
                    }
                }
IL_18C8:
                i++;
                continue;
IL_459:
                int num29 = 0;
                num22     = this.waterfallDist;
                Color color3 = Color.White;
                for (int k = 0; k < num22; k++)
                {
                    if (num29 < 2)
                    {
                        if (num12 != 1)
                        {
                            if (num12 != 2)
                            {
                                switch (num12)
                                {
                                case 15:
                                {
                                    float num30 = 0f;
                                    float num31 = 0f;
                                    float num32 = 0.2f;
                                    Lighting.AddLight(num13, num14, num30, num31, num32);
                                    break;
                                }

                                case 16:
                                {
                                    float num30 = 0f;
                                    float num31 = 0.2f;
                                    float num32 = 0f;
                                    Lighting.AddLight(num13, num14, num30, num31, num32);
                                    break;
                                }

                                case 17:
                                {
                                    float num30 = 0f;
                                    float num31 = 0f;
                                    float num32 = 0.2f;
                                    Lighting.AddLight(num13, num14, num30, num31, num32);
                                    break;
                                }

                                case 18:
                                {
                                    float num30 = 0f;
                                    float num31 = 0.2f;
                                    float num32 = 0f;
                                    Lighting.AddLight(num13, num14, num30, num31, num32);
                                    break;
                                }

                                case 19:
                                {
                                    float num30 = 0.2f;
                                    float num31 = 0f;
                                    float num32 = 0f;
                                    Lighting.AddLight(num13, num14, num30, num31, num32);
                                    break;
                                }

                                case 20:
                                    Lighting.AddLight(num13, num14, 0.2f, 0.2f, 0.2f);
                                    break;

                                case 21:
                                {
                                    float num30 = 0.2f;
                                    float num31 = 0f;
                                    float num32 = 0f;
                                    Lighting.AddLight(num13, num14, num30, num31, num32);
                                    break;
                                }
                                }
                            }
                            else
                            {
                                float num30 = (float)Main.DiscoR / 255f;
                                float num31 = (float)Main.DiscoG / 255f;
                                float num32 = (float)Main.DiscoB / 255f;
                                num30 *= 0.2f;
                                num31 *= 0.2f;
                                num32 *= 0.2f;
                                Lighting.AddLight(num13, num14, num30, num31, num32);
                            }
                        }
                        else
                        {
                            float num30;
                            float expr_4CE = num30 = (0.55f + (float)(270 - (int)Main.mouseTextColor) / 900f) * 0.4f;
                            float num31    = expr_4CE * 0.3f;
                            float num32    = expr_4CE * 0.1f;
                            Lighting.AddLight(num13, num14, num30, num31, num32);
                        }
                        Tile tile2 = Main.tile[num13, num14];
                        if (tile2 == null)
                        {
                            tile2 = new Tile();
                            Main.tile[num13, num14] = tile2;
                        }
                        Tile tile3 = Main.tile[num13 - 1, num14];
                        if (tile3 == null)
                        {
                            tile3 = new Tile();
                            Main.tile[num13 - 1, num14] = tile3;
                        }
                        Tile tile4 = Main.tile[num13, num14 + 1];
                        if (tile4 == null)
                        {
                            tile4 = new Tile();
                            Main.tile[num13, num14 + 1] = tile4;
                        }
                        Tile tile5 = Main.tile[num13 + 1, num14];
                        if (tile5 == null)
                        {
                            tile5 = new Tile();
                            Main.tile[num13 + 1, num14] = tile5;
                        }
                        int num33 = (int)(tile2.liquid / 16);
                        int num34 = 0;
                        int num35 = num18;
                        int num36;
                        int num37;
                        if (tile4.topSlope())
                        {
                            if (tile4.slope() == 1)
                            {
                                num34 = 1;
                                num36 = 1;
                                num17 = 1;
                                num18 = num17;
                            }
                            else
                            {
                                num34 = -1;
                                num36 = -1;
                                num17 = -1;
                                num18 = num17;
                            }
                            num37 = 1;
                        }
                        else if ((((!WorldGen.SolidTile(tile4) && !tile4.bottomSlope()) || tile4.type == 162) && !tile2.halfBrick()) || (!tile4.active() && !tile2.halfBrick()))
                        {
                            num29 = 0;
                            num37 = 1;
                            num36 = 0;
                        }
                        else if ((WorldGen.SolidTile(tile3) || tile3.topSlope() || tile3.liquid > 0) && !WorldGen.SolidTile(tile5) && tile5.liquid == 0)
                        {
                            if (num17 == -1)
                            {
                                num29++;
                            }
                            num36 = 1;
                            num37 = 0;
                            num17 = 1;
                        }
                        else if ((WorldGen.SolidTile(tile5) || tile5.topSlope() || tile5.liquid > 0) && !WorldGen.SolidTile(tile3) && tile3.liquid == 0)
                        {
                            if (num17 == 1)
                            {
                                num29++;
                            }
                            num36 = -1;
                            num37 = 0;
                            num17 = -1;
                        }
                        else if (((!WorldGen.SolidTile(tile5) && !tile2.topSlope()) || tile5.liquid == 0) && !WorldGen.SolidTile(tile3) && !tile2.topSlope() && tile3.liquid == 0)
                        {
                            num37 = 0;
                            num36 = num17;
                        }
                        else
                        {
                            num29++;
                            num37 = 0;
                            num36 = 0;
                        }
                        if (num29 >= 2)
                        {
                            num17 *= -1;
                            num36 *= -1;
                        }
                        int num38 = -1;
                        if (num12 != 1 && num12 != 14)
                        {
                            if (tile4.active())
                            {
                                num38 = (int)tile4.type;
                            }
                            if (tile2.active())
                            {
                                num38 = (int)tile2.type;
                            }
                        }
                        if (num38 != -1)
                        {
                            if (num38 == 160)
                            {
                                num12 = 2;
                            }
                            else if (num38 >= 262 && num38 <= 268)
                            {
                                num12 = 15 + num38 - 262;
                            }
                        }
                        if (WorldGen.SolidTile(tile4) && !tile2.halfBrick())
                        {
                            num11 = 8;
                        }
                        else if (num16 != 0)
                        {
                            num11 = 0;
                        }
                        Color color4 = Lighting.GetColor(num13, num14);
                        Color color5 = color4;
                        float num39;
                        if (num12 == 1)
                        {
                            num39 = 1f;
                        }
                        else if (num12 == 14)
                        {
                            num39 = 0.8f;
                        }
                        else if (tile2.wall == 0 && (double)num14 < Main.worldSurface)
                        {
                            num39 = Alpha;
                        }
                        else
                        {
                            num39 = 0.6f * Alpha;
                        }
                        if (k > num22 - 10)
                        {
                            num39 *= (float)(num22 - k) / 10f;
                        }
                        float num40 = (float)color4.R * num39;
                        float num41 = (float)color4.G * num39;
                        float num42 = (float)color4.B * num39;
                        float num43 = (float)color4.A * num39;
                        if (num12 == 1)
                        {
                            if (num40 < 190f * num39)
                            {
                                num40 = 190f * num39;
                            }
                            if (num41 < 190f * num39)
                            {
                                num41 = 190f * num39;
                            }
                            if (num42 < 190f * num39)
                            {
                                num42 = 190f * num39;
                            }
                        }
                        else if (num12 == 2)
                        {
                            num40 = (float)Main.DiscoR * num39;
                            num41 = (float)Main.DiscoG * num39;
                            num42 = (float)Main.DiscoB * num39;
                        }
                        else if (num12 >= 15 && num12 <= 21)
                        {
                            num40 = 255f * num39;
                            num41 = 255f * num39;
                            num42 = 255f * num39;
                        }
                        color4 = new Color((int)num40, (int)num41, (int)num42, (int)num43);
                        if (num12 == 1)
                        {
                            float num44 = Math.Abs((float)(num13 * 16 + 8) - (Main.screenPosition.X + (float)(Main.screenWidth / 2)));
                            float num45 = Math.Abs((float)(num14 * 16 + 8) - (Main.screenPosition.Y + (float)(Main.screenHeight / 2)));
                            if (num44 < (float)(Main.screenWidth * 2) && num45 < (float)(Main.screenHeight * 2))
                            {
                                float num46 = (float)Math.Sqrt((double)(num44 * num44 + num45 * num45));
                                float num47 = 1f - num46 / ((float)Main.screenWidth * 0.75f);
                                if (num47 > 0f)
                                {
                                    num6 += num47;
                                }
                            }
                            if (num44 < num7)
                            {
                                num7 = num44;
                                num9 = num13 * 16 + 8;
                            }
                            if (num45 < num8)
                            {
                                num8  = num44;
                                num10 = num14 * 16 + 8;
                            }
                        }
                        else if (num12 != 1 && num12 != 14 && num12 != 11 && num12 != 12 && num12 != 22)
                        {
                            float num48 = Math.Abs((float)(num13 * 16 + 8) - (Main.screenPosition.X + (float)(Main.screenWidth / 2)));
                            float num49 = Math.Abs((float)(num14 * 16 + 8) - (Main.screenPosition.Y + (float)(Main.screenHeight / 2)));
                            if (num48 < (float)(Main.screenWidth * 2) && num49 < (float)(Main.screenHeight * 2))
                            {
                                float num50 = (float)Math.Sqrt((double)(num48 * num48 + num49 * num49));
                                float num51 = 1f - num50 / ((float)Main.screenWidth * 0.75f);
                                if (num51 > 0f)
                                {
                                    num += num51;
                                }
                            }
                            if (num48 < num2)
                            {
                                num2 = num48;
                                num4 = num13 * 16 + 8;
                            }
                            if (num49 < num3)
                            {
                                num3 = num48;
                                num5 = num14 * 16 + 8;
                            }
                        }
                        if (k > 50 && (color5.R > 20 || color5.B > 20 || color5.G > 20))
                        {
                            float num52 = (float)color5.R;
                            if ((float)color5.G > num52)
                            {
                                num52 = (float)color5.G;
                            }
                            if ((float)color5.B > num52)
                            {
                                num52 = (float)color5.B;
                            }
                            if ((float)Main.rand.Next(20000) < num52 / 30f)
                            {
                                int num53 = Dust.NewDust(new Vector2((float)(num13 * 16 - num17 * 7), (float)(num14 * 16 + 6)), 10, 8, 43, 0f, 0f, 254, Color.White, 0.5f);
                                Main.dust[num53].velocity *= 0f;
                            }
                        }
                        if (num15 == 0 && num34 != 0 && num16 == 1 && num17 != num18)
                        {
                            num34  = 0;
                            num17  = num18;
                            color4 = Color.White;
                            if (num17 == 1)
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16 + 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color4, 0f, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                            else
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16 + 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 8)), color4, 0f, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                        }
                        if (num19 != 0 && num36 == 0 && num37 == 1)
                        {
                            if (num17 == 1)
                            {
                                if (num20 != num12)
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11 + 8)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 0, 16, 16 - num33 - 8)), color3, 0f, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally, 0f);
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11 + 8)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 0, 16, 16 - num33 - 8)), color4, 0f, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally, 0f);
                                }
                            }
                            else
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11 + 8)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 0, 16, 16 - num33 - 8)), color4, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                            }
                        }
                        if (num11 == 8 && num16 == 1 && num19 == 0)
                        {
                            if (num18 == -1)
                            {
                                if (num20 != num12)
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 8)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 8)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                                }
                            }
                            else if (num20 != num12)
                            {
                                spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 8)), color3, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                            else
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 8)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                        }
                        if (num34 != 0 && num15 == 0)
                        {
                            if (num35 == 1)
                            {
                                if (num20 != num12)
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color3, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                                }
                            }
                            else if (num20 != num12)
                            {
                                spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                            }
                            else
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                            }
                        }
                        if (num37 == 1 && num34 == 0 && num19 == 0)
                        {
                            if (num17 == -1)
                            {
                                if (num16 == 0)
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 0, 16, 16 - num33)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                                }
                                else if (num20 != num12)
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                                }
                            }
                            else if (num16 == 0)
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 0, 16, 16 - num33)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                            else if (num20 != num12)
                            {
                                spriteBatch.Draw(this.waterfallTexture[num20], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color3, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                            else
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 - 16), (float)(num14 * 16)) - Main.screenPosition, new Rectangle?(new Rectangle(num21, 24, 32, 16 - num33)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                            }
                        }
                        else if (num36 == 1)
                        {
                            if (Main.tile[num13, num14].liquid <= 0 || Main.tile[num13, num14].halfBrick())
                            {
                                if (num34 == 1)
                                {
                                    for (int l = 0; l < 8; l++)
                                    {
                                        int num54 = l * 2;
                                        int num55 = 14 - l * 2;
                                        int num56 = num54;
                                        num11 = 8;
                                        if (num15 == 0 && l < 2)
                                        {
                                            num56 = 4;
                                        }
                                        spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 + num54), (float)(num14 * 16 + num11 + num56)) - Main.screenPosition, new Rectangle?(new Rectangle(16 + num21 + num55, 0, 2, 16 - num11)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                                    }
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11)) - Main.screenPosition, new Rectangle?(new Rectangle(16 + num21, 0, 16, 16)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                                }
                            }
                        }
                        else if (num36 == -1)
                        {
                            if (Main.tile[num13, num14].liquid <= 0 || Main.tile[num13, num14].halfBrick())
                            {
                                if (num34 == -1)
                                {
                                    for (int m = 0; m < 8; m++)
                                    {
                                        int num57 = m * 2;
                                        int num58 = m * 2;
                                        int num59 = 14 - m * 2;
                                        num11 = 8;
                                        if (num15 == 0 && m > 5)
                                        {
                                            num59 = 4;
                                        }
                                        spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16 + num57), (float)(num14 * 16 + num11 + num59)) - Main.screenPosition, new Rectangle?(new Rectangle(16 + num21 + num58, 0, 2, 16 - num11)), color4, 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
                                    }
                                }
                                else
                                {
                                    spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11)) - Main.screenPosition, new Rectangle?(new Rectangle(16 + num21, 0, 16, 16)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                                }
                            }
                        }
                        else if (num36 == 0 && num37 == 0)
                        {
                            if (Main.tile[num13, num14].liquid <= 0 || Main.tile[num13, num14].halfBrick())
                            {
                                spriteBatch.Draw(this.waterfallTexture[num12], new Vector2((float)(num13 * 16), (float)(num14 * 16 + num11)) - Main.screenPosition, new Rectangle?(new Rectangle(16 + num21, 0, 16, 16)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                            }
                            k = 1000;
                        }
                        if (tile2.liquid > 0 && !tile2.halfBrick())
                        {
                            k = 1000;
                        }
                        num16  = num37;
                        num18  = num17;
                        num15  = num36;
                        num13 += num36;
                        num14 += num37;
                        num19  = num34;
                        color3 = color4;
                        if (num20 != num12)
                        {
                            num20 = num12;
                        }
                        if ((tile3.active() && (tile3.type == 189 || tile3.type == 196)) || (tile5.active() && (tile5.type == 189 || tile5.type == 196)) || (tile4.active() && (tile4.type == 189 || tile4.type == 196)))
                        {
                            num22 = (int)((float)(40 * (Main.maxTilesX / 4200)) * Main.gfxQuality);
                        }
                    }
                }
                goto IL_18C8;
            }
            Main.ambientWaterfallX        = (float)num4;
            Main.ambientWaterfallY        = (float)num5;
            Main.ambientWaterfallStrength = num;
            Main.ambientLavafallX         = (float)num9;
            Main.ambientLavafallY         = (float)num10;
            Main.ambientLavafallStrength  = num6;
        }
예제 #3
0
파일: Lighting.cs 프로젝트: egshels/Sources
 public static void AddLight(Vector2 position, Vector3 rgb)
 {
     Lighting.AddLight((int)((double)position.X / 16.0), (int)((double)position.Y / 16.0), rgb.X, rgb.Y, rgb.Z);
 }
예제 #4
0
파일: Lighting.cs 프로젝트: egshels/Sources
 public static void AddLight(Vector2 position, float r, float g, float b)
 {
     Lighting.AddLight((int)((double)position.X / 16.0), (int)((double)position.Y / 16.0), r, g, b);
 }
예제 #5
0
 public void Update()
 {
     if (Main.netMode == 2 || !active)
     {
         return;
     }
     if (type >= 276 && type <= 282)
     {
         velocity.X *= 0.98f;
         velocity.Y *= 0.98f;
         if (velocity.Y < scale)
         {
             velocity.Y += 0.05f;
         }
         if ((double)velocity.Y > 0.1)
         {
             if (velocity.X > 0f)
             {
                 rotation += 0.01f;
             }
             else
             {
                 rotation -= 0.01f;
             }
         }
     }
     if (type >= 570 && type <= 572)
     {
         scale -= 0.001f;
         if ((double)scale <= 0.01)
         {
             scale    = 0.01f;
             goreTime = 0;
         }
         sticky   = false;
         rotation = velocity.X * 0.1f;
     }
     else if (type >= 706 && type <= 717)
     {
         if ((double)position.Y < Main.worldSurface * 16.0 + 8.0)
         {
             alpha = 0;
         }
         else
         {
             alpha = 100;
         }
         int num = 4;
         frameCounter++;
         if (frame <= 4)
         {
             int num2 = (int)(position.X / 16f);
             int num3 = (int)(position.Y / 16f) - 1;
             if (WorldGen.InWorld(num2, num3) && !Main.tile[num2, num3].active())
             {
                 active = false;
             }
             if (frame == 0)
             {
                 num = 24 + Main.rand.Next(256);
             }
             if (frame == 1)
             {
                 num = 24 + Main.rand.Next(256);
             }
             if (frame == 2)
             {
                 num = 24 + Main.rand.Next(256);
             }
             if (frame == 3)
             {
                 num = 24 + Main.rand.Next(96);
             }
             if (frame == 5)
             {
                 num = 16 + Main.rand.Next(64);
             }
             if (type == 716)
             {
                 num *= 2;
             }
             if (type == 717)
             {
                 num *= 4;
             }
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
                 if (frame == 5)
                 {
                     int num4 = NewGore(position, velocity, type);
                     Main.gore[num4].frame     = 9;
                     Main.gore[num4].velocity *= 0f;
                 }
             }
         }
         else if (frame <= 6)
         {
             num = 8;
             if (type == 716)
             {
                 num *= 2;
             }
             if (type == 717)
             {
                 num *= 3;
             }
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
                 if (frame == 7)
                 {
                     active = false;
                 }
             }
         }
         else if (frame <= 9)
         {
             num = 6;
             if (type == 716)
             {
                 num         = (int)((double)num * 1.5);
                 velocity.Y += 0.175f;
             }
             else if (type == 717)
             {
                 num        *= 2;
                 velocity.Y += 0.15f;
             }
             else
             {
                 velocity.Y += 0.2f;
             }
             if ((double)velocity.Y < 0.5)
             {
                 velocity.Y = 0.5f;
             }
             if (velocity.Y > 12f)
             {
                 velocity.Y = 12f;
             }
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
             }
             if (frame > 9)
             {
                 frame = 7;
             }
         }
         else
         {
             if (type == 716)
             {
                 num *= 2;
             }
             else if (type == 717)
             {
                 num *= 6;
             }
             velocity.Y += 0.1f;
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
             }
             velocity *= 0f;
             if (frame > 14)
             {
                 active = false;
             }
         }
     }
     else if (type == 11 || type == 12 || type == 13 || type == 61 || type == 62 || type == 63 || type == 99 || type == 220 || type == 221 || type == 222 || (type >= 375 && type <= 377) || (type >= 435 && type <= 437) || (type >= 861 && type <= 862))
     {
         velocity.Y *= 0.98f;
         velocity.X *= 0.98f;
         scale      -= 0.007f;
         if ((double)scale < 0.1)
         {
             scale = 0.1f;
             alpha = 255;
         }
     }
     else if (type == 16 || type == 17)
     {
         velocity.Y *= 0.98f;
         velocity.X *= 0.98f;
         scale      -= 0.01f;
         if ((double)scale < 0.1)
         {
             scale = 0.1f;
             alpha = 255;
         }
     }
     else if (type == 331)
     {
         alpha      += 5;
         velocity.Y *= 0.95f;
         velocity.X *= 0.95f;
         rotation    = velocity.X * 0.1f;
     }
     else if (type != 860 && type != 892 && type != 893 && (type < 825 || type > 827) && (type < 411 || type > 430))
     {
         velocity.Y += 0.2f;
     }
     rotation += velocity.X * 0.1f;
     if (type >= 580 && type <= 582)
     {
         rotation    = 0f;
         velocity.X *= 0.95f;
     }
     if (type >= 825 && type <= 827)
     {
         if (timeLeft < 60)
         {
             alpha += Main.rand.Next(1, 7);
         }
         else if (alpha > 100)
         {
             alpha -= Main.rand.Next(1, 4);
         }
         if (alpha < 0)
         {
             alpha = 0;
         }
         if (alpha > 255)
         {
             timeLeft = 0;
         }
         velocity.X = (velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
         float num5 = 0f;
         if (velocity.X < 0f)
         {
             num5 = velocity.X * 0.2f;
         }
         velocity.Y = (velocity.Y * 50f + -0.35f + num5 + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
         rotation   = velocity.X * 0.6f;
         float num6 = -1f;
         if (Main.goreLoaded[type])
         {
             Rectangle rectangle = new Rectangle((int)position.X, (int)position.Y, (int)((float)Main.goreTexture[type].Width * scale), (int)((float)Main.goreTexture[type].Height * scale));
             for (int i = 0; i < 16; i++)
             {
                 if (Main.player[i].active && !Main.player[i].dead)
                 {
                     Rectangle value = new Rectangle((int)Main.player[i].position.X, (int)Main.player[i].position.Y, Main.player[i].width, Main.player[i].height);
                     if (rectangle.Intersects(value))
                     {
                         timeLeft = 0;
                         num6     = Main.player[i].velocity.Length();
                         break;
                     }
                 }
             }
         }
         if (timeLeft > 0)
         {
             if (Main.rand.Next(2) == 0)
             {
                 timeLeft--;
             }
             if (Main.rand.Next(50) == 0)
             {
                 timeLeft -= 5;
             }
             if (Main.rand.Next(100) == 0)
             {
                 timeLeft -= 10;
             }
         }
         else
         {
             alpha = 255;
             if (Main.goreLoaded[type] && num6 != -1f)
             {
                 float num7  = (float)Main.goreTexture[type].Width * scale * 0.8f;
                 float x     = position.X;
                 float y     = position.Y;
                 float num8  = (float)Main.goreTexture[type].Width * scale;
                 float num9  = (float)Main.goreTexture[type].Height * scale;
                 int   num10 = 31;
                 for (int j = 0; (float)j < num7; j++)
                 {
                     int num11 = Dust.NewDust(new Vector2(x, y), (int)num8, (int)num9, num10);
                     Main.dust[num11].velocity *= (1f + num6) / 3f;
                     Main.dust[num11].noGravity = true;
                     Main.dust[num11].alpha     = 100;
                     Main.dust[num11].scale     = scale;
                 }
             }
         }
     }
     if (type >= 411 && type <= 430)
     {
         alpha      = 50;
         velocity.X = (velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
         velocity.Y = (velocity.Y * 50f + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
         rotation   = velocity.X * 0.3f;
         if (Main.goreLoaded[type])
         {
             Rectangle rectangle2 = new Rectangle((int)position.X, (int)position.Y, (int)((float)Main.goreTexture[type].Width * scale), (int)((float)Main.goreTexture[type].Height * scale));
             for (int k = 0; k < 16; k++)
             {
                 if (Main.player[k].active && !Main.player[k].dead)
                 {
                     Rectangle value2 = new Rectangle((int)Main.player[k].position.X, (int)Main.player[k].position.Y, Main.player[k].width, Main.player[k].height);
                     if (rectangle2.Intersects(value2))
                     {
                         timeLeft = 0;
                     }
                 }
             }
             if (Collision.SolidCollision(position, (int)((float)Main.goreTexture[type].Width * scale), (int)((float)Main.goreTexture[type].Height * scale)))
             {
                 timeLeft = 0;
             }
         }
         if (timeLeft > 0)
         {
             if (Main.rand.Next(2) == 0)
             {
                 timeLeft--;
             }
             if (Main.rand.Next(50) == 0)
             {
                 timeLeft -= 5;
             }
             if (Main.rand.Next(100) == 0)
             {
                 timeLeft -= 10;
             }
         }
         else
         {
             alpha = 255;
             if (Main.goreLoaded[type])
             {
                 float num12 = (float)Main.goreTexture[type].Width * scale * 0.8f;
                 float x2    = position.X;
                 float y2    = position.Y;
                 float num13 = (float)Main.goreTexture[type].Width * scale;
                 float num14 = (float)Main.goreTexture[type].Height * scale;
                 int   num15 = 176;
                 if (type >= 416 && type <= 420)
                 {
                     num15 = 177;
                 }
                 if (type >= 421 && type <= 425)
                 {
                     num15 = 178;
                 }
                 if (type >= 426 && type <= 430)
                 {
                     num15 = 179;
                 }
                 for (int l = 0; (float)l < num12; l++)
                 {
                     int num16 = Dust.NewDust(new Vector2(x2, y2), (int)num13, (int)num14, num15);
                     Main.dust[num16].noGravity = true;
                     Main.dust[num16].alpha     = 100;
                     Main.dust[num16].scale     = scale;
                 }
             }
         }
     }
     else if (type != 860 && type != 892 && type != 893)
     {
         if (type >= 706 && type <= 717)
         {
             if (type == 716)
             {
                 float num17 = 1f;
                 float num18 = 1f;
                 float num19 = 1f;
                 float num20 = 0.6f;
                 num20 = ((frame == 0) ? (num20 * 0.1f) : ((frame == 1) ? (num20 * 0.2f) : ((frame == 2) ? (num20 * 0.3f) : ((frame == 3) ? (num20 * 0.4f) : ((frame == 4) ? (num20 * 0.5f) : ((frame == 5) ? (num20 * 0.4f) : ((frame == 6) ? (num20 * 0.2f) : ((frame <= 9) ? (num20 * 0.5f) : ((frame == 10) ? (num20 * 0.5f) : ((frame == 11) ? (num20 * 0.4f) : ((frame == 12) ? (num20 * 0.3f) : ((frame == 13) ? (num20 * 0.2f) : ((frame != 14) ? 0f : (num20 * 0.1f))))))))))))));
                 num17 = 1f * num20;
                 num18 = 0.5f * num20;
                 num19 = 0.1f * num20;
                 Lighting.AddLight(position + new Vector2(8f, 8f), num17, num18, num19);
             }
             Vector2 value3 = velocity;
             velocity = Collision.TileCollision(position, velocity, 16, 14);
             if (velocity != value3)
             {
                 if (frame < 10)
                 {
                     frame        = 10;
                     frameCounter = 0;
                     if (type != 716 && type != 717)
                     {
                         Main.PlaySound(39, (int)position.X + 8, (int)position.Y + 8, Main.rand.Next(2));
                     }
                 }
             }
             else if (Collision.WetCollision(position + velocity, 16, 14))
             {
                 if (frame < 10)
                 {
                     frame        = 10;
                     frameCounter = 0;
                     if (type != 716 && type != 717)
                     {
                         Main.PlaySound(39, (int)position.X + 8, (int)position.Y + 8, 2);
                     }
                 }
                 int num21 = (int)(position.X + 8f) / 16;
                 int num22 = (int)(position.Y + 14f) / 16;
                 if (Main.tile[num21, num22] != null && Main.tile[num21, num22].liquid > 0)
                 {
                     velocity  *= 0f;
                     position.Y = num22 * 16 - (int)Main.tile[num21, num22].liquid / 16;
                 }
             }
         }
         else if (sticky)
         {
             int num23 = 32;
             if (Main.goreLoaded[type])
             {
                 num23 = Main.goreTexture[type].Width;
                 if (Main.goreTexture[type].Height < num23)
                 {
                     num23 = Main.goreTexture[type].Height;
                 }
             }
             num23    = (int)((float)num23 * 0.9f);
             velocity = Collision.TileCollision(position, velocity, (int)((float)num23 * scale), (int)((float)num23 * scale));
             if (velocity.Y == 0f)
             {
                 velocity.X *= 0.97f;
                 if ((double)velocity.X > -0.01 && (double)velocity.X < 0.01)
                 {
                     velocity.X = 0f;
                 }
             }
             if (timeLeft > 0)
             {
                 timeLeft--;
             }
             else
             {
                 alpha++;
             }
         }
         else
         {
             alpha += 2;
         }
     }
     if (type == 860 || type == 892 || type == 893)
     {
         if (velocity.Y < 0f)
         {
             Vector2 vector = new Vector2(velocity.X, 0.6f);
             int     num24  = 32;
             if (Main.goreLoaded[type])
             {
                 num24 = Main.goreTexture[type].Width;
                 if (Main.goreTexture[type].Height < num24)
                 {
                     num24 = Main.goreTexture[type].Height;
                 }
             }
             num24     = (int)((float)num24 * 0.9f);
             vector    = Collision.TileCollision(position, vector, (int)((float)num24 * scale), (int)((float)num24 * scale));
             vector.X *= 0.97f;
             if ((double)vector.X > -0.01 && (double)vector.X < 0.01)
             {
                 vector.X = 0f;
             }
             if (timeLeft > 0)
             {
                 timeLeft--;
             }
             else
             {
                 alpha++;
             }
             velocity.X = vector.X;
         }
         else
         {
             velocity.Y += (float)Math.PI / 60f;
             Vector2 vector2 = new Vector2(Vector2.UnitY.RotatedBy(velocity.Y).X * 2f, Math.Abs(Vector2.UnitY.RotatedBy(velocity.Y).Y) * 3f);
             vector2 *= 2f;
             int num25 = 32;
             if (Main.goreLoaded[type])
             {
                 num25 = Main.goreTexture[type].Width;
                 if (Main.goreTexture[type].Height < num25)
                 {
                     num25 = Main.goreTexture[type].Height;
                 }
             }
             Vector2 value4 = vector2;
             vector2 = Collision.TileCollision(position, vector2, (int)((float)num25 * scale), (int)((float)num25 * scale));
             if (vector2 != value4)
             {
                 velocity.Y = -1f;
             }
             position += vector2;
             rotation  = vector2.ToRotation() + (float)Math.PI;
             if (timeLeft > 0)
             {
                 timeLeft--;
             }
             else
             {
                 alpha++;
             }
         }
     }
     else
     {
         position += velocity;
     }
     if (alpha >= 255)
     {
         active = false;
     }
     if (light > 0f)
     {
         float num26 = light * scale;
         float num27 = light * scale;
         float num28 = light * scale;
         if (type == 16)
         {
             num28 *= 0.3f;
             num27 *= 0.8f;
         }
         else if (type == 17)
         {
             num27 *= 0.6f;
             num26 *= 0.3f;
         }
         if (Main.goreLoaded[type])
         {
             Lighting.AddLight((int)((position.X + (float)Main.goreTexture[type].Width * scale / 2f) / 16f), (int)((position.Y + (float)Main.goreTexture[type].Height * scale / 2f) / 16f), num26, num27, num28);
         }
         else
         {
             Lighting.AddLight((int)((position.X + 32f * scale / 2f) / 16f), (int)((position.Y + 32f * scale / 2f) / 16f), num26, num27, num28);
         }
     }
 }