private void DrawNPCCorpseVisual(ref DrawingVisualSpawn corpse, ResizeValHolder rvh, bool isTarget) {
            //X and Y location are inverted from how we display on window, so multiply by -1 to get inverse
            double x = (double)-corpse.spawn.xLoc;
            double y = (double)-corpse.spawn.yLoc;
            x = x - rvh.minX;
            y = y - rvh.minY;
            x = x * rvh.resizeRatio;
            y = y * rvh.resizeRatio;
            x = x + rvh.centerDistanceX;
            y = y + rvh.centerDistanceY;

            using(DrawingContext dc = corpse.RenderOpen()) {
                Brush targetBrush;

                if(isTarget) {
                    targetBrush = Brushes.Fuchsia;
                }
                else {
                    targetBrush = Brushes.LightBlue;
                }
                Pen colorPen = new Pen(targetBrush, 2.0);
                dc.DrawLine(colorPen, new Point(x, y - 3), new Point(x, y + 3));
                dc.DrawLine(colorPen, new Point(x - 3, y), new Point(x + 3, y));
            }
        }
        private void DrawPCCorpseVisual(ref DrawingVisualSpawn corpse, ResizeValHolder rvh, bool isTarget) {
            //X and Y location are inverted from how we display on window, so multiply by -1 to get inverse
            double x = (double)-corpse.spawn.xLoc;
            double y = (double)-corpse.spawn.yLoc;
            x = x - rvh.minX;
            y = y - rvh.minY;
            x = x * rvh.resizeRatio;
            y = y * rvh.resizeRatio;
            x = x + rvh.centerDistanceX;
            y = y + rvh.centerDistanceY;

            using (DrawingContext dc = corpse.RenderOpen()) {
                Brush targetBrush;
                
                if (isTarget) {
                    targetBrush = Brushes.Fuchsia;
                }
                else {
                    targetBrush = Brushes.LightPink;
                }
                Pen colorPen = new Pen(targetBrush,2.0);
                dc.DrawLine(colorPen, new Point(x, y-3), new Point(x, y+3));
                dc.DrawLine(colorPen, new Point(x-3, y), new Point(x+3, y));
                //Rect rect = new Rect(new Point(x - 3, y - 3), new Size(6, 6));
                //dc.DrawRectangle(null, new Pen(targetBrush, 1), rect);
                
                /* text
                FormattedText ft = new FormattedText(
                    corpse.spawn.name,
                    CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight,
                    new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold, FontStretches.Normal),
                    9,
                    Brushes.Black);
                // Draw the text at a location
                dc.DrawText(ft, new Point(x + 5.0, y + 5.0));
                 */
            }

            //draw vert and horiz lines like this
            /*DrawingVisual drawingVisual = new DrawingVisual();
            using (DrawingContext dc = drawingVisual.RenderOpen()) {
                bool a = colorPen.IsFrozen;
                foreach (MapLineSegment segment in segmentList) {
                    dc.DrawLine(colorPen, new Point(segment.aX, segment.aY), new Point(segment.bX, segment.bY));
                }
            }
            this.children.Add(drawingVisual);
             * */

        }
        /*private void GameAnalyzer_OnPlayerChangeLevel(object sender, IntEventArgs e) {
            this.playerLevel = e.value; //this doesnt fix the problem. f**k.
            //this.Clear();
        }*/

        

        //something spawned
        public void Add(Spawn s, ResizeValHolder rvh) {
            DrawingVisualSpawn visual = new DrawingVisualSpawn(s);
            DrawVisual(ref visual, rvh, false);
            children.Add(visual);
        }
        private void DrawPCVisual(ref DrawingVisualSpawn pc, ResizeValHolder rvh, bool isTarget) {
            //X and Y location are inverted from how we display on window, so multiply by -1 to get inverse
            double x = (double)-pc.spawn.xLoc;
            double y = (double)-pc.spawn.yLoc;
            x = x - rvh.minX;
            y = y - rvh.minY;
            x = x * rvh.resizeRatio;
            y = y * rvh.resizeRatio;
            x = x + rvh.centerDistanceX;
            y = y + rvh.centerDistanceY;

            using (DrawingContext dc = pc.RenderOpen()) {
                if (pc.spawn.isSelf) {
                    /*if(this.playerLevel == 0) {
                        this.playerLevel = (int)pc.spawn.level;
                    }*/
                    Brush targetBrush;
                    if (isTarget) {
                        targetBrush = Brushes.Fuchsia;
                    }
                    else {
                        targetBrush = Brushes.RoyalBlue;
                    }
                    double magnitude = 6.0; //describes how big the triangle is
                    int heading = Convert.ToInt32(pc.spawn.heading);

                    int angleA = 270 - ((heading * 360) >> 9);
                    double radiansA = Math.PI * angleA / 180;
                    double xOffsetA = Math.Cos(radiansA);
                    double yOffsetA = Math.Sin(radiansA);

                    int angleB = angleA + 120;
                    double radiansB = Math.PI * angleB / 180;
                    double xOffsetB = Math.Cos(radiansB);
                    double yOffsetB = Math.Sin(radiansB);

                    int angleC = angleA + 180;
                    double radiansC = Math.PI * angleC / 180;
                    double xOffsetC = Math.Cos(radiansC);
                    double yOffsetC = Math.Sin(radiansC);

                    int angleD = angleA - 120;
                    double radiansD = Math.PI * angleD / 180;
                    double xOffsetD = Math.Cos(radiansD);
                    double yOffsetD = Math.Sin(radiansD);

                    Point pointA = new Point(x + xOffsetA * magnitude * 2, y + yOffsetA * magnitude * 2);
                    Point pointB = new Point(x + xOffsetB * magnitude, y + yOffsetB * magnitude);
                    Point pointC = new Point(x, y);
                    Point pointD = new Point(x + xOffsetD * magnitude, y + yOffsetD * magnitude);
                    LineSegment[] segments = new LineSegment[] { new LineSegment(pointB, true), new LineSegment(pointC, true), new LineSegment(pointD, true) };
                    PathFigure figure = new PathFigure(pointA, segments, true);
                    PathGeometry geo = new PathGeometry(new PathFigure[] { figure });
                    dc.DrawGeometry(Brushes.RoyalBlue, new Pen(targetBrush, 1), geo);
                }
                else {
                    Brush targetBrush;
                    Brush conBrush;                  
                    if(playerLevel + 4 < pc.spawn.level) {
                        conBrush = Brushes.Red;
                    }
                    else if(playerLevel - 4 > pc.spawn.level) {
                        conBrush = Brushes.Green;
                    }
                    else {
                        conBrush = Brushes.White;
                    }

                    if(isTarget) {
                        targetBrush = Brushes.Fuchsia;
                    }
                    else {
                        targetBrush = conBrush;
                    }
                    Rect rect = new Rect(new Point(x - 4, y - 4), new Size(8, 8));
                    dc.DrawRectangle(conBrush, new Pen(targetBrush, 1), rect);
                    FormattedText ft = new FormattedText(
                        "[" + pc.spawn.level.ToString() + " " + (SpawnClassShort)pc.spawn.eqClass + "] " + pc.spawn.name,
                        CultureInfo.CurrentCulture,
                        FlowDirection.LeftToRight,
                        new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold, FontStretches.Normal),
                        9,
                        targetBrush);
                    // Draw the text at a location
                    dc.DrawText(ft, new Point(x + 5.0, y + 5.0));
                }
            }
        }
        private void DrawNPCVisual(ref DrawingVisualSpawn npc, ResizeValHolder rvh, bool isTarget) {
            //X and Y location are inverted from how we display on window, so multiply by -1 to get inverse
            double x = (double)-npc.spawn.xLoc;
            double y = (double)-npc.spawn.yLoc;
            x = x - rvh.minX;
            y = y - rvh.minY;
            x = x * rvh.resizeRatio;
            y = y * rvh.resizeRatio;
            x = x + rvh.centerDistanceX;
            y = y + rvh.centerDistanceY;

            using (DrawingContext dc = npc.RenderOpen()) {
                SolidColorBrush conBrush = GetConsiderBrush(this.playerLevel, npc.spawn.level);
                if (isTarget) {
                    FormattedText ft = new FormattedText(
                        npc.spawn.name + "\n" + npc.spawn.level.ToString() + " " + Spawn.GetRace(npc.spawn.race) + " / " + (SpawnClass)npc.spawn.eqClass,
                        CultureInfo.CurrentCulture,
                        FlowDirection.LeftToRight,
                        new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.ExtraLight, FontStretches.Normal),
                        10,
                        Brushes.Fuchsia);
                    // Draw text
                    dc.DrawText(ft, new Point(x + 3.0, y + 3.0));
                    dc.DrawEllipse(conBrush, new Pen(Brushes.Fuchsia, 1), new Point(x, y), 3, 3);
                }
                else if(isDragon(npc.spawn.name)) {
                    conBrush = Brushes.BlueViolet;
                    BitmapImage image = new BitmapImage(new Uri("..//..//images//dragon.png", UriKind.Relative));
                    Rect rect = new Rect(x - 5.0, y - 5.0, 10.0, 10.0);
                    dc.DrawImage(image, rect);
                }
                else if(isNamed(npc.spawn.name)) { //add logic to check for any nameds here and show as "!" or something better than circle
                    conBrush = Brushes.BlueViolet;
                    dc.DrawEllipse(conBrush, new Pen(conBrush, 1), new Point(x, y), 3, 3);
                }
                
                else {
                    dc.DrawEllipse(conBrush, new Pen(conBrush, 1), new Point(x, y), 3, 3);
                }     
            }
        }
 private void DrawVisual(ref DrawingVisualSpawn visual, ResizeValHolder rvh, bool isTarget) {
     switch ((SpawnType)visual.spawn.type) {
         case SpawnType.PC:
             DrawPCVisual(ref visual, rvh, isTarget);
             break;
         case SpawnType.NPC:
             DrawNPCVisual(ref visual, rvh, isTarget);
             break;
         case SpawnType.NPC_CORPSE:
             DrawNPCCorpseVisual(ref visual, rvh, isTarget);
             break;
         case SpawnType.PC_CORPSE:
             DrawPCCorpseVisual(ref visual, rvh, isTarget);
             break;
     }
 }