/* ==========================================================================
* 파    일 : Gathering.h
* 목    적 : 
* 작 성 자 : 박경희
* 작 성 일 : 2008-12-11
* 주의사항 :
*===========================================================================*/
#pragma once

#include "Gathering_Common.h"
#include "BaseObject.h"

enum eACTION_GAT_ID;
enum eACTION_GAT_CHANGE;

class cGathering : public cBaseObject
{

public:
	/// 생성소멸
	cGathering( void );
	~cGathering( void );

	/// 메모리 할당 제거 pool 사용
	void* operator new ( size_t n ); 
	void operator delete ( void* ptr, size_t n );

	bool			GatheringInit( unsigned long objectIdx, unsigned long regenIdx );

	void			Update( unsigned long elapsedTime, unsigned long accumTime );

	float			GetAppendZ() { return mpRegenDetail->mHeight; }
	float			GetDirection() { return mpRegenDetail->mDirection; }

	bool			SelectRegenPos();

	unsigned long	GetClassIdx();

	void			SendRegenSync();
	
	/// 채집하는 유저 추가
	void			AddGatherPlayer( cPlayer* pPlayer );

	/// 유저 취소 신청
	void			ReqEraseGatherPlayer( cPlayer* pPlayer );

	void			EraseGatherPlayer( cPlayer* pPlayer );

	/// 채집 종료 - 드롭처리
	void			GatheringDie( unsigned long playerIdx );

private:

	/// 스크립트 정보
	sGatheringRegen* mpRegenDetail;
	sGatheringList*	mpGatheringInfo;

	typedef tHashMap<unsigned long /*playerIdx*/, unsigned long /*startTime*/> cHashMap;
	cHashMap		mGatherCharactorMap;

	unsigned long	mRegenIndex;

	cRangeCheck		mRangeCheck;

public:
	bool           SendSightIn        ( char category, char protocol, unsigned long connectionIdx );
	bool           SendSightOut       ( char category, char protocol, unsigned long connectionIdx );
};

