#pragma once
#define FEATUREPOOL_HPP

#include "Compost.hpp"

namespace Compost
{

class FeatureGrid;

class FeaturePool
{
	friend class FeatureGrid;

	public:
		FeaturePool();
		FeaturePool(
			Stuff::MemoryStream *stream
		);

		~FeaturePool();

		void
			LoadIndex(
				Stuff::MemoryStream *stream
			);
		void
			SaveIndex(
				Stuff::MemoryStream *stream
			);

		void
			LoadIndex(
				Stuff::NotationFile *note_file
			);
		void
			SaveIndex(
				Stuff::NotationFile *note_file
			);

		void
			Add(Feature *f);
		void
			Insert(Feature *f, int at);
		void
			Move(int from, int to);
		void
			Remove(int from);
		void
			Remove(Feature *f);
		int
			Find(Feature *f);

		int
			GetNumberOfFeatures() { return used; }
		Feature*
			GetFeatureNumber(int idx) { return features[idx]; }
		Feature*
			GetFeature(int idx);
		Feature*
			GetFeature(const char *feture_name);
		int
			GetFeaturePosition(Feature*);

		Feature*
			IsUsed(Feature_Texture*);
/*
		int
			ShootRay(unsigned short x, unsigned short z);
		int
			ShootRectangle(
				unsigned short x, 
				unsigned short z,
				unsigned short width,
				unsigned short height
			);
*/
		void
			SaveFeature(
				Stuff::MemoryStream *stream,
				Feature*
			);

		Feature*
			LoadFeature(
				Stuff::MemoryStream *stream,
				int version
			);

		void
			SaveFeature(
				Stuff::NotationFile *note_file,
				Feature*
			);

		Feature*
			LoadFeature(
				Stuff::Page *fet_page,
				int version
			);


	protected:

		int max, used;
		Feature* rayCollect[MAX_NUMBER_LAYERS];
		Stuff::DynamicArrayOf<Feature*> rectangleCollect;
		Stuff::DynamicArrayOf<Feature*> features;
};

}