NL3D::CTileVegetableDesc Class Reference

#include <tile_vegetable_desc.h>


Detailed Description

A descriptor of vegetables for a tile.
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 50 of file tile_vegetable_desc.h.

Public Member Functions

void build (const std::vector< CVegetable > &vegetables)
 Build the CTileVegetableDesc.

void clear ()
 clear lists.

 CTileVegetableDesc ()
 Constructor.

const std::vector< CVegetable > & getVegetableList (uint distType) const
 get the vegetable list for a specific distanceType

uint getVegetableSeed (uint distType) const
 get the vegetable seed for a specific distanceType

void registerToManager (CVegetableManager *vegetableManager)
 register all Vegetables in this to the manager.

void serial (NLMISC::IStream &f)
 serial.


Private Attributes

std::vector< CVegetable_VegetableList [NL3D_VEGETABLE_BLOCK_NUMDIST]
uint32 _VegetableSeed [NL3D_VEGETABLE_BLOCK_NUMDIST]


Constructor & Destructor Documentation

NL3D::CTileVegetableDesc::CTileVegetableDesc  ) 
 

Constructor.

Definition at line 43 of file tile_vegetable_desc.cpp.

00044 {
00045 }


Member Function Documentation

void NL3D::CTileVegetableDesc::build const std::vector< CVegetable > &  vegetables  ) 
 

Build the CTileVegetableDesc.

Definition at line 57 of file tile_vegetable_desc.cpp.

References _VegetableList, _VegetableSeed, clear(), min, NL3D_VEGETABLE_BLOCK_NUMDIST, and uint.

00058 {
00059         uint    i;
00060 
00061         // first clear().
00062         clear();
00063 
00064         // Parse all landscape vegetables, and store them in appropriate distance Type.
00065         for(i=0;i<vegetables.size();i++)
00066         {
00067                 uint    distType= vegetables[i].DistType;
00068                 distType= min(distType, (uint)(NL3D_VEGETABLE_BLOCK_NUMDIST-1));
00069                 _VegetableList[distType].push_back(vegetables[i]);
00070         }
00071 
00072         // Compute Seed such that creation of one vegetable for a tile will never receive same seed.
00073         uint    sumVeget= 0;
00074         for(i=0; i<NL3D_VEGETABLE_BLOCK_NUMDIST; i++)
00075         {
00076                 _VegetableSeed[i]= sumVeget;
00077                 // add number of vegetable for next seed.
00078                 sumVeget+= _VegetableList[i].size();
00079         }
00080 
00081 }

void NL3D::CTileVegetableDesc::clear  ) 
 

clear lists.

Definition at line 48 of file tile_vegetable_desc.cpp.

References _VegetableList, NL3D_VEGETABLE_BLOCK_NUMDIST, and sint.

Referenced by build().

00049 {
00050         for(sint i=0; i<NL3D_VEGETABLE_BLOCK_NUMDIST; i++)
00051         {
00052                 _VegetableList[i].clear();
00053         }
00054 }

const std::vector< CVegetable > & NL3D::CTileVegetableDesc::getVegetableList uint  distType  )  const
 

get the vegetable list for a specific distanceType

Definition at line 112 of file tile_vegetable_desc.cpp.

References _VegetableList, NL3D_VEGETABLE_BLOCK_NUMDIST, nlassert, and uint.

Referenced by NL3D::CPatch::generateTileVegetable().

00113 {
00114         nlassert(distType < NL3D_VEGETABLE_BLOCK_NUMDIST);
00115 
00116         return _VegetableList[distType];
00117 }

uint NL3D::CTileVegetableDesc::getVegetableSeed uint  distType  )  const
 

get the vegetable seed for a specific distanceType

Definition at line 120 of file tile_vegetable_desc.cpp.

References _VegetableSeed, NL3D_VEGETABLE_BLOCK_NUMDIST, nlassert, and uint.

Referenced by NL3D::CPatch::generateTileVegetable().

00121 {
00122         nlassert(distType < NL3D_VEGETABLE_BLOCK_NUMDIST);
00123 
00124         return _VegetableSeed[distType];
00125 }

void NL3D::CTileVegetableDesc::registerToManager CVegetableManager vegetableManager  ) 
 

register all Vegetables in this to the manager.

Definition at line 84 of file tile_vegetable_desc.cpp.

References _VegetableList, NL3D_VEGETABLE_BLOCK_NUMDIST, and uint.

Referenced by NL3D::CTileBank::initTileVegetableDescs().

00085 {
00086         // Pasre all distanceType.
00087         for(uint i=0; i<NL3D_VEGETABLE_BLOCK_NUMDIST; i++)
00088         {
00089                 // Parse all vegetables of the list.
00090                 for(uint j=0; j<_VegetableList[i].size(); j++)
00091                 {
00092                         // register the vegetable to the manager
00093                         _VegetableList[i][j].registerToManager(vegetableManager);
00094                 }
00095         }
00096 }

void NL3D::CTileVegetableDesc::serial NLMISC::IStream f  ) 
 

serial.

Definition at line 99 of file tile_vegetable_desc.cpp.

References _VegetableList, _VegetableSeed, NL3D_VEGETABLE_BLOCK_NUMDIST, nlassert, NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), and uint.

00100 {
00101         (void)f.serialVersion(0);
00102 
00103         nlassert(NL3D_VEGETABLE_BLOCK_NUMDIST==5);
00104         for(uint i=0; i<NL3D_VEGETABLE_BLOCK_NUMDIST; i++)
00105         {
00106                 f.serialCont(_VegetableList[i]);
00107                 f.serial(_VegetableSeed[i]);
00108         }
00109 }


Field Documentation

std::vector<CVegetable> NL3D::CTileVegetableDesc::_VegetableList[NL3D_VEGETABLE_BLOCK_NUMDIST] [private]
 

List of vegetable to instanciate for a specific tile Grouped by distance Type.

Definition at line 81 of file tile_vegetable_desc.h.

Referenced by build(), clear(), getVegetableList(), registerToManager(), and serial().

uint32 NL3D::CTileVegetableDesc::_VegetableSeed[NL3D_VEGETABLE_BLOCK_NUMDIST] [private]
 

Definition at line 83 of file tile_vegetable_desc.h.

Referenced by build(), getVegetableSeed(), and serial().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 08:05:56 2004 for NeL by doxygen 1.3.6