#!/usr/bin/perl -w

# (c) Copyright by Tels 1999-2000. All Rights Reserved.
# 2000-03-11 v0.0.1 - from scratch
# 2000-05-06 v0.0.2 - fixed unknown sub bug/room gen

use Cowgen::Bunch;                  # for a bunch of brushes
use Cowgen::Dromed;                 # for some Thief constants and specifics
use Cowgen::Texture;                # to get texture mappings
use Cowgen::VWorld::Room;           # virtual world based on cells
use Cowgen::VWorld::RoomGen;        # room generators
use Cowgen::Objsize;                # for size of objects
use Cowgen::Architecture::Basics;   # balcony, rooms etc
use Cowgen::Architecture::Building; # stairs
use Cowgen::Thief;

print "VWorld Tutorial Wrapper v0.0.1 (C) Copyright by Tels 2000. All Rights Reserved.\n\n";
print "Call as perl vtutorial.pl [section] where section is 1..x and defaults to 1.\n\n";

my $section = shift || 1;

print "Reading tutorial section $section...\n";

if (!-e "tutorial/section$section.txt")
  {
  print "Cant find tutorial/section$section.txt, please give valid section.\n";
  exit;
  }

# make a runtime include ;)
require "tutorial/section$section.txt";

# create a vbr object from template mission
$vbr = Cowgen::Vbr->create("houses.mis");
$txt = Cowgen::Texture->create($vbr->getTXT()); 
$gf = Cowgen::Gamfile->create("Dark.gam");

$outfile = "data/vtut_$section.mis"; 

$bunch = createWorld($txt,$gf);
$bunch->debug();
# optimize and generate rooms and flows, then write out
$bunch->optimize();
$bunch->autoRoom(0,3); $bunch->autoFlow(); optimizeSky($bunch);
$vbr->missionEAX ( eax => eax_stoneRoom() );
$vbr->renderParams ( ambient => 20 ); # always use this!
$vbr->missionDescription ( number => 20, path => "section$section", ); # for save/load to work
$vbr->scriptModules ( "convict" );
$vbr->saveMission($gf,$bunch,$outfile);
print "Done, enjoy $outfile!\n";

# EOF
1;

