本文整理汇总了C++中CClientEntity::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientEntity::GetType方法的具体用法?C++ CClientEntity::GetType怎么用?C++ CClientEntity::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientEntity
的用法示例。
在下文中一共展示了CClientEntity::GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetElementPosition
void CElementRPCs::SetElementPosition ( NetBitStreamInterface& bitStream )
{
// Read out the entity id and the position
ElementID ID;
CVector vecPosition;
unsigned char ucTimeContext;
if ( bitStream.Read ( ID ) &&
bitStream.Read ( vecPosition.fX ) &&
bitStream.Read ( vecPosition.fY ) &&
bitStream.Read ( vecPosition.fZ ) &&
bitStream.Read ( ucTimeContext ) )
{
// Grab the entity
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
// Update the sync context to the new one
pEntity->SetSyncTimeContext ( ucTimeContext );
// If it's a player, use Teleport
if ( pEntity->GetType () == CCLIENTPLAYER )
{
unsigned char ucWarp = 1;
bitStream.Read ( ucWarp );
CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity );
if ( ucWarp )
{
pPlayer->Teleport ( vecPosition );
pPlayer->ResetInterpolation ();
}
else
{
pPlayer->SetPosition ( vecPosition );
}
// If local player, reset return position (so we can't warp back if connection fails)
if ( pPlayer->IsLocalPlayer () )
{
m_pClientGame->GetNetAPI ()->ResetReturnPosition ();
}
}
else if ( pEntity->GetType () == CCLIENTVEHICLE )
{
CClientVehicle* pVehicle = static_cast < CClientVehicle* > ( pEntity );
pVehicle->RemoveTargetPosition ();
pVehicle->SetPosition ( vecPosition );
}
else
{
// Set its position
pEntity->SetPosition ( vecPosition );
}
}
}
}
示例2: Get
CClientPed* CClientPedManager::Get ( ElementID ID, bool bCheckPlayers )
{
// Grab the element with the given id. Check its type.
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity && ( pEntity->GetType () == CCLIENTPED || ( bCheckPlayers && pEntity->GetType () == CCLIENTPLAYER ) ) )
{
return static_cast < CClientPed* > ( pEntity );
}
return NULL;
}
示例3: SetElementHealth
void CElementRPCs::SetElementHealth ( NetBitStreamInterface& bitStream )
{
ElementID ID;
float fHealth;
unsigned char ucTimeContext;
if ( bitStream.Read ( ID ) &&
bitStream.Read ( fHealth ) &&
bitStream.Read ( ucTimeContext ) )
{
CClientEntity * pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
pEntity->SetSyncTimeContext ( ucTimeContext );
switch ( pEntity->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed * > ( pEntity );
pPed->SetHealth ( fHealth );
break;
}
case CCLIENTVEHICLE:
{
CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pEntity );
pVehicle->SetHealth ( fHealth );
break;
}
}
}
}
}
示例4: SetCameraTarget
void CCameraRPCs::SetCameraTarget ( NetBitStreamInterface& bitStream )
{
ElementID targetID;
if ( bitStream.Read ( targetID ) )
{
CClientEntity * pEntity = CElementIDs::GetElement ( targetID );
if ( pEntity )
{
// Save our current target for later
CClientEntity * pPreviousTarget = m_pCamera->GetTargetEntity ();
switch ( pEntity->GetType () )
{
case CCLIENTPLAYER:
{
CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity );
if ( pPlayer->IsLocalPlayer () )
{
// Return the focus to the local player
m_pCamera->SetFocusToLocalPlayer ();
}
else
{
// Put the focus on that player
m_pCamera->SetFocus ( pPlayer, MODE_BEHINDCAR, false );
}
break;
}
default:
return;
}
}
}
}
示例5: SetElementAlpha
void CElementRPCs::SetElementAlpha ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned char ucAlpha;
if ( bitStream.Read ( ID ) && bitStream.Read ( ucAlpha ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
switch ( pEntity->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed* > ( pEntity );
pPed->SetAlpha ( ucAlpha );
break;
}
case CCLIENTVEHICLE:
{
CClientVehicle* pVehicle = static_cast < CClientVehicle* > ( pEntity );
pVehicle->SetAlpha ( ucAlpha );
break;
}
case CCLIENTOBJECT:
{
CClientObject * pObject = static_cast < CClientObject* > ( pEntity );
pObject->SetAlpha ( ucAlpha );
break;
}
default: break;
}
}
}
}
示例6: GetTeam
CClientTeam* CClientTeamManager::GetTeam(ElementID ID)
{
CClientEntity* pEntity = CElementIDs::GetElement(ID);
if (pEntity && pEntity->GetType() == CCLIENTTEAM)
{
return static_cast<CClientTeam*>(pEntity);
}
return NULL;
}
示例7: DoHitDetectionForColShape
//
// Handle the changing state of collision between one colshape and any entity
//
void CClientColManager::DoHitDetectionForColShape ( CClientColShape* pShape )
{
// Ensure colshape is enabled and not being deleted
if ( pShape->IsBeingDeleted () || !pShape->IsEnabled () )
return;
std::map < CClientEntity*, int > entityList;
// Get all entities within the sphere
CSphere querySphere = pShape->GetWorldBoundingSphere ();
CClientEntityResult result;
GetClientSpatialDatabase()->SphereQuery ( result, querySphere );
// Extract relevant types
for ( CClientEntityResult::const_iterator it = result.begin () ; it != result.end (); ++it )
{
CClientEntity* pEntity = *it;
switch ( pEntity->GetType () )
{
case CCLIENTRADARMARKER:
case CCLIENTRADARAREA:
case CCLIENTTEAM:
case CCLIENTGUI:
case CCLIENTCOLSHAPE:
case CCLIENTDUMMY:
case SCRIPTFILE:
case CCLIENTDFF:
case CCLIENTCOL:
case CCLIENTTXD:
case CCLIENTSOUND:
break;
default:
if ( pEntity->GetParent () )
entityList[ pEntity ] = 1;
}
}
// Add existing colliders, so they can be disconnected if required
for ( CFastList < CClientEntity* > ::const_iterator it = pShape->CollidersBegin () ; it != pShape->CollidersEnd (); ++it )
{
entityList[ *it ] = 1;
}
// Test each entity against the colshape
for ( std::map < CClientEntity*, int > ::const_iterator it = entityList.begin () ; it != entityList.end (); ++it )
{
CClientEntity* pEntity = it->first;
CVector vecPosition;
pEntity->GetPosition ( vecPosition );
// Collided?
bool bHit = pShape->DoHitDetection ( vecPosition, 0.0f );
HandleHitDetectionResult ( bHit, pShape, pEntity );
}
}
示例8: ReadElements
bool CClientTask::ReadElements ( lua_State* luaVM, int iTableIndex, bool bClear )
{
// Clear the old parameters first
if ( bClear )
{
m_Elements.clear ();
}
// Grab the stack position for the table after we've pushed data to it.
// This is table index - 1 if the index is negative, otherwize it stays
// the same.
int iNewTableIndex;
if ( iTableIndex < 0 )
iNewTableIndex = iTableIndex - 1;
else
iNewTableIndex = iTableIndex;
// Not a table? Bad
if ( !lua_istable ( luaVM, iTableIndex ) )
{
return false;
}
// Loop through our table, beginning at the first key
lua_pushnil ( luaVM );
while ( lua_next ( luaVM, iNewTableIndex ) != 0 )
{
// Get the index and the element ID
unsigned int uiIndex = static_cast < unsigned int > ( lua_tonumber ( luaVM, -2 ) );
ElementID ID = static_cast < ElementID > ( lua_tonumber ( luaVM, -1 ) );
// Grab the element and check he's a player/ped
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity && pEntity->GetType () == CCLIENTPLAYER )
{
// If we cleared, just add it
if ( bClear )
{
// Store it
m_Elements.push_back ( ID );;
}
else
{
// Otherwize merge it in
AddElement ( pEntity );
}
}
// Remove the value and keep the key for the next iteration
lua_pop ( luaVM, 1 );
}
// Success
return true;
}
示例9: SetElementDimension
void CElementRPCs::SetElementDimension ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned short usDimension;
if ( bitStream.Read ( ID ) && bitStream.Read ( usDimension ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
if ( pEntity->GetType () == CCLIENTTEAM )
{
CClientTeam* pTeam = static_cast < CClientTeam* > ( pEntity );
list < CClientPlayer* > ::const_iterator iter = pTeam->IterBegin ();
for ( ; iter != pTeam->IterEnd () ; iter++ )
{
CClientPlayer* pPlayer = *iter;
if ( pPlayer->IsLocalPlayer () )
{
// Update all of our streamers/managers to the local player's dimension
m_pClientGame->SetAllDimensions ( usDimension );
}
pPlayer->SetDimension ( usDimension );
}
}
else
{
if ( pEntity->GetType () == CCLIENTPLAYER )
{
CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity );
if ( pPlayer->IsLocalPlayer () )
{
// Update all of our streamers/managers to the local player's dimension
m_pClientGame->SetAllDimensions ( usDimension );
}
}
pEntity->SetDimension ( usDimension );
}
}
}
}
示例10: Get
CClientPathNode* CClientPathManager::Get(ElementID ID)
{
// Grab the element with the given id. Check its type.
CClientEntity* pEntity = CElementIDs::GetElement(ID);
if (pEntity && pEntity->GetType() == CCLIENTPATHNODE)
{
return static_cast<CClientPathNode*>(pEntity);
}
return NULL;
}
示例11: Get
CClientCivilian* CClientCivilianManager::Get ( ElementID ID )
{
// Grab the element with the given id. Check its type.
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity && pEntity->GetType () == CCLIENTCIVILIAN )
{
return static_cast < CClientCivilian* > ( pEntity );
}
return NULL;
}
示例12: Get
CClientEffect* CClientEffectManager::Get ( ElementID ID )
{
// Grab the element with the given id. Check its type.
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity && pEntity->GetType () == CCLIENTEFFECT )
{
return static_cast < CClientEffect* > ( pEntity );
}
return NULL;
}
示例13: Get
CClientPointLights* CClientPointLightsManager::Get ( ElementID ID )
{
// Grab the element with the given id. Check its type.
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity && pEntity->GetType () == CCLIENTPOINTLIGHTS )
{
return static_cast < CClientPointLights* > ( pEntity );
}
return NULL;
}
示例14: Get
CClientRadarMarker* CClientRadarMarkerManager::Get ( ElementID ID )
{
// Grab the element with the given id. Check its type.
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity && pEntity->GetType () == CCLIENTRADARMARKER )
{
return static_cast < CClientRadarMarker* > ( pEntity );
}
return NULL;
}
示例15: SetElementVelocity
void CElementRPCs::SetElementVelocity ( NetBitStreamInterface& bitStream )
{
// Read out the entity id and the speed
ElementID ID;
CVector vecVelocity;
if ( bitStream.Read ( ID ) &&
bitStream.Read ( vecVelocity.fX ) &&
bitStream.Read ( vecVelocity.fY ) &&
bitStream.Read ( vecVelocity.fZ ) )
{
// Grab the entity
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
switch ( pEntity->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed* > ( pEntity );
pPed->SetMoveSpeed ( vecVelocity );
pPed->ResetInterpolation ();
// If local player, reset return position (so we can't warp back if connection fails)
if ( pPed->IsLocalPlayer () )
{
m_pClientGame->GetNetAPI ()->ResetReturnPosition ();
}
break;
}
case CCLIENTVEHICLE:
{
CClientVehicle* pVehicle = static_cast < CClientVehicle* > ( pEntity );
pVehicle->SetMoveSpeed ( vecVelocity );
break;
}
case CCLIENTOBJECT:
{
CClientObject * pObject = static_cast < CClientObject * > ( pEntity );
pObject->SetMoveSpeed ( vecVelocity );
break;
}
}
}
}
}