public void BuildRenderList()
        {
            var entityPlayer = new EntityPlayerListRender(
                structs.NickName,
                structs.PlayerColor,
                10,
                structs.PosX,
                structs.PosY,
                structs.PosZ,
                structs.ViewX,
                structs.Weapons,
                structs.Side,
                structs.HealthPercent,
                structs.Pose,
                structs.Cheater);

            if (structs.LocalPlayer)
            {
                HelperOpenGL.PlayerListToRenderPre.Insert(0, entityPlayer);
            }
            else
            {
                HelperOpenGL.PlayerListToRenderPre.Add(entityPlayer);
            }
        }
Exemple #2
0
        // Main Draw Cycle it includes the logic that need to be split later on.
        private void GlControl_Map_PrepareObjects()
        {
            /* Here comes all logic that is required before rendering objects
             * we do all calculations here and add everything else and then add it to render list */

            /* X.Y.
             * Left Top ( - | + )
             * Left Bottom ( - | - )
             * Right Top ( + | + )
             * Right Bottom ( + | - )
             */

            // Fix for shoreline, dont know how to make this more beautiful but it`s OK.
            switch (Settings.CurrentMap)
            {
            case "Shoreline":
                openglInvertMap = -1;
                break;

            case "Interchange":
                openglInvertMap = -1;
                break;

            default:
                openglInvertMap = 1;
                break;
            }

            // Fix to keep up with network.
            if (HelperOpenGL.PlayerListToRenderFinal.Count == 0)
            {
                return;
            }

            Helper.myPosXingame = HelperOpenGL.PlayerListToRenderFinal[0].MapLocX;
            Helper.myPosYingame = HelperOpenGL.PlayerListToRenderFinal[0].MapLocY;
            Helper.myPosZingame = HelperOpenGL.PlayerListToRenderFinal[0].MapLocZ;

            var distance = 0f;

            // On Screen Display
            var osdText = new StringBuilder();

            // Render item declare.
            RenderItem renderItem;

            /* The order it goes to openGL
             * From least important to most, includes text. */

            // Check iteration readcomplete open close bools. It must check if true then iterate then close.
            if (Settings.FindLoot)
            {
                GlControl_Map_PrepareObjects_Loot();
            }

            // Check iteration readcomplete open close bools. It must check if true then iterate then close.
            if (mapMarkerDraw)
            {
                renderItem = new RenderItem();
                renderItem.structs.MapPosX   = mapMarkerX;
                renderItem.structs.MapPosZ   = mapMarkerY;
                renderItem.structs.Text      = "loot";
                renderItem.structs.Rotation  = 45;
                renderItem.structs.DrawColor = Color.Yellow;
                HelperOpenGL.OpenglMapIcons.Add(renderItem);

                renderItem = new RenderItem();
                renderItem.structs.MapPosX   = mapMarkerX;
                renderItem.structs.MapPosZ   = mapMarkerY;
                renderItem.structs.Text      = "circlefill";
                renderItem.structs.Size      = 32 * Settings.MapSizeIcon;
                renderItem.structs.DrawColor = Color.FromArgb(64, 255, 255, 0);
                HelperOpenGL.OpenglMapGeometry.Add(renderItem);

                ////glControl_Map_Draw_Circle((float)Settings.Data.map_MapMarkerScanSize * map_ratio, mapMarkerX, mapMarkerY, Color.FromArgb(64, 255, 255, 0));
                ////
                ////int distance = (int)Math.Sqrt(Math.Pow((my_player_coord_real_Y - reversalmapMarkerLocY), 2) + Math.Pow((my_player_coord_real_X - reversalmapMarkerLocX), 2));
                ////glControl_Map_DrawLines(3, my_player_coord_formap_X, my_player_coord_formap_Y, mapMarkerX, mapMarkerY, Color.FromArgb(64, Color.Red));
                ////string distanceString = distance + "m";
                ////glControl_Map_DrawText(distanceString, Color.White, 10, mapMarkerX - 20, mapMarkerY + 30);
            }

            // Map Maker TEMP
            for (int i = 0; i < HelperOpenGL.MapMakerDots.Count; i++)
            {
                var entityPosXingame = HelperOpenGL.MapMakerDots[i].MapLocX;
                var entityPosYingame = HelperOpenGL.MapMakerDots[i].MapLocY;
                var entityPosZingame = HelperOpenGL.MapMakerDots[i].MapLocZ;
                var entityPosXmap    = (entityPosXingame * Settings.MapZoomLevelFromZoomLevels * openglInvertMap) + openglControlMapDragOffsetX;
                var entityPosZmap    = (entityPosZingame * Settings.MapZoomLevelFromZoomLevels * openglInvertMap) + openglControlMapDragOffsetY;
                var entityPosYmap    = entityPosYingame;

                renderItem = new RenderItem();
                renderItem.structs.Text      = "point";
                renderItem.structs.MapPosX   = entityPosXmap;
                renderItem.structs.MapPosZ   = entityPosZmap;
                renderItem.structs.DrawColor = HelperOpenGL.MapMakerDots[i].Drawcolor;
                renderItem.structs.Size      = HelperOpenGL.MapMakerDots[i].Size;
                HelperOpenGL.OpenglMapGeometry.Add(renderItem);
            }

            // Players
            for (int i = 0; i < HelperOpenGL.PlayerListToRenderFinal.Count; i++)
            {
                // Default FOV.
                var lengthFOV = Settings.MapFOVlineOther * Settings.MapZoomLevelFromZoomLevels;

                var entityPosXingame = HelperOpenGL.PlayerListToRenderFinal[i].MapLocX;
                var entityPosYingame = HelperOpenGL.PlayerListToRenderFinal[i].MapLocY;
                var entityPosZingame = HelperOpenGL.PlayerListToRenderFinal[i].MapLocZ;

                // Don`t draw who at 0.0.0
                if (entityPosXingame == 0 || entityPosZingame == 0)
                {
                    continue;
                }

                var entityPosXmap = (entityPosXingame * Settings.MapZoomLevelFromZoomLevels * openglInvertMap) + openglControlMapDragOffsetX;
                var entityPosZmap = (entityPosZingame * Settings.MapZoomLevelFromZoomLevels * openglInvertMap) + openglControlMapDragOffsetY;
                var entityPosYmap = entityPosYingame;

                // Override for OurPlayer.
                if (i == 0)
                {
                    // dot do map maker
                    if (dotDo)
                    {
                        var entityPlayer = new EntityPlayerListRender(
                            "point",
                            Color.Black,
                            1,
                            HelperOpenGL.PlayerListToRenderFinal[i].MapLocX,
                            HelperOpenGL.PlayerListToRenderFinal[i].MapLocY,
                            HelperOpenGL.PlayerListToRenderFinal[i].MapLocZ,
                            0,
                            string.Empty,
                            string.Empty,
                            0,
                            string.Empty,
                            false);

                        HelperOpenGL.MapMakerDots.Add(entityPlayer);
                    }

                    // Inner circle
                    renderItem = new RenderItem();
                    renderItem.structs.Text      = "circle";
                    renderItem.structs.MapPosX   = entityPosXmap;
                    renderItem.structs.MapPosZ   = entityPosZmap;
                    renderItem.structs.DrawColor = Color.FromArgb(255, Color.Red);
                    renderItem.structs.Size      = 100 * Settings.MapZoomLevelFromZoomLevels;
                    HelperOpenGL.OpenglMapGeometry.Add(renderItem);

                    // Medium circle
                    renderItem = new RenderItem();
                    renderItem.structs.Text      = "circle";
                    renderItem.structs.MapPosX   = entityPosXmap;
                    renderItem.structs.MapPosZ   = entityPosZmap;
                    renderItem.structs.DrawColor = Color.FromArgb(255, Color.Green);
                    renderItem.structs.Size      = 200 * Settings.MapZoomLevelFromZoomLevels;
                    HelperOpenGL.OpenglMapGeometry.Add(renderItem);

                    // Outer circle
                    renderItem = new RenderItem();
                    renderItem.structs.Text      = "circle";
                    renderItem.structs.MapPosX   = entityPosXmap;
                    renderItem.structs.MapPosZ   = entityPosZmap;
                    renderItem.structs.DrawColor = Color.FromArgb(255, Color.Red);
                    renderItem.structs.Size      = 300 * Settings.MapZoomLevelFromZoomLevels;
                    HelperOpenGL.OpenglMapGeometry.Add(renderItem);

                    lengthFOV = Settings.MapFOVlineMyself * Settings.MapZoomLevelFromZoomLevels;
                    textBoxMyPosition.Text = entityPosXingame.ToString() + " | " + entityPosYingame.ToString() + " | " + entityPosZingame.ToString();
                }

                /* Classic Way. Leaving for history.
                 * distance = (int)Math.Sqrt(Math.Pow((
                 * ReaderCore.Entities[0].MapLocZ - ReaderCore.Entities[i].MapLocZ), 2) +
                 * Math.Pow((ReaderCore.Entities[0].MapLocX - ReaderCore.Entities[i].MapLocX), 2));
                 */

                Vector3 vectorMe     = new Vector3(Helper.myPosXingame, Helper.myPosZingame, 0);
                Vector3 vectorTarget = new Vector3(entityPosXingame, entityPosZingame, 0);
                Vector3 vectorFOV;

                // Get degress from game for player.
                var degressFOVcenter = HelperOpenGL.PlayerListToRenderFinal[i].MapLocXview;

                // FOV Calculator
                if (openglInvertMap == -1)
                {
                    degressFOVcenter += 180;
                }

                // Correction for negative value.
                if (degressFOVcenter < 0)
                {
                    degressFOVcenter = 360 + degressFOVcenter;
                }

                float degreesFOVleft  = degressFOVcenter - 22;
                float degreesFOVright = degressFOVcenter + 22;

                if (degreesFOVleft < 0)
                {
                    degreesFOVleft = 360 + degreesFOVleft;
                }

                if (degreesFOVright < 0)
                {
                    degreesFOVright = 360 + degreesFOVright;
                }

                // Azimuth for OSD.
                if (Settings.MapOSDShowStats && Settings.MapOSDAzimuth && i == 0)
                {
                    // If i is I am :D
                    osdText.Append("AZT: " + ((int)degressFOVcenter).ToString()).AppendLine().AppendLine();
                }

                // Draw FOV Line.
                // Direction for FOV and angle calculator.
                var fov_line_X = (float)(entityPosXmap + (Math.Cos(((degressFOVcenter * Math.PI) / -180) + (Math.PI / 2)) * lengthFOV));
                var fov_line_Z = (float)(entityPosZmap + (Math.Sin(((degressFOVcenter * Math.PI) / -180) + (Math.PI / 2)) * lengthFOV));
                vectorFOV = new Vector3(fov_line_X, fov_line_Z, 0);

                if (Settings.MapShowPlayerFOV)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text       = "linestripple";
                    renderItem.structs.MapPosX    = entityPosXmap;
                    renderItem.structs.MapPosZ    = entityPosZmap;
                    renderItem.structs.MapPosXend = fov_line_X;
                    renderItem.structs.MapPosZend = fov_line_Z;
                    renderItem.structs.DrawColor  = HelperOpenGL.PlayerListToRenderFinal[i].Drawcolor;
                    renderItem.structs.Size       = 2;
                    HelperOpenGL.OpenglMapGeometry.Add(renderItem);

                    renderItem = new RenderItem();
                    renderItem.structs.Text       = "linestripple_invert";
                    renderItem.structs.MapPosX    = entityPosXmap;
                    renderItem.structs.MapPosZ    = entityPosZmap;
                    renderItem.structs.MapPosXend = fov_line_X;
                    renderItem.structs.MapPosZend = fov_line_Z;
                    renderItem.structs.DrawColor  = System.Windows.Forms.ControlPaint.Dark(HelperOpenGL.PlayerListToRenderFinal[i].Drawcolor);
                    renderItem.structs.Size       = 2;
                    HelperOpenGL.OpenglMapGeometry.Add(renderItem);
                }

                distance = (int)Math.Round(Helper.GetDistance(vectorTarget, vectorMe));

                if (i != 0 && Settings.MapShowPlayerDistance)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text        = distance + "m";
                    renderItem.structs.MapPosX     = entityPosXmap + 20;
                    renderItem.structs.MapPosZ     = entityPosZmap + 15;
                    renderItem.structs.DrawColor   = Settings.ColorText;
                    renderItem.structs.Size        = (int)FontSizes.misc;
                    renderItem.structs.TextOutline = true;
                    HelperOpenGL.OpenglMapText.Add(renderItem);
                }

                // Draw Player Icon.
                if (Settings.MapShowPlayers)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text      = "player";
                    renderItem.structs.MapPosX   = entityPosXmap;
                    renderItem.structs.MapPosZ   = entityPosZmap;
                    renderItem.structs.DrawColor = HelperOpenGL.PlayerListToRenderFinal[i].Drawcolor;
                    renderItem.structs.Rotation  = degressFOVcenter * -1;
                    HelperOpenGL.OpenglMapIcons.Add(renderItem);
                }

                // Draw Player Nickname.
                if (i != 0 && Settings.MapShowPlayerName)
                {
                    switch (HelperOpenGL.PlayerListToRenderFinal[i].Nickname)
                    {
                    case "BOT":
                    case "SCAV":
                        break;

                    default:
                        renderItem = new RenderItem();
                        renderItem.structs.Text        = HelperOpenGL.PlayerListToRenderFinal[i].Nickname;
                        renderItem.structs.MapPosX     = entityPosXmap + 20 + Settings.MapZoomLevelFromZoomLevels;
                        renderItem.structs.MapPosZ     = entityPosZmap;
                        renderItem.structs.DrawColor   = HelperOpenGL.PlayerListToRenderFinal[i].Drawcolor;
                        renderItem.structs.TextOutline = true;
                        renderItem.structs.Size        = (int)FontSizes.misc;
                        HelperOpenGL.OpenglMapText.Add(renderItem);
                        break;
                    }
                }

                // Draw Weapon.
                if (i != 0 && Settings.MapShowPlayerWeapons)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text        = HelperOpenGL.PlayerListToRenderFinal[i].Weapon;
                    renderItem.structs.MapPosX     = entityPosXmap + 20 + Settings.MapZoomLevelFromZoomLevels;
                    renderItem.structs.MapPosZ     = entityPosZmap - 15;
                    renderItem.structs.DrawColor   = Settings.ColorText;
                    renderItem.structs.TextOutline = true;
                    renderItem.structs.Size        = (int)FontSizes.misc;
                    HelperOpenGL.OpenglMapText.Add(renderItem);
                }

                // PlayerSide.
                if (i != 0 && Settings.MapShowPlayerSide)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text    = "point";
                    renderItem.structs.MapPosX = entityPosXmap - 7 - Settings.MapZoomLevelFromZoomLevels;
                    renderItem.structs.MapPosZ = entityPosZmap + 7 + Settings.MapZoomLevelFromZoomLevels;
                    renderItem.structs.Size    = 5;

                    switch (HelperOpenGL.PlayerListToRenderFinal[i].Side)
                    {
                    case "BEAR":
                        renderItem.structs.DrawColor = Settings.ColorPlayerSideBEAR;
                        HelperOpenGL.OpenglMapGeometry.Add(renderItem);
                        break;

                    case "USEC":
                        renderItem.structs.DrawColor = Settings.ColorPlayerSideUSEC;
                        HelperOpenGL.OpenglMapGeometry.Add(renderItem);
                        break;

                    case "SCAV":
                        renderItem.structs.DrawColor = Settings.ColorPlayerSideSCAV;
                        HelperOpenGL.OpenglMapGeometry.Add(renderItem);
                        break;

                    default:
                        break;
                    }
                }

                // Player Health.
                if (i != 0 && Settings.MapShowPlayerHealth)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text        = HelperOpenGL.PlayerListToRenderFinal[i].Health.ToString() + "%";
                    renderItem.structs.TextOutline = true;

                    renderItem.structs.MapPosX   = entityPosXmap + 20;
                    renderItem.structs.MapPosZ   = entityPosZmap - 20;
                    renderItem.structs.DrawColor = Settings.ColorText;
                    renderItem.structs.Size      = (int)FontSizes.misc;
                    HelperOpenGL.OpenglMapText.Add(renderItem);
                }

                // Cheater
                if (HelperOpenGL.PlayerListToRenderFinal[i].Cheater)
                {
                    renderItem = new RenderItem();
                    renderItem.structs.Text      = "circlefill";
                    renderItem.structs.MapPosX   = entityPosXmap;
                    renderItem.structs.MapPosZ   = entityPosZmap;
                    renderItem.structs.DrawColor = Color.FromArgb(128, Color.Red);
                    renderItem.structs.Size      = Settings.MapSizeIcon + 30;
                }

                // Counters for OSD.
                switch (HelperOpenGL.PlayerListToRenderFinal[i].Side)
                {
                case "BEAR":
                case "USEC":
                    reader.PlayerCountPMC++;
                    break;

                default:
                    break;
                }

                // Counters for OSD.
                switch (HelperOpenGL.PlayerListToRenderFinal[i].Nickname)
                {
                case "BOT":
                    reader.PlayerCountBOT++;
                    break;

                case "SCAV":
                    reader.PlayerCountSCAV++;
                    break;

                default:
                    break;
                }
            }

            Settings.FramesPerSecondCounter++;

            //// OSD.

            if (Settings.MapOSDShowStats && Settings.MapOSDPlayerCount)
            {
                osdText.Append(
                    "PMC: " + reader.PlayerCountPMC.ToString()).AppendLine().Append(
                    "SCAV: " + reader.PlayerCountSCAV.ToString()).AppendLine().Append(
                    "BOT: " + reader.PlayerCountBOT.ToString()).AppendLine().Append(
                    "TEAMS: " + Settings.ListTeams.Count).AppendLine().AppendLine();
            }

            if (Settings.MapOSDShowStats)
            {
                osdText.Append(
                    "ZOOM: " + Settings.MapZoomLevelFromZoomLevels.ToString()).AppendLine();
            }

            if (Settings.MapOSDShowStats && Settings.MapOSDFPS)
            {
                osdText.Append(
                    "FPS: " + Settings.FramerPerSecondOSD).AppendLine();
            }

            if (Settings.MapOSDShowStats && Settings.MapOSDReadCalls)
            {
                osdText.Append(
                    "RPM/TICK: " + Memory.RPMCount).AppendLine();
            }

            if (Settings.MapOSDShowStats && Settings.MapOSDDateTime)
            {
                osdText.Append(DateTime.Now.ToString("HH:mm:ss fff"));
            }

            Memory.RPMCount = 0;

            if ((DateTime.Now - Settings.FramesPerSecondTime).Seconds > 1)
            {
                Settings.FramerPerSecondOSD     = Settings.FramesPerSecondCounter;
                Settings.FramesPerSecondTime    = DateTime.Now;
                Settings.FramesPerSecondCounter = 0;
            }

            renderItem = new RenderItem();
            renderItem.structs.Text        = osdText.ToString();
            renderItem.structs.TextOutline = true;

            renderItem.structs.MapPosX   = -(openglControlMap.Width / 2) + 10;
            renderItem.structs.MapPosZ   = (openglControlMap.Height / 2) - 10;
            renderItem.structs.DrawColor = Settings.ColorOSD;
            renderItem.structs.Size      = (int)FontSizes.misc;
            HelperOpenGL.OpenglMapText.Add(renderItem);
        }