private void GetScreenShotMapData(SceneNode node, ref ScreenShotData screenShotData)
        {
            var itemsOnMap = screenShotData.Items;

            if (node is ContainerNode container)
            {
                foreach (var item in container.Slots)
                {
                    if (item is LifeItem life)
                    {
                        var rectangle = this.GetLifeBoundingBox(life);
                        if (rectangle.HasValue)
                        {
                            itemsOnMap.Add(new TargetItem(life, rectangle.Value, RenderObjectType.Mob)
                            {
                                Id = life.ID
                            });
                        }
                    }
                }
            }
            else
            {
                for (int i = 0, total = node.Nodes.Count; i < total; ++i)
                {
                    GetScreenShotMapData(node.Nodes[i], ref screenShotData);
                }
            }
        }
 protected override void Draw(GameTime gameTime)
 {
     base.Draw(gameTime);
     if (_screenShotStream != null)
     {
         ScreenShotHelper(_screenShotStream, gameTime);
         _screenShotData = new ScreenShotData(new List <TargetItem>(), this.renderEnv.Camera.ClipRect);
         GetScreenShotMapData(mapData.Scene, ref _screenShotData);
         _screenShotStream = null;
     }
 }
        /// <summary>
        /// Take Screen, save image to stream, and return items info on the entire map.
        /// </summary>
        /// <param name="stream">Stream to save image</param>
        public ScreenShotData TakeScreenShot(Stream stream)
        {
            _screenShotStream = stream;
            while (_screenShotStream != null)
            {
                ;                               //Wait next Draw(), yield to GetScreenShotMapData()
            }
            var ret = _screenShotData;

            _screenShotData = null;
            return(ret);
        }