void PostInit() { rules = Exts.Lazy(() => { try { return(Game.modData.RulesetCache.LoadMapRules(this)); } catch (Exception e) { InvalidCustomRules = true; Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e.Message); } return(Game.modData.DefaultRules); }); cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]); var tl = Map.MapToCell(TileShape, new CPos(Bounds.Left, Bounds.Top)); var br = Map.MapToCell(TileShape, new CPos(Bounds.Right - 1, Bounds.Bottom - 1)); Cells = new CellRegion(TileShape, tl, br); CustomTerrain = new CellLayer <byte>(this); foreach (var cell in Cells) { CustomTerrain[cell] = byte.MaxValue; } }
/// <summary>Expand the specified region with an additional cordon. This may expand the region outside the map borders.</summary> public static CellRegion Expand(CellRegion region, int cordon) { var offset = new CVec(cordon, cordon); var tl = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.TopLeft) - offset); var br = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.BottomRight) + offset); return(new CellRegion(region.shape, tl, br)); }
public void ResizeCordon(int left, int top, int right, int bottom) { Bounds = Rectangle.FromLTRB(left, top, right, bottom); var tl = Map.MapToCell(TileShape, new CPos(Bounds.Left, Bounds.Top)); var br = Map.MapToCell(TileShape, new CPos(Bounds.Right - 1, Bounds.Bottom - 1)); Cells = new CellRegion(TileShape, tl, br); }
void PostInit() { rules = Exts.Lazy(() => Game.modData.RulesetCache.LoadMapRules(this)); cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]); var tl = Map.MapToCell(TileShape, new CPos(Bounds.Left, Bounds.Top)); var br = Map.MapToCell(TileShape, new CPos(Bounds.Right - 1, Bounds.Bottom - 1)); Cells = new CellRegion(TileShape, tl, br); CustomTerrain = new CellLayer <int>(this); foreach (var cell in Cells) { CustomTerrain[cell] = -1; } }
public bool MoveNext() { u += 1; // Check for column overflow if (u > r.mapBottomRight.X) { v += 1; u = r.mapTopLeft.X; // Check for row overflow if (v > r.mapBottomRight.Y) { return(false); } } current = Map.MapToCell(r.shape, new CPos(u, v)); return(true); }