
class TestGen extends WorldGenerator
{
  // tags="WorldGen"

  function generate()
  {
    // function testRequest(r)
    // {
    //   print(format("WELEMS(\"%s\"):\n", r))
    //   local elems=WELEMS(r)
    //   foreach (e in elems)
    //   {
    //     foreach (n,v in getroottable())
    //       if (v==e) { print("  "+n); break; }
    //   }
    //   print("\n")
    // }
    // testRequest("Circle")
    // testRequest("stone")
    // testRequest("Circle stone")
    // testRequest("!Circle stone")
    // testRequest("Circle !stone")
    // testRequest("!PlayerTrigger -megalith whatever")
    // testRequest("!whatever")
    // testRequest("-Circle")
    // testRequest("-whatever")
    // testRequest("-Circle stone")

    local c =SpawnMonstersAround({ event="spawn1" })
    local c2=SpawnMonstersAround({ event="spawn2" })

    topo=TopoScatter([
      TopoCircle(30),
      c.topo,
      c2.topo,
      TopoCircle(30),
      TopoCircle(10),
      TopoCircle(10),
      TopoCircle(10),
      TopoCircle(10),
      ])
    addGeo(GeoSkeleton(topo, { avgh=10 }))
    addGeo(c.geo)
    addGeo(c2.geo)

    base.generate()

    c.placeObjects()
    c2.placeObjects()

    TriggerHub({ completionEvent="complete", events=["spawn1", "spawn2"] })
    SpawnPortalListener("complete", { topo=c.topo })

    // function f(e)
    // {
    //   if ("sub" in e) f(e.sub)
    //   if ("children" in e)
    //     foreach (c in e.children) f(c)
    //   else
    //     TreeObject(e.ox, e.oz,
    //       get_pal_color(cur_world_pal, "leaves"),
    //       get_pal_color(cur_world_pal, "trunk"))
    // }
    // // f(topo)
  }
}
