CNCMaps.Engine.Map.GameObject.GetBounds C# (CSharp) Method

GetBounds() public method

public GetBounds ( ) : Rectangle
return System.Drawing.Rectangle
        public Rectangle GetBounds()
        {
            if (RequiresBoundsInvalidation && Drawable != null) {
                cachedBounds = Drawable.GetBounds(this);
                RequiresBoundsInvalidation = false;
            }
            return cachedBounds;
        }

Usage Example

示例#1
0
        internal void ExamineNeighbourhood(GameObject obj)
        {
            // Debug.WriteLine("Examining neighhourhood of " + obj);
            // Debug.Assert(!_hist.Contains(obj), "examining neighbourhood for an object that's already in the draw list");
            var objBB  = obj.GetBounds();
            var tileTL = _map.GetTileScreen(objBB.Location, true, false);
            var tileBR = _map.GetTileScreen(objBB.Location + objBB.Size);

            for (int y = tileTL.Dy - 3; y <= tileBR.Dy + 3; y++)
            {
                for (int x = tileTL.Dx - 3; x <= tileBR.Dx + 3; x += 2)
                {
                    if ((x + (y + obj.TopTile.Dy)) < 0 || y < 0)
                    {
                        continue;
                    }
                    var tile2 = _map[x + (y + obj.TopTile.Dy) % 2, y / 2];
                    if (tile2 == null)
                    {
                        continue;
                    }

                    // Debug.WriteLine("neighhourhood tile " + tile2 + " of obj " + obj + " at " + obj.Tile);
                    ExamineObjects(obj, tile2);
                    foreach (var obj2 in tile2.AllObjects)
                    {
                        ExamineObjects(obj, obj2);
                    }
                }
            }
        }
All Usage Examples Of CNCMaps.Engine.Map.GameObject::GetBounds