Esempio n. 1
0
        /// <summary>
        /// Draw a Scene
        /// </summary>
        //private void DrawScenes2(DrawingContext dc, CanvasData canvas)
        //{
        //    try
        //    {
        //        if (Math.Abs(CenterActor.Point.X) < 0.01f && Math.Abs(CenterActor.Point.Y) < 0.01f)
        //            return;

        //        var worldId = AdvDia.CurrentWorldDynamicId;
        //        foreach (var adventurerScene in GridProvider.CachedScenes.Values.Where(s => s.WorldId == worldId
        //        //&&
        //        //centerActorPosition.X >= s.Min.X && centerActorPosition.Y >= s.Min.Y &&
        //        //centerActorPosition.X <= s.Max.X && centerActorPosition.Y <= s.Max.Y
        //        ).ToList())
        //        {
        //            // Combine navcells into one drawing and store it; because they don't change relative to each other
        //            // And because translating geometry for every navcell on every frame is waaaaay too slow.
        //            if (Drawings.Relative.ContainsKey(adventurerScene.NameHash)) continue;

        //            var drawing = new DrawingGroup();

        //            using (var groupdc = drawing.Open())
        //            {
        //                #region Terrain
        //                if (adventurerScene.SceneDefinition != null && adventurerScene.SceneDefinition.NavCellDefinitions != null)
        //                {
        //                    var figures = new List<PathFigure>();
        //                    foreach (var navCell in adventurerScene.SceneDefinition.NavCellDefinitions.Where(nc => nc.Flags.HasFlag(NavCellFlags.AllowWalk)))
        //                    {
        //                        var topLeft = new Vector3(adventurerScene.Min.X + navCell.Min.X, adventurerScene.Min.Y + navCell.Min.Y, 0);
        //                        var topRight = new Vector3(adventurerScene.Min.X + navCell.Max.X, adventurerScene.Min.Y + navCell.Min.Y, 0);
        //                        var bottomLeft = new Vector3(adventurerScene.Min.X + navCell.Min.X, adventurerScene.Min.Y + navCell.Max.Y, 0);
        //                        var bottomRight = new Vector3(adventurerScene.Min.X + navCell.Max.X, adventurerScene.Min.Y + navCell.Max.Y, 0);
        //                        var segments = new[]
        //                                       {
        //                                           new LineSegment(topLeft.ToCanvasPoint(), true),
        //                                           new LineSegment(topRight.ToCanvasPoint(), true),
        //                                           new LineSegment(bottomRight.ToCanvasPoint(), true)
        //                                       };

        //                        figures.Add(new PathFigure(bottomLeft.ToCanvasPoint(), segments, true));
        //                    }
        //                    var geo = new PathGeometry(figures, FillRule.Nonzero, null);
        //                    geo.GetOutlinedPathGeometry();
        //                    groupdc.DrawGeometry(RadarResources.WalkableTerrain, null, geo);
        //                }
        //                #endregion

        //                #region Scene Borders
        //                var sceneTopLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Min.Y, 0);
        //                var sceneTopRight = new Vector3(adventurerScene.Max.X, adventurerScene.Min.Y, 0);
        //                var sceneBottomLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Max.Y, 0);
        //                var sceneBottomRight = new Vector3(adventurerScene.Max.X, adventurerScene.Max.Y, 0);

        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneTopRight.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneBottomLeft.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneBottomLeft.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopRight.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
        //                #endregion

        //                #region Scene Title
        //                var textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
        //                var glyphRun = DrawingUtilities.CreateGlyphRun(adventurerScene.Name, 10, textPoint);
        //                groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
        //                textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
        //                textPoint.Y = textPoint.Y + 20;
        //                glyphRun = DrawingUtilities.CreateGlyphRun((adventurerScene.Max - adventurerScene.Min).ToString(), 8, textPoint);
        //                groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
        //                #endregion

        //                #region Nodes
        //                //var sceneNodePen = new Pen { Brush = Brushes.Black, Thickness = 0.1f };
        //                //foreach (var cell in adventurerScene.GridCells)
        //                //{
        //                //    //if (node.HasEnoughNavigableCells)
        //                //    //{
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.TopRight.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomLeft.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.BottomLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomRight.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopRight.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomRight.ToVector3().ToCanvasPoint()));

        //                //    //    //var textPoint1 = node.Center.ToVector3().ToCanvasPoint();
        //                //    //    ////                                var glyphRun1 = DrawingUtilities.CreateGlyphRun(string.Format("{2} {0} ({1:P0})", node.NavigableCellCount, node.FillPercentage, node.LevelAreaId), 8, textPoint1);
        //                //    //    //var glyphRun1 = DrawingUtilities.CreateGlyphRun(node.LevelAreaId.ToString(), 8, textPoint1);
        //                //    //    //groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun1);
        //                //    //}
        //                //    //foreach (var navPoint in node.Nodes.Where(n=>n.NodeFlags.HasFlag(NodeFlags.NearWall)))
        //                //    //{
        //                //    DrawNavNode(groupdc, canvas, cell);
        //                //    //    //groupdc.DrawEllipse(Brushes.LightSlateGray, sceneNodePen, navPoint.Center.ToVector3().ToCanvasPoint(), (float)GridSize / 2, (float)GridSize / 2);
        //                //    //}
        //                //}
        //                #endregion



        //            }

        //            // Have to use SceneHash as key because scenes can appear multiple times with the same name
        //            Drawings.Relative.TryAdd(adventurerScene.NameHash, new RelativeDrawing
        //            {
        //                Drawing = drawing,
        //                Origin = CenterActor.Morph,
        //                Center = adventurerScene.Center.ToVector3(),
        //                WorldId = adventurerScene.WorldId,
        //                //Image = new DrawingImage(drawing),
        //                //ImageRect = drawing.Bounds

        //            });
        //        }

        //        foreach (var pair in Drawings.Relative)
        //        {
        //            //if (pair.Value.WorldId != AdvDia.CurrentWorldDynamicId)
        //            //    continue;

        //            if (!pair.Value.Drawing.Bounds.IntersectsWith(CanvasData.ClipRegion.Rect))
        //                continue;
        //            dc.DrawDrawing(pair.Value.Drawing);

        //            //if (!pair.Value.ImageRect.IntersectsWith(CanvasData.ClipRegion.Rect))
        //            //    continue;
        //            //dc.DrawImage(pair.Value.Image, pair.Value.ImageRect);
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        Logger.Debug("Exception in RadarUI.DrawScenes(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
        //    }
        //}


        private void DrawActor(DrawingContext dc, CanvasData canvas, RadarObject radarObject)
        {
            try
            {
                var res = RadarResources.GetActorResourceSet(radarObject);

                // Draw a dot in the center of the actor;
                dc.DrawEllipse(res.Brush, null, radarObject.Point, MarkerSize / 2, MarkerSize / 2);

                // Draw a circle representing the size of the actor
                res.Brush.Opacity = 0.25;
                var gridRadius = radarObject.CachedActorRadius * GridSize;

                var pen = RadarResources.LineOfSightLightPen;

                dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Black, 0.1), radarObject.Point, gridRadius, gridRadius);
                dc.DrawEllipse(Brushes.Transparent, RadarResources.LineOfSightLightPen, radarObject.Point, 45 * GridSize, 45 * GridSize);

                DrawActorLabel(dc, canvas, radarObject, res.Brush);
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawActor(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a base color for actor based on type and stuff
        /// </summary>
        public static ResourceSet GetActorResourceSet(RadarObject radarObject)
        {
            var res = new ResourceSet();

            res.Brush = ActorDefaultBrush;


            res.Brush = TransparentBrush;
            res.Pen   = TransparentPen;

            return(res);
        }
Esempio n. 3
0
        /// <summary>
        /// Go through the ItemSource collection and calculate their canvas positions
        /// </summary>
        public void UpdateData()
        {
            try
            {
                using (new PerformanceLogger("RadarUI UpdateData"))
                {
                    if (DesiredSize.Height <= 0 || DesiredSize.Width <= 0)
                    {
                        return;
                    }

                    if (!IsVisible || ZetaDia.Me == null || ZetaDia.IsLoadingWorld || !ZetaDia.IsInGame)
                    {
                        return;
                    }

                    Objects.Clear();

                    CanvasData.Update(DesiredSize, GridSize);

                    // Find the actor who should be in the center of the radar
                    // and whos position all other points should be plotted against.

                    var center = ZetaDia.Me;
                    if (center == null)
                    {
                        return;
                    }

                    CenterActor = new RadarObject(center, CanvasData);
                    CenterActor.CachedActorName   = "Player";
                    CenterActor.CachedActorRadius = 6;
                    if (CenterActor.IsValid)
                    {
                        CanvasData.CenterVector = CenterActor.Actor.Position;
                        CanvasData.CenterMorph  = CenterActor.Morph;

                        // Calculate locations for all actors positions
                        // on RadarObject ctor; or with .Update();

                        UpdateRelativeDrawings();
                    }
                }

                // Trigger Canvas to Render
                InvalidateVisual();
            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.UpdateData(). {0} {1}", ex.Message, ex.InnerException);
            }
        }
Esempio n. 4
0
        private static void DrawActorLabel(DrawingContext dc, CanvasData canvas, RadarObject radarObject, Brush brush)
        {
            var text = radarObject.CachedActorName;

            if (text == null)
            {
                return;
            }

            const int textSize  = 12;
            const int charLimit = 20;

            if (text.Length > charLimit)
            {
                text = text.Substring(0, charLimit);
            }

            // FormattedText is very slow, so instead create text manually with glyphs
            var glyphRun = DrawingUtilities.CreateGlyphRun(text, textSize, radarObject.Point);

            dc.DrawGlyphRun(brush, glyphRun);
        }
Esempio n. 5
0
        /// <summary>
        /// Returns a base color for actor based on type and stuff
        /// </summary>
        public static ResourceSet GetActorResourceSet(RadarObject radarObject)
        {
            var res = new ResourceSet();
            res.Brush = ActorDefaultBrush;


            res.Brush = TransparentBrush;
            res.Pen = TransparentPen;

            return res;
        }
Esempio n. 6
0
        /// <summary>
        /// Go through the ItemSource collection and calculate their canvas positions
        /// </summary>
        void UpdateData()
        {
            try
            {
                using (new PerformanceLogger("RadarUI UpdateData"))
                {
                    Logger.Debug("DataUpdating");
                    
                    if (DesiredSize.Height <= 0 || DesiredSize.Width <= 0)
                        return;

                    if (!IsVisible || ZetaDia.Me == null || ZetaDia.IsLoadingWorld || !ZetaDia.IsInGame)
                        return;

                    Objects.Clear();

                    CanvasData.Update(DesiredSize, GridSize);

                    // Find the actor who should be in the center of the radar
                    // and whos position all other points should be plotted against.

                    var center = ZetaDia.Me;
                    if (center == null)
                        return;

                    CenterActor = new RadarObject(center, CanvasData);
                    CanvasData.CenterVector = CenterActor.Actor.Position;
                    CanvasData.CenterMorph = CenterActor.Morph;

                    // Calculate locations for all actors positions
                    // on RadarObject ctor; or with .Update();

                    foreach (var trinityObject in ItemsSource.OfType<DiaObject>())
                    {
                        var radarObject = new RadarObject(trinityObject, CanvasData);
                        Objects.Add(radarObject);
                    }

                    Logger.Debug("DataUpdated");

                    //UpdateRelativeDrawings();

                    //UpdateAvoidanceGridData();

                    //Logger.Log("Heading={0}",ZetaDia.Me.Movement.RotationDegrees);

                }

                // Trigger Canvas to Render
                InvalidateVisual();  

            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.UpdateData(). {0} {1}", ex.Message, ex.InnerException);
            }
        }
Esempio n. 7
0
        private static void DrawActorLabel(DrawingContext dc, CanvasData canvas, RadarObject radarObject, Brush brush)
        {
            var text = radarObject.CachedActorName;

            if (text == null)
                return;

            const int textSize = 12;
            const int charLimit = 20;

            if (text.Length > charLimit)
                text = text.Substring(0, charLimit);

            // FormattedText is very slow, so instead create text manually with glyphs
            var glyphRun = DrawingUtilities.CreateGlyphRun(text, textSize, radarObject.Point);
            dc.DrawGlyphRun(brush, glyphRun);
        }
Esempio n. 8
0
        /// <summary>
        /// Draw a Scene
        /// </summary>
        //private void DrawScenes2(DrawingContext dc, CanvasData canvas)
        //{
        //    try
        //    {
        //        if (Math.Abs(CenterActor.Point.X) < 0.01f && Math.Abs(CenterActor.Point.Y) < 0.01f)
        //            return;

        //        var worldId = AdvDia.CurrentWorldDynamicId;
        //        foreach (var adventurerScene in GridProvider.CachedScenes.Values.Where(s => s.WorldId == worldId
        //        //&&
        //        //centerActorPosition.X >= s.Min.X && centerActorPosition.Y >= s.Min.Y &&
        //        //centerActorPosition.X <= s.Max.X && centerActorPosition.Y <= s.Max.Y
        //        ).ToList())
        //        {
        //            // Combine navcells into one drawing and store it; because they don't change relative to each other
        //            // And because translating geometry for every navcell on every frame is waaaaay too slow.
        //            if (Drawings.Relative.ContainsKey(adventurerScene.NameHash)) continue;

        //            var drawing = new DrawingGroup();

        //            using (var groupdc = drawing.Open())
        //            {
        //                #region Terrain
        //                if (adventurerScene.SceneDefinition != null && adventurerScene.SceneDefinition.NavCellDefinitions != null)
        //                {
        //                    var figures = new List<PathFigure>();
        //                    foreach (var navCell in adventurerScene.SceneDefinition.NavCellDefinitions.Where(nc => nc.Flags.HasFlag(NavCellFlags.AllowWalk)))
        //                    {
        //                        var topLeft = new Vector3(adventurerScene.Min.X + navCell.Min.X, adventurerScene.Min.Y + navCell.Min.Y, 0);
        //                        var topRight = new Vector3(adventurerScene.Min.X + navCell.Max.X, adventurerScene.Min.Y + navCell.Min.Y, 0);
        //                        var bottomLeft = new Vector3(adventurerScene.Min.X + navCell.Min.X, adventurerScene.Min.Y + navCell.Max.Y, 0);
        //                        var bottomRight = new Vector3(adventurerScene.Min.X + navCell.Max.X, adventurerScene.Min.Y + navCell.Max.Y, 0);
        //                        var segments = new[]
        //                                       {
        //                                           new LineSegment(topLeft.ToCanvasPoint(), true),
        //                                           new LineSegment(topRight.ToCanvasPoint(), true),
        //                                           new LineSegment(bottomRight.ToCanvasPoint(), true)
        //                                       };

        //                        figures.Add(new PathFigure(bottomLeft.ToCanvasPoint(), segments, true));
        //                    }
        //                    var geo = new PathGeometry(figures, FillRule.Nonzero, null);
        //                    geo.GetOutlinedPathGeometry();
        //                    groupdc.DrawGeometry(RadarResources.WalkableTerrain, null, geo);
        //                }
        //                #endregion

        //                #region Scene Borders
        //                var sceneTopLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Min.Y, 0);
        //                var sceneTopRight = new Vector3(adventurerScene.Max.X, adventurerScene.Min.Y, 0);
        //                var sceneBottomLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Max.Y, 0);
        //                var sceneBottomRight = new Vector3(adventurerScene.Max.X, adventurerScene.Max.Y, 0);

        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneTopRight.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneBottomLeft.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneBottomLeft.ToCanvasPoint()));
        //                groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopRight.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
        //                #endregion

        //                #region Scene Title
        //                var textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
        //                var glyphRun = DrawingUtilities.CreateGlyphRun(adventurerScene.Name, 10, textPoint);
        //                groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
        //                textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
        //                textPoint.Y = textPoint.Y + 20;
        //                glyphRun = DrawingUtilities.CreateGlyphRun((adventurerScene.Max - adventurerScene.Min).ToString(), 8, textPoint);
        //                groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
        //                #endregion

        //                #region Nodes
        //                //var sceneNodePen = new Pen { Brush = Brushes.Black, Thickness = 0.1f };
        //                //foreach (var cell in adventurerScene.GridCells)
        //                //{
        //                //    //if (node.HasEnoughNavigableCells)
        //                //    //{
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.TopRight.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomLeft.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.BottomLeft.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomRight.ToVector3().ToCanvasPoint()));
        //                //    //    groupdc.DrawGeometry(null, sceneNodePen,
        //                //    //        new LineGeometry(node.TopRight.ToVector3().ToCanvasPoint(),
        //                //    //            node.BottomRight.ToVector3().ToCanvasPoint()));

        //                //    //    //var textPoint1 = node.Center.ToVector3().ToCanvasPoint();
        //                //    //    ////                                var glyphRun1 = DrawingUtilities.CreateGlyphRun(string.Format("{2} {0} ({1:P0})", node.NavigableCellCount, node.FillPercentage, node.LevelAreaId), 8, textPoint1);
        //                //    //    //var glyphRun1 = DrawingUtilities.CreateGlyphRun(node.LevelAreaId.ToString(), 8, textPoint1);
        //                //    //    //groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun1);
        //                //    //}
        //                //    //foreach (var navPoint in node.Nodes.Where(n=>n.NodeFlags.HasFlag(NodeFlags.NearWall)))
        //                //    //{
        //                //    DrawNavNode(groupdc, canvas, cell);
        //                //    //    //groupdc.DrawEllipse(Brushes.LightSlateGray, sceneNodePen, navPoint.Center.ToVector3().ToCanvasPoint(), (float)GridSize / 2, (float)GridSize / 2);
        //                //    //}
        //                //}
        //                #endregion




        //            }

        //            // Have to use SceneHash as key because scenes can appear multiple times with the same name
        //            Drawings.Relative.TryAdd(adventurerScene.NameHash, new RelativeDrawing
        //            {
        //                Drawing = drawing,
        //                Origin = CenterActor.Morph,
        //                Center = adventurerScene.Center.ToVector3(),
        //                WorldId = adventurerScene.WorldId,
        //                //Image = new DrawingImage(drawing),
        //                //ImageRect = drawing.Bounds

        //            });
        //        }

        //        foreach (var pair in Drawings.Relative)
        //        {
        //            //if (pair.Value.WorldId != AdvDia.CurrentWorldDynamicId)
        //            //    continue;

        //            if (!pair.Value.Drawing.Bounds.IntersectsWith(CanvasData.ClipRegion.Rect))
        //                continue;
        //            dc.DrawDrawing(pair.Value.Drawing);

        //            //if (!pair.Value.ImageRect.IntersectsWith(CanvasData.ClipRegion.Rect))
        //            //    continue;
        //            //dc.DrawImage(pair.Value.Image, pair.Value.ImageRect);
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        Logger.Debug("Exception in RadarUI.DrawScenes(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
        //    }
        //}


        private void DrawActor(DrawingContext dc, CanvasData canvas, RadarObject radarObject)
        {
            try
            {
                var res = RadarResources.GetActorResourceSet(radarObject);

                // Draw a dot in the center of the actor;
                dc.DrawEllipse(res.Brush, null, radarObject.Point, MarkerSize / 2, MarkerSize / 2);

                // Draw a circle representing the size of the actor
                res.Brush.Opacity = 0.25;
                var gridRadius = radarObject.CachedActorRadius * GridSize;

                var pen = RadarResources.LineOfSightLightPen;

                dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Black, 0.1), radarObject.Point, gridRadius, gridRadius);
                dc.DrawEllipse(Brushes.Transparent, RadarResources.LineOfSightLightPen, radarObject.Point, 45 * GridSize, 45 * GridSize);

                DrawActorLabel(dc, canvas, radarObject, res.Brush);

            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawActor(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Go through the ItemSource collection and calculate their canvas positions
        /// </summary>
        public void UpdateData()
        {
            try
            {
                using (new PerformanceLogger("RadarUI UpdateData"))
                {
                    if (DesiredSize.Height <= 0 || DesiredSize.Width <= 0)
                        return;

                    if (!IsVisible || ZetaDia.Me == null || ZetaDia.IsLoadingWorld || !ZetaDia.IsInGame)
                        return;

                    Objects.Clear();

                    CanvasData.Update(DesiredSize, GridSize);

                    // Find the actor who should be in the center of the radar
                    // and whos position all other points should be plotted against.

                    var center = ZetaDia.Me;
                    if (center == null)
                        return;

                    CenterActor = new RadarObject(center, CanvasData);
                    CenterActor.CachedActorName = "Player";
                    CenterActor.CachedActorRadius = 6;
                    if (CenterActor.IsValid)
                    {
                        CanvasData.CenterVector = CenterActor.Actor.Position;
                        CanvasData.CenterMorph = CenterActor.Morph;

                        // Calculate locations for all actors positions
                        // on RadarObject ctor; or with .Update();

                        UpdateRelativeDrawings();
                    }

                }

                // Trigger Canvas to Render
                InvalidateVisual();

            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.UpdateData(). {0} {1}", ex.Message, ex.InnerException);
            }
        }