CNCMaps.Engine.Map.Map.SetBaseTiles C# (CSharp) Méthode

SetBaseTiles() private méthode

private SetBaseTiles ( ) : void
Résultat void
        private void SetBaseTiles()
        {
            // we need foundations from the theater to place the structures at the correct tile,
            foreach (GameObject obj in _structureObjects.Cast<GameObject>().Union(_overlayObjects).Union(_smudgeObjects)) {
                if (obj.BottomTile == null) {
                    // s.BottomTile set means we've already moved it
                    var foundation = obj.Drawable.Foundation;
                    var bottom = _tiles.GetTileR(obj.Tile.Rx + foundation.Width - 1, obj.Tile.Ry + foundation.Height - 1);
                    obj.BottomTile = bottom ?? obj.Tile;
                    obj.TopTile = obj.Tile;
                }
            }

            foreach (GameObject obj in _unitObjects.Cast<GameObject>().Union(_aircraftObjects).Union(_infantryObjects)) {
                var bounds = obj.GetBounds();
                // bounds to foundation
                Size occupy = new Size(
                    (int)Math.Max(1, Math.Ceiling(bounds.Width / (double)Drawable.TileWidth)),
                    (int)Math.Max(1, Math.Ceiling(bounds.Height / (double)Drawable.TileHeight)));

                int bridge = (obj as OwnableObject).OnBridge ? -2 : 0;
                var top = _tiles.GetTileR(obj.Tile.Rx + bridge - 1 + occupy.Width, obj.Tile.Ry + bridge - 1 + occupy.Height);
                var bottom = _tiles.GetTileR(obj.Tile.Rx, obj.Tile.Ry);
                obj.BottomTile = bottom ?? obj.Tile;
                obj.TopTile = top ?? obj.Tile;
            }

            foreach (OverlayObject obj in _overlayObjects.Where(SpecialOverlays.IsHighBridge)) {
                var bottom = _tiles.GetTileR(obj.Tile.Rx + 2, obj.Tile.Ry + 2);
                obj.BottomTile = bottom ?? obj.Tile;
                obj.TopTile = obj.BottomTile;
            }
        }