protected override List <(float x, float y, float z)> GetVerticesTopDownView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float marioY = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset);

            int xMin = (int)Config.MapGraphics.MapViewXMin - 1;
            int xMax = (int)Config.MapGraphics.MapViewXMax + 1;
            int zMin = (int)Config.MapGraphics.MapViewZMin - 1;
            int zMax = (int)Config.MapGraphics.MapViewZMax + 1;

            List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();

            for (int x = xMin; x <= xMax; x += 1)
            {
                vertices.Add((x, marioY, zMin));
                vertices.Add((x, marioY, zMax));
            }
            for (int z = zMin; z <= zMax; z += 1)
            {
                vertices.Add((xMin, marioY, z));
                vertices.Add((xMax, marioY, z));
            }
            return(vertices);
        }
        protected override List <(float x, float y, float z)> GetGridlineIntersectionPositionsTopDownView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float marioY = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);

            int xMin = Normalize(Config.CurrentMapGraphics.MapViewXMin) - _multiplier;
            int xMax = Normalize(Config.CurrentMapGraphics.MapViewXMax) + _multiplier;
            int zMin = Normalize(Config.CurrentMapGraphics.MapViewZMin) - _multiplier;
            int zMax = Normalize(Config.CurrentMapGraphics.MapViewZMax) + _multiplier;

            List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();

            for (int x = xMin; x <= xMax; x += _multiplier)
            {
                for (int z = zMin; z <= zMax; z += _multiplier)
                {
                    vertices.Add((x, marioY, z));
                }
            }
            return(vertices);
        }
Exemple #3
0
        private List <(float?minHeight, float?maxHeight, Color color)> GetDrawData()
        {
            if (_enableQuarterFrameLandings)
            {
                float marioY      = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);
                float marioYSpeed = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YSpeedOffset);
                List <(float y, float ySpeed)> steps = new List <(float y, float ySpeed)>();
                for (int i = 0; i < 100 && steps.Count < 10; i++)
                {
                    if (marioYSpeed < 0)
                    {
                        steps.Add((marioY, marioYSpeed));
                    }
                    marioY     += marioYSpeed;
                    marioYSpeed = Math.Max(marioYSpeed - 4, -75);
                }

                List <(float yMin, float yMax)> yBounds = new List <(float yMin, float yMax)>();
                foreach ((float y, float ySpeed) in steps)
                {
                    float y0 = y + (0 / 4f) * ySpeed;
                    float y1 = y + (1 / 4f) * ySpeed;
                    float y2 = y + (2 / 4f) * ySpeed;
                    float y3 = y + (3 / 4f) * ySpeed;
                    float y4 = y + (4 / 4f) * ySpeed;
                    yBounds.Add((y1, y0));
                    yBounds.Add((y2, y1));
                    yBounds.Add((y3, y2));
                    yBounds.Add((y4, y3));
                }

                List <(float?minHeight, float?maxHeight, Color color)> drawData =
                    new List <(float?minHeight, float?maxHeight, Color color)>();
                for (int i = 0; i < yBounds.Count; i++)
                {
                    (float yMin, float yMax) = yBounds[i];
                    List <Color> colors = new List <Color>()
                    {
                        Color.Red, Color.Yellow, Color.Green, Color.Cyan
                    };
                    Color color = colors[i % 4];
                    if (_showTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
                    {
                        drawData.Add((yMin, yMax, color));
                    }
                    else
                    {
                        drawData.Add((yMin, MoreMath.GetPreviousFloat(yMax), color));
                    }
                }
                return(drawData);
            }
            else
            {
                return(new List <(float?minHeight, float?maxHeight, Color color)>()
                {
                    (_minHeight, _maxHeight, Color),
                });
            }
        }
 public override void DrawOn2DControlTopDownView()
 {
     if (_enableQuarterFrameLandings)
     {
         float marioY      = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset);
         float marioYSpeed = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YSpeedOffset);
         List <(float y, float ySpeed)> steps = new List <(float y, float ySpeed)>();
         for (int i = 0; i < 100 && steps.Count < 10; i++)
         {
             if (marioYSpeed < 0)
             {
                 steps.Add((marioY, marioYSpeed));
             }
             marioY     += marioYSpeed;
             marioYSpeed = Math.Max(marioYSpeed - 4, -75);
         }
         List <(float yMin, float yMax)> yBounds = new List <(float yMin, float yMax)>();
         foreach ((float y, float ySpeed) in steps)
         {
             float y0 = y + (0 / 4f) * ySpeed;
             float y1 = y + (1 / 4f) * ySpeed;
             float y2 = y + (2 / 4f) * ySpeed;
             float y3 = y + (3 / 4f) * ySpeed;
             float y4 = y + (4 / 4f) * ySpeed;
             yBounds.Add((y1, y0));
             yBounds.Add((y2, y1));
             yBounds.Add((y3, y2));
             yBounds.Add((y4, y3));
         }
         for (int i = 0; i < yBounds.Count; i++)
         {
             (float yMin, float yMax) = yBounds[i];
             List <Color> colors = new List <Color>()
             {
                 Color.Red, Color.Yellow, Color.Green, Color.Cyan
             };
             Color color = colors[i % 4];
             if (ShowTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
             {
                 DrawOn2DControlTopDownViewWithUnits(yMin, yMax, color);
             }
             else
             {
                 DrawOn2DControlTopDownViewWithoutUnits(yMin, MoreMath.GetPreviousFloat(yMax), color);
             }
         }
     }
     else
     {
         if (ShowTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
         {
             DrawOn2DControlTopDownViewWithUnits(_minHeight, _maxHeight, Color);
         }
         else
         {
             DrawOn2DControlTopDownViewWithoutUnits(_minHeight, _maxHeight, Color);
         }
     }
 }
        protected override List <(float x, float y, float z)> GetVerticesOrthographicView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float xCenter = Config.MapGraphics.MapViewCenterXValue;
            float zCenter = Config.MapGraphics.MapViewCenterZValue;
            int   xMin    = (int)Config.MapGraphics.MapViewXMin - 1;
            int   xMax    = (int)Config.MapGraphics.MapViewXMax + 1;
            int   yMin    = (int)Config.MapGraphics.MapViewYMin - 1;
            int   yMax    = (int)Config.MapGraphics.MapViewYMax + 1;
            int   zMin    = (int)Config.MapGraphics.MapViewZMin - 1;
            int   zMax    = (int)Config.MapGraphics.MapViewZMax + 1;

            if (Config.MapGraphics.MapViewPitchValue == 0 &&
                (Config.MapGraphics.MapViewYawValue == 0 ||
                 Config.MapGraphics.MapViewYawValue == 32768))
            {
                List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();
                for (int x = xMin; x <= xMax; x += 1)
                {
                    vertices.Add((x, yMin, zCenter));
                    vertices.Add((x, yMax, zCenter));
                }
                for (int y = yMin; y <= yMax; y += 1)
                {
                    vertices.Add((xMin, y, zCenter));
                    vertices.Add((xMax, y, zCenter));
                }
                return(vertices);
            }
            else if (Config.MapGraphics.MapViewPitchValue == 0 &&
                     (Config.MapGraphics.MapViewYawValue == 16384 ||
                      Config.MapGraphics.MapViewYawValue == 49152))
            {
                List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();
                for (int z = zMin; z <= zMax; z += 1)
                {
                    vertices.Add((xCenter, yMin, z));
                    vertices.Add((xCenter, yMax, z));
                }
                for (int y = yMin; y <= yMax; y += 1)
                {
                    vertices.Add((zCenter, y, zMin));
                    vertices.Add((xCenter, y, zMax));
                }
                return(vertices);
            }
            else
            {
                return(new List <(float x, float y, float z)>());
            }
        }
        protected override List <(float x, float y, float z)> GetGridlineIntersectionPositionsOrthographicView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float xCenter = Config.CurrentMapGraphics.MapViewCenterXValue;
            float zCenter = Config.CurrentMapGraphics.MapViewCenterZValue;
            int   xMin    = Normalize(Config.CurrentMapGraphics.MapViewXMin) - _multiplier;
            int   xMax    = Normalize(Config.CurrentMapGraphics.MapViewXMax) + _multiplier;
            int   yMin    = Normalize(Config.CurrentMapGraphics.MapViewYMin) - _multiplier;
            int   yMax    = Normalize(Config.CurrentMapGraphics.MapViewYMax) + _multiplier;
            int   zMin    = Normalize(Config.CurrentMapGraphics.MapViewZMin) - _multiplier;
            int   zMax    = Normalize(Config.CurrentMapGraphics.MapViewZMax) + _multiplier;

            if (Config.CurrentMapGraphics.MapViewPitchValue == 0 &&
                (Config.CurrentMapGraphics.MapViewYawValue == 0 ||
                 Config.CurrentMapGraphics.MapViewYawValue == 32768))
            {
                List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();
                for (int x = xMin; x <= xMax; x += _multiplier)
                {
                    for (int y = yMin; y <= yMax; y += _multiplier)
                    {
                        vertices.Add((x, y, zCenter));
                    }
                }
                return(vertices);
            }
            else if (Config.CurrentMapGraphics.MapViewPitchValue == 0 &&
                     (Config.CurrentMapGraphics.MapViewYawValue == 16384 ||
                      Config.CurrentMapGraphics.MapViewYawValue == 49152))
            {
                List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();
                for (int z = zMin; z <= zMax; z += _multiplier)
                {
                    for (int y = yMin; y <= yMax; y += _multiplier)
                    {
                        vertices.Add((xCenter, y, z));
                    }
                }
                return(vertices);
            }
            else
            {
                return(new List <(float x, float y, float z)>());
            }
        }
Exemple #7
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            List <(float?minHeight, float?maxHeight, Color color)> drawData = GetDrawData();

            if (_showTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
            {
                List <List <(float x, float z, Color color, TriangleDataModel tri)> > vertexListsForControl =
                    GetVertexListsForControlWithUnits(drawData);
                DrawVertexListsForControlWithUnits(vertexListsForControl, hoverData);
            }
            else
            {
                List <List <(float x, float z, Color color, TriangleDataModel tri)> > vertexListsForControl =
                    GetVertexListsForControlWithoutUnits(drawData);
                DrawVertexListsForControlWithoutUnits(vertexListsForControl, hoverData);
            }
        }
        protected override List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData)
        {
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <List <(float x, float y, float z, Color color, bool isHovered)> >());
            }

            int xMin = (int)Config.CurrentMapGraphics.MapViewXMin - 1;
            int xMax = (int)Config.CurrentMapGraphics.MapViewXMax + 1;
            int zMin = (int)Config.CurrentMapGraphics.MapViewZMin - 1;
            int zMax = (int)Config.CurrentMapGraphics.MapViewZMax + 1;

            float y = GetHeight();

            List <List <(float x, float y, float z, Color color, bool isHovered)> > quads =
                new List <List <(float x, float y, float z, Color color, bool isHovered)> >();

            for (int x = xMin; x <= xMax; x++)
            {
                for (int z = zMin; z <= zMax; z++)
                {
                    (TriangleDataModel floorTri, float floorY)     = _cellSnapshot.FindFloorAndY(x, y, z);
                    (TriangleDataModel ceilingTri, float ceilingY) = _cellSnapshot.FindCeilingAndY(x, floorY + 80, z);

                    if (floorTri == null || ceilingTri == null)
                    {
                        continue;
                    }
                    if (!floorTri.BelongsToObject && !ceilingTri.BelongsToObject)
                    {
                        continue;
                    }
                    if (floorTri.NormY >= 0.5f && ceilingTri.NormY <= -0.5f)
                    {
                        continue;
                    }

                    float ceilToFloorDist = ceilingY - floorY;
                    if (0 <= ceilToFloorDist && ceilToFloorDist <= 150.0f)
                    {
                        bool  painful = ceilToFloorDist < 10.1f;
                        Color color   = painful ? Color.Red : Color.Green;
                        List <List <(float x, float y, float z)> > currentQuads = MapUtilities.ConvertUnitPointsToQuads(new List <(int x, int z)>()
                        {
                            (x, z)
                        });
                        quads.AddRange(currentQuads.ConvertAll(quad => quad.ConvertAll(point => (point.x, point.y, point.z, color, false))));
                    }
                }
            }
            if (hoverData != null)
            {
                for (int i = 0; i < quads.Count; i++)
                {
                    bool isHovered = this == hoverData?.MapObject && i == hoverData?.Index;
                    if (isHovered)
                    {
                        quads[i] = quads[i].ConvertAll(point => (point.x, point.y, point.z, point.color, isHovered));
                    }
                }
            }
            return(quads);
        }