#!/usr/bin/perl -w

# (c) Copyright by Tels 1999. All Rights Reserved.

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::Architecture::Building;  # to get stairs etc
use Cowgen::Architecture::Basics;

print "Demo script to show usage of stairs\n\n";

$core = Cowgen::Texture->create(); $core->loadMapping("core.map");
print "Loaded texture mapping from 'core.map'\n";

# get commandline parameter
$outfile = shift || "stairs.mis";
$vbr = Cowgen::Vbr->create("houses.mis"); 
# alternatively, load tetxure mapping from houses.mis
# $core = Cowgen::Texture->create( $vbr->getTXT() );

my $bunch = Cowgen::Bunch->create("Room with Stairs");

srand(1);
$bunch->setDefTexture($core->texture("slab"));

my $face = $core->texture("brick");
my $top = $core->texture("wood");
my $side = $core->texture("tile");
my $it = $core->texture("ston");
my $ot = $core->texture("tile2");

print "Top: ",$core->textureLName($top)," $top\n";
print "Face: ",$core->textureLName($face)," $face\n";

$brush = $bunch->addBrush(air(),cube(),-4,4,10,64,36,20);
$brush = $bunch->addBrush(air(),cube(),24,10,20,62,20,16,$core->texture("rufgr"));

$p = { steps => 12, stepheight => 1, stepdepth => 2, flags => bslabs()+basroom(),
       toptexture => $top, facetexture => $face, sidetexture => $side,
     };
$bunch->merge( stairs(2,-16,6.5,10,0,0,$p) );

$p->{flags} = bfilled()+bair(); $p->{stepdepth} = 1;
$bunch->merge( stairs(8,-2,6.5,10,0,0,$p) );

$p->{stepdepth} = 2;
$p->{flags} = bfilled()+bleft()+bright()+basroom();
$p->{raisingwidth} = 1.5; $p->{raisingheight} = 1;
$bunch->merge( stairs(2,12,7,10,0,0,$p) );

# with landing, only left raised
$p->{stepdepth} = 2;
$p->{steps} = 10; 
$p->{headroomheight} = 8;
$p->{flags} = basroom()+bair()+bfilled()+bright()+bwedge();
$p->{raisingwidth} = 1.5; $p->{raisingheight} = 1; $p->{sidetexture} = $it;
#$p->{facing} = aWest(); # turned
$bunch->merge( stairs(0,30,10,12,28,0,$p) );

#$stairs = spiralstairs(30,-38,-4,12,8,4,2,1,8,0,10,basroom(),$top,$face,$ot,$it);
#$bunch->merge($stairs);

#$stairs = spiralstairs(60,-38,-4,12,8,4,2,1,8,0,10,bleft()+basroom(),$top,$face,$ot,$it);
#$bunch->merge($stairs);

#$stairs = spiralstairs(40,0,24,12,16,6,0,0.75,4,1,16,bleft()+basroom(),$side,$face,$ot,$it);
#$bunch->merge($stairs);

#$stairs = spiralstairs(18,25,24,16,0,8,0,0.5,2,0,16,bleft(),$side,$face,$ot);
#$bunch->merge($stairs);

$brush = $bunch->addBrush(air(),cube(),34,-26,16,16,8,8);
$brush = $bunch->addBrush(solid(),cube(),34,-26,11,16,8,2);

# tower
$brush = $bunch->addBrush(air(),cube(),-46,0,-20,32,32,64,$core->texture("rufgr"));
$brush = $bunch->addBrush(air(),cube(),-26,0,5,4,8,7,$core->texture("bricks")); # door to tower

# stepwidth == stepdepth, otherwise it wont work
$p = { steps => 8, stepheight => 0.75, stepwidth => 4, stepdepth => 4, flags => basroom(),
       toptexture => $top, facetexture => $face, sidetexture => $side, 
       walltexture => $core->texture("rufgr"), startpart => 1, parts => 8
     };
#$bunch->merge( towerstairs(-46,0,-20,32,32,64,$p) );

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

# EOF

1;
