예제 #1
0
BOOL KPlayerBaseProcess::OnSyncDoodadState( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_DOODAD_STATE* pReceived = (KS2C_SYNC_DOODAD_STATE*)pData;

	KDoodad* pDoodad = g_cDoodadMgr.GetById(pReceived->dwId);
	QCONFIRM_RET_FALSE(pDoodad);

	if (pReceived->nDoodadState != (INT)pDoodad->GetState())
	{
		pDoodad->SetState((KEDOODAD_STATE)pReceived->nDoodadState);

		pDoodad->FireEvent(emKOBJEVENTTYPE_DOODAD_STATE_CHANGED,
			pReceived->dwPlayerId,
			pDoodad->GetId(),
			pReceived->nDoodadState);

		// 因为要传递四个参数,现有机制不支持,使用CallFunction来告之脚本这个事情
		//pReceived->dwPlayerId
		//CallTableFunction();
	}
	return TRUE;
}
예제 #2
0
BOOL KPlayerBaseProcess::OnSyncDoodad( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_DOODAD* pReceived = (KS2C_SYNC_DOODAD*)pData;
	KDoodad* pDoodad = NULL;

	// TODO: improve
	if (g_cDoodadMgr.GetById(pReceived->dwId))
		return FALSE;	

	//pDoodad = g_cOrpgWorld.AddDoodadToScene(pReceived->dwTemplateId, g_cOrpgWorld.m_dwClientSceneId, pReceived->nX, pReceived->nY, pReceived->nZ, pReceived->nDirectionXY, pReceived->dwId);
	pDoodad = g_cDoodadMgr.CreateDoodad(pReceived->dwTemplateId, pReceived->dwId);
	QCONFIRM_RET_FALSE(pDoodad);

	pDoodad->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
	pDoodad->m_nVelocityXY = pReceived->nVelocityXY;
	pDoodad->m_nDestX = pReceived->nDestX;
	pDoodad->m_nDestY = pReceived->nDestY;
	pDoodad->m_nDestZ = pReceived->nDestZ;
	pDoodad->m_nFaceDirection = pReceived->nDirectionXY; // 暂时用速度方向代替
	pDoodad->SetState((KEDOODAD_STATE)pReceived->nDoodadState);
	g_cDoodadMgr.AddToScene(pDoodad, g_cOrpgWorld.m_dwClientSceneId, pReceived->nX, pReceived->nY, pReceived->nZ, pReceived->nDirectionXY);
	pDoodad->FireEvent(emKOBJEVENTTYPE_DOODAD_STATE_CHANGED, pReceived->dwPlayerId, pDoodad->GetId(), pReceived->nDoodadState);
	return TRUE;
}