コード例 #1
0
        private void StepLiquids()
        {
            _isWaveBufferDirty = true;
            Vector2        value          = (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange));
            Vector2        vector         = value - Main.screenPosition;
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;

            graphicsDevice.SetRenderTarget(_distortionTarget);
            if (_clearNextFrame)
            {
                graphicsDevice.Clear(new Color(0.5f, 0.5f, 0f, 1f));
                _clearNextFrame = false;
            }
            DrawWaves();
            graphicsDevice.SetRenderTarget(_distortionTargetSwap);
            graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.5f, 1f));
            Main.tileBatch.Begin();
            vector  *= 0.25f;
            vector.X = (float)Math.Floor(vector.X);
            vector.Y = (float)Math.Floor(vector.Y);
            Vector2 vector2 = vector - _lastDistortionDrawOffset;

            _lastDistortionDrawOffset = vector;
            tileBatch.Draw(_distortionTarget, new Vector4(vector2.X, vector2.Y, _distortionTarget.Width, _distortionTarget.Height), new VertexColors(Color.White));
            GameShaders.Misc["WaterProcessor"].Apply(new DrawData(_distortionTarget, Vector2.Zero, Color.White));
            tileBatch.End();
            RenderTarget2D distortionTarget = _distortionTarget;

            _distortionTarget     = _distortionTargetSwap;
            _distortionTargetSwap = distortionTarget;
            if (_useViscosityFilter)
            {
                LiquidRenderer.Instance.SetWaveMaskData(_viscosityMaskChain[_activeViscosityMask]);
                tileBatch.Begin();
                Rectangle cachedDrawArea = LiquidRenderer.Instance.GetCachedDrawArea();
                Rectangle value2         = new Rectangle(0, 0, cachedDrawArea.Height, cachedDrawArea.Width);
                Vector4   destination    = new Vector4(cachedDrawArea.X + cachedDrawArea.Width, cachedDrawArea.Y, cachedDrawArea.Height, cachedDrawArea.Width);
                destination   *= 16f;
                destination.X -= value.X;
                destination.Y -= value.Y;
                destination   *= 0.25f;
                destination.X += vector.X;
                destination.Y += vector.Y;
                graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
                tileBatch.Draw(_viscosityMaskChain[_activeViscosityMask], destination, value2, new VertexColors(Color.White), Vector2.Zero, SpriteEffects.FlipHorizontally, (float)Math.PI / 2f);
                tileBatch.End();
                _activeViscosityMask++;
                _activeViscosityMask %= _viscosityMaskChain.Length;
            }
            graphicsDevice.SetRenderTarget(null);
        }
コード例 #2
0
ファイル: WaterShaderData.cs プロジェクト: windlex/mylualib
        // Token: 0x060011FF RID: 4607 RVA: 0x00411A24 File Offset: 0x0040FC24
        private void StepLiquids()
        {
            this._isWaveBufferDirty = true;
            Vector2        vector         = Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
            Vector2        vector2        = vector - Main.screenPosition;
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;

            graphicsDevice.SetRenderTarget(this._distortionTarget);
            if (this._clearNextFrame)
            {
                graphicsDevice.Clear(new Color(0.5f, 0.5f, 0f, 1f));
                this._clearNextFrame = false;
            }
            this.DrawWaves();
            graphicsDevice.SetRenderTarget(this._distortionTargetSwap);
            graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.5f, 1f));
            Main.tileBatch.Begin();
            vector2  *= 0.25f;
            vector2.X = (float)Math.Floor((double)vector2.X);
            vector2.Y = (float)Math.Floor((double)vector2.Y);
            Vector2 vector3 = vector2 - this._lastDistortionDrawOffset;

            this._lastDistortionDrawOffset = vector2;
            tileBatch.Draw(this._distortionTarget, new Vector4(vector3.X, vector3.Y, (float)this._distortionTarget.Width, (float)this._distortionTarget.Height), new VertexColors(Color.White));
            GameShaders.Misc["WaterProcessor"].Apply(new DrawData?(new DrawData(this._distortionTarget, Vector2.Zero, Color.White)));
            tileBatch.End();
            RenderTarget2D distortionTarget = this._distortionTarget;

            this._distortionTarget     = this._distortionTargetSwap;
            this._distortionTargetSwap = distortionTarget;
            if (this._useViscosityFilter)
            {
                LiquidRenderer.Instance.SetWaveMaskData(ref this._viscosityMaskChain[this._activeViscosityMask]);
                tileBatch.Begin();
                Rectangle cachedDrawArea = LiquidRenderer.Instance.GetCachedDrawArea();
                Rectangle value          = new Rectangle(0, 0, cachedDrawArea.Height, cachedDrawArea.Width);
                Vector4   vector4        = new Vector4((float)(cachedDrawArea.X + cachedDrawArea.Width), (float)cachedDrawArea.Y, (float)cachedDrawArea.Height, (float)cachedDrawArea.Width);
                vector4   *= 16f;
                vector4.X -= vector.X;
                vector4.Y -= vector.Y;
                vector4   *= 0.25f;
                vector4.X += vector2.X;
                vector4.Y += vector2.Y;
                graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
                tileBatch.Draw(this._viscosityMaskChain[this._activeViscosityMask], vector4, new Rectangle?(value), new VertexColors(Color.White), Vector2.Zero, SpriteEffects.FlipHorizontally, 1.57079637f);
                tileBatch.End();
                this._activeViscosityMask++;
                this._activeViscosityMask %= this._viscosityMaskChain.Length;
            }
            graphicsDevice.SetRenderTarget(null);
        }
コード例 #3
0
ファイル: WaterShaderData.cs プロジェクト: PhelixSky/TeDW
        private void StepLiquids()
        {
            this._isWaveBufferDirty = true;
            Vector2        vector2_1      = Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
            Vector2        vector2_2      = vector2_1 - Main.screenPosition;
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;

            graphicsDevice.SetRenderTarget(this._distortionTarget);
            if (this._clearNextFrame)
            {
                graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.0f, 1f));
                this._clearNextFrame = false;
            }
            this.DrawWaves();
            graphicsDevice.SetRenderTarget(this._distortionTargetSwap);
            graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.5f, 1f));
            Main.tileBatch.Begin();
            Vector2 vector2_3 = vector2_2 * 0.25f;

            vector2_3.X = (float)Math.Floor((double)vector2_3.X);
            vector2_3.Y = (float)Math.Floor((double)vector2_3.Y);
            Vector2 vector2_4 = vector2_3 - this._lastDistortionDrawOffset;

            this._lastDistortionDrawOffset = vector2_3;
            tileBatch.Draw((Texture2D)this._distortionTarget, new Vector4(vector2_4.X, vector2_4.Y, (float)this._distortionTarget.Width, (float)this._distortionTarget.Height), new VertexColors(Color.White));
            GameShaders.Misc["WaterProcessor"].Apply(new DrawData?(new DrawData((Texture2D)this._distortionTarget, Vector2.Zero, Color.White)));
            tileBatch.End();
            RenderTarget2D distortionTarget = this._distortionTarget;

            this._distortionTarget     = this._distortionTargetSwap;
            this._distortionTargetSwap = distortionTarget;
            if (this._useViscosityFilter)
            {
                LiquidRenderer.Instance.SetWaveMaskData(this._waveMaskChain[this._activeWaveMask]);
                tileBatch.Begin();
                Rectangle cachedDrawArea = LiquidRenderer.Instance.GetCachedDrawArea();
                Rectangle rectangle      = new Rectangle(0, 0, cachedDrawArea.Width, cachedDrawArea.Height);
                Vector4   destination    = new Vector4((float)cachedDrawArea.X, (float)cachedDrawArea.Y, (float)cachedDrawArea.Width, (float)cachedDrawArea.Height) * 16f;
                destination.X -= vector2_1.X;
                destination.Y -= vector2_1.Y;
                destination   *= 0.25f;
                destination.X += vector2_3.X;
                destination.Y += vector2_3.Y;
                graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
                tileBatch.Draw(this._waveMaskChain[this._activeWaveMask], destination, new Rectangle?(rectangle), new VertexColors(Color.White));
                tileBatch.End();
                ++this._activeWaveMask;
                this._activeWaveMask %= this._waveMaskChain.Length;
            }
            graphicsDevice.SetRenderTarget((RenderTarget2D)null);
        }
コード例 #4
0
ファイル: WaterShaderData.cs プロジェクト: xiongyaya/Terraria
        private void StepLiquids()
        {
            this._isWaveBufferDirty = true;
            Vector2        vector2_1      = Main.drawToScreen ? Vector2.get_Zero() : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
            Vector2        vector2_2      = Vector2.op_Subtraction(vector2_1, Main.screenPosition);
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.get_GraphicsDevice();

            graphicsDevice.SetRenderTarget(this._distortionTarget);
            if (this._clearNextFrame)
            {
                graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.0f, 1f));
                this._clearNextFrame = false;
            }
            this.DrawWaves();
            graphicsDevice.SetRenderTarget(this._distortionTargetSwap);
            graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.5f, 1f));
            Main.tileBatch.Begin();
            Vector2 vector2_3 = Vector2.op_Multiply(vector2_2, 0.25f);

            vector2_3.X = (__Null)Math.Floor((double)vector2_3.X);
            vector2_3.Y = (__Null)Math.Floor((double)vector2_3.Y);
            Vector2 vector2_4 = Vector2.op_Subtraction(vector2_3, this._lastDistortionDrawOffset);

            this._lastDistortionDrawOffset = vector2_3;
            tileBatch.Draw((Texture2D)this._distortionTarget, new Vector4((float)vector2_4.X, (float)vector2_4.Y, (float)((Texture2D)this._distortionTarget).get_Width(), (float)((Texture2D)this._distortionTarget).get_Height()), new VertexColors(Color.get_White()));
            GameShaders.Misc["WaterProcessor"].Apply(new DrawData?(new DrawData((Texture2D)this._distortionTarget, Vector2.get_Zero(), Color.get_White())));
            tileBatch.End();
            RenderTarget2D distortionTarget = this._distortionTarget;

            this._distortionTarget     = this._distortionTargetSwap;
            this._distortionTargetSwap = distortionTarget;
            if (this._useViscosityFilter)
            {
                LiquidRenderer.Instance.SetWaveMaskData(ref this._viscosityMaskChain[this._activeViscosityMask]);
                tileBatch.Begin();
                Rectangle cachedDrawArea = LiquidRenderer.Instance.GetCachedDrawArea();
                Rectangle rectangle;
                // ISSUE: explicit reference operation
                ((Rectangle)@rectangle).\u002Ector(0, 0, (int)cachedDrawArea.Height, (int)cachedDrawArea.Width);
                Vector4 vector4_1;
                // ISSUE: explicit reference operation
                ((Vector4)@vector4_1).\u002Ector((float)(cachedDrawArea.X + cachedDrawArea.Width), (float)cachedDrawArea.Y, (float)cachedDrawArea.Height, (float)cachedDrawArea.Width);
                Vector4 vector4_2 = Vector4.op_Multiply(vector4_1, 16f);
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                __Null& local1 = @vector4_2.X;
                // ISSUE: cast to a reference type
                // ISSUE: explicit reference operation
                double num1 = (double) ^ (float&)local1 - vector2_1.X;
コード例 #5
0
        public void DrawWalls()
        {
            float   gfxQuality     = Main.gfxQuality;
            int     offScreenRange = Main.offScreenRange;
            int     num1           = Main.drawToScreen ? 1 : 0;
            Vector2 screenPosition = Main.screenPosition;
            int     screenWidth    = Main.screenWidth;
            int     screenHeight   = Main.screenHeight;
            int     maxTilesX      = Main.maxTilesX;
            int     maxTilesY      = Main.maxTilesY;

            int[]       wallBlend   = Main.wallBlend;
            SpriteBatch spriteBatch = Main.spriteBatch;
            TileBatch   tileBatch   = Main.tileBatch;

            this._tileArray = Main.tile;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int     num2;
            int     num3    = (int)((double)(num2 = (int)(120.0 * (1.0 - (double)gfxQuality) + 40.0 * (double)gfxQuality)) * 0.400000005960464);
            int     num4    = (int)((double)num2 * 0.349999994039536);
            int     num5    = (int)((double)num2 * 0.300000011920929);
            Vector2 vector2 = new Vector2((float)offScreenRange, (float)offScreenRange);

            if (num1 != 0)
            {
                vector2 = Vector2.Zero;
            }
            int num6  = (int)(((double)screenPosition.X - (double)vector2.X) / 16.0 - 1.0);
            int num7  = (int)(((double)screenPosition.X + (double)screenWidth + (double)vector2.X) / 16.0) + 2;
            int num8  = (int)(((double)screenPosition.Y - (double)vector2.Y) / 16.0 - 1.0);
            int num9  = (int)(((double)screenPosition.Y + (double)screenHeight + (double)vector2.Y) / 16.0) + 5;
            int num10 = offScreenRange / 16;
            int num11 = offScreenRange / 16;

            if (num6 - num10 < 4)
            {
                num6 = num10 + 4;
            }
            if (num7 + num10 > maxTilesX - 4)
            {
                num7 = maxTilesX - num10 - 4;
            }
            if (num8 - num11 < 4)
            {
                num8 = num11 + 4;
            }
            if (num9 + num11 > maxTilesY - 4)
            {
                num9 = maxTilesY - num11 - 4;
            }
            VertexColors vertices             = new VertexColors();
            Rectangle    rectangle            = new Rectangle(0, 0, 32, 32);
            int          underworldLayer      = Main.UnderworldLayer;
            Point        screenOverdrawOffset = Main.GetScreenOverdrawOffset();

            for (int index1 = num8 - num11 + screenOverdrawOffset.Y; index1 < num9 + num11 - screenOverdrawOffset.Y; ++index1)
            {
                for (int index2 = num6 - num10 + screenOverdrawOffset.X; index2 < num7 + num10 - screenOverdrawOffset.X; ++index2)
                {
                    Tile tile = this._tileArray[index2, index1];
                    if (tile == null)
                    {
                        tile = new Tile();
                        this._tileArray[index2, index1] = tile;
                    }
                    ushort wall = tile.wall;
                    if (wall > (ushort)0 && !this.FullTile(index2, index1))
                    {
                        Color color1 = Lighting.GetColor(index2, index1);
                        if (tile.wallColor() == (byte)31)
                        {
                            color1 = Color.White;
                        }
                        if (color1.R != (byte)0 || color1.G != (byte)0 || (color1.B != (byte)0 || index1 >= underworldLayer))
                        {
                            Main.instance.LoadWall((int)wall);
                            rectangle.X = tile.wallFrameX();
                            rectangle.Y = tile.wallFrameY() + (int)Main.wallFrame[(int)wall] * 180;
                            switch (tile.wall)
                            {
                            case 242:
                            case 243:
                                int num12 = 20;
                                int num13 = ((int)Main.wallFrameCounter[(int)wall] + index2 * 11 + index1 * 27) % (num12 * 8);
                                rectangle.Y = tile.wallFrameY() + 180 * (num13 / num12);
                                break;
                            }
                            if (Lighting.NotRetro && !Main.wallLight[(int)wall] && tile.wall != (ushort)241 && ((tile.wall <(ushort)88 || tile.wall> (ushort) 93) && !WorldGen.SolidTile(tile)))
                            {
                                Texture2D tileDrawTexture = this.GetTileDrawTexture(tile, index2, index1);
                                if (tile.wall == (ushort)44)
                                {
                                    Color color2 = new Color((int)(byte)Main.DiscoR, (int)(byte)Main.DiscoG, (int)(byte)Main.DiscoB);
                                    vertices.BottomLeftColor  = color2;
                                    vertices.BottomRightColor = color2;
                                    vertices.TopLeftColor     = color2;
                                    vertices.TopRightColor    = color2;
                                }
                                else
                                {
                                    Lighting.GetCornerColors(index2, index1, out vertices, 1f);
                                    if (tile.wallColor() == (byte)31)
                                    {
                                        vertices = WallDrawing._glowPaintColors;
                                    }
                                }
                                tileBatch.Draw(tileDrawTexture, new Vector2((float)(index2 * 16 - (int)screenPosition.X - 8), (float)(index1 * 16 - (int)screenPosition.Y - 8)) + vector2, new Rectangle?(rectangle), vertices, Vector2.Zero, 1f, SpriteEffects.None);
                            }
                            else
                            {
                                Color color2 = color1;
                                if (wall == (ushort)44)
                                {
                                    color2 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
                                }
                                Texture2D tileDrawTexture = this.GetTileDrawTexture(tile, index2, index1);
                                spriteBatch.Draw(tileDrawTexture, new Vector2((float)(index2 * 16 - (int)screenPosition.X - 8), (float)(index1 * 16 - (int)screenPosition.Y - 8)) + vector2, new Rectangle?(rectangle), color2, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                            }
                            if ((int)color1.R > num3 || (int)color1.G > num4 || (int)color1.B > num5)
                            {
                                int  num14 = this._tileArray[index2 - 1, index1].wall <= (ushort)0 ? 0 : (wallBlend[(int)this._tileArray[index2 - 1, index1].wall] != wallBlend[(int)tile.wall] ? 1 : 0);
                                bool flag1 = this._tileArray[index2 + 1, index1].wall > (ushort)0 && wallBlend[(int)this._tileArray[index2 + 1, index1].wall] != wallBlend[(int)tile.wall];
                                bool flag2 = this._tileArray[index2, index1 - 1].wall > (ushort)0 && wallBlend[(int)this._tileArray[index2, index1 - 1].wall] != wallBlend[(int)tile.wall];
                                bool flag3 = this._tileArray[index2, index1 + 1].wall > (ushort)0 && wallBlend[(int)this._tileArray[index2, index1 + 1].wall] != wallBlend[(int)tile.wall];
                                if (num14 != 0)
                                {
                                    spriteBatch.Draw(TextureAssets.WallOutline.Value, new Vector2((float)(index2 * 16 - (int)screenPosition.X), (float)(index1 * 16 - (int)screenPosition.Y)) + vector2, new Rectangle?(new Rectangle(0, 0, 2, 16)), color1, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                                }
                                if (flag1)
                                {
                                    spriteBatch.Draw(TextureAssets.WallOutline.Value, new Vector2((float)(index2 * 16 - (int)screenPosition.X + 14), (float)(index1 * 16 - (int)screenPosition.Y)) + vector2, new Rectangle?(new Rectangle(14, 0, 2, 16)), color1, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                                }
                                if (flag2)
                                {
                                    spriteBatch.Draw(TextureAssets.WallOutline.Value, new Vector2((float)(index2 * 16 - (int)screenPosition.X), (float)(index1 * 16 - (int)screenPosition.Y)) + vector2, new Rectangle?(new Rectangle(0, 0, 16, 2)), color1, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                                }
                                if (flag3)
                                {
                                    spriteBatch.Draw(TextureAssets.WallOutline.Value, new Vector2((float)(index2 * 16 - (int)screenPosition.X), (float)(index1 * 16 - (int)screenPosition.Y + 14)) + vector2, new Rectangle?(new Rectangle(0, 14, 16, 2)), color1, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
                                }
                            }
                        }
                    }
                }
            }
            Main.instance.DrawTileCracks(2, Main.LocalPlayer.hitReplace);
            Main.instance.DrawTileCracks(2, Main.LocalPlayer.hitTile);
            TimeLogger.DrawTime(2, stopwatch.Elapsed.TotalMilliseconds);
        }
コード例 #6
0
        public void DrawWalls()
        {
            float   gfxQuality     = Main.gfxQuality;
            int     offScreenRange = Main.offScreenRange;
            bool    drawToScreen   = Main.drawToScreen;
            Vector2 screenPosition = Main.screenPosition;
            int     screenWidth    = Main.screenWidth;
            int     screenHeight   = Main.screenHeight;
            int     maxTilesX      = Main.maxTilesX;
            int     maxTilesY      = Main.maxTilesY;

            int[]       wallBlend   = Main.wallBlend;
            SpriteBatch spriteBatch = Main.spriteBatch;
            TileBatch   tileBatch   = Main.tileBatch;

            _tileArray = Main.tile;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int     num   = (int)(120f * (1f - gfxQuality) + 40f * gfxQuality);
            int     num2  = (int)((float)num * 0.4f);
            int     num3  = (int)((float)num * 0.35f);
            int     num4  = (int)((float)num * 0.3f);
            Vector2 value = new Vector2(offScreenRange, offScreenRange);

            if (drawToScreen)
            {
                value = Vector2.Zero;
            }
            int num5  = (int)((screenPosition.X - value.X) / 16f - 1f);
            int num6  = (int)((screenPosition.X + (float)screenWidth + value.X) / 16f) + 2;
            int num7  = (int)((screenPosition.Y - value.Y) / 16f - 1f);
            int num8  = (int)((screenPosition.Y + (float)screenHeight + value.Y) / 16f) + 5;
            int num9  = offScreenRange / 16;
            int num10 = offScreenRange / 16;

            if (num5 - num9 < 4)
            {
                num5 = num9 + 4;
            }
            if (num6 + num9 > maxTilesX - 4)
            {
                num6 = maxTilesX - num9 - 4;
            }
            if (num7 - num10 < 4)
            {
                num7 = num10 + 4;
            }
            if (num8 + num10 > maxTilesY - 4)
            {
                num8 = maxTilesY - num10 - 4;
            }
            VertexColors vertices             = default(VertexColors);
            Rectangle    value2               = new Rectangle(0, 0, 32, 32);
            int          underworldLayer      = Main.UnderworldLayer;
            Point        screenOverdrawOffset = Main.GetScreenOverdrawOffset();

            for (int i = num7 - num10 + screenOverdrawOffset.Y; i < num8 + num10 - screenOverdrawOffset.Y; i++)
            {
                for (int j = num5 - num9 + screenOverdrawOffset.X; j < num6 + num9 - screenOverdrawOffset.X; j++)
                {
                    Tile tile = _tileArray[j, i];
                    if (tile == null)
                    {
                        tile             = new Tile();
                        _tileArray[j, i] = tile;
                    }
                    ushort wall = tile.wall;
                    if (wall <= 0 || FullTile(j, i))
                    {
                        continue;
                    }
                    Color color = Lighting.GetColor(j, i);
                    if (tile.wallColor() == 31)
                    {
                        color = Color.White;
                    }
                    if (color.R == 0 && color.G == 0 && color.B == 0 && i < underworldLayer)
                    {
                        continue;
                    }
                    Main.instance.LoadWall(wall);
                    value2.X = tile.wallFrameX();
                    value2.Y = tile.wallFrameY() + Main.wallFrame[wall] * 180;
                    ushort wall2 = tile.wall;
                    if ((uint)(wall2 - 242) <= 1u)
                    {
                        int num11 = 20;
                        int num12 = (Main.wallFrameCounter[wall] + j * 11 + i * 27) % (num11 * 8);
                        value2.Y = tile.wallFrameY() + 180 * (num12 / num11);
                    }
                    if (Lighting.NotRetro && !Main.wallLight[wall] && tile.wall != 241 && (tile.wall < 88 || tile.wall > 93) && !WorldGen.SolidTile(tile))
                    {
                        Texture2D tileDrawTexture = GetTileDrawTexture(tile, j, i);
                        if (tile.wall == 44)
                        {
                            vertices.TopRightColor = (vertices.TopLeftColor = (vertices.BottomRightColor = (vertices.BottomLeftColor = new Color((byte)Main.DiscoR, (byte)Main.DiscoG, (byte)Main.DiscoB))));
                        }
                        else
                        {
                            Lighting.GetCornerColors(j, i, out vertices);
                            if (tile.wallColor() == 31)
                            {
                                vertices = _glowPaintColors;
                            }
                        }
                        tileBatch.Draw(tileDrawTexture, new Vector2(j * 16 - (int)screenPosition.X - 8, i * 16 - (int)screenPosition.Y - 8) + value, value2, vertices, Vector2.Zero, 1f, SpriteEffects.None);
                    }
                    else
                    {
                        Color color2 = color;
                        if (wall == 44)
                        {
                            color2 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
                        }
                        Texture2D tileDrawTexture2 = GetTileDrawTexture(tile, j, i);
                        spriteBatch.Draw(tileDrawTexture2, new Vector2(j * 16 - (int)screenPosition.X - 8, i * 16 - (int)screenPosition.Y - 8) + value, value2, color2, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                    if (color.R > num2 || color.G > num3 || color.B > num4)
                    {
                        bool num13 = _tileArray[j - 1, i].wall > 0 && wallBlend[_tileArray[j - 1, i].wall] != wallBlend[tile.wall];
                        bool flag  = _tileArray[j + 1, i].wall > 0 && wallBlend[_tileArray[j + 1, i].wall] != wallBlend[tile.wall];
                        bool flag2 = _tileArray[j, i - 1].wall > 0 && wallBlend[_tileArray[j, i - 1].wall] != wallBlend[tile.wall];
                        bool flag3 = _tileArray[j, i + 1].wall > 0 && wallBlend[_tileArray[j, i + 1].wall] != wallBlend[tile.wall];
                        if (num13)
                        {
                            spriteBatch.Draw(TextureAssets.WallOutline.get_Value(), new Vector2(j * 16 - (int)screenPosition.X, i * 16 - (int)screenPosition.Y) + value, new Rectangle(0, 0, 2, 16), color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                        }
                        if (flag)
                        {
                            spriteBatch.Draw(TextureAssets.WallOutline.get_Value(), new Vector2(j * 16 - (int)screenPosition.X + 14, i * 16 - (int)screenPosition.Y) + value, new Rectangle(14, 0, 2, 16), color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                        }
                        if (flag2)
                        {
                            spriteBatch.Draw(TextureAssets.WallOutline.get_Value(), new Vector2(j * 16 - (int)screenPosition.X, i * 16 - (int)screenPosition.Y) + value, new Rectangle(0, 0, 16, 2), color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                        }
                        if (flag3)
                        {
                            spriteBatch.Draw(TextureAssets.WallOutline.get_Value(), new Vector2(j * 16 - (int)screenPosition.X, i * 16 - (int)screenPosition.Y + 14) + value, new Rectangle(0, 14, 16, 2), color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                        }
                    }
                }
            }
            Main.instance.DrawTileCracks(2, Main.LocalPlayer.hitReplace);
            Main.instance.DrawTileCracks(2, Main.LocalPlayer.hitTile);
            TimeLogger.DrawTime(2, stopwatch.Elapsed.TotalMilliseconds);
        }
コード例 #7
0
ファイル: WaterShaderData.cs プロジェクト: windlex/mylualib
        // Token: 0x06001200 RID: 4608 RVA: 0x00411D14 File Offset: 0x0040FF14
        private void DrawWaves()
        {
            Vector2        screenPosition = Main.screenPosition;
            Vector2        value          = Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
            Vector2        value2         = -this._lastDistortionDrawOffset / 0.25f + value;
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice arg_52_0       = Main.instance.GraphicsDevice;
            Vector2        dimensions     = new Vector2((float)Main.screenWidth, (float)Main.screenHeight);
            Vector2        value3         = new Vector2(16f, 16f);

            tileBatch.Begin();
            GameShaders.Misc["WaterDistortionObject"].Apply(null);
            if (this._useNPCWaves)
            {
                for (int i = 0; i < 200; i++)
                {
                    if (Main.npc[i] != null && Main.npc[i].active && (Main.npc[i].wet || Main.npc[i].wetCount != 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions, Main.npc[i].position - value3, Main.npc[i].Size + value3))
                    {
                        NPC     nPC     = Main.npc[i];
                        Vector2 vector  = nPC.Center - value2;
                        Vector2 vector2 = nPC.velocity.RotatedBy((double)(-(double)nPC.rotation), default(Vector2)) / new Vector2((float)nPC.height, (float)nPC.width);
                        float   num     = vector2.LengthSquared();
                        num  = num * 0.3f + 0.7f * num * (1024f / (float)(nPC.height * nPC.width));
                        num  = Math.Min(num, 0.08f);
                        num += (nPC.velocity - nPC.oldVelocity).Length() * 0.5f;
                        vector2.Normalize();
                        Vector2 velocity = nPC.velocity;
                        velocity.Normalize();
                        vector -= velocity * 10f;
                        if (!this._useViscosityFilter && (nPC.honeyWet || nPC.lavaWet))
                        {
                            num *= 0.3f;
                        }
                        if (nPC.wet)
                        {
                            tileBatch.Draw(Main.magicPixel, new Vector4(vector.X, vector.Y, (float)nPC.width * 2f, (float)nPC.height * 2f) * 0.25f, null, new VertexColors(new Color(vector2.X * 0.5f + 0.5f, vector2.Y * 0.5f + 0.5f, 0.5f * num)), new Vector2((float)Main.magicPixel.Width / 2f, (float)Main.magicPixel.Height / 2f), SpriteEffects.None, nPC.rotation);
                        }
                        if (nPC.wetCount != 0)
                        {
                            num = nPC.velocity.Length();
                            num = 0.195f * (float)Math.Sqrt((double)num);
                            float scaleFactor = 5f;
                            if (!nPC.wet)
                            {
                                scaleFactor = -20f;
                            }
                            this.QueueRipple(nPC.Center + velocity * scaleFactor, new Color(0.5f, (nPC.wet ? num : (-num)) * 0.5f + 0.5f, 0f, 1f) * 0.5f, new Vector2((float)nPC.width, (float)nPC.height * ((float)nPC.wetCount / 9f)) * MathHelper.Clamp(num * 10f, 0f, 1f), RippleShape.Circle, 0f);
                        }
                    }
                }
            }
            if (this._usePlayerWaves)
            {
                for (int j = 0; j < 255; j++)
                {
                    if (Main.player[j] != null && Main.player[j].active && (Main.player[j].wet || Main.player[j].wetCount != 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions, Main.player[j].position - value3, Main.player[j].Size + value3))
                    {
                        Player  player  = Main.player[j];
                        Vector2 vector3 = player.Center - value2;
                        float   num2    = player.velocity.Length();
                        num2 = 0.05f * (float)Math.Sqrt((double)num2);
                        Vector2 velocity2 = player.velocity;
                        velocity2.Normalize();
                        vector3 -= velocity2 * 10f;
                        if (!this._useViscosityFilter && (player.honeyWet || player.lavaWet))
                        {
                            num2 *= 0.3f;
                        }
                        if (player.wet)
                        {
                            tileBatch.Draw(Main.magicPixel, new Vector4(vector3.X - (float)player.width * 2f * 0.5f, vector3.Y - (float)player.height * 2f * 0.5f, (float)player.width * 2f, (float)player.height * 2f) * 0.25f, new VertexColors(new Color(velocity2.X * 0.5f + 0.5f, velocity2.Y * 0.5f + 0.5f, 0.5f * num2)));
                        }
                        if (player.wetCount != 0)
                        {
                            float scaleFactor2 = 5f;
                            if (!player.wet)
                            {
                                scaleFactor2 = -20f;
                            }
                            num2 *= 3f;
                            this.QueueRipple(player.Center + velocity2 * scaleFactor2, player.wet ? num2 : (-num2), new Vector2((float)player.width, (float)player.height * ((float)player.wetCount / 9f)) * MathHelper.Clamp(num2 * 10f, 0f, 1f), RippleShape.Circle, 0f);
                        }
                    }
                }
            }
            if (this._useProjectileWaves)
            {
                for (int k = 0; k < 1000; k++)
                {
                    Projectile projectile = Main.projectile[k];
                    if (projectile.wet && !projectile.lavaWet)
                    {
                        bool arg_686_0 = !projectile.honeyWet;
                    }
                    bool flag  = projectile.lavaWet;
                    bool flag2 = projectile.honeyWet;
                    bool flag3 = projectile.wet;
                    if (projectile.ignoreWater)
                    {
                        flag3 = true;
                    }
                    if (((projectile != null && projectile.active && ProjectileID.Sets.CanDistortWater[projectile.type]) & flag3) && !ProjectileID.Sets.NoLiquidDistortion[projectile.type] && Collision.CheckAABBvAABBCollision(screenPosition, dimensions, projectile.position - value3, projectile.Size + value3))
                    {
                        if (projectile.ignoreWater)
                        {
                            bool arg_756_0 = Collision.LavaCollision(projectile.position, projectile.width, projectile.height);
                            flag  = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
                            flag2 = Collision.honey;
                            flag3 = (arg_756_0 | flag | flag2);
                            if (!flag3)
                            {
                                goto IL_86A;
                            }
                        }
                        Vector2 vector4 = projectile.Center - value2;
                        float   num3    = projectile.velocity.Length();
                        num3 = 2f * (float)Math.Sqrt((double)(0.05f * num3));
                        Vector2 velocity3 = projectile.velocity;
                        velocity3.Normalize();
                        if (!this._useViscosityFilter && (flag2 | flag))
                        {
                            num3 *= 0.3f;
                        }
                        float num4 = Math.Max(12f, (float)projectile.width * 0.75f);
                        float num5 = Math.Max(12f, (float)projectile.height * 0.75f);
                        tileBatch.Draw(Main.magicPixel, new Vector4(vector4.X - num4 * 0.5f, vector4.Y - num5 * 0.5f, num4, num5) * 0.25f, new VertexColors(new Color(velocity3.X * 0.5f + 0.5f, velocity3.Y * 0.5f + 0.5f, num3 * 0.5f)));
                    }
                    IL_86A:;
                }
            }
            tileBatch.End();
            if (this._useRippleWaves)
            {
                tileBatch.Begin();
                for (int l = 0; l < this._rippleQueueCount; l++)
                {
                    Vector2   vector5            = this._rippleQueue[l].Position - value2;
                    Vector2   size               = this._rippleQueue[l].Size;
                    Rectangle sourceRectangle    = this._rippleQueue[l].SourceRectangle;
                    Texture2D rippleShapeTexture = this._rippleShapeTexture;
                    tileBatch.Draw(rippleShapeTexture, new Vector4(vector5.X, vector5.Y, size.X, size.Y) * 0.25f, new Rectangle?(sourceRectangle), new VertexColors(this._rippleQueue[l].WaveData), new Vector2((float)(sourceRectangle.Width / 2), (float)(sourceRectangle.Height / 2)), SpriteEffects.None, this._rippleQueue[l].Rotation);
                }
                tileBatch.End();
            }
            this._rippleQueueCount = 0;
            if (this._useCustomWaves && this.OnWaveDraw != null)
            {
                tileBatch.Begin();
                this.OnWaveDraw(tileBatch);
                tileBatch.End();
            }
        }
コード例 #8
0
        private void DrawWaves()
        {
            Vector2   screenPosition = Main.screenPosition;
            Vector2   value          = (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange));
            Vector2   value2         = -_lastDistortionDrawOffset / 0.25f + value;
            TileBatch tileBatch      = Main.tileBatch;

            _ = Main.instance.GraphicsDevice;
            Vector2 dimensions = new Vector2(Main.screenWidth, Main.screenHeight);
            Vector2 value3     = new Vector2(16f, 16f);

            tileBatch.Begin();
            GameShaders.Misc["WaterDistortionObject"].Apply();
            if (_useNPCWaves)
            {
                for (int i = 0; i < 200; i++)
                {
                    if (Main.npc[i] == null || !Main.npc[i].active || (!Main.npc[i].wet && Main.npc[i].wetCount == 0) || !Collision.CheckAABBvAABBCollision(screenPosition, dimensions, Main.npc[i].position - value3, Main.npc[i].Size + value3))
                    {
                        continue;
                    }
                    NPC     nPC     = Main.npc[i];
                    Vector2 vector  = nPC.Center - value2;
                    Vector2 vector2 = nPC.velocity.RotatedBy(0f - nPC.rotation) / new Vector2(nPC.height, nPC.width);
                    float   num     = vector2.LengthSquared();
                    num  = num * 0.3f + 0.7f * num * (1024f / (float)(nPC.height * nPC.width));
                    num  = Math.Min(num, 0.08f);
                    num += (nPC.velocity - nPC.oldVelocity).Length() * 0.5f;
                    vector2.Normalize();
                    Vector2 velocity = nPC.velocity;
                    velocity.Normalize();
                    vector -= velocity * 10f;
                    if (!_useViscosityFilter && (nPC.honeyWet || nPC.lavaWet))
                    {
                        num *= 0.3f;
                    }
                    if (nPC.wet)
                    {
                        tileBatch.Draw(TextureAssets.MagicPixel.Value, new Vector4(vector.X, vector.Y, (float)nPC.width * 2f, (float)nPC.height * 2f) * 0.25f, null, new VertexColors(new Color(vector2.X * 0.5f + 0.5f, vector2.Y * 0.5f + 0.5f, 0.5f * num)), new Vector2((float)TextureAssets.MagicPixel.Width() / 2f, (float)TextureAssets.MagicPixel.Height() / 2f), SpriteEffects.None, nPC.rotation);
                    }
                    if (nPC.wetCount != 0)
                    {
                        num = nPC.velocity.Length();
                        num = 0.195f * (float)Math.Sqrt(num);
                        float scaleFactor = 5f;
                        if (!nPC.wet)
                        {
                            scaleFactor = -20f;
                        }
                        QueueRipple(nPC.Center + velocity * scaleFactor, new Color(0.5f, (nPC.wet ? num : (0f - num)) * 0.5f + 0.5f, 0f, 1f) * 0.5f, new Vector2(nPC.width, (float)nPC.height * ((float)(int)nPC.wetCount / 9f)) * MathHelper.Clamp(num * 10f, 0f, 1f), RippleShape.Circle);
                    }
                }
            }
            if (_usePlayerWaves)
            {
                for (int j = 0; j < 255; j++)
                {
                    if (Main.player[j] == null || !Main.player[j].active || (!Main.player[j].wet && Main.player[j].wetCount == 0) || !Collision.CheckAABBvAABBCollision(screenPosition, dimensions, Main.player[j].position - value3, Main.player[j].Size + value3))
                    {
                        continue;
                    }
                    Player  player  = Main.player[j];
                    Vector2 vector3 = player.Center - value2;
                    float   num2    = player.velocity.Length();
                    num2 = 0.05f * (float)Math.Sqrt(num2);
                    Vector2 velocity2 = player.velocity;
                    velocity2.Normalize();
                    vector3 -= velocity2 * 10f;
                    if (!_useViscosityFilter && (player.honeyWet || player.lavaWet))
                    {
                        num2 *= 0.3f;
                    }
                    if (player.wet)
                    {
                        tileBatch.Draw(TextureAssets.MagicPixel.Value, new Vector4(vector3.X - (float)player.width * 2f * 0.5f, vector3.Y - (float)player.height * 2f * 0.5f, (float)player.width * 2f, (float)player.height * 2f) * 0.25f, new VertexColors(new Color(velocity2.X * 0.5f + 0.5f, velocity2.Y * 0.5f + 0.5f, 0.5f * num2)));
                    }
                    if (player.wetCount != 0)
                    {
                        float scaleFactor2 = 5f;
                        if (!player.wet)
                        {
                            scaleFactor2 = -20f;
                        }
                        num2 *= 3f;
                        QueueRipple(player.Center + velocity2 * scaleFactor2, player.wet ? num2 : (0f - num2), new Vector2(player.width, (float)player.height * ((float)(int)player.wetCount / 9f)) * MathHelper.Clamp(num2 * 10f, 0f, 1f), RippleShape.Circle);
                    }
                }
            }
            if (_useProjectileWaves)
            {
                for (int k = 0; k < 1000; k++)
                {
                    Projectile projectile = Main.projectile[k];
                    if (projectile.wet && !projectile.lavaWet)
                    {
                        _ = !projectile.honeyWet;
                    }
                    else
                    {
                        _ = 0;
                    }
                    bool flag  = projectile.lavaWet;
                    bool flag2 = projectile.honeyWet;
                    bool flag3 = projectile.wet;
                    if (projectile.ignoreWater)
                    {
                        flag3 = true;
                    }
                    if (!(projectile != null && projectile.active && ProjectileID.Sets.CanDistortWater[projectile.type] && flag3) || ProjectileID.Sets.NoLiquidDistortion[projectile.type] || !Collision.CheckAABBvAABBCollision(screenPosition, dimensions, projectile.position - value3, projectile.Size + value3))
                    {
                        continue;
                    }
                    if (projectile.ignoreWater)
                    {
                        bool num3 = Collision.LavaCollision(projectile.position, projectile.width, projectile.height);
                        flag  = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
                        flag2 = Collision.honey;
                        if (!(num3 || flag || flag2))
                        {
                            continue;
                        }
                    }
                    Vector2 vector4 = projectile.Center - value2;
                    float   num4    = projectile.velocity.Length();
                    num4 = 2f * (float)Math.Sqrt(0.05f * num4);
                    Vector2 velocity3 = projectile.velocity;
                    velocity3.Normalize();
                    if (!_useViscosityFilter && (flag2 || flag))
                    {
                        num4 *= 0.3f;
                    }
                    float num5 = Math.Max(12f, (float)projectile.width * 0.75f);
                    float num6 = Math.Max(12f, (float)projectile.height * 0.75f);
                    tileBatch.Draw(TextureAssets.MagicPixel.Value, new Vector4(vector4.X - num5 * 0.5f, vector4.Y - num6 * 0.5f, num5, num6) * 0.25f, new VertexColors(new Color(velocity3.X * 0.5f + 0.5f, velocity3.Y * 0.5f + 0.5f, num4 * 0.5f)));
                }
            }
            tileBatch.End();
            if (_useRippleWaves)
            {
                tileBatch.Begin();
                for (int l = 0; l < _rippleQueueCount; l++)
                {
                    Vector2   vector5         = _rippleQueue[l].Position - value2;
                    Vector2   size            = _rippleQueue[l].Size;
                    Rectangle sourceRectangle = _rippleQueue[l].SourceRectangle;
                    Texture2D value4          = _rippleShapeTexture.Value;
                    tileBatch.Draw(value4, new Vector4(vector5.X, vector5.Y, size.X, size.Y) * 0.25f, sourceRectangle, new VertexColors(_rippleQueue[l].WaveData), new Vector2(sourceRectangle.Width / 2, sourceRectangle.Height / 2), SpriteEffects.None, _rippleQueue[l].Rotation);
                }
                tileBatch.End();
            }
            _rippleQueueCount = 0;
            if (_useCustomWaves && this.OnWaveDraw != null)
            {
                tileBatch.Begin();
                this.OnWaveDraw(tileBatch);
                tileBatch.End();
            }
        }
コード例 #9
0
        private void DrawWaves()
        {
            Vector2        screenPosition = Main.screenPosition;
            Vector2        vector2_1      = -this._lastDistortionDrawOffset / 0.25f + (Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange));
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;
            Vector2        dimensions1    = new Vector2((float)Main.screenWidth, (float)Main.screenHeight);
            Vector2        vector2_2      = new Vector2(16f, 16f);

            tileBatch.Begin();
            GameShaders.Misc["WaterDistortionObject"].Apply(new DrawData?());
            if (this._useNPCWaves)
            {
                for (int index = 0; index < 200; ++index)
                {
                    if (Main.npc[index] != null && Main.npc[index].active && (Main.npc[index].wet || (int)Main.npc[index].wetCount != 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Main.npc[index].position - vector2_2, Main.npc[index].Size + vector2_2))
                    {
                        NPC     npc       = Main.npc[index];
                        Vector2 vector2_3 = npc.Center - vector2_1;
                        Vector2 vector2_4 = npc.velocity.RotatedBy(-(double)npc.rotation, new Vector2()) / new Vector2((float)npc.height, (float)npc.width);
                        float   num1      = vector2_4.LengthSquared();
                        float   num2      = Math.Min((float)((double)num1 * 0.300000011920929 + 0.699999988079071 * (double)num1 * (1024.0 / (double)(npc.height * npc.width))), 0.08f) + (npc.velocity - npc.oldVelocity).Length() * 0.5f;
                        vector2_4.Normalize();
                        Vector2 velocity = npc.velocity;
                        velocity.Normalize();
                        vector2_3 -= velocity * 10f;
                        if (!this._useViscosityFilter && (npc.honeyWet || npc.lavaWet))
                        {
                            num2 *= 0.3f;
                        }
                        if (npc.wet)
                        {
                            tileBatch.Draw(Main.magicPixel, new Vector4(vector2_3.X, vector2_3.Y, (float)npc.width * 2f, (float)npc.height * 2f) * 0.25f, new Rectangle?(), new VertexColors(new Color((float)((double)vector2_4.X * 0.5 + 0.5), (float)((double)vector2_4.Y * 0.5 + 0.5), 0.5f * num2)), new Vector2((float)Main.magicPixel.Width / 2f, (float)Main.magicPixel.Height / 2f), SpriteEffects.None, npc.rotation);
                        }
                        if ((int)npc.wetCount != 0)
                        {
                            float num3 = 0.195f * (float)Math.Sqrt((double)npc.velocity.Length());
                            float num4 = 5f;
                            if (!npc.wet)
                            {
                                num4 = -20f;
                            }
                            this.QueueRipple(npc.Center + velocity * num4, new Color(0.5f, (float)((npc.wet ? (double)num3 : -(double)num3) * 0.5 + 0.5), 0.0f, 1f) * 0.5f, new Vector2((float)npc.width, (float)npc.height * ((float)npc.wetCount / 9f)) * MathHelper.Clamp(num3 * 10f, 0.0f, 1f), RippleShape.Circle, 0.0f);
                        }
                    }
                }
            }
            if (this._usePlayerWaves)
            {
                for (int index = 0; index < (int)byte.MaxValue; ++index)
                {
                    if (Main.player[index] != null && Main.player[index].active && (Main.player[index].wet || (int)Main.player[index].wetCount != 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Main.player[index].position - vector2_2, Main.player[index].Size + vector2_2))
                    {
                        Player  player    = Main.player[index];
                        Vector2 vector2_3 = player.Center - vector2_1;
                        float   num1      = 0.05f * (float)Math.Sqrt((double)player.velocity.Length());
                        Vector2 velocity  = player.velocity;
                        velocity.Normalize();
                        Vector2 vector2_4 = vector2_3 - velocity * 10f;
                        if (!this._useViscosityFilter && (player.honeyWet || player.lavaWet))
                        {
                            num1 *= 0.3f;
                        }
                        if (player.wet)
                        {
                            tileBatch.Draw(Main.magicPixel, new Vector4(vector2_4.X - (float)((double)player.width * 2.0 * 0.5), vector2_4.Y - (float)((double)player.height * 2.0 * 0.5), (float)player.width * 2f, (float)player.height * 2f) * 0.25f, new VertexColors(new Color((float)((double)velocity.X * 0.5 + 0.5), (float)((double)velocity.Y * 0.5 + 0.5), 0.5f * num1)));
                        }
                        if ((int)player.wetCount != 0)
                        {
                            float num2 = 5f;
                            if (!player.wet)
                            {
                                num2 = -20f;
                            }
                            float num3 = num1 * 3f;
                            this.QueueRipple(player.Center + velocity * num2, player.wet ? num3 : -num3, new Vector2((float)player.width, (float)player.height * ((float)player.wetCount / 9f)) * MathHelper.Clamp(num3 * 10f, 0.0f, 1f), RippleShape.Circle, 0.0f);
                        }
                    }
                }
            }
            if (this._useProjectileWaves)
            {
                for (int index = 0; index < 1000; ++index)
                {
                    Projectile projectile = Main.projectile[index];
                    bool       flag1      = projectile.wet && !projectile.lavaWet && !projectile.honeyWet;
                    bool       flag2      = projectile.lavaWet;
                    bool       flag3      = projectile.honeyWet;
                    bool       flag4      = projectile.wet;
                    if (projectile.ignoreWater)
                    {
                        flag4 = true;
                    }
                    if (projectile != null && projectile.active && (ProjectileID.Sets.CanDistortWater[projectile.type] && flag4) && (!ProjectileID.Sets.NoLiquidDistortion[projectile.type] && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, projectile.position - vector2_2, projectile.Size + vector2_2)))
                    {
                        if (projectile.ignoreWater)
                        {
                            bool flag5 = Collision.LavaCollision(projectile.position, projectile.width, projectile.height);
                            flag2 = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
                            flag3 = Collision.honey;
                            if (!flag5 && !flag2 && !flag3)
                            {
                                continue;
                            }
                        }
                        Vector2 vector2_3 = projectile.Center - vector2_1;
                        float   num       = 2f * (float)Math.Sqrt(0.0500000007450581 * (double)projectile.velocity.Length());
                        Vector2 velocity  = projectile.velocity;
                        velocity.Normalize();
                        if (!this._useViscosityFilter && (flag3 || flag2))
                        {
                            num *= 0.3f;
                        }
                        float z = Math.Max(12f, (float)projectile.width * 0.75f);
                        float w = Math.Max(12f, (float)projectile.height * 0.75f);
                        tileBatch.Draw(Main.magicPixel, new Vector4(vector2_3.X - z * 0.5f, vector2_3.Y - w * 0.5f, z, w) * 0.25f, new VertexColors(new Color((float)((double)velocity.X * 0.5 + 0.5), (float)((double)velocity.Y * 0.5 + 0.5), num * 0.5f)));
                    }
                }
            }
            tileBatch.End();
            if (this._useRippleWaves)
            {
                tileBatch.Begin();
                for (int index = 0; index < this._rippleQueueCount; ++index)
                {
                    Vector2   vector2_3          = this._rippleQueue[index].Position - vector2_1;
                    Vector2   size               = this._rippleQueue[index].Size;
                    Rectangle sourceRectangle    = this._rippleQueue[index].SourceRectangle;
                    Texture2D rippleShapeTexture = this._rippleShapeTexture;
                    tileBatch.Draw(rippleShapeTexture, new Vector4(vector2_3.X, vector2_3.Y, size.X, size.Y) * 0.25f, new Rectangle?(sourceRectangle), new VertexColors(this._rippleQueue[index].WaveData), new Vector2((float)(sourceRectangle.Width / 2), (float)(sourceRectangle.Height / 2)), SpriteEffects.None, this._rippleQueue[index].Rotation);
                }
                tileBatch.End();
            }
            this._rippleQueueCount = 0;
            if (!this._useCustomWaves || this.OnWaveDraw == null)
            {
                return;
            }
            tileBatch.Begin();
            this.OnWaveDraw(tileBatch);
            tileBatch.End();
        }
コード例 #10
0
        private void StepLiquids()
        {
            this._isWaveBufferDirty = true;
            Vector2        vector2_1      = Main.drawToScreen ? Vector2.get_Zero() : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
            Vector2        vector2_2      = Vector2.op_Subtraction(vector2_1, Main.screenPosition);
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;

            graphicsDevice.SetRenderTarget(this._distortionTarget);
            if (this._clearNextFrame)
            {
                graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.0f, 1f));
                this._clearNextFrame = false;
            }
            this.DrawWaves();
            graphicsDevice.SetRenderTarget(this._distortionTargetSwap);
            graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.5f, 1f));
            Main.tileBatch.Begin();
            Vector2 vector2_3 = Vector2.op_Multiply(vector2_2, 0.25f);

            vector2_3.X = (__Null)Math.Floor((double)vector2_3.X);
            vector2_3.Y = (__Null)Math.Floor((double)vector2_3.Y);
            Vector2 vector2_4 = Vector2.op_Subtraction(vector2_3, this._lastDistortionDrawOffset);

            this._lastDistortionDrawOffset = vector2_3;
            tileBatch.Draw((Texture2D)this._distortionTarget, new Vector4((float)vector2_4.X, (float)vector2_4.Y, (float)((Texture2D)this._distortionTarget).get_Width(), (float)((Texture2D)this._distortionTarget).get_Height()), new VertexColors(Color.get_White()));
            GameShaders.Misc["WaterProcessor"].Apply(new DrawData?(new DrawData((Texture2D)this._distortionTarget, Vector2.get_Zero(), Color.get_White())));
            tileBatch.End();
            RenderTarget2D distortionTarget = this._distortionTarget;

            this._distortionTarget     = this._distortionTargetSwap;
            this._distortionTargetSwap = distortionTarget;
            if (this._useViscosityFilter)
            {
                LiquidRenderer.Instance.SetWaveMaskData(ref this._viscosityMaskChain[this._activeViscosityMask]);
                tileBatch.Begin();
                Rectangle cachedDrawArea = LiquidRenderer.Instance.GetCachedDrawArea();
                Rectangle rectangle;
                // ISSUE: explicit reference operation
                ((Rectangle)@rectangle).\u002Ector(0, 0, (int)cachedDrawArea.Height, (int)cachedDrawArea.Width);
                Vector4 vector4_1;
                // ISSUE: explicit reference operation
                ((Vector4)@vector4_1).\u002Ector((float)(cachedDrawArea.X + cachedDrawArea.Width), (float)cachedDrawArea.Y, (float)cachedDrawArea.Height, (float)cachedDrawArea.Width);
                Vector4 vector4_2 = Vector4.op_Multiply(vector4_1, 16f);
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                Vector4& local1 = @vector4_2;
                // ISSUE: explicit reference operation
                // ISSUE: variable of the null type
                __Null local2 = (^ local1).X - vector2_1.X;
                // ISSUE: explicit reference operation
                (^ local1).X = local2;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                Vector4& local3 = @vector4_2;
                // ISSUE: explicit reference operation
                // ISSUE: variable of the null type
                __Null local4 = (^ local3).Y - vector2_1.Y;
                // ISSUE: explicit reference operation
                (^ local3).Y = local4;
                Vector4 destination = Vector4.op_Multiply(vector4_2, 0.25f);
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                Vector4& local5 = @destination;
                // ISSUE: explicit reference operation
                // ISSUE: variable of the null type
                __Null local6 = (^ local5).X + vector2_3.X;
                // ISSUE: explicit reference operation
                (^ local5).X = local6;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                Vector4& local7 = @destination;
                // ISSUE: explicit reference operation
                // ISSUE: variable of the null type
                __Null local8 = (^ local7).Y + vector2_3.Y;
                // ISSUE: explicit reference operation
                (^ local7).Y = local8;
                graphicsDevice.get_SamplerStates().set_Item(0, (SamplerState)SamplerState.PointClamp);
                tileBatch.Draw(this._viscosityMaskChain[this._activeViscosityMask], destination, new Rectangle?(rectangle), new VertexColors(Color.get_White()), Vector2.get_Zero(), (SpriteEffects)1, 1.570796f);
                tileBatch.End();
                ++this._activeViscosityMask;
                this._activeViscosityMask %= this._viscosityMaskChain.Length;
            }
            graphicsDevice.SetRenderTarget((RenderTarget2D)null);
        }
コード例 #11
0
        private void DrawWaves()
        {
            Vector2        screenPosition = Main.screenPosition;
            Vector2        vector2_1      = Vector2.op_Addition(Vector2.op_Division(Vector2.op_UnaryNegation(this._lastDistortionDrawOffset), 0.25f), Main.drawToScreen ? Vector2.get_Zero() : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange));
            TileBatch      tileBatch      = Main.tileBatch;
            GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;
            Vector2        dimensions1;

            // ISSUE: explicit reference operation
            ((Vector2)@dimensions1).\u002Ector((float)Main.screenWidth, (float)Main.screenHeight);
            Vector2 vector2_2;

            // ISSUE: explicit reference operation
            ((Vector2)@vector2_2).\u002Ector(16f, 16f);
            tileBatch.Begin();
            GameShaders.Misc["WaterDistortionObject"].Apply(new DrawData?());
            if (this._useNPCWaves)
            {
                for (int index = 0; index < 200; ++index)
                {
                    if (Main.npc[index] != null && Main.npc[index].active && (Main.npc[index].wet || (int)Main.npc[index].wetCount != 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Vector2.op_Subtraction(Main.npc[index].position, vector2_2), Vector2.op_Addition(Main.npc[index].Size, vector2_2)))
                    {
                        NPC     npc       = Main.npc[index];
                        Vector2 vector2_3 = Vector2.op_Subtraction(npc.Center, vector2_1);
                        Vector2 vector2_4 = Vector2.op_Division(npc.velocity.RotatedBy(-(double)npc.rotation, (Vector2)null), new Vector2((float)npc.height, (float)npc.width));
                        // ISSUE: explicit reference operation
                        float   num1      = ((Vector2)@vector2_4).LengthSquared();
                        double  num2      = (double)Math.Min((float)((double)num1 * 0.300000011920929 + 0.699999988079071 * (double)num1 * (1024.0 / (double)(npc.height * npc.width))), 0.08f);
                        Vector2 vector2_5 = Vector2.op_Subtraction(npc.velocity, npc.oldVelocity);
                        // ISSUE: explicit reference operation
                        double num3 = (double)((Vector2)@vector2_5).Length() * 0.5;
                        float  num4 = (float)(num2 + num3);
                        // ISSUE: explicit reference operation
                        ((Vector2)@vector2_4).Normalize();
                        Vector2 velocity = npc.velocity;
                        // ISSUE: explicit reference operation
                        ((Vector2)@velocity).Normalize();
                        vector2_3 = Vector2.op_Subtraction(vector2_3, Vector2.op_Multiply(velocity, 10f));
                        if (!this._useViscosityFilter && (npc.honeyWet || npc.lavaWet))
                        {
                            num4 *= 0.3f;
                        }
                        if (npc.wet)
                        {
                            tileBatch.Draw(Main.magicPixel, Vector4.op_Multiply(new Vector4((float)vector2_3.X, (float)vector2_3.Y, (float)npc.width * 2f, (float)npc.height * 2f), 0.25f), new Rectangle?(), new VertexColors(new Color((float)(vector2_4.X * 0.5 + 0.5), (float)(vector2_4.Y * 0.5 + 0.5), 0.5f * num4)), new Vector2((float)Main.magicPixel.get_Width() / 2f, (float)Main.magicPixel.get_Height() / 2f), (SpriteEffects)0, npc.rotation);
                        }
                        if ((int)npc.wetCount != 0)
                        {
                            // ISSUE: explicit reference operation
                            float num5 = 0.195f * (float)Math.Sqrt((double)((Vector2)@npc.velocity).Length());
                            float num6 = 5f;
                            if (!npc.wet)
                            {
                                num6 = -20f;
                            }
                            this.QueueRipple(Vector2.op_Addition(npc.Center, Vector2.op_Multiply(velocity, num6)), Color.op_Multiply(new Color(0.5f, (float)((npc.wet ? (double)num5 : -(double)num5) * 0.5 + 0.5), 0.0f, 1f), 0.5f), Vector2.op_Multiply(new Vector2((float)npc.width, (float)npc.height * ((float)npc.wetCount / 9f)), MathHelper.Clamp(num5 * 10f, 0.0f, 1f)), RippleShape.Circle, 0.0f);
                        }
                    }
                }
            }
            if (this._usePlayerWaves)
            {
                for (int index = 0; index < (int)byte.MaxValue; ++index)
                {
                    if (Main.player[index] != null && Main.player[index].active && (Main.player[index].wet || (int)Main.player[index].wetCount != 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Vector2.op_Subtraction(Main.player[index].position, vector2_2), Vector2.op_Addition(Main.player[index].Size, vector2_2)))
                    {
                        Player  player    = Main.player[index];
                        Vector2 vector2_3 = Vector2.op_Subtraction(player.Center, vector2_1);
                        // ISSUE: explicit reference operation
                        float   num1     = 0.05f * (float)Math.Sqrt((double)((Vector2)@player.velocity).Length());
                        Vector2 velocity = player.velocity;
                        // ISSUE: explicit reference operation
                        ((Vector2)@velocity).Normalize();
                        Vector2 vector2_4 = Vector2.op_Subtraction(vector2_3, Vector2.op_Multiply(velocity, 10f));
                        if (!this._useViscosityFilter && (player.honeyWet || player.lavaWet))
                        {
                            num1 *= 0.3f;
                        }
                        if (player.wet)
                        {
                            tileBatch.Draw(Main.magicPixel, Vector4.op_Multiply(new Vector4((float)(vector2_4.X - (double)player.width * 2.0 * 0.5), (float)(vector2_4.Y - (double)player.height * 2.0 * 0.5), (float)player.width * 2f, (float)player.height * 2f), 0.25f), new VertexColors(new Color((float)(velocity.X * 0.5 + 0.5), (float)(velocity.Y * 0.5 + 0.5), 0.5f * num1)));
                        }
                        if ((int)player.wetCount != 0)
                        {
                            float num2 = 5f;
                            if (!player.wet)
                            {
                                num2 = -20f;
                            }
                            float num3 = num1 * 3f;
                            this.QueueRipple(Vector2.op_Addition(player.Center, Vector2.op_Multiply(velocity, num2)), player.wet ? num3 : -num3, Vector2.op_Multiply(new Vector2((float)player.width, (float)player.height * ((float)player.wetCount / 9f)), MathHelper.Clamp(num3 * 10f, 0.0f, 1f)), RippleShape.Circle, 0.0f);
                        }
                    }
                }
            }
            if (this._useProjectileWaves)
            {
                for (int index = 0; index < 1000; ++index)
                {
                    Projectile projectile = Main.projectile[index];
                    bool       flag1      = projectile.wet && !projectile.lavaWet && !projectile.honeyWet;
                    bool       flag2      = projectile.lavaWet;
                    bool       flag3      = projectile.honeyWet;
                    bool       flag4      = projectile.wet;
                    if (projectile.ignoreWater)
                    {
                        flag4 = true;
                    }
                    if (projectile != null && projectile.active && (ProjectileID.Sets.CanDistortWater[projectile.type] && flag4) && (!ProjectileID.Sets.NoLiquidDistortion[projectile.type] && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Vector2.op_Subtraction(projectile.position, vector2_2), Vector2.op_Addition(projectile.Size, vector2_2))))
                    {
                        if (projectile.ignoreWater)
                        {
                            bool flag5 = Collision.LavaCollision(projectile.position, projectile.width, projectile.height);
                            flag2 = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
                            flag3 = Collision.honey;
                            if (!flag5 && !flag2 && !flag3)
                            {
                                continue;
                            }
                        }
                        Vector2 vector2_3 = Vector2.op_Subtraction(projectile.Center, vector2_1);
                        // ISSUE: explicit reference operation
                        float   num1     = 2f * (float)Math.Sqrt(0.0500000007450581 * (double)((Vector2)@projectile.velocity).Length());
                        Vector2 velocity = projectile.velocity;
                        // ISSUE: explicit reference operation
                        ((Vector2)@velocity).Normalize();
                        if (!this._useViscosityFilter && (flag3 || flag2))
                        {
                            num1 *= 0.3f;
                        }
                        float num2 = Math.Max(12f, (float)projectile.width * 0.75f);
                        float num3 = Math.Max(12f, (float)projectile.height * 0.75f);
                        tileBatch.Draw(Main.magicPixel, Vector4.op_Multiply(new Vector4((float)(vector2_3.X - (double)num2 * 0.5), (float)(vector2_3.Y - (double)num3 * 0.5), num2, num3), 0.25f), new VertexColors(new Color((float)(velocity.X * 0.5 + 0.5), (float)(velocity.Y * 0.5 + 0.5), num1 * 0.5f)));
                    }
                }
            }
            tileBatch.End();
            if (this._useRippleWaves)
            {
                tileBatch.Begin();
                for (int index = 0; index < this._rippleQueueCount; ++index)
                {
                    Vector2   vector2_3          = Vector2.op_Subtraction(this._rippleQueue[index].Position, vector2_1);
                    Vector2   size               = this._rippleQueue[index].Size;
                    Rectangle sourceRectangle    = this._rippleQueue[index].SourceRectangle;
                    Texture2D rippleShapeTexture = this._rippleShapeTexture;
                    tileBatch.Draw(rippleShapeTexture, Vector4.op_Multiply(new Vector4((float)vector2_3.X, (float)vector2_3.Y, (float)size.X, (float)size.Y), 0.25f), new Rectangle?(sourceRectangle), new VertexColors(this._rippleQueue[index].WaveData), new Vector2((float)(sourceRectangle.Width / 2), (float)(sourceRectangle.Height / 2)), (SpriteEffects)0, this._rippleQueue[index].Rotation);
                }
                tileBatch.End();
            }
            this._rippleQueueCount = 0;
            if (!this._useCustomWaves || this.OnWaveDraw == null)
            {
                return;
            }
            tileBatch.Begin();
            this.OnWaveDraw(tileBatch);
            tileBatch.End();
        }