示例#1
0
  private static void ApplyPhrase(Age.TerrainChunk map, Phrase phrase) {
    // Let param changing adjectives have their turn

    ChunkParameters parms = new ChunkParameters();

    parms.targetRadius = 0.5f;
    parms.targetHeight = 0.5f;
    parms.world = map;

    // Default location
    int x = map.GetWidth() / 2;
    int y = map.GetHeight() / 2;

    foreach (Adjective adjective in phrase.adjectives) {
      adjective.MutateParameters(parms);
    }

    Age.TerrainPoint[] points = new Age.TerrainPoint[]{new Age.TerrainPoint(x, y)};
    if (phrase.location != null) {
      points = phrase.location.GetPoints(parms);
    }
    foreach (Age.TerrainPoint point in points) {
      Age.TerrainChunk chunk = phrase.feature.GetChunk(parms);
      foreach (Adjective adjective in phrase.adjectives) {
        if (adjective.adverbDelegate == null) {
          adjective.MutateChunk(chunk, parms);
        } else {
          adjective.adverbDelegate.MutateChunk(chunk, parms);
        }
      }
      int px = point.x - chunk.GetWidth() / 2;
      int py = point.y - chunk.GetHeight() / 2;
      map.AddChunk(chunk, px, py, parms.addMode); 
    }
  }