#!/usr/bin/perl -w

# 2000-06-07 0.0.1 first version

# test to show usage of WC.pm (Halflife/worldcraft mapping)

$VERSION = '0.01';
$| = 1; # disable out buffer

use Cowgen::Dromed;    # for some Thief constants and specifics
use Cowgen::Wc;        # worldcraft stuff
use Cowgen::Bunch;
use strict 'vars';

print "HL/WC (c) Copyright by Tels 1999-2000. All Rights Reserved.\n\n";
print "Creates a test halflife/worldcraft map file.\n\n";
print "Usage: perl [output.map]\n";

# get commandline parameter
my $outfile = shift || "output.map"; 

my $bunch = Cowgen::Bunch->create("Helo Worldcraft!");

my ($l,$p,$m);

# put something into bunch

# sample solid brush
$bunch->addBrush (solid(),cube(),0,0,0,32,32,32,1);

# sample brushlight (spot not yet supported)
$l = { red => 255, green => 80, blue => 0 };
$bunch->addLight (omni(),0,0,0,$l);

# sample object 
# you need base to avoid error msg, even WC doesnt support hirarchical objects
$p = { name => "startingPoint", base => -1, };
my $o = $bunch->addObject (0,0,16,0,0,0,$p);
$bunch->setProperty ($o, 'classname', "info_player_start");

# another sample object
$p = { name => "some_glow", base => -1, };
my $glow = $bunch->addObject (32,0,0,0,0,0,$p);
# show that setProperty still works
$bunch->setProperties($glow, { "renderamt" => 150, 
    rendercolor => [255,255,128], renderfx => 14,
    model => "sprites/flare1.spr", rendermode => 3,
    classname => "env_glow", }
);

# define WAD files (not yet automatic)
my $wads = [ "\games\halflife\valve\halflife.wad", "\games\halflife\valve\decals.wad" ];
# create a map text
$m = Cowgen::WC::asMap($bunch,$wads);

# write out to file
open FILE, ">$outfile" or die "Cant write $outfile: $!\n";
print FILE $m;
close FILE;

print "\nCreated $outfile. Done.\n";

1; # EOF
