#pragma once
#include "Doodad.h"
#include "IDList.h"
#include "ByteArray.h"
#include "War3StrID.h"

typedef RECT CRect;

// listed doodad type
class CListedDoodad  
{
public:
	CListedDoodad();
	virtual ~CListedDoodad();
	CListedDoodad *next; // next in the linear list
	CListedDoodad *mapnext; // next in the square of the map where the doodad is
	CListedDoodad *radiusnext; // next when a findradius occured
	CDoodad doodad;
	//const CListedDoodad &operator=(const CListedDoodad &LD);// перегрузка оператора присваивания
};

typedef CListedDoodad (*PCListedDoodad);

class CDoodadsList  
{
public:
	CByteArray m_baUnsupportedBuffer;
	void UnselectDoodad(CDoodad doodad);
	void UnselectAll();
	void RePlaceAllDoodads();
	void SetDoodadMapOrigin(float x, float y);
	void SetSize(float width, float height);
	CDoodad GetRadiusNext();
	void FindRadius(float fx, float fy, float fradius);
	CDoodad GetClosestDoodad(float x, float y);
	CDoodad GetClosestDoodad(float x, float y, float distance2_1, float distance2_2, CWar3StrID  vWar3StrID);
	CDoodad GetMapNext();
	void GoMapDoodad(float fx, float fy);
	CDoodad GetNext();
	void GoFirstDoodad();
	void SetDoodad(CDoodad doodad);
	CDoodad GetDoodad(int ID);
	int GetNbDoodads();
	void DelDoodads(CRect area);
	void DelDoodad(CDoodad doodad);
	void AddDoodad(CDoodad &doodad);
	void ClearList();
	CDoodadsList();
	virtual ~CDoodadsList();
	//PCListedDoodad GetHeadDoodad();
	//const CDoodadsList &operator=(const CDoodadsList &DL);// перегрузка оператора присваивания
	//void operator =(const char acStrID[]);
	PCListedDoodad GetHead();

protected:
	void RemoveFromRadiusList(PCListedDoodad pRadLDoodad);
	void UnplaceDoodad(PCListedDoodad pUpLDoodad);
	void PlaceDoodad(PCListedDoodad pLDoodad);
	CIDList m_FreeIDList;
	PCListedDoodad *m_pDoodadsMap;
	PCListedDoodad m_pMapCurrent;
	PCListedDoodad current;
	PCListedDoodad last;
	PCListedDoodad head;
	float m_fMapWidth;
	float m_fMapHeight;
	float m_fMapOrgX;
	float m_fMapOrgY;
	int m_iDoodadsMapSize;
	int m_iNbDoodads;
	int m_iHighestID;



};