# !/usr/bin/perl -w

# This is the package Waters. It contains some objects for usage in water
# like boots and some waterworks architecture.

# (c) Copyright by Tels 1999-2000. All Rights Reserved. Do NOT distribute.
# Updates and support on bloodgate.com/thief

# 2000-01-04 v0.0.1 - from scratch

package Cowgen::Architecture::Waters;
require Exporter;
@ISA    = qw(Exporter);
@EXPORT = qw( 
            boot raft
          
            floorGrate
            );
#@EXPORT_OK = qw();

use Cowgen::Bunch;
use Cowgen::Dromed;

sub boot
  {
  # create a simple, small boot
  # named parameters:  texture, facing, thick (floor thickess)
  my ($x,$y,$z,$w,$l,$h,$p) = @_;
  my $t = $p->{texture} || -1;
  my $thick = $p->{thick} || 0.25;
  my $facing = $p->{facing} || aSouth();
  my $b = Cowgen::Bunch->create("boot##num##");
  $b->addBrush (solid(),cube(),$x,$y,$z,$w,$l,$h,$t);
  $b->addBrush (solid(),cube(),$x,$y,$z+$thick,$w,$l,$h-$thick,$t);
  $b->rotateByFacing($x,$y,$z,$facing);
  return $b; # boot
  }

sub raft
  {
  # create a simple, small raft (not quite ready yet)
  # named parameters:  texture, facing, thick (floor thickess)
  my ($x,$y,$z,$w,$l,$h,$p) = @_;
  my $t = $p->{texture} || -1;
  my $thick = $p->{thick} || 0.25;
  my $facing = $p->{facing} || aSouth();
  my $b = Cowgen::Bunch->create("boot##num##");
  $b->addBrush (solid(),cube(),$x,$y,$z,$w,$l,$h,$t);
  $b->addBrush (solid(),cube(),$x,$y,$z+$thick,$w,$l,$h-$thick,$t);
  $b->rotateByFacing($x,$y,$z,$facing);
  return $b; # boot
  }

sub floorGrate
  {
  # create a cubic floor hole and put grate at top
  # named parameters:  texture, facing, headroom (distance from top to
  # grate start; defaults to 0.25), thick (grate outer thickness), gridheight
  # (height of outer gridframe),
  # barwidth (grate bar width),
  # barheight (grate bar height; defaults to 3/4 height), 
  # barsx (count of bars in x axis; default 0), barsy 
  # (count of bars in y axis; default 0), bartexture
  my ($x,$y,$z,$w,$l,$h,$p) = @_;
  my $t = $p->{texture} || -1;
  my $thick = $p->{thick} || 0.25;
  my $bw = $p->{barwidth} || 0.25;
  my $bh = $p->{barheight} || 0.75*$h;
  my $gh = $p->{gridheight} || 1;
  my $bx = $p->{barsx} || 0;
  my $by = $p->{barsy} || 0;
  my $bt = $p->{bartexture} || $t;
  my $hr = $p->{headroom} || 0.25;
  my $facing = $p->{facing} || aSouth();
  my $b = Cowgen::Bunch->create("floorgrate##num##");
  $b->addBrush (air()+MROOM,cube(),$x,$y,$z,$w,$l,$h,$t);
  my $e = { barsx => $bx, barsy => $by, framethick => thick,
     gridthick => $bh, frametexture => $bt, gridtexture => $bt, 
     facing => top(), 
     };
  $b->merge ( grid ( $x,$y,$z-$hr-$gh/2, $w,$l,$gh, $e) );
  $b->rotateByFacing($x,$y,$z,$facing);
  return $b; # boot
  }

1;

