public GeneratorProcess Generate(CubeWorldGenerator generator) { enqueueTileUpdates = false; reportTileInvalidated = false; updateLighting = false; ChainedWorldGenerator chained = new ChainedWorldGenerator(); chained.AddGenertor(generator); chained.AddGenertor(new InternalWorldInitializationGenerator()); return(new GeneratorProcess(chained, this.world)); }
private CubeWorldGenerator CreateGenerator(XmlElement generatorXML) { CubeWorldGenerator generator = null; switch (generatorXML.Name) { case "Chained": generator = new ChainedWorldGenerator(); foreach (XmlElement childGeneratorXML in GetChildElements(generatorXML)) { ((ChainedWorldGenerator)generator).AddGenertor(CreateGenerator(childGeneratorXML)); } break; case "Plain": generator = new PlainWorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType"))); break; case "PlainRandom": generator = new PlainRandomWorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), GetTileTypeProbabilities(GetChildElements(generatorXML))); break; case "ParticleDeposition": generator = new ParticleDepositionWorldGenerator( GetAttributeRelativeValue(generatorXML, "minParticles"), GetAttributeRelativeValue(generatorXML, "maxParticles"), GetAttributeRelativeValue(generatorXML, "minDrops"), GetAttributeRelativeValue(generatorXML, "maxDrops"), TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType"))); break; case "Water": generator = new WaterWorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), TileIdToTileType(GetAttributeStringValue(generatorXML, "waterTileType"))); break; case "TopTileTransformation": generator = new TopTileTransformationWorldGenerator( TileIdToTileType(GetAttributeStringValue(generatorXML, "fromTile")), TileIdToTileType(GetAttributeStringValue(generatorXML, "toTile")), GetAttributeFloatValue(generatorXML, "probability")); break; case "Tree": generator = new TreeWorldGenerator( GetAttributeRelativeValue(generatorXML, "min"), GetAttributeRelativeValue(generatorXML, "max"), GetAttributeIntValue(generatorXML, "minTrunkHeight"), GetAttributeIntValue(generatorXML, "maxTrunkHeight"), GetAttributeIntValue(generatorXML, "minLeavesHeight"), GetAttributeIntValue(generatorXML, "maxLeavesHeight"), GetAttributeIntValue(generatorXML, "minLeavesRadius"), GetAttributeIntValue(generatorXML, "maxLeavesRadius"), TileIdToTileType(GetAttributeStringValue(generatorXML, "overTile")), TileIdToTileType(GetAttributeStringValue(generatorXML, "trunkTile")), TileIdToTileType(GetAttributeStringValue(generatorXML, "leavesTile"))); break; case "Smooth": generator = new SmoothWorldGenerator( TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType")), GetAttributeRelativeValue(generatorXML, "iterations"), GetAttributeRelativeValue(generatorXML, "minRadius"), GetAttributeRelativeValue(generatorXML, "maxRadius")); break; case "Hole": generator = new HoleWorldGenerator( GetAttributeRelativeValue(generatorXML, "iterations"), GetAttributeRelativeValue(generatorXML, "minRadius"), GetAttributeRelativeValue(generatorXML, "maxRadius"), GetAttributeRelativeValue(generatorXML, "minDepth"), GetAttributeRelativeValue(generatorXML, "maxDepth")); break; case "Cave": generator = new CaveWorldGenerator( GetAttributeRelativeValue(generatorXML, "iterations"), GetAttributeRelativeValue(generatorXML, "minRadius"), GetAttributeRelativeValue(generatorXML, "maxRadius"), GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY")); break; case "CaveCell": generator = new CaveCellWorldGenerator( GetAttributeRelativeValue(generatorXML, "iterations"), GetAttributeRelativeValue(generatorXML, "minRadius"), GetAttributeRelativeValue(generatorXML, "maxRadius"), GetAttributeRelativeValue(generatorXML, "minDepth"), GetAttributeRelativeValue(generatorXML, "maxDepth")); break; case "MidpointDisplacement": generator = new MidpointDisplacementWorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), GetAttributeFloatValue(generatorXML, "roughness"), TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType"))); break; case "PerlinNoise": generator = new PerlinNoiseWorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), GetAttributeIntValue(generatorXML, "octaves"), GetAttributeFloatValue(generatorXML, "freq"), TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType"))); break; case "PerlinNoise2": generator = new PerlinNoise2WorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), GetAttributeIntValue(generatorXML, "octaves"), GetAttributeFloatValue(generatorXML, "freq"), TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType"))); break; case "Deposit": generator = new DepositWorldGenerator( GetAttributeRelativeValue(generatorXML, "fromY"), GetAttributeRelativeValue(generatorXML, "toY"), GetAttributeRelativeValue(generatorXML, "iterations"), GetAttributeRelativeValue(generatorXML, "minRadius"), GetAttributeRelativeValue(generatorXML, "maxRadius"), TileIdToTileType(GetAttributeStringValue(generatorXML, "overTile")), TileIdToTileType(GetAttributeStringValue(generatorXML, "tileType")), GetAttributeBoolValue(generatorXML, "allowEmptyAbove", false)); break; default: throw new System.Exception("Unknown generator type: " + generatorXML.Name); } return(generator); }