# !/usr/bin/perl -w

# (c) Copyright by Tels 1999-2000. All Rights Reserved.
# 2000-01-09 v0.0.1 - from scratch

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::House;        # virtual houses
use Cowgen::Architecture::Basics;
use Cowgen::Route;

print "Shows how create automatic patrol routes.\n\n";

$vbr = Cowgen::Vbr->create("houses.mis");
$txt = Cowgen::Texture->create($vbr->getTXT()); 
$gf = Cowgen::Gamfile->create("Dark.gam");

# get commandline parameter
$outfile = shift || "vroute.mis"; 
print "Need .mis as outfile!\n" if ($outfile !~ /\.mis$/);
$outfile = "data/$outfile" if ($outfile !~ /^data\//);

# first define some basic templates
# txt is for some roomGenerators, so that they can get their textures

$room = { texture => $txt->texture("rufgry"), wallthick => 0.5,
          ceilingtexture => $txt->texture("wdplnk2"),
          bandheight => 3, bandtexture => $txt->texture("stone2s2"),
          floortexture => $txt->texture("mosaic"), bandthick => 0.25, 
          gridsize => 0.25, 
        };

my $clist = $txt->weightedList( { r02 => 1, r03 => 1, r04 => 1, r05 => 1, r06 => 1,
              r07 => 1, r08 => 1, r11 => 1, } );

my $carpet = { texture => randTexture($clist), sx => 1, sy => 1,};

print "Today using ",$txt->textureName($carpet->{texture}->{t})," as carpet.\n";

# blockthick and blocktexture are ignored for fake things
# door/window type is defined later on
my $mydoor = { floortexture => $txt->texture("tile"), texture => $txt->texture("wdplanko"), 
        innertexture => $txt->texture("wdplanko"), framethick => 0.25,
        blocktexture => $txt->texture("wood"), blockthick => 0.5,
        height => 8, width => 4
        };

$mywindow = { texture => $txt->texture("stucco"), framethick => 0.5,
              blocktexture => $txt->texture("win325s"), 
              blockthick => 0.5, height => 5, width => 5,
              sidetexture => { t => sky(), s => 24 },
            };

# now make from some ready-made template
$house = smallHouse("myHouse", 2, 1 , $room, $mydoor, $mywindow);

$house->{debug} = 1;
$house->{gamfile} = $gf;
($bunch,$tp) = worldAsBunch (0, 32, 0, 48, 32, 44, $house);
$bunch->debug();

$n = { 0 => "kitchen", 1 => "hallway", 2 => "sitting", 3 => "sleep",
       4 => "hallway", };

$ro = Cowgen::Route->fromNames ($tp,$n);

$bunch->merge ( $ro->asBunch($gf,circular()+shuffle()) );

$bunch->autoRoom(1); $bunch->autoFlow(); optimizeSky($bunch); 
$vbr->missionEAX ( eax => eax_stoneRoom() );
$vbr->renderParams ( ambient => 20 ); # always use this!
$vbr->saveMission($gf,$bunch,$outfile);
print "Done, enjoy $outfile!\n";

# EOF
1;

