public static void RotateDirection(TileDirection initialDirection, TileOrientation orientation, ref TileDirection ResultDirection) { ResultDirection = initialDirection; if ( orientation.SwitchedAxes ) { ResultDirection.SwitchAxes(); } if ( orientation.ResultXFlip ) { ResultDirection.FlipX(); } if ( orientation.ResultYFlip ) { ResultDirection.FlipY(); } }
public override void ActionPerform() { var PainterBrushNum = 0; var A = 0; Terrain = Map.Terrain; Painter = Map.Painter; Tile = Terrain.Tiles[PosNum.X, PosNum.Y]; Texture = Tile.Texture; Terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff = false; Terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff = false; Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = false; Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = false; Terrain.Tiles[PosNum.X, PosNum.Y].DownSide = TileUtil.None; for ( PainterBrushNum = 0; PainterBrushNum <= Painter.CliffBrushCount - 1; PainterBrushNum++ ) { for ( A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Straight.TileCount - 1; A++ ) { PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Straight.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { if ( Tile.Tri ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = true; } else { Terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = true; } Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection); Terrain.Tiles[PosNum.X, PosNum.Y].DownSide = ResultDirection; } } for ( A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_In.TileCount - 1; A++ ) { PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_In.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection); if ( Tile.Tri ) { if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.TopLeft) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } else if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.BottomRight) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } } else { if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.TopRight) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } else if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.BottomLeft) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } } } } for ( A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_Out.TileCount - 1; A++ ) { PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_Out.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { OppositeDirection = PainterTexture.Direction; OppositeDirection.FlipX(); OppositeDirection.FlipY(); TileUtil.RotateDirection(OppositeDirection, Texture.Orientation, ref ResultDirection); if ( Tile.Tri ) { if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.TopLeft) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } else if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.BottomRight) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } } else { if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.TopRight) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } else if ( TileUtil.IdenticalTileDirections(ResultDirection, TileUtil.BottomLeft) ) { Terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = true; Terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true; } } } } } Map.SectorTerrainUndoChanges.TileChanged(PosNum); }
private void ToolPerformTile() { var PainterBrushNum = 0; var A = 0; for ( PainterBrushNum = 0; PainterBrushNum <= Painter.TerrainCount - 1; PainterBrushNum++ ) { PainterTerrainA = Painter.Terrains[PainterBrushNum]; for ( A = 0; A <= PainterTerrainA.Tiles.TileCount - 1; A++ ) { PainterTexture = PainterTerrainA.Tiles.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TerrainCount[PainterTerrainA.Num]++; } } } for ( PainterBrushNum = 0; PainterBrushNum <= Painter.TransitionBrushCount - 1; PainterBrushNum++ ) { PainterTerrainA = Painter.TransitionBrushes[PainterBrushNum].Terrain_Inner; PainterTerrainB = Painter.TransitionBrushes[PainterBrushNum].Terrain_Outer; for ( A = 0; A <= Painter.TransitionBrushes[PainterBrushNum].Tiles_Straight.TileCount - 1; A++ ) { PainterTexture = Painter.TransitionBrushes[PainterBrushNum].Tiles_Straight.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection); if ( TileUtil.DirectionsOnSameSide(VertexDirection, ResultDirection) ) { TerrainCount[PainterTerrainB.Num]++; } else { TerrainCount[PainterTerrainA.Num]++; } } } for ( A = 0; A <= Painter.TransitionBrushes[PainterBrushNum].Tiles_Corner_In.TileCount - 1; A++ ) { PainterTexture = Painter.TransitionBrushes[PainterBrushNum].Tiles_Corner_In.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection); if ( TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection) ) { TerrainCount[PainterTerrainB.Num]++; } else { TerrainCount[PainterTerrainA.Num]++; } } } for ( A = 0; A <= Painter.TransitionBrushes[PainterBrushNum].Tiles_Corner_Out.TileCount - 1; A++ ) { PainterTexture = Painter.TransitionBrushes[PainterBrushNum].Tiles_Corner_Out.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { OppositeDirection = PainterTexture.Direction; OppositeDirection.FlipX(); OppositeDirection.FlipY(); TileUtil.RotateDirection(OppositeDirection, Texture.Orientation, ref ResultDirection); if ( TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection) ) { TerrainCount[PainterTerrainA.Num]++; } else { TerrainCount[PainterTerrainB.Num]++; } } } } for ( PainterBrushNum = 0; PainterBrushNum <= Painter.CliffBrushCount - 1; PainterBrushNum++ ) { PainterTerrainA = Painter.CliffBrushes[PainterBrushNum].Terrain_Inner; PainterTerrainB = Painter.CliffBrushes[PainterBrushNum].Terrain_Outer; for ( A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Straight.TileCount - 1; A++ ) { PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Straight.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection); if ( TileUtil.DirectionsOnSameSide(VertexDirection, ResultDirection) ) { TerrainCount[PainterTerrainB.Num]++; } else { TerrainCount[PainterTerrainA.Num]++; } } } for ( A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_In.TileCount - 1; A++ ) { PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_In.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection); if ( TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection) ) { TerrainCount[PainterTerrainA.Num]++; } else { TerrainCount[PainterTerrainB.Num]++; } } } for ( A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_Out.TileCount - 1; A++ ) { PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_Out.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { OppositeDirection = PainterTexture.Direction; OppositeDirection.FlipX(); OppositeDirection.FlipY(); TileUtil.RotateDirection(OppositeDirection, Texture.Orientation, ref ResultDirection); if ( TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection) ) { TerrainCount[PainterTerrainA.Num]++; } else { TerrainCount[PainterTerrainB.Num]++; } } } } for ( PainterBrushNum = 0; PainterBrushNum <= Painter.RoadBrushCount - 1; PainterBrushNum++ ) { PainterTerrainA = Painter.RoadBrushes[PainterBrushNum].Terrain; for ( A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_Corner_In.TileCount - 1; A++ ) { PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_Corner_In.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TerrainCount[PainterTerrainA.Num]++; } } for ( A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_CrossIntersection.TileCount - 1; A++ ) { PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_CrossIntersection.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TerrainCount[PainterTerrainA.Num]++; } } for ( A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_End.TileCount - 1; A++ ) { PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_End.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TerrainCount[PainterTerrainA.Num]++; } } for ( A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_Straight.TileCount - 1; A++ ) { PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_Straight.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TerrainCount[PainterTerrainA.Num]++; } } for ( A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_TIntersection.TileCount - 1; A++ ) { PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_TIntersection.Tiles[A]; if ( PainterTexture.TextureNum == Texture.TextureNum ) { TerrainCount[PainterTerrainA.Num]++; } } } }