本文整理汇总了C++中CClientPlayer::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientPlayer::GetPosition方法的具体用法?C++ CClientPlayer::GetPosition怎么用?C++ CClientPlayer::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientPlayer
的用法示例。
在下文中一共展示了CClientPlayer::GetPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoPulse
void CFoo::DoPulse ( void )
{
CClientManager* pManager = g_pClientGame->GetManager ();
if ( pManager->IsGameLoaded () )
{
CClientPlayerManager* pPlayerManager = pManager->GetPlayerManager ();
CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer ();
if ( !pLocal ) return;
CVector vecLocal;
pLocal->GetPosition ( vecLocal );
CClientCamera* pCamera = pManager->GetCamera ();
/*
CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
if ( pVehicle )
{
unsigned char ucGear = pVehicle->GetGameVehicle ()->GetCurrentGear ();
g_pCore->GetGraphics ()->DrawText ( 200, 200, 0xFFFFFFFF, 1.0f, "Gear = %u", ucGear );
}
*/
// ChrML: Reproduces issue #2741
if ( bFoo_PlayerLimitCrash )
{
static CClientPed* pPed = NULL;
if ( !pPed )
{
pPed = new CClientPlayer ( pManager, 50 );
CVector vecLocal;
pPlayerManager->GetLocalPlayer ()->GetPosition ( vecLocal );
vecLocal.fX += 10;
pPed->SetPosition ( vecLocal );
}
static unsigned long ulTestTime = 0;
if ( ulTestTime == 0 )
{
ulTestTime = CClientTime::GetTime () + 50;
}
if ( CClientTime::GetTime () > ulTestTime )
{
ulTestTime = CClientTime::GetTime () + 50;
static unsigned int uiIndex = 0;
++uiIndex;
pPed->SetModel ( uiIndex );
if ( uiIndex > 290 )
uiIndex = 0;
}
}
}
}
示例2: Test
void CFoo::Test ( const char* szString )
{
CClientManager* pManager = g_pClientGame->GetManager ();
CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer ();
CClientVehicleManager* pVehicleManager = pManager->GetVehicleManager ();
CVector vecLocal;
pLocal->GetPosition ( vecLocal );
CClientCamera* pCamera = pManager->GetCamera ();
// ChrML: Trying to reproduce mantis issue #2760
if ( stricmp ( szString, "2760" ) == 0 )
{
vecLocal = CVector ( 0.0f, 0.0f, 5.0f );
for ( int i = 0; i < 20; i++ )
{
vecLocal.fX += 5.0f;
CClientPlayer* pPlayer = new CClientPlayer ( pManager, i + 50 );
pPlayer->SetDeadOnNetwork ( false );
pPlayer->SetModel ( 168 + i );
pPlayer->AttachTo ( NULL );
pPlayer->SetFrozen ( false );
pPlayer->RemoveAllWeapons ();
pPlayer->Teleport ( vecLocal );
pPlayer->SetCameraRotation ( 0 );
pPlayer->ResetInterpolation ();
pPlayer->SetMoveSpeed ( CVector () );
pPlayer->SetHealth ( 100.0f );
pPlayer->SetArmor ( 0 );
pPlayer->SetCurrentRotation ( 0 );
pPlayer->SetInterior ( 0 );
pPlayer->SetDimension ( 0 );
}
pLocal->SetDeadOnNetwork ( false );
pLocal->SetModel ( 145 );
pLocal->AttachTo ( NULL );
pLocal->SetFrozen ( false );
pLocal->RemoveAllWeapons ();
pLocal->Teleport ( vecLocal );
pLocal->SetCameraRotation ( 0 );
pLocal->ResetInterpolation ();
pLocal->SetMoveSpeed ( CVector () );
pLocal->SetHealth ( 100.0f );
pLocal->SetArmor ( 0 );
pLocal->SetCurrentRotation ( 0 );
pLocal->SetInterior ( 0 );
pLocal->SetDimension ( 0 );
g_pClientGame->SetAllDimensions ( 0 );
// Reset return position so we can't warp back to where we were if local player
g_pClientGame->GetNetAPI ()->ResetReturnPosition ();
// Make sure the camera is normal
pCamera->SetFocusToLocalPlayer ();
pCamera->FadeIn ( 0.0f );
}
// Player load crash
else if ( stricmp ( szString, "2741" ) == 0 )
{
bFoo_PlayerLimitCrash = true;
}
//
else if ( strnicmp ( szString, "interp", 6 ) == 0 )
{
if ( pVehicleManager->Count () > 0 )
{
CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();
float fdelta = atof ( szString + 7 );
CVector vecT;
pVehicle->GetPosition ( vecT );
vecT.fZ = fdelta;
pVehicle->SetTargetPosition ( vecT, TICK_RATE );
g_pCore->ChatPrintf ( "Done %f", false, fdelta );
static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false );
}
}
//
else if ( strnicmp ( szString, "interr", 6 ) == 0 )
{
if ( pVehicleManager->Count () > 0 )
{
CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();
CVector vecT;
//.........这里部分代码省略.........
示例3: DrawDefault
//.........这里部分代码省略.........
break;
}
}
}
}
// Grab the local player vehicle
CClientVehicle* pLocalVehicle = pLocalPlayer->GetOccupiedVehicle();
CVehicle* pLocalGameVehicle = NULL;
if (pLocalVehicle)
pLocalGameVehicle = pLocalVehicle->GetGameVehicle();
CMatrix CameraMatrix;
g_pGame->GetCamera()->GetMatrix(&CameraMatrix);
// Remove collision from our local vehicle (if we have one)
if (pLocalVehicle)
pLocalVehicle->WorldIgnore(true);
// Draw the nametags we need to
CVector vecPlayerPosition;
CClientVehicle* pPlayerVehicle = NULL;
float fDistanceExp;
bool bCollision;
CColPoint* pColPoint = NULL;
CEntity* pGameEntity = NULL;
CClientEntity* pEntity = NULL;
CClientPlayer* pPlayer;
CClientStreamElement* pElement;
list<CClientStreamElement*>::const_iterator iter = m_pPlayerStreamer->ActiveElementsBegin();
for (; iter != m_pPlayerStreamer->ActiveElementsEnd(); ++iter)
{
pElement = *iter;
if (!pElement->IsStreamedIn())
continue;
if (pElement->GetType() != CCLIENTPLAYER)
continue;
pPlayer = static_cast<CClientPlayer*>(pElement);
if (pPlayer->IsLocalPlayer())
continue;
// Get the distance from the camera
pPlayer->GetPosition(vecPlayerPosition);
fDistanceExp = pPlayer->GetExpDistance();
pPlayerVehicle = pPlayer->GetOccupiedVehicle();
// Is he in the same vehicle as the local player?
if ((pSniperTargetedPlayer == pPlayer) || (pSniperTargetedVehicle && pSniperTargetedVehicle == pPlayerVehicle) ||
(pLocalVehicle && pLocalVehicle == pPlayerVehicle) || (fDistanceExp < DEFAULT_VIEW_RANGE_EXP && pPlayer->IsOnScreen()))
{
SLineOfSightFlags flags;
flags.bCheckBuildings = true;
flags.bCheckVehicles = true;
flags.bCheckPeds = false;
flags.bCheckObjects = true;
bCollision = g_pCore->GetGame()->GetWorld()->ProcessLineOfSight(&CameraMatrix.vPos, &vecPlayerPosition, &pColPoint, &pGameEntity, flags);
if (!bCollision || (pGameEntity && pPlayerVehicle && pGameEntity == pPlayerVehicle->GetGameEntity()))
{
pPlayer->SetNametagDistance(sqrt(fDistanceExp));
playerTags.push_front(pPlayer);
}
// Destroy the colpoint
if (pColPoint)
pColPoint->Destroy();
}
}
// Readd collision from our local vehicle (if we have one)
if (pLocalVehicle)
pLocalVehicle->WorldIgnore(false);
// Draw each player's nametag
float fAlphaModifier;
unsigned char ucAlpha;
float fDistance;
list<CClientPlayer*>::iterator iterTags = playerTags.begin();
for (; iterTags != playerTags.end(); ++iterTags)
{
pPlayer = *iterTags;
fDistance = pPlayer->GetNametagDistance();
static float fFullAlphaDistance = 7.0f;
if ((fDistance < fFullAlphaDistance) || (pSniperTargetedPlayer && pSniperTargetedPlayer == pPlayer) ||
(pSniperTargetedVehicle && pSniperTargetedVehicle == pPlayer->GetOccupiedVehicle()))
{
fAlphaModifier = 1.0f;
}
else
{
fAlphaModifier = 1.0f - ((fDistance - fFullAlphaDistance) / (DEFAULT_VIEW_RANGE - fFullAlphaDistance));
}
// Calculate the alpha for the nametag
ucAlpha = static_cast<unsigned char>(180.0f * fAlphaModifier);
// Draw the tag
DrawTagForPlayer(pPlayer, ucAlpha);
}
}
示例4: SetupMapVariables
void CRadarMap::SetupMapVariables ( void )
{
// Calculate the map size and the middle of the screen coords
m_fMapSize = static_cast < float > ( m_uiHeight * m_fZoom );
int iMiddleX = static_cast < int > ( m_uiWidth / 2 );
int iMiddleY = static_cast < int > ( m_uiHeight / 2 );
// If we are attached to the local player and zoomed in at all
if ( m_bIsAttachedToLocal && m_fZoom > 1 )
{
// Get the local player position
CVector vec;
CClientPlayer* pLocalPlayer = m_pManager->GetPlayerManager ()->GetLocalPlayer ();
if ( pLocalPlayer )
pLocalPlayer->GetPosition ( vec );
// Calculate the maps min and max vector positions putting the local player in the middle of the map
m_iMapMinX = static_cast < int > ( iMiddleX - ( iMiddleY * m_fZoom ) - ( ( vec.fX * m_fMapSize ) / 6000.0f ) );
m_iMapMaxX = static_cast < int > ( m_iMapMinX + m_fMapSize );
m_iMapMinY = static_cast < int > ( iMiddleY - ( iMiddleY * m_fZoom ) + ( ( vec.fY * m_fMapSize ) / 6000.0f ) );
m_iMapMaxY = static_cast < int > ( m_iMapMinY + m_fMapSize );
// If we are moving the map too far then stop centering the local player blip
if ( m_iMapMinX > 0 )
{
m_iMapMinX = 0;
m_iMapMaxX = static_cast < int > ( m_iMapMinX + m_fMapSize );
}
else if ( m_iMapMaxX <= static_cast < int > ( m_uiWidth ) )
{
m_iMapMaxX = m_uiWidth;
m_iMapMinX = static_cast < int > ( m_iMapMaxX - m_fMapSize );
}
if ( m_iMapMinY > 0 )
{
m_iMapMinY = 0;
m_iMapMaxY = static_cast < int > ( m_iMapMinY + m_fMapSize );
}
else if ( m_iMapMaxY <= static_cast < int > ( m_uiHeight ) )
{
m_iMapMaxY = m_uiHeight;
m_iMapMinY = static_cast < int > ( m_iMapMaxY - m_fMapSize );
}
}
// If we are in free roam mode or not zoomed in
else
{
// Set the maps min and max vector positions relative to the movement selected
m_iMapMinX = static_cast < int > ( iMiddleX - ( iMiddleY * m_fZoom ) - ( ( m_iHorizontalMovement * m_fMapSize ) / 6000.0f ) );
m_iMapMaxX = static_cast < int > ( m_iMapMinX + m_fMapSize );
m_iMapMinY = static_cast < int > ( iMiddleY - ( iMiddleY * m_fZoom ) + ( ( m_iVerticalMovement * m_fMapSize ) / 6000.0f ) );
m_iMapMaxY = static_cast < int > ( m_iMapMinY + m_fMapSize );
// If we are zoomed in
if ( m_fZoom > 1 )
{
if ( m_iMapMinX >= 0 )
{
m_iMapMinX = 0;
m_iMapMaxX = static_cast < int > ( m_iMapMinX + m_fMapSize );
}
else if ( m_iMapMaxX <= static_cast < int > ( m_uiWidth ) )
{
m_iMapMaxX = m_uiWidth;
m_iMapMinX = static_cast < int > ( m_iMapMaxX - m_fMapSize );
}
if ( m_iMapMinY >= 0 )
{
m_iMapMinY = 0;
m_iMapMaxY = static_cast < int > ( m_iMapMinY + m_fMapSize );
}
else if ( m_iMapMaxY <= static_cast < int > ( m_uiHeight ) )
{
m_iMapMaxY = m_uiHeight;
m_iMapMinY = static_cast < int > ( m_iMapMaxY - m_fMapSize );
}
}
// If we are not zoomed in
else
{
// Set the movement margins to 0
m_iHorizontalMovement = 0;
m_iVerticalMovement = 0;
}
}
// Show mode only when zoomed in
if ( !m_HelpTextList.empty () )
{
m_HelpTextList[0]->SetVisible ( m_fZoom > 1 && m_bTextVisible );
m_HelpTextList[1]->SetVisible ( m_fZoom > 1 && m_bTextVisible );
}
}
示例5: DoRender
void CRadarMap::DoRender ( void )
{
bool bIsRadarShowing = IsRadarShowing ();
// Render if showing
if ( bIsRadarShowing )
{
// Get the alpha value from the settings
int iRadarAlpha;
g_pCore->GetCVars()->Get ( "mapalpha", iRadarAlpha );
g_pCore->GetGraphics()->DrawTexture ( m_pRadarImage, static_cast < float > ( m_iMapMinX ),
static_cast < float > ( m_iMapMinY ),
m_fMapSize / m_pRadarImage->m_uiSizeX,
m_fMapSize / m_pRadarImage->m_uiSizeY,
0.0f, 0.0f, 0.0f,
SColorARGB ( iRadarAlpha, 255, 255, 255 ) );
// Grab the info for the local player blip
CVector2D vecLocalPos;
CVector vecLocal;
CVector vecLocalRot;
if ( m_pManager->GetCamera()->IsInFixedMode() )
{
m_pManager->GetCamera()->GetPosition ( vecLocal );
m_pManager->GetCamera()->GetRotation ( vecLocalRot );
}
else
{
CClientPlayer* pLocalPlayer = m_pManager->GetPlayerManager ()->GetLocalPlayer ();
if ( !pLocalPlayer )
return;
pLocalPlayer->GetPosition ( vecLocal );
pLocalPlayer->GetRotationDegrees ( vecLocalRot );
}
CalculateEntityOnScreenPosition ( vecLocal, vecLocalPos );
// Now loop our radar areas
unsigned short usDimension = m_pRadarAreaManager->GetDimension ();
CClientRadarArea * pArea = NULL;
list < CClientRadarArea* > ::const_iterator areaIter = m_pRadarAreaManager->IterBegin ();
for ( ; areaIter != m_pRadarAreaManager->IterEnd (); areaIter++ )
{
pArea = *areaIter;
if ( pArea->GetDimension() == usDimension )
{
// Grab the area image and calculate the position to put it on the screen
CVector2D vecPos;
CalculateEntityOnScreenPosition ( pArea, vecPos );
// Get the area size and work out the ratio
CVector2D vecSize;
float fX = (*areaIter)->GetSize ().fX;
float fY = (*areaIter)->GetSize ().fY;
float fRatio = 6000.0f / m_fMapSize;
// Calculate the size of the area
vecSize.fX = static_cast < float > ( fX / fRatio );
vecSize.fY = static_cast < float > ( fY / fRatio );
g_pCore->GetGraphics ()->DrawRectangle ( vecPos.fX, vecPos.fY, vecSize.fX, -vecSize.fY, pArea->GetColor () );
}
}
// Now loop our radar markers
usDimension = m_pRadarMarkerManager->GetDimension();
list < CClientRadarMarker* > ::const_iterator markerIter = m_pRadarMarkerManager->IterBegin ();
for ( ; markerIter != m_pRadarMarkerManager->IterEnd (); markerIter++ )
{
if ( (*markerIter)->IsVisible () && (*markerIter)->GetDimension() == usDimension )
{
// Grab the marker image and calculate the position to put it on the screen
float fScale = 1;
SColor color;
CTextureItem* pTexture = GetMarkerTexture ( *markerIter, vecLocal.fZ, &fScale, &color );
if ( pTexture )
{
CVector2D vecPos;
CalculateEntityOnScreenPosition ( *markerIter, vecPos );
g_pCore->GetGraphics()->DrawTexture ( pTexture, vecPos.fX, vecPos.fY, fScale, fScale, 0.0f, 0.5f, 0.5f, color );
}
}
}
g_pCore->GetGraphics()->DrawTexture ( m_pLocalPlayerBlip, vecLocalPos.fX, vecLocalPos.fY, 1.0, 1.0, vecLocalRot.fZ, 0.5f, 0.5f );
}
// Update visibility of help text
bool bRequiredTextVisible = bIsRadarShowing && !m_bHideHelpText;
if ( bRequiredTextVisible != m_bTextVisible )
{
m_bTextVisible = bRequiredTextVisible;
for ( uint i = 0 ; i < m_HelpTextList.size () ; i++ )
m_HelpTextList[i]->SetVisible ( m_bTextVisible );
SetupMapVariables ();
}
}
示例6: ProcessPlayerList
///////////////////////////////////////////////////////////////
//
// CClientModelCacheManagerImpl::ProcessPlayerList
//
///////////////////////////////////////////////////////////////
void CClientModelCacheManagerImpl::ProcessPlayerList(std::map<ushort, float>& outNeedCacheList, const std::vector<CClientPlayer*>& playerList,
float fMaxStreamDistanceSq)
{
const ulong ulTimeNow = CClientTime::GetTime();
for (std::vector<CClientPlayer*>::const_iterator iter = playerList.begin(); iter != playerList.end(); ++iter)
{
CClientPlayer* pPlayer = *iter;
ushort usModelId = (ushort)pPlayer->GetModel();
if (usModelId < 7 || usModelId > 312)
continue;
// Check if currently within distance
{
// Check distance
CVector vecPosition;
pPlayer->GetPosition(vecPosition);
float fDistSq = (m_vecCameraPos - vecPosition).LengthSquared();
if (fDistSq < fMaxStreamDistanceSq)
{
// Add model to needed list
InsertIntoNeedCacheList(outNeedCacheList, usModelId, fDistSq);
AddProcessStat("p", true, PURESYNC_TYPE_NONE, usModelId, vecPosition, vecPosition);
continue;
}
}
// Check if will be within distance soon
ePuresyncType syncType = pPlayer->GetLastPuresyncType();
if (syncType == PURESYNC_TYPE_PURESYNC || syncType == PURESYNC_TYPE_LIGHTSYNC)
{
ulong ulSyncAge = ulTimeNow - pPlayer->GetLastPuresyncTime();
if (ulSyncAge < 8000)
{
// Get velocity from somewhere
CVector vecVelocity;
CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle();
if (syncType == PURESYNC_TYPE_LIGHTSYNC)
{
vecVelocity = pPlayer->GetLightsyncCalcedVelocity();
}
else
{
if (pVehicle)
pVehicle->GetMoveSpeed(vecVelocity);
else
pPlayer->GetMoveSpeed(vecVelocity);
vecVelocity *= m_fGameFps;
}
// Extrapolate position
float fSecondsToAdd = std::min(6000UL, ulSyncAge + 2000) * 0.001f;
CVector vecPosition;
pPlayer->GetPosition(vecPosition);
CVector vecNewPosition = vecPosition + vecVelocity * fSecondsToAdd;
// Check distance
float fDistSq = (m_vecCameraPos - vecNewPosition).LengthSquared();
if (fDistSq < fMaxStreamDistanceSq)
{
// Add model to needed list
InsertIntoNeedCacheList(outNeedCacheList, usModelId, fDistSq);
AddProcessStat("l", true, syncType, usModelId, vecPosition, vecNewPosition);
continue;
}
AddProcessStat("n", false, syncType, usModelId, vecPosition, vecNewPosition);
continue;
}
}
}
}