Example #1
0
 public void Apply_Cliff()
 {
     clsMouseOver.clsOverTerrain mouseOverTerrain = this.GetMouseOverTerrain();
     if (mouseOverTerrain != null)
     {
         double num;
         clsMap.clsApplyCliff tool = new clsMap.clsApplyCliff {
             Map = this.Map
         };
         if (modIO.InvariantParse_dbl(modMain.frmMainInstance.txtAutoCliffSlope.Text, ref num))
         {
             tool.Angle = modMath.Clamp_dbl(num * 0.017453292519943295, 0.0, 1.5707963267948966);
             tool.SetTris = modMain.frmMainInstance.cbxCliffTris.Checked;
             modProgram.CliffBrush.PerformActionMapTiles(tool, mouseOverTerrain.Tile);
             this.Map.Update();
             this.MapView.DrawViewLater();
         }
     }
 }
Example #2
0
        public void Apply_Cliff()
        {
            clsMouseOver.clsOverTerrain MouseOverTerrain = GetMouseOverTerrain();

            if ( MouseOverTerrain == null )
            {
                return;
            }

            clsMap.clsApplyCliff ApplyCliff = new clsMap.clsApplyCliff();
            ApplyCliff.Map = Map;
            double Angle = 0;
            if ( !IOUtil.InvariantParse(Program.frmMainInstance.txtAutoCliffSlope.Text, ref Angle) )
            {
                return;
            }
            ApplyCliff.Angle = MathUtil.Clamp_dbl(Angle * MathUtil.RadOf1Deg, 0.0D, MathUtil.RadOf90Deg);
            ApplyCliff.SetTris = Program.frmMainInstance.cbxCliffTris.Checked;
            App.CliffBrush.PerformActionMapTiles(ApplyCliff, MouseOverTerrain.Tile);

            Map.Update();

            MapViewControl.DrawViewLater();
        }
Example #3
0
        private clsResult FinishTextures()
        {
            clsResult ReturnResult = new clsResult("");

            if ( cbxMasterTexture.Checked )
            {
                switch ( cboTileset.SelectedIndex )
                {
                    case 0:
                        Generator.GenerateTileset = DefaultGenerator.Generator_TilesetArizona;
                        DefaultGenerator.TerrainStyle_Arizona.Watermap = Generator.GetWaterMap();
                        DefaultGenerator.TerrainStyle_Arizona.LevelCount = Generator.LevelCount;
                        Generator.Map.GenerateMasterTerrain(DefaultGenerator.TerrainStyle_Arizona);
                        DefaultGenerator.TerrainStyle_Arizona.Watermap = null;
                        break;
                    case 1:
                        Generator.GenerateTileset = DefaultGenerator.Generator_TilesetUrban;
                        DefaultGenerator.TerrainStyle_Urban.Watermap = Generator.GetWaterMap();
                        DefaultGenerator.TerrainStyle_Urban.LevelCount = Generator.LevelCount;
                        Generator.Map.GenerateMasterTerrain(DefaultGenerator.TerrainStyle_Urban);
                        DefaultGenerator.TerrainStyle_Urban.Watermap = null;
                        break;
                    case 2:
                        Generator.GenerateTileset = DefaultGenerator.Generator_TilesetRockies;
                        DefaultGenerator.TerrainStyle_Rockies.Watermap = Generator.GetWaterMap();
                        DefaultGenerator.TerrainStyle_Rockies.LevelCount = Generator.LevelCount;
                        Generator.Map.GenerateMasterTerrain(DefaultGenerator.TerrainStyle_Rockies);
                        DefaultGenerator.TerrainStyle_Rockies.Watermap = null;
                        break;
                    default:
                        ReturnResult.ProblemAdd("Error: bad tileset selection.");
                        btnGenerateLayout.Enabled = true;
                        return ReturnResult;
                }
                Generator.Map.TileType_Reset();
                Generator.Map.SetPainterToDefaults();
            }
            else
            {
                switch ( cboTileset.SelectedIndex )
                {
                    case 0:
                        Generator.Map.Tileset = App.Tileset_Arizona;
                        Generator.GenerateTileset = DefaultGenerator.Generator_TilesetArizona;
                        break;
                    case 1:
                        Generator.Map.Tileset = App.Tileset_Urban;
                        Generator.GenerateTileset = DefaultGenerator.Generator_TilesetUrban;
                        break;
                    case 2:
                        Generator.Map.Tileset = App.Tileset_Rockies;
                        Generator.GenerateTileset = DefaultGenerator.Generator_TilesetRockies;
                        break;
                    default:
                        ReturnResult.ProblemAdd("Error: bad tileset selection.");
                        btnGenerateLayout.Enabled = true;
                        return ReturnResult;
                }
                Generator.Map.TileType_Reset();
                Generator.Map.SetPainterToDefaults();
                double CliffAngle = Math.Atan(255.0D * Generator.Map.HeightMultiplier / (2.0D * (Generator.LevelCount - 1.0D) * App.TerrainGridSpacing)) -
                                    MathUtil.RadOf1Deg;
                clsBrush tmpBrush = new clsBrush((Math.Max(Generator.Map.Terrain.TileSize.X, Generator.Map.Terrain.TileSize.Y)) * 1.1D, clsBrush.enumShape.Square);
                clsMap.clsApplyCliff ApplyCliff = new clsMap.clsApplyCliff();
                ApplyCliff.Map = Generator.Map;
                ApplyCliff.Angle = CliffAngle;
                ApplyCliff.SetTris = true;
                clsBrush.sPosNum Alignments = new clsBrush.sPosNum();
                Alignments.Normal = new sXY_int((int)(Conversion.Int(Generator.Map.Terrain.TileSize.X / 2.0D)),
                    (int)(Conversion.Int(Generator.Map.Terrain.TileSize.Y / 2.0D)));
                Alignments.Alignment = Alignments.Normal;
                tmpBrush.PerformActionMapTiles(ApplyCliff, Alignments);
                bool[] RevertSlope = null;
                bool[] RevertHeight = null;
                clsBooleanMap WaterMap = new clsBooleanMap();
                clsBooleanMap bmTemp = new clsBooleanMap();
                int A = 0;
                WaterMap = Generator.GetWaterMap();
                RevertSlope = new bool[Generator.GenerateTileset.OldTextureLayers.LayerCount];
                RevertHeight = new bool[Generator.GenerateTileset.OldTextureLayers.LayerCount];
                for ( A = 0; A <= Generator.GenerateTileset.OldTextureLayers.LayerCount - 1; A++ )
                {
                    App.sLayerList.clsLayer with_2 = Generator.GenerateTileset.OldTextureLayers.Layers[A];
                    with_2.Terrainmap = Generator.Map.GenerateTerrainMap(with_2.Scale, with_2.Density);
                    if ( with_2.SlopeMax < 0.0F )
                    {
                        with_2.SlopeMax = (float)(CliffAngle - MathUtil.RadOf1Deg);
                        if ( with_2.HeightMax < 0.0F )
                        {
                            with_2.HeightMax = 255.0F;
                            bmTemp.Within(with_2.Terrainmap, WaterMap);
                            with_2.Terrainmap.ValueData = bmTemp.ValueData;
                            bmTemp.ValueData = new clsBooleanMap.clsValueData();
                            RevertHeight[A] = true;
                        }
                        RevertSlope[A] = true;
                    }
                }
                Generator.Map.MapTexturer(Generator.GenerateTileset.OldTextureLayers);
                for ( A = 0; A <= Generator.GenerateTileset.OldTextureLayers.LayerCount - 1; A++ )
                {
                    App.sLayerList.clsLayer with_3 = Generator.GenerateTileset.OldTextureLayers.Layers[A];
                    with_3.Terrainmap = null;
                    if ( RevertSlope[A] )
                    {
                        with_3.SlopeMax = -1.0F;
                    }
                    if ( RevertHeight[A] )
                    {
                        with_3.HeightMax = -1.0F;
                    }
                }
            }

            Generator.Map.LevelWater();

            Generator.Map.WaterTriCorrection();

            Generator.Map.SectorGraphicsChanges.SetAllChanged();
            Generator.Map.SectorUnitHeightsChanges.SetAllChanged();

            Generator.Map.Update();

            Generator.Map.UndoStepCreate("Generated Textures");

            if ( Generator.Map == _Owner.MainMap )
            {
                Program.frmMainInstance.PainterTerrains_Refresh(-1, -1);
                Program.frmMainInstance.MainMapTilesetChanged();
            }

            return ReturnResult;
        }
Example #4
0
        private clsResult FinishTextures()
        {
            int num;
            clsBrush.sPosNum num2;
            clsResult result2 = new clsResult("");
            if (!this.cbxMasterTexture.Checked)
            {
                switch (this.cboTileset.SelectedIndex)
                {
                    case 0:
                        this.Generator.Map.Tileset = modProgram.Tileset_Arizona;
                        this.Generator.GenerateTileset = modGenerator.Generator_TilesetArizona;
                        goto Label_023D;

                    case 1:
                        this.Generator.Map.Tileset = modProgram.Tileset_Urban;
                        this.Generator.GenerateTileset = modGenerator.Generator_TilesetUrban;
                        goto Label_023D;

                    case 2:
                        this.Generator.Map.Tileset = modProgram.Tileset_Rockies;
                        this.Generator.GenerateTileset = modGenerator.Generator_TilesetRockies;
                        goto Label_023D;
                }
                result2.ProblemAdd("Error: bad tileset selection.");
                this.btnGenerateLayout.Enabled = true;
                return result2;
            }
            switch (this.cboTileset.SelectedIndex)
            {
                case 0:
                    this.Generator.GenerateTileset = modGenerator.Generator_TilesetArizona;
                    modGenerator.TerrainStyle_Arizona.Watermap = this.Generator.GetWaterMap();
                    modGenerator.TerrainStyle_Arizona.LevelCount = this.Generator.LevelCount;
                    this.Generator.Map.GenerateMasterTerrain(ref modGenerator.TerrainStyle_Arizona);
                    modGenerator.TerrainStyle_Arizona.Watermap = null;
                    break;

                case 1:
                    this.Generator.GenerateTileset = modGenerator.Generator_TilesetUrban;
                    modGenerator.TerrainStyle_Urban.Watermap = this.Generator.GetWaterMap();
                    modGenerator.TerrainStyle_Urban.LevelCount = this.Generator.LevelCount;
                    this.Generator.Map.GenerateMasterTerrain(ref modGenerator.TerrainStyle_Urban);
                    modGenerator.TerrainStyle_Urban.Watermap = null;
                    break;

                case 2:
                    this.Generator.GenerateTileset = modGenerator.Generator_TilesetRockies;
                    modGenerator.TerrainStyle_Rockies.Watermap = this.Generator.GetWaterMap();
                    modGenerator.TerrainStyle_Rockies.LevelCount = this.Generator.LevelCount;
                    this.Generator.Map.GenerateMasterTerrain(ref modGenerator.TerrainStyle_Rockies);
                    modGenerator.TerrainStyle_Rockies.Watermap = null;
                    break;

                default:
                    result2.ProblemAdd("Error: bad tileset selection.");
                    this.btnGenerateLayout.Enabled = true;
                    return result2;
            }
            this.Generator.Map.TileType_Reset();
            this.Generator.Map.SetPainterToDefaults();
            goto Label_054A;
            Label_023D:
            this.Generator.Map.TileType_Reset();
            this.Generator.Map.SetPainterToDefaults();
            double num3 = Math.Atan((255.0 * this.Generator.Map.HeightMultiplier) / ((2.0 * (this.Generator.LevelCount - 1.0)) * 128.0)) - 0.017453292519943295;
            clsBrush brush = new clsBrush(Math.Max(this.Generator.Map.Terrain.TileSize.X, this.Generator.Map.Terrain.TileSize.Y) * 1.1, clsBrush.enumShape.Square);
            clsMap.clsApplyCliff tool = new clsMap.clsApplyCliff {
                Map = this.Generator.Map,
                Angle = num3,
                SetTris = true
            };
            num2.Normal = new modMath.sXY_int((int) Math.Round(((double) (((double) this.Generator.Map.Terrain.TileSize.X) / 2.0))), (int) Math.Round(((double) (((double) this.Generator.Map.Terrain.TileSize.Y) / 2.0))));
            num2.Alignment = num2.Normal;
            brush.PerformActionMapTiles(tool, num2);
            clsBooleanMap exterior = new clsBooleanMap();
            clsBooleanMap map = new clsBooleanMap();
            exterior = this.Generator.GetWaterMap();
            clsGeneratorTileset generateTileset = this.Generator.GenerateTileset;
            bool[] flagArray2 = new bool[(generateTileset.OldTextureLayers.LayerCount - 1) + 1];
            bool[] flagArray = new bool[(generateTileset.OldTextureLayers.LayerCount - 1) + 1];
            int num6 = generateTileset.OldTextureLayers.LayerCount - 1;
            for (num = 0; num <= num6; num++)
            {
                modProgram.sLayerList.clsLayer layer = generateTileset.OldTextureLayers.Layers[num];
                layer.Terrainmap = this.Generator.Map.GenerateTerrainMap(layer.Scale, layer.Density);
                if (layer.SlopeMax < 0f)
                {
                    layer.SlopeMax = (float) (num3 - 0.017453292519943295);
                    if (layer.HeightMax < 0f)
                    {
                        layer.HeightMax = 255f;
                        map.Within(layer.Terrainmap, exterior);
                        layer.Terrainmap.ValueData = map.ValueData;
                        map.ValueData = new clsBooleanMap.clsValueData();
                        flagArray[num] = true;
                    }
                    flagArray2[num] = true;
                }
                layer = null;
            }
            this.Generator.Map.MapTexturer(ref generateTileset.OldTextureLayers);
            int num7 = generateTileset.OldTextureLayers.LayerCount - 1;
            for (num = 0; num <= num7; num++)
            {
                modProgram.sLayerList.clsLayer layer2 = generateTileset.OldTextureLayers.Layers[num];
                layer2.Terrainmap = null;
                if (flagArray2[num])
                {
                    layer2.SlopeMax = -1f;
                }
                if (flagArray[num])
                {
                    layer2.HeightMax = -1f;
                }
                layer2 = null;
            }
            generateTileset = null;
            Label_054A:
            this.Generator.Map.LevelWater();
            this.Generator.Map.WaterTriCorrection();
            this.Generator.Map.SectorGraphicsChanges.SetAllChanged();
            this.Generator.Map.SectorUnitHeightsChanges.SetAllChanged();
            this.Generator.Map.Update();
            this.Generator.Map.UndoStepCreate("Generated Textures");
            if (this.Generator.Map == this._Owner.MainMap)
            {
                modMain.frmMainInstance.PainterTerrains_Refresh(-1, -1);
                modMain.frmMainInstance.MainMapTilesetChanged();
            }
            return result2;
        }