Example #1
0
 /// <summary>
 /// Handy dandy game method for implementating screen shake
 /// </summary>
 /// <param name="Transform"></param>
 /// <returns></returns>
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     if (!Main.gameMenu)
     {
         shakeTick++;
         if (shakeIntensity >= 0 && shakeTick >= 12)
         {
             shakeIntensity--;
         }
         if (shakeIntensity > 10)
         {
             shakeIntensity = 10;                     //cap it
         }
         if (shakeIntensity < 0)
         {
             shakeIntensity = 0;
         }
         if (!Main.gamePaused && Main.hasFocus)
         {
             Main.screenPosition += new Vector2(
                 shakeIntensity * Main.rand.NextFloatDirection() / 2f,
                 shakeIntensity * Main.rand.NextFloatDirection() / 2f);
         }
     }
     else
     {
         shakeIntensity = 0;
         shakeTick      = 0;
     }
 }
Example #2
0
 public static void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     foreach (var system in HookModifyTransformMatrix.arr)
     {
         system.ModifyTransformMatrix(ref Transform);
     }
 }
Example #3
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     if (Main.gameMenu)
     {
         return;
     }
 }
Example #4
0
 /* Cutscene zoom */
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     if (!Main.gameMenu && Utils.CutSceneManager.playing)
     {
         Transform.Zoom = Utils.CutSceneManager.GetZoom();
     }
 }
Example #5
0
 internal static void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     foreach (Mod mod in ModLoader.Mods)
     {
         mod.ModifyTransformMatrix(ref Transform);
     }
 }
        private static void GetDistance(Player localPlayer, DynamicSpriteFont font, Player player, string nameToShow, out Vector2 namePlatePos, out float namePlateDist, out Vector2 measurement)
        {
            float            uIScale        = Main.UIScale;
            int              screenWidth    = Main.screenWidth;
            int              screenHeight   = Main.screenHeight;
            Vector2          screenPosition = Main.screenPosition;
            SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;

            namePlatePos = font.MeasureString(nameToShow);
            float num = 0f;

            if (player.chatOverhead.timeLeft > 0)
            {
                num = (0f - namePlatePos.Y) * uIScale;
            }
            else if (player.emoteTime > 0)
            {
                num = (0f - namePlatePos.Y) * uIScale;
            }
            Vector2 value    = new Vector2((float)(screenWidth / 2) + screenPosition.X, (float)(screenHeight / 2) + screenPosition.Y);
            Vector2 position = player.position;

            position     += (position - value) * (gameViewMatrix.Zoom - Vector2.One);
            namePlateDist = 0f;
            float num2 = position.X + (float)(player.width / 2) - value.X;
            float num3 = position.Y - namePlatePos.Y - 2f + num - value.Y;
            float num4 = (float)Math.Sqrt(num2 * num2 + num3 * num3);
            int   num5 = screenHeight;

            if (screenHeight > screenWidth)
            {
                num5 = screenWidth;
            }
            num5 = num5 / 2 - 50;
            if (num5 < 100)
            {
                num5 = 100;
            }
            if (num4 < (float)num5)
            {
                namePlatePos.X = position.X + (float)(player.width / 2) - namePlatePos.X / 2f - screenPosition.X;
                namePlatePos.Y = position.Y - namePlatePos.Y - 2f + num - screenPosition.Y;
            }
            else
            {
                namePlateDist  = num4;
                num4           = (float)num5 / num4;
                namePlatePos.X = (float)(screenWidth / 2) + num2 * num4 - namePlatePos.X / 2f;
                namePlatePos.Y = (float)(screenHeight / 2) + num3 * num4 + 40f * uIScale;
            }
            measurement   = font.MeasureString(nameToShow);
            namePlatePos += measurement / 2f;
            namePlatePos *= 1f / uIScale;
            namePlatePos -= measurement / 2f;
            if (localPlayer.gravDir == -1f)
            {
                namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
            }
        }
Example #7
0
        private static Matrix GetNormalizedTransformationmatrix(SpriteViewMatrix matrix)
        {
            Viewport viewport = (Viewport)EMiscShaderData.vpinfo.GetValue(matrix);
            Vector2  vector   = new Vector2((float)viewport.Width, (float)viewport.Height);
            Matrix   matrix2  = Matrix.CreateOrthographicOffCenter(0f, vector.X, vector.Y, 0f, 0f, 1f);

            return(Matrix.Invert(matrix.EffectMatrix) * matrix.ZoomMatrix * matrix2);
        }
Example #8
0
        /// <summary>
        /// Change Zoom
        /// </summary>
        /// <param name="Transform">Screen Transform Matrix</param>
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            if (!Main.gameMenu)
            {
                if (zoom != 1)
                {
                    // Between -1 and 10
                    zoom = MathHelper.Clamp(zoom, -1, 10);

                    //prevent crash
                    if (zoom >= -0.18f && zoom <= 0.18f &&
                        !(zoom <= -0.2f) &&
                        !Main.keyState.IsKeyDown(Keys.OemPlus))
                    {
                        zoom = -0.2f;
                    }
                    if (zoom >= -0.18f && zoom <= 0.18f &&
                        !(zoom <= -0.2f) &&
                        Main.keyState.IsKeyDown(Keys.OemPlus))
                    {
                        zoom = 0.2f;
                    }

                    //Change zoom
                    Main.GameZoomTarget = zoom;
                    Transform.Zoom      = new Vector2(Main.GameZoomTarget);

                    //Flip background if below zero
                    if (flipBackground && zoom < 0)
                    {
                        Main.BackgroundViewMatrix.Zoom = new Vector2(-1, -1);
                    }

                    //Zoom with background if above one
                    if (zoomBackground)
                    {
                        Main.BackgroundViewMatrix.Zoom = new Vector2(Main.GameZoomTarget);
                    }
                }
                // change hotbar scale
                if (hotbarScale != 1f)
                {
                    float[] scale = { hotbarScale, hotbarScale, hotbarScale, hotbarScale, hotbarScale, hotbarScale, hotbarScale, hotbarScale, hotbarScale, hotbarScale }; // for each hotbar slot
                    Main.hotbarScale = scale;
                }
                if (uiScale != 1)
                {
                    // between 0.2 and 2
                    uiScale = MathHelper.Clamp(uiScale, 0.2f, 2);

                    // change UI scale
                    Main.UIScale = uiScale;
                }
            }
        }
Example #9
0
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            if (Rotation != 0)
            {
                Matrix rotation     = Matrix.CreateRotationZ(Rotation);
                Matrix translation  = Matrix.CreateTranslation(new Vector3(Main.screenWidth / 2, Main.screenHeight / 2, 0));
                Matrix translation2 = Matrix.CreateTranslation(new Vector3(Main.screenWidth / -2, Main.screenHeight / -2, 0));

                _transformMatrix.SetValue(Transform, (translation2 * rotation) * translation);
                base.ModifyTransformMatrix(ref Transform);
                Helper.UpdateTilt();
            }
        }
Example #10
0
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            rotation += Main.rand.NextFloat(-0.6f, 0.6f);

            var type  = typeof(SpriteViewMatrix);
            var field = type.GetField("_transformationMatrix", BindingFlags.NonPublic | BindingFlags.Instance);

            Matrix rotation2    = Matrix.CreateRotationZ(rotation);
            Matrix translation  = Matrix.CreateTranslation(new Vector3(Main.screenWidth / 2, Main.screenHeight / 2, 0));
            Matrix translation2 = Matrix.CreateTranslation(new Vector3(Main.screenWidth / -2, Main.screenHeight / -2, 0));

            field.SetValue(Transform, (translation2 * rotation2) * translation);
            base.ModifyTransformMatrix(ref Transform);
        }
Example #11
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     if (Main.gameMenu)
     {
         return;
     }
     if (UnlimitedZoomConfig.Instance.SuperZoom >= 1)
     {
         Transform.Zoom = new Vector2(((float)UnlimitedZoomConfig.Instance.SuperZoom) / 100f);
     }
     if (UnlimitedZoomConfig.Instance.UIZoom >= 1)
     {
         Main.UIScale = ((float)UnlimitedZoomConfig.Instance.UIZoom) / 100f;
     }
 }
Example #12
0
        //private readonly FieldInfo _transformMatrix = typeof(SpriteViewMatrix).GetField("_transformationMatrix", BindingFlags.NonPublic | BindingFlags.Instance);

        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            if (false) //ignore this block
            {
                Matrix rotation     = Matrix.CreateRotationZ(Rotation);
                Matrix translation  = Matrix.CreateTranslation(new Vector3(Main.screenWidth / 2, Main.screenHeight / 2, 0));
                Matrix translation2 = Matrix.CreateTranslation(new Vector3(Main.screenWidth / -2, Main.screenHeight / -2, 0));

                //_transformMatrix.SetValue(Transform, ((translation2 * rotation) * translation));
                //base.ModifyTransformMatrix(ref Transform);
                //Helper.UpdateTilt();
            }

            Transform.Zoom = ZoomHandler.ScaleVector;
            ZoomHandler.UpdateZoom();
        }
Example #13
0
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            if (Rotation != 0)
            {
                var type  = typeof(SpriteViewMatrix);
                var field = type.GetField("_transformationMatrix", BindingFlags.NonPublic | BindingFlags.Instance);

                Matrix rotation     = Matrix.CreateRotationZ(Rotation);
                Matrix translation  = Matrix.CreateTranslation(new Vector3(Main.screenWidth / 2, Main.screenHeight / 2, 0));
                Matrix translation2 = Matrix.CreateTranslation(new Vector3(Main.screenWidth / -2, Main.screenHeight / -2, 0));

                field.SetValue(Transform, (translation2 * rotation) * translation);
                base.ModifyTransformMatrix(ref Transform);
                Helper.UpdateTilt();
            }
        }
Example #14
0
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            Player player = Main.LocalPlayer;

            //Cant shake main menu, :widepeeposad:
            //We'll see about that - goodpro
            //We certainly will - Oli

            if (!Main.gameMenu)
            {
                if (shakeAmount != 0 && ShakeTimer != 0)
                {
                    ShakeTimer--;
                    Vector2 Shakey = new Vector2(player.Center.X + Main.rand.NextFloat(shakeAmount), player.Center.Y + Main.rand.NextFloat(shakeAmount)) - new Vector2(Main.screenWidth / 2, Main.screenHeight / 2);
                    Main.screenPosition = Shakey;
                }
            }
        }
Example #15
0
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            Player player = Main.LocalPlayer;

            //Cant shake main menu, :widepeeposad:
            //We'll see about that - goodpro
            //We certainly will - Oli

            if (!Main.gameMenu)
            {
                if (shakeAmount != 0 && ShakeTimer != 0)
                {
                    ShakeTimer--;
                    Vector2 Shakey = new Vector2(player.Center.X + Main.rand.NextFloat(shakeAmount), player.Center.Y + Main.rand.NextFloat(shakeAmount)) - new Vector2(Main.screenWidth / 2, Main.screenHeight / 2);
                    Main.screenPosition = Shakey;
                }
            }

            if (doingBarrelRoll)
            {
                barrelRollRotation += 1.75f;

                if (barrelRollRotation >= 360)
                {
                    barrelRollRotation = 0;

                    vanillaScreenMatrix.SetValue(Transform, Matrix.CreateRotationZ(0));
                    vanillaUIMatrix.SetValue(Main.instance, Matrix.CreateRotationZ(0));

                    doingBarrelRoll = false;

                    return;
                }

                Matrix rotation     = Matrix.CreateRotationZ(MathHelper.ToRadians(barrelRollRotation));
                Matrix translation  = Matrix.CreateTranslation(new Vector3(Main.screenWidth / 2, Main.screenHeight / 2, 0));
                Matrix translation2 = Matrix.CreateTranslation(new Vector3(Main.screenWidth / -2, Main.screenHeight / -2, 0));

                vanillaScreenMatrix.SetValue(Transform, translation2 * rotation * translation);
                vanillaUIMatrix.SetValue(Main.instance, translation2 * rotation * translation);
            }
        }
Example #16
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     if (!Main.gameMenu && MyWorld.activeEvents.Contains(EventID.tremors))
     {
         screenshakeTimer++;
         if (MyWorld.screenshakeAmount >= 0 && screenshakeTimer >= 5)    // so it doesnt immediately decrease
         {
             MyWorld.screenshakeAmount -= 0.1f;
         }
         if (MyWorld.screenshakeAmount < 0)
         {
             MyWorld.screenshakeAmount = 0;
         }
         Main.screenPosition += new Vector2(MyWorld.screenshakeAmount * Main.rand.NextFloat(), MyWorld.screenshakeAmount * Main.rand.NextFloat()); //NextFloat creates a random value between 0 and 1, multiply screenshake amount for a bit of variety
     }
     else                                                                                                                                          // dont shake on the menu
     {
         MyWorld.screenshakeAmount = 0;
         screenshakeTimer          = 0;
     }
 }
Example #17
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     if (!Main.gameMenu)
     {
         screenshakeTimer++;
         if (tremorTime >= 0 && screenshakeTimer >= 20) // so it doesnt immediately decrease
         {
             tremorTime -= 0.5f;
         }
         if (tremorTime < 0)
         {
             tremorTime = 0;
         }
         Main.screenPosition += new Vector2(tremorTime * Main.rand.NextFloat(), tremorTime * Main.rand.NextFloat()); //NextFloat creates a random value between 0 and 1, multiply screenshake amount for a bit of variety
     }
     else                                                                                                            // dont shake on the menu
     {
         tremorTime       = 0;
         screenshakeTimer = 0;
     }
 }
Example #18
0
        public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
        {
            // 43 + 42 = 85 (width of bathrooms)
            // 65 + (57 + 74) = 196 (width of tunnel)
            Player player = Main.player[Main.myPlayer];

            // Main.tile[2091, 367] /* TopLeft of Bathrooms */
            // Main.tile[640,298] /* TopLeft of Tunnel */
            if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
            {
                Rectangle insideTunnel = new Rectangle(640 * SpookyTerrariaUtils.tileScaling, 298 * SpookyTerrariaUtils.tileScaling, 138 * SpookyTerrariaUtils.tileScaling, 8 * SpookyTerrariaUtils.tileScaling);
                if (player.Hitbox.Intersects(insideTunnel))
                {
                    Transform.Zoom = new Vector2(updateGameZoomTargetValue + 7f);
                }
                Rectangle insideBathrooms = new Rectangle(2091 * SpookyTerrariaUtils.tileScaling, 367 * SpookyTerrariaUtils.tileScaling, 85 * SpookyTerrariaUtils.tileScaling, 26 * SpookyTerrariaUtils.tileScaling);
                if (player.Hitbox.Intersects(insideBathrooms))
                {
                    Transform.Zoom = new Vector2(updateGameZoomTargetValue + 8.75f);
                }
            }
        }
Example #19
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     //this is needed for Boss Radar, so it takes the range at which to draw the icon properly
     ZoomFactor = Transform.Zoom - (Vector2.UnitX + Vector2.UnitY);
 }
Example #20
0
 private bool UpdateMatrixFirst(On.Terraria.Graphics.SpriteViewMatrix.orig_ShouldRebuild orig, SpriteViewMatrix self) => StarlightRiver.Rotation == 0 && orig(self);
        public void Draw()
        {
            int namePlateDistance = Main.teamNamePlateDistance;

            if (namePlateDistance <= 0)
            {
                return;
            }
            SpriteBatch spriteBatch = Main.spriteBatch;

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, (BlendState)null, (SamplerState)null, (DepthStencilState)null, (RasterizerState)null, (Effect)null, Main.UIScaleMatrix);
            PlayerInput.SetZoom_World();
            int     screenWidth     = Main.screenWidth;
            int     screenHeight    = Main.screenHeight;
            Vector2 screenPosition1 = Main.screenPosition;

            PlayerInput.SetZoom_UI();
            float uiScale = Main.UIScale;
            int   num1    = namePlateDistance * 8;

            Player[]         player1        = Main.player;
            int              player2        = Main.myPlayer;
            SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;
            byte             mouseTextColor = Main.mouseTextColor;

            Color[]         teamColor       = Main.teamColor;
            Camera          camera          = Main.Camera;
            IPlayerRenderer playerRenderer  = Main.PlayerRenderer;
            Vector2         screenPosition2 = Main.screenPosition;

            for (int index = 0; index < (int)byte.MaxValue; ++index)
            {
                if (player1[index].active && player2 != index && (!player1[index].dead && player1[player2].team > 0) && player1[player2].team == player1[index].team)
                {
                    string  name         = player1[index].name;
                    Vector2 namePlatePos = FontAssets.MouseText.get_Value().MeasureString(name);
                    float   num2         = 0.0f;
                    if (player1[index].chatOverhead.timeLeft > 0)
                    {
                        num2 = -namePlatePos.Y * uiScale;
                    }
                    else if (player1[index].emoteTime > 0)
                    {
                        num2 = -namePlatePos.Y * uiScale;
                    }
                    Vector2 vector2_1      = new Vector2((float)(screenWidth / 2) + screenPosition1.X, (float)(screenHeight / 2) + screenPosition1.Y);
                    Vector2 position1      = player1[index].position;
                    Vector2 vector2_2      = position1 + (position1 - vector2_1) * (gameViewMatrix.Zoom - Vector2.One);
                    float   num3           = 0.0f;
                    float   num4           = (float)mouseTextColor / (float)byte.MaxValue;
                    Color   namePlateColor = new Color((int)(byte)((double)teamColor[player1[index].team].R * (double)num4), (int)(byte)((double)teamColor[player1[index].team].G * (double)num4), (int)(byte)((double)teamColor[player1[index].team].B * (double)num4), (int)mouseTextColor);
                    float   num5           = vector2_2.X + (float)(player1[index].width / 2) - vector2_1.X;
                    float   num6           = (float)((double)vector2_2.Y - (double)namePlatePos.Y - 2.0) + num2 - vector2_1.Y;
                    float   num7           = (float)Math.Sqrt((double)num5 * (double)num5 + (double)num6 * (double)num6);
                    int     num8           = screenHeight;
                    if (screenHeight > screenWidth)
                    {
                        num8 = screenWidth;
                    }
                    int num9 = num8 / 2 - 50;
                    if (num9 < 100)
                    {
                        num9 = 100;
                    }
                    if ((double)num7 < (double)num9)
                    {
                        namePlatePos.X = (float)((double)vector2_2.X + (double)(player1[index].width / 2) - (double)namePlatePos.X / 2.0) - screenPosition1.X;
                        namePlatePos.Y = (float)((double)vector2_2.Y - (double)namePlatePos.Y - 2.0) + num2 - screenPosition1.Y;
                    }
                    else
                    {
                        num3 = num7;
                        float num10 = (float)num9 / num7;
                        namePlatePos.X = (float)((double)(screenWidth / 2) + (double)num5 * (double)num10 - (double)namePlatePos.X / 2.0);
                        namePlatePos.Y = (float)((double)(screenHeight / 2) + (double)num6 * (double)num10 + 40.0 * (double)uiScale);
                    }
                    Vector2 vector2_3 = FontAssets.MouseText.get_Value().MeasureString(name);
                    namePlatePos += vector2_3 / 2f;
                    namePlatePos *= 1f / uiScale;
                    namePlatePos -= vector2_3 / 2f;
                    if ((double)player1[player2].gravDir == -1.0)
                    {
                        namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
                    }
                    if ((double)num3 > 0.0)
                    {
                        float num10 = 20f;
                        float num11 = -27f - (float)(((double)vector2_3.X - 85.0) / 2.0);
                        float num12 = player1[index].Center.X - player1[player2].Center.X;
                        float num13 = player1[index].Center.Y - player1[player2].Center.Y;
                        float num14 = (float)Math.Sqrt((double)num12 * (double)num12 + (double)num13 * (double)num13);
                        if ((double)num14 <= (double)num1)
                        {
                            string  textValue = Language.GetTextValue("GameUI.PlayerDistance", (object)(int)((double)num14 / 16.0 * 2.0));
                            Vector2 npDistPos = FontAssets.MouseText.get_Value().MeasureString(textValue);
                            npDistPos.X = namePlatePos.X - num11;
                            npDistPos.Y = (float)((double)namePlatePos.Y + (double)vector2_3.Y / 2.0 - (double)npDistPos.Y / 2.0) - num10;
                            LegacyMultiplayerClosePlayersOverlay.DrawPlayerName2(spriteBatch, ref namePlateColor, textValue, ref npDistPos);
                            Color   headBordersColor = Main.GetPlayerHeadBordersColor(player1[index]);
                            Vector2 position2        = new Vector2(namePlatePos.X, namePlatePos.Y - num10);
                            position2.X -= 22f + num11;
                            position2.Y += 8f;
                            playerRenderer.DrawPlayerHead(camera, player1[index], position2, 1f, 0.8f, headBordersColor);
                            Vector2 vector2_4 = npDistPos + screenPosition2 + new Vector2(26f, 20f);
                            if (player1[index].statLife != player1[index].statLifeMax2)
                            {
                                Main.instance.DrawHealthBar(vector2_4.X, vector2_4.Y, player1[index].statLife, player1[index].statLifeMax2, 1f, 1.25f, true);
                            }
                            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.get_Value(), name, namePlatePos + new Vector2(0.0f, -40f), namePlateColor, 0.0f, Vector2.Zero, Vector2.One, -1f, 2f);
                        }
                    }
                    else
                    {
                        LegacyMultiplayerClosePlayersOverlay.DrawPlayerName(spriteBatch, name, ref namePlatePos, ref namePlateColor);
                    }
                }
            }
        }
        private static void GetDistance(
            Player localPlayer,
            DynamicSpriteFont font,
            Player player,
            string nameToShow,
            out Vector2 namePlatePos,
            out float namePlateDist,
            out Vector2 measurement)
        {
            float            uiScale        = Main.UIScale;
            int              screenWidth    = Main.screenWidth;
            int              screenHeight   = Main.screenHeight;
            Vector2          screenPosition = Main.screenPosition;
            SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;

            namePlatePos = font.MeasureString(nameToShow);
            float num1 = 0.0f;

            if (player.chatOverhead.timeLeft > 0)
            {
                num1 = -namePlatePos.Y * uiScale;
            }
            else if (player.emoteTime > 0)
            {
                num1 = -namePlatePos.Y * uiScale;
            }
            Vector2 vector2_1 = new Vector2((float)(screenWidth / 2) + screenPosition.X, (float)(screenHeight / 2) + screenPosition.Y);
            Vector2 position  = player.position;
            Vector2 vector2_2 = position + (position - vector2_1) * (gameViewMatrix.Zoom - Vector2.One);

            namePlateDist = 0.0f;
            float num2 = vector2_2.X + (float)(player.width / 2) - vector2_1.X;
            float num3 = (float)((double)vector2_2.Y - (double)namePlatePos.Y - 2.0) + num1 - vector2_1.Y;
            float num4 = (float)Math.Sqrt((double)num2 * (double)num2 + (double)num3 * (double)num3);
            int   num5 = screenHeight;

            if (screenHeight > screenWidth)
            {
                num5 = screenWidth;
            }
            int num6 = num5 / 2 - 50;

            if (num6 < 100)
            {
                num6 = 100;
            }
            if ((double)num4 < (double)num6)
            {
                namePlatePos.X = (float)((double)vector2_2.X + (double)(player.width / 2) - (double)namePlatePos.X / 2.0) - screenPosition.X;
                namePlatePos.Y = (float)((double)vector2_2.Y - (double)namePlatePos.Y - 2.0) + num1 - screenPosition.Y;
            }
            else
            {
                namePlateDist = num4;
                float num7 = (float)num6 / num4;
                namePlatePos.X = (float)((double)(screenWidth / 2) + (double)num2 * (double)num7 - (double)namePlatePos.X / 2.0);
                namePlatePos.Y = (float)((double)(screenHeight / 2) + (double)num3 * (double)num7 + 40.0 * (double)uiScale);
            }
            measurement   = font.MeasureString(nameToShow);
            namePlatePos += measurement / 2f;
            namePlatePos *= 1f / uiScale;
            namePlatePos -= measurement / 2f;
            if ((double)localPlayer.gravDir != -1.0)
            {
                return;
            }
            namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
        }
Example #23
0
 /// <summary>
 /// Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.)
 /// </summary>
 public virtual void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
 }
        public void Draw()
        {
            int teamNamePlateDistance = Main.teamNamePlateDistance;

            if (teamNamePlateDistance <= 0)
            {
                return;
            }
            SpriteBatch spriteBatch = Main.spriteBatch;

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix);
            PlayerInput.SetZoom_World();
            int     screenWidth    = Main.screenWidth;
            int     screenHeight   = Main.screenHeight;
            Vector2 screenPosition = Main.screenPosition;

            PlayerInput.SetZoom_UI();
            float uIScale = Main.UIScale;
            int   num     = teamNamePlateDistance * 8;

            Player[]         player         = Main.player;
            int              myPlayer       = Main.myPlayer;
            SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;
            byte             mouseTextColor = Main.mouseTextColor;

            Color[]         teamColor       = Main.teamColor;
            Camera          camera          = Main.Camera;
            IPlayerRenderer playerRenderer  = Main.PlayerRenderer;
            Vector2         screenPosition2 = Main.screenPosition;

            for (int i = 0; i < 255; i++)
            {
                if (!player[i].active || myPlayer == i || player[i].dead || player[myPlayer].team <= 0 || player[myPlayer].team != player[i].team)
                {
                    continue;
                }
                string  name         = player[i].name;
                Vector2 namePlatePos = FontAssets.MouseText.get_Value().MeasureString(name);
                float   num2         = 0f;
                if (player[i].chatOverhead.timeLeft > 0)
                {
                    num2 = (0f - namePlatePos.Y) * uIScale;
                }
                else if (player[i].emoteTime > 0)
                {
                    num2 = (0f - namePlatePos.Y) * uIScale;
                }
                Vector2 value    = new Vector2((float)(screenWidth / 2) + screenPosition.X, (float)(screenHeight / 2) + screenPosition.Y);
                Vector2 position = player[i].position;
                position += (position - value) * (gameViewMatrix.Zoom - Vector2.One);
                float num3           = 0f;
                float num4           = (float)(int)mouseTextColor / 255f;
                Color namePlateColor = new Color((byte)((float)(int)teamColor[player[i].team].R * num4), (byte)((float)(int)teamColor[player[i].team].G * num4), (byte)((float)(int)teamColor[player[i].team].B * num4), mouseTextColor);
                float num5           = position.X + (float)(player[i].width / 2) - value.X;
                float num6           = position.Y - namePlatePos.Y - 2f + num2 - value.Y;
                float num7           = (float)Math.Sqrt(num5 * num5 + num6 * num6);
                int   num8           = screenHeight;
                if (screenHeight > screenWidth)
                {
                    num8 = screenWidth;
                }
                num8 = num8 / 2 - 50;
                if (num8 < 100)
                {
                    num8 = 100;
                }
                if (num7 < (float)num8)
                {
                    namePlatePos.X = position.X + (float)(player[i].width / 2) - namePlatePos.X / 2f - screenPosition.X;
                    namePlatePos.Y = position.Y - namePlatePos.Y - 2f + num2 - screenPosition.Y;
                }
                else
                {
                    num3           = num7;
                    num7           = (float)num8 / num7;
                    namePlatePos.X = (float)(screenWidth / 2) + num5 * num7 - namePlatePos.X / 2f;
                    namePlatePos.Y = (float)(screenHeight / 2) + num6 * num7 + 40f * uIScale;
                }
                Vector2 value2 = FontAssets.MouseText.get_Value().MeasureString(name);
                namePlatePos += value2 / 2f;
                namePlatePos *= 1f / uIScale;
                namePlatePos -= value2 / 2f;
                if (player[myPlayer].gravDir == -1f)
                {
                    namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
                }
                if (num3 > 0f)
                {
                    float num9  = 20f;
                    float num10 = -27f;
                    num10 -= (value2.X - 85f) / 2f;
                    num5   = player[i].Center.X - player[myPlayer].Center.X;
                    num6   = player[i].Center.Y - player[myPlayer].Center.Y;
                    float num11 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
                    if (!(num11 > (float)num))
                    {
                        string  textValue = Language.GetTextValue("GameUI.PlayerDistance", (int)(num11 / 16f * 2f));
                        Vector2 npDistPos = FontAssets.MouseText.get_Value().MeasureString(textValue);
                        npDistPos.X = namePlatePos.X - num10;
                        npDistPos.Y = namePlatePos.Y + value2.Y / 2f - npDistPos.Y / 2f - num9;
                        DrawPlayerName2(spriteBatch, ref namePlateColor, textValue, ref npDistPos);
                        Color   playerHeadBordersColor = Main.GetPlayerHeadBordersColor(player[i]);
                        Vector2 position2 = new Vector2(namePlatePos.X, namePlatePos.Y - num9);
                        position2.X -= 22f + num10;
                        position2.Y += 8f;
                        playerRenderer.DrawPlayerHead(camera, player[i], position2, 1f, 0.8f, playerHeadBordersColor);
                        Vector2 vector = npDistPos + screenPosition2 + new Vector2(26f, 20f);
                        if (player[i].statLife != player[i].statLifeMax2)
                        {
                            Main.instance.DrawHealthBar(vector.X, vector.Y, player[i].statLife, player[i].statLifeMax2, 1f, 1.25f, noFlip: true);
                        }
                        ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.get_Value(), name, namePlatePos + new Vector2(0f, -40f), namePlateColor, 0f, Vector2.Zero, Vector2.One);
                    }
                }
                else
                {
                    DrawPlayerName(spriteBatch, name, ref namePlatePos, ref namePlateColor);
                }
            }
        }
Example #25
0
 private bool UpdateMatrixFirst(On.Terraria.Graphics.SpriteViewMatrix.orig_ShouldRebuild orig, SpriteViewMatrix self) => orig(self);
Example #26
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     IoCHooks.Call(out object _, this.ModifyTransformMatrix_Method);
 }
Example #27
0
 private bool UpdateMatrixFirst(On.Terraria.Graphics.SpriteViewMatrix.orig_ShouldRebuild orig, SpriteViewMatrix self)
 {
     return(false);
 }
Example #28
0
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     zoomValue = Transform.Zoom;
     base.ModifyTransformMatrix(ref Transform);
 }
 public override void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
 {
     Transform.Zoom = new Vector2(Main.GameZoomTarget);
 }