/// <summary> /// Loads a chunk specified by filename. /// Assumes that the file exists and the chunk is generated. /// If there is ANY doubt about this (i.e. if the chunk is part of the main map), use loadChunk(IntVector) instead. /// </summary> /// <param name="filename">The file that the chunk is described in.</param> /// <returns>An Octree representation of the chunk.</returns> Chunk loadChunk(string filename) { mapV1 mapmaker = content.Load<mapV1>(filename); Chunk building = new Chunk(4, filename, graphics); //Actual chunk loading code goes here. building.endFill(); return building; }
/// <summary> /// NOT FULLY IMPLEMENTED /// </summary> /// <param name="position"></param> /// <returns></returns> public patternOrChunk getPatternOrChunk(IntVector3 position) { patternOrChunk toMake; //map first if ((position >= mapOffset) && position < mapOffset + new IntVector3(mapSize)) { Chunk possible = map.get(position - mapOffset); if (possible != null) { toMake = new patternOrChunk(possible); if (mapGenHelper != null) { mapGenHelper[position] = toMake; } return toMake; } } //then helper //because if you do helper first, then ones generated during a run don't get acknowledged if (mapGenHelper != null) { if (mapGenHelper.ContainsKey(position)) { return mapGenHelper[position]; } } //then, check for a file String filename = position.ToString(); mapV1 mapmaker; try { //for some reason this is slow as f**k //probably because hard drives are slow //so it's commented for now //I wonder if it would be better if it was actually loading things? //mapmaker = content.Load<mapV1>(filename); } catch (ContentLoadException) { //if no file, then generate the pattern //mapmaker = Mapgen.generatePatterns(this, position); } //beyond here lies TEMP SHIT CODE //if (mapmaker.layers[0] == "ungenerated") { toMake = new patternOrChunk(OutpostLibrary.Structure.field); if (mapGenHelper != null) { mapGenHelper[position] = toMake; } return toMake; } Chunk building = new Chunk(position, graphics); //chunk loading from file goes here building.endFill(); toMake = new patternOrChunk(building); if (mapGenHelper != null) { mapGenHelper[position] = toMake; } return toMake; }