/*****************************************************************************
 * $Id: game_pony_world.hh,v 1.12 2006/08/10 03:18:59 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Game world.
 *//*
 * LEGAL:	COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#ifndef GAME_PONY_WORLD_HH
#define GAME_PONY_WORLD_HH 1

#include "eng_world.hh"

enum eWorldSize { eWorldSize_NORMAL, eWorldSize_LARGE, eWorldSize_HUGE };

////////////////////////////////////////////////////////////////////////////////
/// @class GamePonyWorld
class GamePonyWorld : public World
{
private:
	PREVENT_COPYING(GamePonyWorld)
	typedef World Parent;

public:
					GamePonyWorld( void ) { }	// substituted by Make()
					~GamePonyWorld() { }		// substituted by Destroy()
	void			Make( void );
	void			PopulateQuadrant( QuadrantPtrc q );
	bool			Fence( Dyna& dyna, Position& pos /*IN/OUT*/ );
	bool			IfSmallObject( const Object& obj ) const { return obj.GetRadius() < WORLD(150.0); }
	bool			TooCloseToInitialViewpoint( const Posrad& posrad ) const;
	void			LodUserChanged( void );
};

//------------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief Super-struct for the parameters of the simulated world.
class GamePonyWorldParm
{
	PREVENT_COPYING(GamePonyWorldParm)
public:

//------------------------------------------
// World parameters.
// Defines the size of the simulated world.
//------------------------------------------
	GamePonyWorldParm( void )
	{
        mObjRatio           = 0.5;          ///< order-dependent
		mWorldDim[XX]		= 12;			///< in quadrants
		mWorldDim[YY]		= 1;
		mWorldDim[ZZ]		= 12;
		mQuadrantEdge		= WORLD(mObjRatio * 70*1000);
		mMargin				= WORLD(200.0);
		mWorldSize			= eWorldSize_NORMAL;
	}
    // mObjRatio helps to populate quadrants when quadrant scale is changed.
    // If populating objects in a quadrant is tuned for arbitrary ratio of 1.0,
    // then if the quadrant size is scaled down 50%, change the ratio to 0.5.
    fp          mObjRatio;
	Array<3>	mWorldDim;
	fp			mQuadrantEdge;		///< length in world coord
	fp			mMargin;			///< for when Fence() wraps a Dyna
	eWorldSize	mWorldSize;

//------------------------------------------
// Terrain parameters.
//------------------------------------------
	struct TerrainParm
	{
		bool	mDesert;
		int		mMountains;
	};
	TerrainParm mTerrain;

	struct HillParm
	{
		fp		mDensity;
		fp		mTallest;
		fp		mHeight;
		int		mWidth1Rand;
		int		mWidth1Base;
		int		mWidth2Rand;
		int		mWidth2Base;
		int		mHillsQuadrantRand;
		int		mHillsQuadrantBase;
	};
	HillParm mHill;

	struct TreeParm
	{
		bool	mDisable;
		fp		mDensity;
	};
	TreeParm mTree;

//------------------------------------------
// Water parameters.
//------------------------------------------
	struct WaterParm
	{
		WaterParm( void )
		{
			mDensity		= 0.5;
			mIslandDensity	= 0.4;
		}
		fp		mDensity;			///< {0,..,1}
		fp		mIslandDensity;		///< {0,..,1}
	};
	WaterParm mWater;

//------------------------------------------
// Fog parameters.
//------------------------------------------
#if 0 // obsolete
	struct FogParm
	{
		FogParm( void )
		{
			mDensity	= 0.5;
			mQuality	= 0;
		}
		fp		mDensity;
		int		mQuality;
	};
	FogParm mFog;
#endif
};
// public (but hidden to code outside this game module)
#if COMPILING_GAME_PONY // set by makefile
#ifdef GAME_PONY_WORLD_CC
       GamePonyWorldParm	gWorldParm;
#else
extern GamePonyWorldParm	gWorldParm;
#endif // GAME_PONY_WORLD_CC
#endif // GAME_MODULE_PONY

//------------------------------------------------------------------------------

#endif // GAME_PONY_WORLD_HH
