本文整理汇总了C++中CNetworkVehicle类的典型用法代码示例。如果您正苦于以下问题:C++ CNetworkVehicle类的具体用法?C++ CNetworkVehicle怎么用?C++ CNetworkVehicle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CNetworkVehicle类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachToVehicle
void CBlipManager::AttachToVehicle(EntityId blipId, EntityId vehicleId)
{
if(m_bActive[blipId])
{
if(g_pVehicleManager->Exists(vehicleId))
{
CNetworkVehicle * pVehicle = g_pVehicleManager->Get(vehicleId);
//Remove the position blip
Scripting::RemoveBlip(m_Blips[blipId].uiBlipIndex);
//And create one for the vehicle
Scripting::AddBlipForCar(pVehicle->GetScriptingHandle(), &m_Blips[blipId].uiBlipIndex);
// Set the blip sprite
ChangeBlipSprite(m_Blips[blipId].uiBlipIndex, (Scripting::eBlipSprite)m_Blips[blipId].iSprite);
// Set the blip color
SetColor(blipId, m_Blips[blipId].uiColor);
// Set the blip size
SetSize(blipId, m_Blips[blipId].fSize);
// Set short-range
ToggleShortRange(blipId, m_Blips[blipId].bShortRange);
// Set route
ToggleRouteBlip(blipId, m_Blips[blipId].bRouteBlip);
m_Blips[blipId].attachedVehicle = vehicleId;
}
}
}
示例2: RespawnVehicle
void RespawnVehicle( RakNet::BitStream * pBitStream, RakNet::Packet * pPacket )
{
// Read the vehicle id
EntityId vehicleId;
pBitStream->ReadCompressed( vehicleId );
// Read the spawn position
CVector3 vecPosition;
pBitStream->Read( vecPosition );
// Read teh spawn rotation
CVector3 vecRotation;
pBitStream->Read( vecRotation );
// Get a pointer to the network vehicle
CNetworkVehicle * pNetworkVehicle = pCore->GetVehicleManager()->Get( vehicleId );
// Is the vehicle pointer valid?
if( pNetworkVehicle )
{
// Set the spawn position
pNetworkVehicle->SetSpawnPosition( CVector3( vecPosition.fX, vecPosition.fY, (vecPosition.fZ - 1.0f) ) );
// Set the spawn rotation
pNetworkVehicle->SetSpawnRotation( vecRotation );
// Handle the respawn with the vehicle
pNetworkVehicle->HandleRespawn();
}
}
示例3: sq_getentity
// getVehicleRotation(vehicleid)
SQInteger CVehicleNatives::GetRotation(SQVM * pVM)
{
EntityId vehicleId;
sq_getentity(pVM, -1, &vehicleId);
if(g_pVehicleManager->Exists(vehicleId))
{
CNetworkVehicle * pVehicle = g_pVehicleManager->Get(vehicleId);
if(pVehicle)
{
CVector3 vecRotation;
pVehicle->GetRotation(vecRotation);
CSquirrelArguments args;
args.push(vecRotation.fX);
args.push(vecRotation.fY);
args.push(vecRotation.fZ);
sq_pusharg(pVM, CSquirrelArgument(args, true));
return 1;
}
}
sq_pushbool(pVM, false);
return 1;
}
示例4: sq_getentity
// getVehicleOccupants(vehicleid)
SQInteger CVehicleNatives::GetOccupants(SQVM * pVM)
{
EntityId vehicleId;
sq_getentity(pVM, -1, &vehicleId);
CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);
if(pVehicle)
{
CSquirrelArguments args;
for(BYTE i = 0; i < (MAX_VEHICLE_PASSENGERS + 1); i++)
{
args.push((int)(i + 1));
CNetworkPlayer * pOccupant = pVehicle->GetOccupant(i);
args.push(pOccupant ? (int)pOccupant->GetPlayerId() : (int)INVALID_ENTITY_ID);
}
sq_pusharg(pVM, CSquirrelArgument(args, false));
return 1;
}
sq_pushbool(pVM, false);
return 1;
}
示例5: Pulse
void CVehicleManager::Pulse()
{
std::list<CStreamableEntity *> * streamedVehicles = g_pClient->GetStreamer()->GetStreamedInEntitiesOfType(STREAM_ENTITY_VEHICLE);
for(std::list<CStreamableEntity *>::iterator iter = streamedVehicles->begin(); iter != streamedVehicles->end(); ++iter)
{
CNetworkVehicle * pVehicle = reinterpret_cast<CNetworkVehicle *>(*iter);
// Process the vehicle
pVehicle->Pulse();
}
}
示例6: VehicleToMe
void VehicleToMe(char * szParams)
{
int vehicleId = 0;
sscanf(szParams, "%d", &vehicleId);
CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);
if(pVehicle)
{
CVector3 vecPosition;
g_pClient->GetLocalPlayer()->GetPosition(&vecPosition);
pVehicle->GetGameVehicle()->SetPosition(&vecPosition);
pVehicle->GetGameVehicle()->RemoveFromWorld();
pVehicle->GetGameVehicle()->AddToWorld();
}
}
示例7: UnoccupiedVehicleSync
void UnoccupiedVehicleSync( RakNet::BitStream * pBitStream, RakNet::Packet * pPacket )
{
// Read the vehicle id
EntityId vehicleId;
pBitStream->ReadCompressed( vehicleId );
// Get a pointer to the network vehicle
CNetworkVehicle * pNetworkVehicle = pCore->GetVehicleManager()->Get( vehicleId );
// Is the vehicle pointer valid?
if( pNetworkVehicle )
{
// Process the unoccupied sync with this vehicle
pNetworkVehicle->ProcessUnoccupiedSync( pBitStream );
}
}
示例8: SavePosCommand
void SavePosCommand(char * szParams)
{
FILE * file = fopen(SharedUtility::GetAbsolutePath("SavedData.txt"), "a");
if(!file)
{
g_pClient->GetChatWindow()->AddInfoMessage("Failed to open 'SavedData.txt'");
return;
}
CVector3 vecPosition;
// Get our local player
CLocalPlayer * pLocalPlayer = g_pClient->GetLocalPlayer();
if(pLocalPlayer->IsInVehicle())
{
CNetworkVehicle * pVehicle = pLocalPlayer->GetVehicle();
if(pVehicle)
{
pVehicle->GetPosition(vecPosition);
CVector3 vecRotation;
pVehicle->GetRotation(vecRotation);
BYTE byteColors[4];
pVehicle->GetColors(byteColors[0], byteColors[1], byteColors[2], byteColors[3]);
fprintf(file, "createVehicle(%d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d);%s%s\n", g_pClient->GetModelManager()->ModelHashToVehicleId(pVehicle->GetModelInfo()->GetHash()), vecPosition.fX, vecPosition.fY, vecPosition.fZ, vecRotation.fX, vecRotation.fY, vecRotation.fZ, byteColors[0], byteColors[1], byteColors[2], byteColors[3], szParams ? " // " : "", szParams ? szParams : "");
}
}
else
{
pLocalPlayer->GetPosition(vecPosition);
int iModelId = ModelHashToSkinId(pLocalPlayer->GetModelInfo()->GetHash());
fprintf(file, "PlayerData(%d, %f, %f, %f, %f(%f));%s%s\n", iModelId, vecPosition.fX, vecPosition.fY, vecPosition.fZ, pLocalPlayer->GetCurrentHeading(), pLocalPlayer->GetDesiredHeading(),szParams ? " // " : "", szParams ? szParams : "");
}
fclose(file);
g_pClient->GetChatWindow()->AddInfoMessage("Position data saved to 'SavedData.txt'");
}
示例9: SpawnVehicle
void SpawnVehicle( RakNet::BitStream * pBitStream, RakNet::Packet * pPacket )
{
// Read the vehicle id
EntityId vehicleId;
pBitStream->ReadCompressed( vehicleId );
// Read the spawn position
CVector3 vecPosition;
pBitStream->Read( vecPosition );
// Read teh spawn rotation
CVector3 vecRotation;
pBitStream->Read( vecRotation );
// Get a pointer to the network vehicle
CNetworkVehicle * pNetworkVehicle = pCore->GetVehicleManager()->Get( vehicleId );
// Is the vehicle pointer valid?
if( pNetworkVehicle )
{
// Is the vehicle not already spawned?
if( !pNetworkVehicle->IsSpawned() )
{
// Set the spawn position
pNetworkVehicle->SetSpawnPosition( vecPosition );
// Set the spawn rotation
pNetworkVehicle->SetSpawnRotation( vecRotation );
// Create the vehicle
pNetworkVehicle->Create();
// Read the occupant count
int iTotalOccupants;
pBitStream->Read( iTotalOccupants );
#ifdef DEBUG
CLogFile::Printf( "(SpawnVehicle) Total occupants: %d", iTotalOccupants );
#endif
// Loop over the total occupants
EntityId occupantId = INVALID_ENTITY_ID;
int iSeat = 0;
CRemotePlayer * pOccupant = NULL;
for( int i = 0; i < iTotalOccupants; i++ )
{
// Read the current occupant id
pBitStream->ReadCompressed( occupantId );
// Read the current occupant seat
pBitStream->Read( iSeat );
#ifdef DEBUG
CLogFile::Printf( "SpawnVehicle - Read occupant %d in seat %d.", occupantId, iSeat );
#endif
// Is the read data valid?
if( occupantId != INVALID_ENTITY_ID )
{
// Get a pointer to the current occupant
pOccupant = pCore->GetPlayerManager()->Get( occupantId );
// Is the pointer valid?
if( pOccupant )
{
// Set the occupant vehicle
pOccupant->SetVehicle( pNetworkVehicle );
// Set the occupant seat
pOccupant->SetSeat( (iSeat + 1) );
// Set the vehicle passenger
pNetworkVehicle->SetOccupant( iSeat, pOccupant );
#ifdef DEBUG
CLogFile::Printf( "Put occupant %d into vehicle %d (%d)", occupantId, pNetworkVehicle->GetId(), (iSeat + 1) );
#endif
}
}
}
#ifdef DEBUG
CLogFile::Print ( "SpawnVehicle RPC done!" );
#endif
}
}
}
示例10: GetPlayerPed
void CLocalPlayer::SendInVehicleSync( void )
{
// Are we not connected to the network?
if( !pCore->GetNetworkModule()->IsConnected() )
return;
// Are we dead?
if( IsDead() )
return;
// Get the vehicle instance
CNetworkVehicle * pVehicle = pCore->GetVehicleManager()->GetFromGameGUID( GetPlayerPed()->GetCurrentVehicle()->m_dwGUID );
// Did we fail to find the vehicle?
if( !pVehicle )
return;
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Write the vehicle id
pBitStream.WriteCompressed( pVehicle->GetId() );
// Construct a new in vehicle sync data structure
InVehicleSync inVehicleSync;
// Get the vehicle position
pVehicle->GetPosition( &inVehicleSync.m_vecPosition );
// Get the vehicle rotation
pVehicle->GetRotation( &inVehicleSync.m_vecRotation );
// Get the vehicle dirt level
inVehicleSync.m_fDirtLevel = pVehicle->GetVehicle()->GetDirtLevel();
// Get the vehicle tuning table
inVehicleSync.m_iTuningTable = pVehicle->GetVehicle()->GetTuningTable();
// Get the vehicle horn state
inVehicleSync.m_bHornState = pVehicle->GetVehicle()->IsHornOn();
// Get the vehicle siren state
inVehicleSync.m_bSirenState = pVehicle->GetVehicle()->IsSirenOn();
// Get the vehicle fuel
inVehicleSync.m_fFuel = pVehicle->GetVehicle()->GetFuel();
// Get the vehicle speed
pVehicle->GetSpeedVec( &inVehicleSync.m_vecVelocity );
// Get the turn speed
inVehicleSync.m_fTurnSpeed = pVehicle->GetSteer();
// Get the engine damage
inVehicleSync.m_fEngineDamage = pVehicle->GetVehicle()->GetEngineDamage();
// Get the vehicle plate text
strcpy( inVehicleSync.m_szPlateText, pVehicle->GetPlateText() );
inVehicleSync.m_szPlateText[ 6 ] = '\0';
// Get the vehicle colour
pVehicle->GetColour( &inVehicleSync.m_primaryColour, &inVehicleSync.m_secondaryColour );
// Get the power state
inVehicleSync.m_bPower = pVehicle->GetVehicle()->GetPower();
// Get the brake state
inVehicleSync.m_bBrake = pVehicle->GetVehicle()->GetBrake();
// Get the vehicle wheel models (DISABLED FOR TESTING)
for ( int i = 0; i < 3; i++ )
inVehicleSync.m_bWheelModels[ i ] = 0xFF; //Game::GetIdFromVehicleWheelModel ( pVehicle->GetVehicle()->GetWheelTexture ( i ) );
// Get the handbrake state
inVehicleSync.m_bHandbrake = pVehicle->GetVehicle()->IsHandbrakeOn ();
// Get the light state
inVehicleSync.m_bLightState = pVehicle->GetVehicle()->GetLightState ();
// Write the sync structure into the bitstream
pBitStream.Write( (char *)&inVehicleSync, sizeof(InVehicleSync) );
// Send the bitstream to the server
pCore->GetNetworkModule()->Call( RPC_VEHICLE_SYNC, &pBitStream, LOW_PRIORITY, UNRELIABLE_SEQUENCED, true );
}
示例11: Direct3DRender
//.........这里部分代码省略.........
// Draw the string
g_pGUI->DrawText(strStats, CEGUI::Vector2(26, 30), (CEGUI::colour)D3DCOLOR_RGBA(255, 255, 255, 255), g_pGUI->GetFont("tahoma-bold", 10));
g_pChatWindow->SetEnabled(false);
g_bNetworkStatsDisplayed = true;
}
else
{
// If our network stats were displayed
if(g_bNetworkStatsDisplayed) {
if(g_pChatWindow && !g_pChatWindow->IsEnabled())
g_pChatWindow->SetEnabled(true);
g_bNetworkStatsDisplayed = false;
}
// If our input window exists draw it
if(g_pInputWindow)
g_pInputWindow->Draw();
}
// Update the time
if(g_pTime)
{
// jenksta: Setting this every frame causes the weather to change
// rapidly
unsigned char ucHour = 0, ucMinute = 0;
g_pTime->GetTime(&ucHour, &ucMinute);
CGame::SetTime(ucHour, ucMinute);
CGame::SetDayOfWeek(g_pTime->GetDayOfWeek());
}
/* Vehicle Headlights testcode
IVVehicle * pGameVehicle = pVehicle->GetGameVehicle()->GetVehicle();
//*(BYTE *)(pVehicle->GetGameVehicle()->GetVehicle() + 0xF71) |= 1;
*((BYTE *)pGameVehicle + 3953) = *((BYTE *)pGameVehicle + 3953) & 0xFE | 2;
}
CViewportManager + 0x00 = sysArray (CViewport *)
CViewport + 0x53C = Viewport ID
GET_VIEWPORT_POS_AND_SIZE(unsigned int uiViewportId, float * fPosX, float * fPosY, float * fSizeX, float * fSizeY)
(pViewport + 0x10) is always used
((pViewport + 0x10) + 0x298) = float fPosX;
(((pViewport + 0x10) + 0x298) + 0x4) = float fPosY;
(((pViewport + 0x10) + 0x298) + 0x8) = float fSizeX;
(((pViewport + 0x10) + 0x298) + 0xC) = float fSizeY;
GET_VIEWPORT_POSITION_OF_COORD(float fCoordX, float fCoordY, float fCoordZ, unsigned int uiViewportId, float * fPosX, float * fPosY)
Viewport 1 = CViewportPrimaryOrtho
Viewport 2 = CViewportGame
Viewport 3 = CViewportRadar
*/
if(g_pLocalPlayer)
{
if(g_pLocalPlayer->GetVehicleInfos())
{
if(g_pVehicleManager)
{
CVector3 vecWorldPosition;
Vector2 vecScreenPosition;
for(EntityId i = 0; i < MAX_VEHICLES; i++)
{
if(g_pVehicleManager->Exists(i))
{
CNetworkVehicle * pVehicle = g_pVehicleManager->Get(i);
if(!pVehicle->IsStreamedIn())
continue;
if(!pVehicle->IsOnScreen())
continue;
pVehicle->GetPosition(vecWorldPosition);
CGame::GetScreenPositionFromWorldPosition(vecWorldPosition, vecScreenPosition);
//if(g_pGraphics)
//{
// CVector3 vecScreen;
// g_pGraphics->GetScreenPositionFromWorldPosition(vecWorldPosition, &vecScreen);
// if( vecScreen.fZ < 0 )
// return;
//}
//else
// return;
int health = pVehicle->GetHealth();
int model = pVehicle->GetEngineState();
float petrol = pVehicle->GetPetrolTankHealth();
CVector3 vecPos; pVehicle->GetPosition(vecPos);
CVector3 vecRot; pVehicle->GetRotation(vecRot);
g_pGUI->DrawText(String("VehicleId %d, Enginestate: %d, Health: %d, PetrolTankHealth: %f\nPosition(%.3f,%.3f,%.3f), Rot(%.3f,%.3f,%.3f)", i, model, health, petrol, vecPos.fX,vecPos.fY,vecPos.fZ,vecRot.fX,vecRot.fY,vecRot.fZ), CEGUI::Vector2(vecScreenPosition.X, vecScreenPosition.Y));
}
}
}
}
}
if(g_pNameTags)
g_pNameTags->Draw();
}
}
示例12: SAFE_DELETE
// (John) TODO: Only SAFE_DELETE and re-instantiate things that really need it, otherwise give them a Reset() method.
void CClient::InternalResetGame(bool bAutoConnect)
{
CLogFile::Printf("Initializing game for multiplayer activities");
// Remove local player from vehicle
if(m_pLocalPlayer)
m_pLocalPlayer->RemoveFromVehicle();
// Remove all current GUIs
// CClientScriptManager destructor will take care of this
//m_pClientScriptManager->RemoveAll();
//m_pClientScriptManager->GetGUIManager()->DeleteAll();
SAFE_DELETE(m_pClientScriptManager);
m_pClientScriptManager = new CClientScriptManager();
m_pEvents->clear();
m_pGUI->SetScriptedCursorVisible(false);
CLogFile::Printf("Reset clientside scripting stuff");
SAFE_DELETE(m_pModelManager);
m_pModelManager = new CModelManager();
CLogFile::Printf("Created model manager instance");
SAFE_DELETE(m_pPickupManager);
m_pPickupManager = new CPickupManager();
CLogFile::Printf("Created pickup manager instance");
SAFE_DELETE(m_pCheckpointManager);
m_pCheckpointManager = new CCheckpointManager();
CLogFile::Printf("Created checkpoint manager instance");
SAFE_DELETE(m_pBlipManager);
m_pBlipManager = new CBlipManager();
CLogFile::Printf("Created blip manager instance");
SAFE_DELETE(m_pObjectManager);
m_pObjectManager = new CObjectManager();
CLogFile::Printf("Created object manager instance");
SAFE_DELETE(m_pFireManager);
m_pFireManager = new CFireManager();
CLogFile::Printf("Created fire manager instance");
SAFE_DELETE(m_p3DLabelManager);
m_p3DLabelManager = new C3DLabelManager();
CLogFile::Printf("Created 3d label manager instance");
// Set all vehicles to destroyable
if(m_pVehicleManager)
{
for(EntityId i = 0; i < MAX_PLAYERS; i++)
{
CNetworkVehicle * pVehicle = m_pVehicleManager->Get(i);
if(pVehicle)
pVehicle->MarkAsActorVehicle(false);
}
}
SAFE_DELETE(m_pVehicleManager);
m_pVehicleManager = new CVehicleManager();
CLogFile::Printf("Created vehicle manager instance");
SAFE_DELETE(m_pActorManager);
m_pActorManager = new CActorManager();
CLogFile::Printf("Created actor manager instance");
// Reset the streamer
m_pStreamer->Reset();
CLogFile::Printf("Reset streamer instance");
if(!m_pLocalPlayer)
{
m_pLocalPlayer = new CLocalPlayer();
CLogFile::Printf("Created local player instance");
}
m_pLocalPlayer->Reset();
m_pLocalPlayer->SetPlayerId(INVALID_ENTITY_ID);
m_pLocalPlayer->SetModel(Scripting::MODEL_PLAYER);
m_pLocalPlayer->Teleport(CVector3());
m_pLocalPlayer->SetPlayerControlAdvanced(false, false);
m_pLocalPlayer->RemoveAllWeapons();
m_pLocalPlayer->ResetMoney();
m_pLocalPlayer->SetHealth(200);
m_pLocalPlayer->SetControl(true);
CLogFile::Printf("Reset local player instance");
SAFE_DELETE(m_pPlayerManager);
m_pPlayerManager = new CPlayerManager();
CLogFile::Printf("Created player manager instance");
// Create network manager if it doesn't exist
if(!m_pNetworkManager)
{
m_pNetworkManager = new CNetworkManager();
m_pNetworkManager->Startup(GetHost(), GetPort(), GetPassword());
CLogFile::Printf("Created network manager instance");
//.........这里部分代码省略.........
示例13: if
//.........这里部分代码省略.........
}
}
// Are we in game?
if(CGame::GetState() == GAME_STATE_INGAME)
{
// Is F4 held down and do we have a network manager?
if(GetAsyncKeyState(VK_F4) && m_pNetworkManager && m_pActorManager)
{
// Get the network statistics
CNetStats * pNetStats = m_pNetworkManager->GetNetClient()->GetNetStats();
// Convert the network statistics to a string
char szNetworkStats[10000];
pNetStats->ToString(szNetworkStats, 2);
// Create the statistics string
String strStats(szNetworkStats);
// Append loaded and unloaded model counts to the stats
// jenksta: too performance heavy to be done every frame
//strStats.AppendF("Models (Loaded/Unload): %d/%d\n", CGame::GetLoadedModelCount(), CGame::GetUnloadedModelCount());
// Append streamed in/out entity counts and streamed in limits to the stats
strStats.AppendF("Players (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_PLAYER)+1, m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_PLAYER));
strStats.AppendF("Vehicles (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_VEHICLE), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_VEHICLE));
strStats.AppendF("Actors (Actor-Count/Max-Actors): %d/%d\n", m_pActorManager->GetActorCount(), MAX_ACTORS);
strStats.AppendF("Pickups (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_PICKUP), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_PICKUP));
strStats.AppendF("Objects (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_OBJECT), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_OBJECT));
strStats.AppendF("Checkpoints (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_CHECKPOINT), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_CHECKPOINT));
// Draw the string
m_pGUI->DrawText(strStats, CEGUI::Vector2(26, 30), (CEGUI::colour)D3DCOLOR_RGBA(255, 255, 255, 255), m_pGUI->GetFont("tahoma-bold", 10));
m_pChatWindow->SetEnabled(false);
m_bNetworkStatsDisplayed = true;
}
else
{
// If our network stats were displayed
if(m_bNetworkStatsDisplayed)
{
if(m_pChatWindow && !m_pChatWindow->IsEnabled())
m_pChatWindow->SetEnabled(true);
m_bNetworkStatsDisplayed = false;
}
// If our input window exists draw it
if(m_pInputWindow)
m_pInputWindow->Draw();
}
// Update the time
if(m_pTime)
{
// jenksta: Setting this every frame causes the weather to change
// rapidly
unsigned char ucHour = 0, ucMinute = 0;
m_pTime->GetTime(&ucHour, &ucMinute);
CGame::SetTime(ucHour, ucMinute);
CGame::SetDayOfWeek(m_pTime->GetDayOfWeek());
}
#ifdef IVMP_DEBUG
if(m_pVehicleManager)
{
CVector3 vecWorldPosition;
Vector2 vecScreenPosition;
for(EntityId i = 0; i < MAX_VEHICLES; i++)
{
CNetworkVehicle * pVehicle = m_pVehicleManager->Get(i);
if(pVehicle)
{
if(!pVehicle->IsStreamedIn())
continue;
if(!pVehicle->IsOnScreen())
continue;
pVehicle->GetPosition(vecWorldPosition);
if(!CGame::GetScreenPositionFromWorldPosition(vecWorldPosition, vecScreenPosition))
continue;
int iHealth = pVehicle->GetHealth();
int iModel = pVehicle->GetEngineState();
float fPetrol = pVehicle->GetPetrolTankHealth();
CVector3 vecPos; pVehicle->GetPosition(vecPos);
CVector3 vecRot; pVehicle->GetRotation(vecRot);
m_pGUI->DrawText(String("VehicleId %d, Enginestate: %d, Health: %d, PetrolTankHealth: %f\nPosition(%.3f,%.3f,%.3f), Rot(%.3f,%.3f,%.3f)", i, iModel, iHealth, fPetrol, vecPos.fX,vecPos.fY,vecPos.fZ,vecRot.fX,vecRot.fY,vecRot.fZ), CEGUI::Vector2(vecScreenPosition.fX, vecScreenPosition.fY));
}
}
}
#endif
if(m_pNameTags)
m_pNameTags->Draw();
}
}
示例14: GetPosition
void CLocalPlayer::GetClosestVehicle( CNetworkVehicle ** pNetworkVehicle, EntityId * seatId )
{
// Are we spawned and not dead and not already in a vehicle?
if( IsSpawned() && !IsDead() && !m_pPlayerPed->GetCurrentVehicle() )
{
//
float fCurrentDistance = 2.68f;
CVector3 vecVehiclePos;
CNetworkVehicle * pClosestVehicle = NULL;
// Get our position
CVector3 vecCurrentPosition;
GetPosition( &vecCurrentPosition );
// Loop through all network vehicles
for( int i = 0; i < MAX_VEHICLES; i++ )
{
// Is the current vehicle active?
if( pCore->GetVehicleManager()->IsActive( i ) )
{
// Get a pointer to the current vehicle
CNetworkVehicle * pCurrentVehicle = pCore->GetVehicleManager()->Get( i );
// Get the vehicle position
pCurrentVehicle->GetPosition( &vecVehiclePos );
// Get the distance between the current vehicle and us
float fDistance = Math::GetDistanceBetweenPoints( vecCurrentPosition, vecVehiclePos );
// Is this distance less than the current distance?
if( fDistance < fCurrentDistance )
{
// Set the current distance
fCurrentDistance = fDistance;
// Set the closest vehicle
pClosestVehicle = pCurrentVehicle;
}
}
}
// Isn't there a vehicle in range?
if( !pClosestVehicle )
return;
// Loop through all the passenger seats
BYTE byteCurrentSeat = 0;
for( BYTE i = 2; i < 5; i++ )
{
// Is there no one in this seat?
if( !pClosestVehicle->GetVehicle()->GetSeatOccupant( i ) )
{
byteCurrentSeat = i;
break;
}
}
// Didn't we find a seat?
if( !byteCurrentSeat )
return;
// Set the seat
*seatId = byteCurrentSeat;
// Set the vehicle
*pNetworkVehicle = pClosestVehicle;
}
}