Exemple #1
0
        private void HotspringTarget(On.Terraria.Main.orig_CheckMonoliths orig)
        {
            orig();

            if (Main.gameMenu)
            {
                return;
            }

            var graphics = Main.graphics.GraphicsDevice;

            if (hotspringMapTarget is null || hotspringMapTarget.Size() != new Vector2(Main.screenWidth, Main.screenHeight))
            {
                hotspringMapTarget = new RenderTarget2D(graphics, Main.screenWidth, Main.screenHeight, default, default, default, default, RenderTargetUsage.PreserveContents);
Exemple #2
0
        private void WaterTarget(On.Terraria.Main.orig_CheckMonoliths orig)
        {
            orig();

            if (Main.dedServ)
            {
                return;
            }

            var graphics = Main.graphics.GraphicsDevice;

            if (CatherdalWaterTarget is null || CatherdalWaterTarget.Size() != new Vector2(Main.screenWidth, Main.screenHeight))
            {
                CatherdalWaterTarget = new RenderTarget2D(graphics, Main.screenWidth, Main.screenHeight, default, default, default, default, RenderTargetUsage.PreserveContents);
Exemple #3
0
        private void Main_CheckMonoliths(On.Terraria.Main.orig_CheckMonoliths orig)
        {
            if (Main.graphics.GraphicsDevice != null)
            {
                if (Main.screenWidth != oldScreenWidth || Main.screenHeight != oldScreenHeight)
                {
                    UpdateWindowSize(Main.graphics.GraphicsDevice, Main.screenWidth, Main.screenHeight);
                }
            }

            if (Main.spriteBatch != null && Main.graphics.GraphicsDevice != null && CheckForBalls())
            {
                DrawToTarget(Main.spriteBatch, Main.graphics.GraphicsDevice);
            }

            orig();
        }
Exemple #4
0
        private void DrawTargets(On.Terraria.Main.orig_CheckMonoliths orig)
        {
            //TODO: this may benefit from adding booleans for other places in the code to check if they're going to use the RTs since we don't necessarily need these generated on every frame for some performance improvements

            orig();

            if (Main.gameMenu)
            {
                return;
            }

            if (Main.ActivePlayersCount > 0)
            {
                DrawPlayerTarget();
            }

            if (Main.instance.tileTarget.IsDisposed)
            {
                return;
            }

            RenderTargetBinding[] oldtargets1 = Main.graphics.GraphicsDevice.GetRenderTargets();

            Matrix matrix = Main.GameViewMatrix.ZoomMatrix;

            GraphicsDevice GD = Main.graphics.GraphicsDevice;
            SpriteBatch    sb = Main.spriteBatch;

            GD.SetRenderTarget(ScaledTileTarget);
            GD.Clear(Color.Transparent);

            sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, matrix);
            Main.spriteBatch.Draw(Main.instance.tileTarget, Main.sceneTilePos - Main.screenPosition, Color.White);
            sb.End();

            Main.graphics.GraphicsDevice.SetRenderTargets(oldtargets1);
        }
Exemple #5
0
        private void DrawTargets(On.Terraria.Main.orig_CheckMonoliths orig)
        {
            //TODO: this may benefit from adding booleans for other places in the code to check if they're going to use the RTs since we don't necessarily need these generated on every frame for some performance improvements

            orig();

            if (Main.gameMenu)
            {
                return;
            }

            ReflectionSubConfig reflectionConfig = ModContent.GetInstance <GraphicsConfig>().ReflectionConfig;


            if (reflectionConfig.isReflectingAnything())
            {
                RenderTargetBinding[] oldtargets1 = Main.graphics.GraphicsDevice.GetRenderTargets();
                canUseTarget = false;

                GraphicsDevice GD = Main.graphics.GraphicsDevice;
                SpriteBatch    sb = Main.spriteBatch;

                GD.SetRenderTarget(Target);
                GD.Clear(Color.Transparent);

                Vector2 originalZoom = Main.GameViewMatrix.Zoom;
                Main.GameViewMatrix.Zoom = originalZoom;
                //player draw has its own spritebatch start
                if (reflectionConfig.PlayerReflectionsOn)
                {
                    playerDrawMethod?.Invoke(Main.instance, null);
                }

                if (reflectionConfig.ProjReflectionsOn)
                {
                    drawCachedProjsMethod?.Invoke(Main.instance, new object[] { Main.instance.DrawCacheProjsBehindNPCsAndTiles, true });
                }

                if (reflectionConfig.NpcReflectionsOn)
                {
                    sb.Begin();
                    npcDrawMethod?.Invoke(Main.instance, new object[] { true });
                    sb.End();
                }

                if (reflectionConfig.ProjReflectionsOn)
                {
                    drawCachedProjsMethod?.Invoke(Main.instance, new object[] { Main.instance.DrawCacheProjsBehindNPCs, true });
                }

                if (reflectionConfig.NpcReflectionsOn)
                {
                    sb.Begin();
                    npcDrawMethod?.Invoke(Main.instance, new object[] { false });
                    sb.End();
                    sb.Begin();
                    drawCachedNPCsMethod?.Invoke(Main.instance, new object[] { Main.instance.DrawCacheNPCProjectiles, false });
                    sb.End();
                }
                if (reflectionConfig.ProjReflectionsOn)
                {
                    projectileDrawMethod?.Invoke(Main.instance, null);
                }

                if (reflectionConfig.DustReflectionsOn)
                {
                    dustDrawMethod?.Invoke(Main.instance, null);
                    sb.Begin();
                    goreDrawMethod?.Invoke(Main.instance, null);
                    sb.End();
                }

                GD.SetRenderTarget(reflectionNormalMapTarget);
                GD.Clear(Color.Transparent);

                Main.GameViewMatrix.Zoom = originalZoom;

                Main.spriteBatch.Begin(SpriteSortMode.Texture, default, default, default, default, default, Main.GameViewMatrix.TransformationMatrix);