public static TerrainTile ReadTerrainTile(this BinaryReader reader, MapEnvironmentFormatVersion formatVersion) => new TerrainTile(reader, formatVersion);
public static void Write(this BinaryWriter writer, TerrainTile terrainTile, MapEnvironmentFormatVersion formatVersion) => terrainTile.WriteTo(writer, formatVersion);
internal TerrainTile(BinaryReader reader, MapEnvironmentFormatVersion formatVersion) { ReadFrom(reader, formatVersion); }
public MapEnvironment(Tileset tileset, uint width, uint height, int cliffLevel, RectangleMargins cameraBoundsComplements) : this() { if (!Enum.IsDefined(typeof(Tileset), tileset)) { throw new ArgumentOutOfRangeException(nameof(tileset)); } var maxx = width - 1; if ((maxx % 32) != 0 || width == 0) { throw new ArgumentOutOfRangeException(nameof(width)); } var maxy = height - 1; if ((maxy % 32) != 0 || height == 0) { throw new ArgumentOutOfRangeException(nameof(height)); } if (cameraBoundsComplements is null) { throw new ArgumentNullException(nameof(cameraBoundsComplements)); } _tileset = tileset; _version = LatestVersion; _width = width; _height = height; _left = MapWidth / -2f; _bottom = MapHeight / -2f; _terrainTypes = GetDefaultTerrainTypes().ToList(); _cliffTypes = GetDefaultCliffTypes().ToList(); var edgeLeft = cameraBoundsComplements.Left; var edgeRight = maxx - cameraBoundsComplements.Right; var edgeBottom = cameraBoundsComplements.Bottom; var edgeTop = maxy - cameraBoundsComplements.Top; for (var y = 0; y < _width; y++) { for (var x = 0; x < _height; x++) { var tile = new MapTile(); tile.CliffLevel = cliffLevel; tile.CliffTexture = 15; tile.CliffVariation = 0; tile.Height = 0; tile.IsBlighted = false; tile.IsBoundary = false; tile.IsEdgeTile = x != maxx && y != maxy && (x < edgeLeft || x >= edgeRight || y < edgeBottom || y >= edgeTop); tile.IsRamp = false; tile.IsWater = false; tile.Texture = 0; tile.Variation = 0; tile.WaterHeight = 0; _tiles.Add(tile); } } }
/// <summary> /// Initializes a new instance of the <see cref="MapEnvironment"/> class. /// </summary> /// <param name="formatVersion"></param> public MapEnvironment(MapEnvironmentFormatVersion formatVersion) { FormatVersion = formatVersion; }