#include "Net_Move.h"
#include "../MainProc/NetGlobal.h"
#pragma unmanaged

Net_Move*  Net_Move::This         = NULL;


bool Net_Move::_Init()
{
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_AddToPartition        , _PG_Move_LtoC_AddToPartition  );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_DelFromPartition      , _PG_Move_LtoC_DelFromPartition);
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_SetPostion            , _PG_Move_LtoC_SetPostion      );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_ObjectMove            , _PG_Move_LtoC_ObjectMove      );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_DoAction              , _PG_Move_LtoC_DoAction        );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_MoveSpeed             , _PG_Move_LtoC_MoveSpeed       );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_ModelRate             , _PG_Move_LtoC_ModelRate       );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_EQInfo                , _PG_Move_LtoC_EQInfo          );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_FixEQInfo             , _PG_Move_LtoC_FixEQInfo       );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_LookFace              , _PG_Move_LtoC_LookFace        );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_ClientAutoPlot        , _PG_Move_LtoC_ClientAutoPlot  );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_ActionType            , _PG_Move_LtoC_ActionType      );
//    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_JumpEnd               , _PG_Move_LtoC_JumpEnd         );
    _Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_JumpBegin             , _PG_Move_LtoC_JumpBegin		);
	_Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_Relation              , _PG_Move_LtoC_Relation		);
	_Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_PartyMemberMove       , _PG_Move_LtoC_PartyMemberMove );
	_Net.RegOnSrvPacketFunction	( EM_PG_Move_LtoC_PlayMotion			, _PG_Move_LtoC_PlayMotion		);
    return true;
}
//-------------------------------------------------------------------
bool Net_Move::_Release()
{
    return true;
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_JumpBegin      ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_JumpBegin * PG = (PG_Move_LtoC_JumpBegin *)Data;
    This->R_JumpBegin( PG->GItemID , PG->X , PG->Y , PG->Z , PG->Dir , PG->vX , PG->vY , PG->vZ );

}
void Net_Move::_PG_Move_LtoC_Relation		 ( int Sockid , int Size , void* Data )
{
	PG_Move_LtoC_Relation * PG = (PG_Move_LtoC_Relation *)Data;
	This->R_Relation( PG->GItemID , PG->Relation );

}
void Net_Move::_PG_Move_LtoC_PartyMemberMove ( int Sockid , int Size , void* Data )
{
	PG_Move_LtoC_PartyMemberMove * PG = (PG_Move_LtoC_PartyMemberMove *)Data;
	This->R_PartyMemberMove( PG->DBID , PG->ZoneID , PG->X , PG->Y , PG->Z );
}
/*
void Net_Move::_PG_Move_LtoC_JumpEnd        ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_JumpEnd* PG = (PG_Move_LtoC_JumpEnd*)Data;
    This->R_JumpEnd( PG->GItemID , PG->X , PG->Y , PG->Z , PG->Dir );
}
*/
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_ActionType ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_ActionType * PG = (PG_Move_LtoC_ActionType *)Data;

    This->ActionType( PG->GItemID , PG->Action );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_ClientAutoPlot ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_ClientAutoPlot* PG = (PG_Move_LtoC_ClientAutoPlot*)Data;

    This->ClientAutoPlot( PG->GItemID , (char*)PG->AutoPlot.Begin() );

}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_AddToPartition ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_AddToPartition* PG = (PG_Move_LtoC_AddToPartition*)Data;
    
    This->AddToPartition( PG->GItemID , PG->LGItemID , PG->DBID , &PG->Pos , &PG->GraphObj );

}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_DelFromPartition( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_DelFromPartition* PG = (PG_Move_LtoC_DelFromPartition*)Data;
    This->DelFromPartition( PG->GItemID );

}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_SetPostion     ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_SetPostion* PG = (PG_Move_LtoC_SetPostion*)Data;
    This->SetPos( PG->GItemID , &PG->Pos );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_ObjectMove     ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_ObjectMove* PG = (PG_Move_LtoC_ObjectMove*)Data;
    This->ObjectMove( PG->GItemID , &PG->Pos , PG->vX , PG->vZ , PG->Type );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_DoAction       ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_DoAction* PG = (PG_Move_LtoC_DoAction*)Data;
    This->DoAction( PG->GItemID , PG->ActionID , PG->TempActionID );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_MoveSpeed      ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_MoveSpeed* PG = (PG_Move_LtoC_MoveSpeed*)Data;
    This->MoveSpeed( PG->GItemID , PG->Speed );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_ModelRate      ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_ModelRate* PG = (PG_Move_LtoC_ModelRate*)Data;
    This->ModelRate( PG->GItemID , PG->ModelRate );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_EQInfo         ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_EQInfo* PG = (PG_Move_LtoC_EQInfo*)Data;
    This->EQInfo( PG->ItemID , PG->EQLook );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_FixEQInfo      ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_FixEQInfo* PG = (PG_Move_LtoC_FixEQInfo*)Data;
    This->FixEQInfo( PG->ItemID , PG->Pos , PG->EQ );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_LookFace       ( int Sockid , int Size , void* Data )
{
    PG_Move_LtoC_LookFace* PG = (PG_Move_LtoC_LookFace*)Data;
    This->LookFace( PG->GItemID , PG->Look );
}
//-------------------------------------------------------------------
void Net_Move::_PG_Move_LtoC_PlayMotion		( int Sockid , int Size , void* Data )
{
	PG_Move_LtoC_PlayMotion* PG = (PG_Move_LtoC_PlayMotion*)Data;
	This->PlayMotion( PG->iObjID, PG->szMotion );
}
//-------------------------------------------------------------------
// ¸ê®Æ°e¥X
//-------------------------------------------------------------------
void Net_Move::PlayerMoveObject( int GItemID , float X , float Y , float Z , float Dir , float vX , float vZ , ClientMoveTypeENUM Type )
{
    PG_Move_CtoL_PlayerMoveObject Send;

    Send.GItemID = GItemID;
    Send.Pos.X = X;
    Send.Pos.Y = Y;
    Send.Pos.Z = Z;
    Send.Pos.Dir = Dir;
	Send.vX = vX;
	Send.vZ = vZ;
    Send.Type = Type;

    SendToLocal( sizeof(Send) , &Send );
}
//-------------------------------------------------------------------
void Net_Move::S_DoAction( int GItemID , int ActionID , int TempActionID )
{
    PG_Move_CtoL_DoAction Send;
    Send.GItemID = GItemID;
    Send.ActionID = ActionID;
    Send.TempActionID = TempActionID;
    SendToLocal( sizeof(Send) , &Send );   
}

void Net_Move::S_JumpBegin( int GItemID  , float X , float Y , float Z , float Dir , float vX , float vY , float vZ )
{
    PG_Move_CtoL_JumpBegin Send;
    Send.GItemID = GItemID;
    Send.X = X;
    Send.Y = Y;
    Send.Z = Z;
    Send.Dir = Dir;
    Send.vX = vX;
    Send.vY = vY;
    Send.vZ = vZ;
    SendToLocal( sizeof(Send) , &Send );   
}
/*
void Net_Move::S_JumpEnd( int GItemID  , float X , float Y , float Z , float Dir  )
{
    PG_Move_CtoL_JumpEnd Send;
    Send.GItemID = GItemID;
    Send.X = X;
    Send.Y = Y;
    Send.Z = Z;
    Send.Dir = Dir;

    SendToLocal( sizeof(Send) , &Send );   
}*/