//===========================================================================//
// File:	gaugmap.hpp                                                         //
// Project: MUNGA           Brick: Gauge Renderer        	                 //
// Contents: 																					  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 05/17/95  CPB  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved //
//                      PROPRIETARY and CONFIDENTIAL                         //
//===========================================================================//

#if !defined(GAUGMAP_HPP)
#	define GAUGMAP_HPP

#	if !defined(RESOURCE_HPP)
#		include <resource.hpp>
#	endif

#	if !defined(NODE_HPP)
#		include <node.hpp>
#	endif

#	if !defined(SCALAR_HPP)
#		include <scalar.hpp>
#	endif

#	if !defined(CHAIN_HPP)
#		include <chain.hpp>
#	endif

	class Entity;
	class GaugeEntityList;
	class GaugeEntityArray;
	class Derivation;
	class Point3D;

	//#######################################################################
	// GaugeEntityList
	//#######################################################################
	class GaugeEntityList :
		public Node
	{
	public:
		GaugeEntityList();
		~GaugeEntityList();
		Logical
			TestInstance() const;
		void
			Add(Entity *entity);
		void
			Remove(Entity *entity);
		void
			Clear();
		int
			NumberOfItems();
		int
			CopyEntities(
				GaugeEntityList *destination,
				Derivation *derivation_type = NULL
			);
		int
			CopyEntitiesWithinBounds(
				GaugeEntityList *destination,
				Scalar min_x,
				Scalar min_y,
				Scalar min_z,
				Scalar max_x,
				Scalar max_y,
				Scalar max_z,
				Derivation *derivation_type = NULL
			);
		int
			CopyEntitiesWithinBounds(
				GaugeEntityList *destination,
				Point3D *center,
				Scalar radius,
				Derivation *derivation_type = NULL
			);

		ChainOf<Entity*> * const
			GetInstanceList()
				{
					return &instanceList; 
				}
	protected:
		ChainOf<Entity*>
			instanceList;
	};

	//#######################################################################
	// GaugeEntityArray
	//#######################################################################
	class GaugeEntityArray SIGNATURED
	{
	public:
		GaugeEntityArray();
		~GaugeEntityArray();
		Logical
			TestInstance() const;
		void
			Add(Entity *entity);
		void
			Remove(Entity *entity);
		void
			Clear();
		void
			PrintStatistics();
		int
			CopyEntities(
				GaugeEntityList *destination,
				Derivation *derivation_type = NULL
			);
		int
			CopyEntitiesWithinBounds(
				GaugeEntityList *destination,
				Scalar min_x,
				Scalar min_y,
				Scalar min_z,
				Scalar max_x,
				Scalar max_y,
				Scalar max_z,
				Derivation *derivation_type = NULL
			);
		int
			CopyEntitiesWithinBounds(
				GaugeEntityList *destination,
				Point3D *center,
				Scalar radius,
				Derivation *derivation_type = NULL
			);
		void
			GetBounds(
				Scalar *min_x,
				Scalar *min_y,
				Scalar *min_z,
				Scalar *max_x,
				Scalar *max_y,
				Scalar *max_z
			);

	protected:
		enum
		{
			gaugeMapArraySize=64
		};

		int
			ArrayOffset(Scalar n);

		Scalar
			minimumX,
			minimumY,
			minimumZ,
			maximumX,
			maximumY,
			maximumZ;

		GaugeEntityList
			grid[gaugeMapArraySize][gaugeMapArraySize];
	};

#endif

