示例#1
0
 public void Copy(clsBooleanMap Source)
 {
     this.SizeCopy(Source);
     int num3 = Source.ValueData.Size.Y - 1;
     for (int i = 0; i <= num3; i++)
     {
         int num4 = Source.ValueData.Size.X - 1;
         for (int j = 0; j <= num4; j++)
         {
             this.ValueData.Value[i, j] = Source.ValueData.Value[i, j];
         }
     }
 }
示例#2
0
 public void Expand_One_Tile(clsBooleanMap Source)
 {
     this.SizeCopy(Source);
     int num3 = this.ValueData.Size.Y - 1;
     for (int i = 0; i <= num3; i++)
     {
         int num4 = Source.ValueData.Size.X - 1;
         for (int j = 0; j <= num4; j++)
         {
             if (Source.ValueData.Value[i, j])
             {
                 this.ValueData.Value[i, j] = true;
                 if (i > 0)
                 {
                     if (j > 0)
                     {
                         this.ValueData.Value[i - 1, j - 1] = true;
                     }
                     this.ValueData.Value[i - 1, j] = true;
                     if (j < (Source.ValueData.Size.X - 1))
                     {
                         this.ValueData.Value[i - 1, j + 1] = true;
                     }
                 }
                 if (j > 0)
                 {
                     this.ValueData.Value[i, j - 1] = true;
                 }
                 this.ValueData.Value[i, j] = true;
                 if (j < (this.ValueData.Size.X - 1))
                 {
                     this.ValueData.Value[i, j + 1] = true;
                 }
                 if (i < (this.ValueData.Size.Y - 1))
                 {
                     if (j > 0)
                     {
                         this.ValueData.Value[i + 1, j - 1] = true;
                     }
                     this.ValueData.Value[i + 1, j] = true;
                     if (j < (this.ValueData.Size.X - 1))
                     {
                         this.ValueData.Value[i + 1, j + 1] = true;
                     }
                 }
             }
         }
     }
 }
示例#3
0
 public void Combine(clsBooleanMap Source, clsBooleanMap Insert)
 {
     this.SizeCopy(Source);
     int num3 = Source.ValueData.Size.Y - 1;
     for (int i = 0; i <= num3; i++)
     {
         int num4 = Source.ValueData.Size.X - 1;
         for (int j = 0; j <= num4; j++)
         {
             if (Insert.ValueData.Value[i, j])
             {
                 this.ValueData.Value[i, j] = true;
             }
             else
             {
                 this.ValueData.Value[i, j] = Source.ValueData.Value[i, j];
             }
         }
     }
 }
示例#4
0
 public void Within(clsBooleanMap Interior, clsBooleanMap Exterior)
 {
     this.SizeCopy(Interior);
     int num3 = Interior.ValueData.Size.Y - 1;
     for (int i = 0; i <= num3; i++)
     {
         int num4 = Interior.ValueData.Size.X - 1;
         for (int j = 0; j <= num4; j++)
         {
             if (Interior.ValueData.Value[i, j])
             {
                 bool flag = false;
                 if (i > 0)
                 {
                     if ((j > 0) && !Exterior.ValueData.Value[i - 1, j - 1])
                     {
                         flag = true;
                     }
                     if (!Exterior.ValueData.Value[i - 1, j])
                     {
                         flag = true;
                     }
                     if ((j < (Interior.ValueData.Size.X - 1)) && !Exterior.ValueData.Value[i - 1, j + 1])
                     {
                         flag = true;
                     }
                 }
                 if ((j > 0) && !Exterior.ValueData.Value[i, j - 1])
                 {
                     flag = true;
                 }
                 if (!Exterior.ValueData.Value[i, j])
                 {
                     flag = true;
                 }
                 if ((j < (Interior.ValueData.Size.X - 1)) && !Exterior.ValueData.Value[i, j + 1])
                 {
                     flag = true;
                 }
                 if (i < (Interior.ValueData.Size.Y - 1))
                 {
                     if ((j > 0) && !Exterior.ValueData.Value[i + 1, j - 1])
                     {
                         flag = true;
                     }
                     if (!Exterior.ValueData.Value[i + 1, j])
                     {
                         flag = true;
                     }
                     if ((j < (Interior.ValueData.Size.X - 1)) && !Exterior.ValueData.Value[i + 1, j + 1])
                     {
                         flag = true;
                     }
                 }
                 this.ValueData.Value[i, j] = !flag;
             }
         }
     }
 }
示例#5
0
 public void SizeCopy(clsBooleanMap Source)
 {
     this.ValueData.Size.X = Source.ValueData.Size.X;
     this.ValueData.Size.Y = Source.ValueData.Size.Y;
     this.ValueData.Value = new bool[(this.ValueData.Size.Y - 1) + 1, (this.ValueData.Size.X - 1) + 1];
 }
示例#6
0
 public void Remove(clsBooleanMap Source, clsBooleanMap Remove)
 {
     this.SizeCopy(Source);
     int num3 = Source.ValueData.Size.Y - 1;
     for (int i = 0; i <= num3; i++)
     {
         int num4 = Source.ValueData.Size.X - 1;
         for (int j = 0; j <= num4; j++)
         {
             if (Remove.ValueData.Value[i, j])
             {
                 this.ValueData.Value[i, j] = false;
             }
             else
             {
                 this.ValueData.Value[i, j] = Source.ValueData.Value[i, j];
             }
         }
     }
 }
示例#7
0
 public clsBooleanMap GetWaterMap()
 {
     clsBooleanMap map2 = new clsBooleanMap();
     map2.Blank(this.Map.Terrain.TileSize.X + 1, this.Map.Terrain.TileSize.Y + 1);
     int y = this.Map.Terrain.TileSize.Y;
     for (int i = 0; i <= y; i++)
     {
         int x = this.Map.Terrain.TileSize.X;
         for (int j = 0; j <= x; j++)
         {
             bool isWater;
             float magnitude;
             modMath.sXY_int _int4;
             float maxValue = float.MaxValue;
             modMath.sXY_int point = new modMath.sXY_int(j * 0x80, i * 0x80);
             int num9 = this.ConnectionCount - 1;
             int index = 0;
             while (index <= num9)
             {
                 if (this.Connections[index].PassageNodeA.IsWater == this.Connections[index].PassageNodeB.IsWater)
                 {
                     modMath.sXY_int _int3 = modMath.PointGetClosestPosOnLine(this.Connections[index].PassageNodeA.Pos, this.Connections[index].PassageNodeB.Pos, point) - point;
                     magnitude = (float) _int3.ToDoubles().GetMagnitude();
                     if (magnitude < maxValue)
                     {
                         maxValue = magnitude;
                         _int3 = point - this.Connections[index].PassageNodeA.Pos;
                         _int4 = point - this.Connections[index].PassageNodeB.Pos;
                         if (_int3.ToDoubles().GetMagnitude() <= _int4.ToDoubles().GetMagnitude())
                         {
                             isWater = this.Connections[index].PassageNodeA.IsWater;
                         }
                         else
                         {
                             isWater = this.Connections[index].PassageNodeB.IsWater;
                         }
                     }
                 }
                 index++;
             }
             int num10 = this.PassageNodeCount - 1;
             for (int k = 0; k <= num10; k++)
             {
                 int num11 = this.SymmetryBlockCount - 1;
                 for (index = 0; index <= num11; index++)
                 {
                     _int4 = point - this.PassageNodes[index, k].Pos;
                     magnitude = (float) _int4.ToDoubles().GetMagnitude();
                     if (magnitude < maxValue)
                     {
                         maxValue = magnitude;
                         isWater = this.PassageNodes[index, k].IsWater;
                     }
                 }
             }
             map2.ValueData.Value[i, j] = isWater;
         }
     }
     return map2;
 }
示例#8
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;
        }