public ListModel(IPlanetData planetData) { _planetData = planetData; }
public EditModel(IPlanetData planetData, IHtmlHelper htmlHelper) { _planetData = planetData; _htmlHelper = htmlHelper; }
public Planet(IPlanetData terrain, int seed) { Terrain = terrain; Biomes = Terrain.BiomeList; Seed = seed; var PRNG = new System.Random(seed); int icosphereLevel = 7; if (Tiles == null) { string cachepath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/tiles.dat"; try { using (var stream = new FileStream(cachepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { var reader = new BinaryReader(stream); var version = reader.ReadString(); if (version != System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()) { throw new Exception(string.Format("Wrong version in cache file: found {0}, expected {1}", version, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version)); } int level = reader.ReadInt32(); if (level != icosphereLevel) { throw new Exception(string.Format("Wrong tessellation level in cache file: found {0}, expected {1}", level, icosphereLevel)); } int n = reader.ReadInt32(); Tiles = new TileGeometry[n]; for (int i = 0; i < n; i++) { Tiles[i] = new TileGeometry(reader); } } } catch (Exception e) { Log("Cannot open geometry from cache: {0}", e.Message); var sphere = new Icosphere(icosphereLevel); Tiles = sphere.GetDual(); try { using (var stream = new FileStream(cachepath, FileMode.Create, FileAccess.Write)) { var writer = new BinaryWriter(stream); writer.Write(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); writer.Write(icosphereLevel); writer.Write(Tiles.Length); for (int i = 0; i < Tiles.Length; i++) { Tiles[i].Write(writer); } } } catch (Exception e2) { Log("Cannot write geometry to cache: {0}", e2.Message); } } } TileSeeds = new int[Tiles.Length]; for (int i = 0; i < Tiles.Length; i++) { TileSeeds[i] = PRNG.Next(); } data = new LRUCache <TileData>(idx => new TileData(this, idx), 200); }
public DeleteModel(IPlanetData planetData) { _planetData = planetData; }
public DetailModel(IPlanetData planetData) { _planetData = planetData; }
public PlanetCountViewComponent(IPlanetData planetData) { _planetData = planetData; }
public Planet(IPlanetData terrain, int seed) { Terrain = terrain; Biomes = Terrain.BiomeList; Seed = seed; var PRNG = new System.Random(seed); int icosphereLevel = 7; if (Tiles == null) { string cachepath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/tiles.dat"; try { using (var stream = new FileStream(cachepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { var reader = new BinaryReader(stream); var version = reader.ReadString(); if (version != System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()) { throw new Exception(string.Format("Wrong version in cache file: found {0}, expected {1}", version, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version)); } int level = reader.ReadInt32(); if (level != icosphereLevel) { throw new Exception(string.Format("Wrong tessellation level in cache file: found {0}, expected {1}", level, icosphereLevel)); } int n = reader.ReadInt32(); Tiles = new TileGeometry[n]; for (int i = 0; i < n; i++) { Tiles[i] = new TileGeometry(reader); } } } catch (Exception e) { Log("Cannot open geometry from cache: {0}", e.Message); var sphere = new Icosphere(icosphereLevel); Tiles = sphere.GetDual(); try { using(var stream = new FileStream(cachepath, FileMode.Create, FileAccess.Write)) { var writer = new BinaryWriter(stream); writer.Write(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); writer.Write(icosphereLevel); writer.Write(Tiles.Length); for(int i = 0; i < Tiles.Length; i++) { Tiles[i].Write(writer); } } } catch(Exception e2) { Log("Cannot write geometry to cache: {0}", e2.Message); } } } TileSeeds = new int[Tiles.Length]; for (int i = 0; i < Tiles.Length; i++) { TileSeeds[i] = PRNG.Next(); } data = new LRUCache<TileData>(idx => new TileData(this, idx), 200); }