/* ====================================================================
* 파    일 :	
* 목    적 :	
* 작 성 자 :	정성대
* 작 성 일 :	2006.08.29
*
* 추가내용 :
*		추가날짜	작업자	추가내용
*		2006.08.29	정성대	생성
* 
* 주의사항 :	
* =================================================================== */
#pragma once
#include "../Common/CommonNetworkMsgStruct.h"
#include "BaseObject_Common.h"

enum eSKILLSTATE;

//class cSkillObject;

const float AGGRO_NONE_RATE = 1.0f;
const float AGGRO_DAMAGE_RATE = 1.0f;
const float AGGRO_HEAL_RATE = 0.5f;
const float AGGRO_POTION_RATE = 0.5f;

enum eTAKEDAMAGE_TYPE
{
	/// player
	eTAKEDAMAGETYPE_NONE = 0,
	eTAKEDAMAGETYPE_DAMAGE,
	eTAKEDAMAGETYPE_HEAL,
	eTAKEDAMAGETYPE_POTION,
	eTAKEDAMAGETYPE_DAMAGE_SETTARGET,
	eTAKEDAMAGETYPE_NONETARGET,

	/// monster
	eTAKEDAMAGETYPE_ADDPLAYER,
};

class cBaseObject
{
public:
	cBaseObject( unsigned char objectType );
	virtual ~cBaseObject();

	bool operator == (cBaseObject& baseObject);
	bool operator != (cBaseObject& baseObject);

	sObject                 GetObject     ( ) { return mObject; }

	inline unsigned long	GetObjectID   ( ) { return mObject.index; }
	inline void				SetObjectID   ( unsigned long objectIndex ) { mObject.index = objectIndex; }

	inline unsigned char	GetObjectType ( ) { return mObject.type; }

	inline float			GetXPos       ( ) { return mObjectPos.x; }
	inline float			GetYPos       ( ) { return mObjectPos.y; }
	inline NiPoint2			GetPos        ( ) { return mObjectPos;   }
	inline virtual void		SetPos        ( float x, float y );

	/// 061127 PKH 지정하고 있는 타겟의 index로 object포인터를 얻어냄
	virtual cBaseObject*	GetTarget ( );
	/// 061201 PKH 목표(공격,추적등)의 인덱스와 object종류를 설정한다.
	virtual bool			SetTarget ( unsigned char kind, unsigned long idx );

	/// 061130 PKH 몬스터 생존 유무 셋팅
	inline virtual bool		GetStateDie( ) { return true; }
	/// 061201 PKH 오프젝트 생존유무 셋팅
	inline virtual void		SetStateDie( bool die ) { die; }

	virtual unsigned int	GetRaceGender ( ) { return (unsigned int)(0xffffffff); }
	virtual long			GetMoveSpeed  ( ) { return 0; }

	/// 070807 PKH HP감소
	virtual unsigned long	HPDamage ( unsigned long /*damage*/, bool* /*die*/, bool /*msgSend*/, bool cri = false ) { cri; return 0; }
	/// 070807 PKH 순식간에 HP증가
	virtual void			HPHeal   ( unsigned long /*hp*/, bool /*msgSend*/, unsigned long /*healerIdx*/, long /*distressPoint*/, eTAKEDAMAGE_TYPE /*type*/ ) {}

	/// 070807 PKH mp처리
	virtual void			MPDamage ( unsigned long /*damage*/, bool /*msgSend*/ ) {}
	virtual void			MPHeal   ( unsigned long /*heal*/, bool /*msgSend*/   ) {}

	/// 현재 HP & MP
	virtual unsigned long	GetHP() { return 0; }
	virtual unsigned long	GetMP() { return 0; }
	virtual unsigned long	GetMaxHP() { return 0; }
	virtual unsigned long	GetMaxMP() { return 0; }

	void					SetMapNumber( unsigned short mapNumber ) { mMapNumber = mapNumber; }
	unsigned short			GetMapNumber( ) { return mMapNumber; }

	virtual void			AddTakeDamage( sObject /*attacker*/, unsigned long /*damage*/, long /*distressPoint*/, eTAKEDAMAGE_TYPE /*type*/ ) { assert(NULL); }

	/// 효과 
	virtual bool				     AddInfluence( unsigned long /*uniqueIdx*/, unsigned long /*influenceClassIdx*/ ) { assert(NULL); return false; }
	virtual tHashSet<unsigned long>* GetInfluenceSet() { assert(NULL); return NULL; }
	virtual void				     ReleaseInfluenceSet() { assert(NULL); } 
	virtual void				     DeleteInfluence( unsigned long /*influenceIdx*/ ) { assert(NULL); }

	virtual void			StatusCalc()	{ assert(NULL); }

	virtual bool			IsParentEqual( unsigned long /*parentUniqueIdx*/ ) { return false; }
	/// 오브젝트의 거리 체크 수정 거리 - 적용 범위
	virtual float			GetFixedObjectSize()	{ return 0.0f; }

	/// 상태 이상
	virtual void			StateOddity( long* /*oddity*/ )	{ assert(NULL); }
	virtual unsigned long	GetStateOddity( eODDITYTYPE /*oddityType*/ )	{ assert(NULL); return 0; }

	virtual bool			IsCantSkill()	{ return true; }
	virtual bool			IsCantMove()	{ return true; }

	virtual void			TargetChange( sObject /*attacker*/, long /*distressPoint*/ ) {}

	virtual float			Height();

	virtual int             GetGridPos( ) { return mGridPos; }
	virtual void            SetGridPos( int pos ) { mGridPos = pos; }

	virtual unsigned char	GetLevel( ) { return 1; }

	virtual void			CalcInstantSkill( unsigned long /*applyType1*/, unsigned long /*value1*/, unsigned long /*applyType2*/, unsigned long /*value2*/ ) {}
	virtual unsigned long	DamageCalc( sObject /*target*/, unsigned long /*skillIdx*/, unsigned long /*aType*/, unsigned long /*rType*/ ) { assert(NULL); return 0; }
	virtual bool			AttackSuccess( sObject /*target*/, unsigned long /*skillIdx*/, unsigned long /*aType*/, unsigned short /*accuracyValue*/ ) { assert(NULL); return 0;}
	virtual bool			CriticalSuccess( sObject /*target*/, unsigned long /*skillIdx*/, unsigned long /*aType*/, unsigned short /*criticalValue*/ ) { assert(NULL); return 0;}

protected:
	sObject					mObject;
	NiPoint2				mObjectPos;	///

	sObject					mTarget;

	unsigned short			mMapNumber;
	int                     mGridPos;
};

inline bool cBaseObject::operator == (cBaseObject& baseObject)
{
	return (mObject.index == baseObject.GetObjectID( ));
}

inline bool cBaseObject::operator != (cBaseObject& baseObject)
{
	return !operator==(baseObject);
}

inline void cBaseObject::SetPos(float x, float y)
{
	if ( x < 0 || y < 0 )
	{
		assert(NULL);
		return;
	}
	mObjectPos.x = x; mObjectPos.y = y;
}

