public override void Render()
        {
            Vector2 beamOrigin = boss.BeamOrigin;
            Vector2 vector1    = Calc.AngleToVector(angle, beamSprite.Width);

            beamSprite.Rotation      = angle;
            beamSprite.Color         = Color.White * beamAlpha;
            beamStartSprite.Rotation = angle;
            beamStartSprite.Color    = Color.White * beamAlpha;
            if (beamSprite.CurrentAnimationID == "shoot")
            {
                beamOrigin += Calc.AngleToVector(angle, 8f);
            }

            for (var index = 0; index < 15; ++index)
            {
                beamSprite.RenderPosition = beamOrigin;
                beamSprite.Render();
                beamOrigin += vector1;
            }

            if (beamSprite.CurrentAnimationID == "shoot")
            {
                beamStartSprite.RenderPosition = boss.BeamOrigin;
                beamStartSprite.Render();
            }

            GameplayRenderer.End();
            Vector2 vector2     = vector1.SafeNormalize();
            Vector2 vector2_1   = vector2.Perpendicular();
            Color   color       = Color.Black * sideFadeAlpha * 0.35f;
            Color   transparent = Color.Transparent;
            Vector2 vector2_2   = vector2 * 4000f;
            Vector2 vector2_3   = vector2_1 * 120f;
            var     v           = 0;

            Quad(ref v, beamOrigin, -vector2_2 + vector2_3 * 2f, vector2_2 + vector2_3 * 2f, vector2_2 + vector2_3,
                 -vector2_2 + vector2_3, color, color);
            Quad(ref v, beamOrigin, -vector2_2 + vector2_3, vector2_2 + vector2_3, vector2_2, -vector2_2, color,
                 transparent);
            Quad(ref v, beamOrigin, -vector2_2, vector2_2, vector2_2 - vector2_3, -vector2_2 - vector2_3, transparent,
                 color);
            Quad(ref v, beamOrigin, -vector2_2 - vector2_3, vector2_2 - vector2_3, vector2_2 - vector2_3 * 2f,
                 -vector2_2 - vector2_3 * 2f, color, color);
            GFX.DrawVertices((Scene as Level).Camera.Matrix, fade, fade.Length);
            GameplayRenderer.Begin();
        }
        public override void Render()
        {
            Vector2 beamOrigin = _beamOrigin;
            Vector2 vector     = Calc.AngleToVector(_angle, _beamSprite.Width);

            _beamSprite.Rotation      = _angle;
            _beamSprite.Color         = Color.White * _beamAlpha;
            _beamStartSprite.Rotation = _angle;
            _beamStartSprite.Color    = Color.White * _beamAlpha;
            if (_beamSprite.CurrentAnimationID == "shoot")
            {
                beamOrigin += Calc.AngleToVector(_angle, 8f);
            }
            for (int i = 0; i < 15; i++)
            {
                _beamSprite.RenderPosition = beamOrigin;
                _beamSprite.Render();
                beamOrigin += vector;
            }
            if (_beamSprite.CurrentAnimationID == "shoot")
            {
                _beamStartSprite.RenderPosition = _beamOrigin;
                _beamStartSprite.Render();
            }
            GameplayRenderer.End();
            Vector2 vector2     = vector.SafeNormalize();
            Vector2 vector3     = vector2.Perpendicular();
            Color   color       = Color.Black * _sideFadeAlpha * 0.35f;
            Color   transparent = Color.Transparent;

            vector2 *= 4000f;
            vector3 *= 120f;
            int v = 0;

            Quad(ref v, beamOrigin, -vector2 + vector3 * 2f, vector2 + vector3 * 2f, vector2 + vector3, -vector2 + vector3, color, color);
            Quad(ref v, beamOrigin, -vector2 + vector3, vector2 + vector3, vector2, -vector2, color, transparent);
            Quad(ref v, beamOrigin, -vector2, vector2, vector2 - vector3, -vector2 - vector3, transparent, color);
            Quad(ref v, beamOrigin, -vector2 - vector3, vector2 - vector3, vector2 - vector3 * 2f, -vector2 - vector3 * 2f, color, color);
            GFX.DrawVertices((base.Scene as Level).Camera.Matrix, fade, fade.Length);
            GameplayRenderer.Begin();
        }
Exemplo n.º 3
0
        private static void Player_Render(On.Celeste.Player.orig_Render orig, Player self)
        {
            Level level = self.Scene as Level;

            float   playerRotation = wallPlayerRotations.GetOrDefault(self, new ValueHolder <float>(0f)).value;
            Vector2 renderOffset   = wallPlayerRenderOffset.GetOrDefault(self, new ValueHolder <Vector2>(new Vector2(0f, 0f))).value;

            if (level != null && playerRotation != 0f)
            {
                Camera camera = level.Camera;

                float   originalAngle              = camera.Angle;
                Vector2 originalCameraPosition     = camera.Position;
                Vector2 originalCameraOrigin       = camera.Origin;
                Vector2 originalPlayerPosition     = self.Sprite.Position;
                Vector2 originalPlayerHairPosition = self.Hair.Sprite.Position;

                GameplayRenderer.End();
                camera.Angle          = playerRotation;
                camera.Origin         = self.Position + renderOffset - camera.Position;
                camera.Position      += camera.Origin;
                self.Sprite.Position += renderOffset;
                self.Hair.MoveHairBy(renderOffset);
                GameplayRenderer.Begin();

                orig(self);

                GameplayRenderer.End();
                camera.Angle         = originalAngle;
                camera.Origin        = originalCameraOrigin;
                camera.Position      = originalCameraPosition;
                self.Sprite.Position = originalPlayerPosition;
                self.Hair.MoveHairBy(-renderOffset);
                GameplayRenderer.Begin();
            }
            else
            {
                orig(self);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// ONLY CALL IN RENDER!
        /// Cursed for now
        /// </summary>
        public static RenderTarget2D Get(string path, bool inRender = true)
        {
            if (cache.ContainsKey(path))
            {
                return(cache[path]);
            }

            MTexture       mTexture   = GFX.Game[path];
            RenderTarget2D target     = new RenderTarget2D(Engine.Graphics.GraphicsDevice, mTexture.Width + 2 + (int)mTexture.DrawOffset.X, mTexture.Height + 2 + (int)mTexture.DrawOffset.Y, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
            var            prevTarget = Draw.SpriteBatch.GraphicsDevice.GetRenderTargets();

            if (inRender)
            {
                Draw.SpriteBatch.End();
            }
            Draw.SpriteBatch.Begin();
            Draw.SpriteBatch.GraphicsDevice.SetRenderTarget(target);

            Texture2D texture  = mTexture.Texture.Texture_Safe;
            Rectangle?clipRect = new Rectangle?(mTexture.ClipRect);
            float     scaleFix = mTexture.ScaleFix;
            Vector2   origin   = (Vector2.Zero - mTexture.DrawOffset) / scaleFix;
            Vector2   drawPos  = Vector2.One;

            Draw.SpriteBatch.Draw(texture, drawPos - Vector2.UnitY, clipRect, Color.Black, 0f, origin, scaleFix, SpriteEffects.None, 0f);
            Draw.SpriteBatch.Draw(texture, drawPos + Vector2.UnitY, clipRect, Color.Black, 0f, origin, scaleFix, SpriteEffects.None, 0f);
            Draw.SpriteBatch.Draw(texture, drawPos - Vector2.UnitX, clipRect, Color.Black, 0f, origin, scaleFix, SpriteEffects.None, 0f);
            Draw.SpriteBatch.Draw(texture, drawPos + Vector2.UnitX, clipRect, Color.Black, 0f, origin, scaleFix, SpriteEffects.None, 0f);

            Draw.SpriteBatch.End();
            if (inRender)
            {
                GameplayRenderer.Begin();
            }
            Draw.SpriteBatch.GraphicsDevice.SetRenderTargets(prevTarget);

            cache.Add(path, target);
            return(target);
        }
 public override void Render()
 {
     base.Render();
     if (Activator.IsOn)
     {
         Camera camera = (Scene as Level).Camera;
         if (camera != null)
         {
             for (int i = 0; i < _electricityColorsLerped.Length; i++)
             {
                 _electricityColorsLerped[i] = Color.Lerp(_electricityColors[i], Color.White, Fade);
             }
             int index = 0;
             DrawSimpleLightning(ref index, ref _edgeVerts, _edgeSeed, Position, _start, _end, _electricityColorsLerped[0], 1f + Fade * 1f);
             DrawSimpleLightning(ref index, ref _edgeVerts, _edgeSeed + 1, Position, _start, _end, _electricityColorsLerped[1], 1f + Fade * 1f);
             if (index > 0)
             {
                 GameplayRenderer.End();
                 GFX.DrawVertices(camera.Matrix, _edgeVerts, index);
                 GameplayRenderer.Begin();
             }
         }
     }
 }
        public override void Render()
        {
            GameplayRenderer.End();

            // render the edges of the lava rect.
            if (dirty)
            {
                Vector2 zero = Vector2.Zero;

                Vector2 topLeft     = zero;
                Vector2 topRight    = new Vector2(zero.X + Width, zero.Y);
                Vector2 bottomLeft  = new Vector2(zero.X, zero.Y + Height);
                Vector2 bottomRight = zero + new Vector2(Width, Height);

                Vector2 fadeOffset = new Vector2(Math.Min(Fade, Width / 2f), Math.Min(Fade, Height / 2f));
                vertCount = 0;
                if (OnlyMode == OnlyModes.OnlyLeft)
                {
                    Edge(ref vertCount, topRight, bottomRight, fadeOffset.X);
                    Quad(ref vertCount, topLeft, topRight - new Vector2(fadeOffset.X, 0f), bottomRight - new Vector2(fadeOffset.X, 0f), bottomLeft, CenterColor);
                }
                else if (OnlyMode == OnlyModes.OnlyRight)
                {
                    Edge(ref vertCount, bottomLeft, topLeft, fadeOffset.X);
                    Quad(ref vertCount, topLeft + new Vector2(fadeOffset.X, 0f), topRight, bottomRight, bottomLeft + new Vector2(fadeOffset.X, 0f), CenterColor);
                }

                dirty = false;
            }

            // render the vertices
            Camera camera = (Scene as Level).Camera;

            GFX.DrawVertices(Matrix.CreateTranslation(new Vector3(Entity.Position + Position, 0f)) * camera.Matrix, verts, vertCount);

            GameplayRenderer.Begin();

            Vector2 rectPosition = Entity.Position + Position;

            // render bubbles
            MTexture bubbleTexture = GFX.Game["particles/bubble"];

            for (int i = 0; i < bubbles.Length; i++)
            {
                bubbleTexture.DrawCentered(rectPosition + bubbles[i].Position, SurfaceColor * bubbles[i].Alpha);
            }

            // render surface bubbles
            for (int j = 0; j < surfaceBubbles.Length; j++)
            {
                if (surfaceBubbles[j].Y >= 0f)
                {
                    MTexture surfaceBubbleTexture = surfaceBubbleAnimations[surfaceBubbles[j].Animation][(int)surfaceBubbles[j].Frame];
                    int      bubbleOffset         = (int)(surfaceBubbles[j].Y / SurfaceStep);

                    float x;
                    if (OnlyMode == OnlyModes.OnlyLeft)
                    {
                        x = Width + 7f + Wave(bubbleOffset, Height);
                    }
                    else
                    {
                        x = 1f - Wave(bubbleOffset, Height);
                    }

                    surfaceBubbleTexture.DrawJustified(rectPosition +
                                                       new Vector2(x, OnlyMode == OnlyModes.OnlyRight ? Height - bubbleOffset * SurfaceStep : bubbleOffset * SurfaceStep),
                                                       new Vector2(1f, 0.5f), SurfaceColor);
                }
            }
        }
Exemplo n.º 7
0
        public override void Render()
        {
            Camera camera = SceneAs <Level>().Camera;

            foreach (DreamJellyfish jelly in jellies)
            {
                Rectangle jellyBounds = jelly.ParticleBounds;
                Vector2   pos         = jelly.Position + new Vector2(jellyBounds.X, jellyBounds.Y);

                float left   = pos.X;
                float right  = pos.X + jellyBounds.Width;
                float top    = pos.Y;
                float bottom = pos.Y + jellyBounds.Height;
                if (right < camera.Left || left > camera.Right || bottom < camera.Top || top > camera.Bottom)
                {
                    continue; // Skip jelly rendering if it's not on screen.
                }
                MTexture frame = jelly.Sprite.Texture;

                // Outline
                frame.DrawCentered(jelly.Position + new Vector2(0, -3), Color.White, jelly.Sprite.Scale, jelly.Sprite.Rotation);
                frame.DrawCentered(jelly.Position + new Vector2(0, -5), Color.White, jelly.Sprite.Scale, jelly.Sprite.Rotation);
                frame.DrawCentered(jelly.Position + new Vector2(-1, -4), Color.White, jelly.Sprite.Scale, jelly.Sprite.Rotation);
                frame.DrawCentered(jelly.Position + new Vector2(1, -4), Color.White, jelly.Sprite.Scale, jelly.Sprite.Rotation);

                GameplayRenderer.End();
                // Here we start drawing on a virtual texture.
                Engine.Graphics.GraphicsDevice.SetRenderTarget(renderTarget);
                Engine.Graphics.GraphicsDevice.Clear(Color.Lerp(Color.Black, Color.White, jelly.Flash));

                Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, ColorGrade.Effect);
                for (int i = 0; i < jelly.Particles.Length; i++)
                {
                    int layer = jelly.Particles[i].Layer;

                    Vector2 particlePos = jelly.Particles[i].Position;
                    particlePos += camera.Position * (0.3f + 0.25f * layer);
                    while (particlePos.X < left)
                    {
                        particlePos.X += jellyBounds.Width;
                    }
                    while (particlePos.X > right)
                    {
                        particlePos.X -= jellyBounds.Width;
                    }
                    while (particlePos.Y < top)
                    {
                        particlePos.Y += jellyBounds.Height;
                    }
                    while (particlePos.Y > bottom)
                    {
                        particlePos.Y -= jellyBounds.Height;
                    }

                    Color    color = jelly.AllowDreamDash ? jelly.Particles[i].EnabledColor : jelly.Particles[i].DisabledColor;
                    MTexture mTexture;
                    switch (layer)
                    {
                    case 0: {
                        int num2 = (int)((jelly.Particles[i].TimeOffset * 4f + animTimer) % 4f);
                        mTexture = DreamJellyfish.ParticleTextures[3 - num2];
                        break;
                    }

                    case 1: {
                        int num = (int)((jelly.Particles[i].TimeOffset * 2f + animTimer) % 2f);
                        mTexture = DreamJellyfish.ParticleTextures[1 + num];
                        break;
                    }

                    default:
                        mTexture = DreamJellyfish.ParticleTextures[2];
                        break;
                    }
                    mTexture.DrawCentered(particlePos - pos, color);
                }
                Draw.SpriteBatch.End();

                // We have drawn the dream block background and the stars, and we want to mask it using an alpha mask.
                // The alpha masks are the same images that Gliders have, only with alpha information, no color, so they overlap the region in which we want the background to be visible.

                Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, alphaMaskBlendState, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, ColorGrade.Effect);
                frame.DrawCentered(
                    new Vector2(-1, 10) + new Vector2(jellyBounds.Width, jellyBounds.Height) / 2f,
                    Color.White,
                    jelly.Sprite.Scale,
                    jelly.Sprite.Rotation
                    );
                Draw.SpriteBatch.End();

                // Mask is drawn, we'll switch back to where the game was drawing entities previously.
                Engine.Graphics.GraphicsDevice.SetRenderTarget(GameplayBuffers.Gameplay);
                GameplayRenderer.Begin();
                // Draw Virtual Texture
                Draw.SpriteBatch.Draw(renderTarget, pos, Color.White);
            }
        }