本文整理汇总了C++中CVehicle::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetPosition方法的具体用法?C++ CVehicle::GetPosition怎么用?C++ CVehicle::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPosition
int CVehicleNatives::GetPosition(SQVM * pVM)
{
CVehicle * pVehicle = sq_tovehicle(pVM, 2);
if(pVehicle)
{
CVector3 vecPos;
pVehicle->GetPosition(vecPos);
sq_pushvector3(pVM, &vecPos);
}
else
sq_pushnull(pVM);
return 1;
}
示例2: GetCoordinates
// getVehicleCoordinates(vehicleid)
CVector3 CVehicleModuleNatives::GetCoordinates(EntityId vehicleid)
{
if(g_pVehicleManager->DoesExist(vehicleid))
{
CVehicle * pVehicle = g_pVehicleManager->GetAt(vehicleid);
if(pVehicle)
{
CVector3 vecPosition;
pVehicle->GetPosition(vecPosition);
return vecPosition;
}
}
return CVector3();
}
示例3: Write
bool CVehiclePuresyncPacket::Write ( NetBitStreamInterface& BitStream ) const
{
// Got a player to send?
if ( m_pSourceElement )
{
CPlayer * pSourcePlayer = static_cast < CPlayer * > ( m_pSourceElement );
// Player is in a vehicle and is the driver?
CVehicle* pVehicle = pSourcePlayer->GetOccupiedVehicle ();
if ( pVehicle )
{
// Player ID
ElementID PlayerID = pSourcePlayer->GetID ();
BitStream.Write ( PlayerID );
// Write the time context of that player
BitStream.Write ( pSourcePlayer->GetSyncTimeContext () );
// Write his ping divided with 2 plus a small number so the client can find out when this packet was sent
unsigned short usLatency = pSourcePlayer->GetPing ();
BitStream.WriteCompressed ( usLatency );
// Write the keysync data
CControllerState ControllerState = pSourcePlayer->GetPad ()->GetCurrentControllerState ();
WriteFullKeysync ( ControllerState, BitStream );
// Write the vehicle matrix only if he's the driver
CVector vecTemp;
unsigned int uiSeat = pSourcePlayer->GetOccupiedVehicleSeat ();
if ( uiSeat == 0 )
{
// Vehicle position
SPositionSync position ( false );
position.data.vecPosition = pVehicle->GetPosition ();
BitStream.Write ( &position );
// Vehicle rotation
SRotationDegreesSync rotation;
pVehicle->GetRotationDegrees ( rotation.data.vecRotation );
BitStream.Write ( &rotation );
// Move speed vector
SVelocitySync velocity;
velocity.data.vecVelocity = pVehicle->GetVelocity ();
BitStream.Write ( &velocity );
// Turn speed vector
SVelocitySync turnSpeed;
turnSpeed.data.vecVelocity = pVehicle->GetTurnSpeed ();
BitStream.Write ( &turnSpeed );
// Health
SVehicleHealthSync health;
health.data.fValue = pVehicle->GetHealth ();
BitStream.Write ( &health );
}
// Player health and armor
SPlayerHealthSync health;
health.data.fValue = pSourcePlayer->GetHealth ();
BitStream.Write ( &health );
SPlayerArmorSync armor;
armor.data.fValue = pSourcePlayer->GetArmor ();
BitStream.Write ( &armor );
// Weapon
unsigned char ucWeaponType = pSourcePlayer->GetWeaponType ();
// Flags
SVehiclePuresyncFlags flags;
flags.data.bIsWearingGoggles = pSourcePlayer->IsWearingGoggles ();
flags.data.bIsDoingGangDriveby = pSourcePlayer->IsDoingGangDriveby ();
flags.data.bIsSirenOrAlarmActive = pVehicle->IsSirenActive ();
flags.data.bIsSmokeTrailEnabled = pVehicle->IsSmokeTrailEnabled ();
flags.data.bIsLandingGearDown = pVehicle->IsLandingGearDown ();
flags.data.bIsOnGround = pVehicle->IsOnGround ();
flags.data.bIsInWater = pVehicle->IsInWater ();
flags.data.bIsDerailed = pVehicle->IsDerailed ();
flags.data.bIsAircraft = ( pVehicle->GetVehicleType () == VEHICLE_PLANE ||
pVehicle->GetVehicleType () == VEHICLE_HELI );
flags.data.bHasAWeapon = ( ucWeaponType != 0 );
flags.data.bIsHeliSearchLightVisible = pVehicle->IsHeliSearchLightVisible ();
BitStream.Write ( &flags );
// Write the weapon stuff
if ( flags.data.bHasAWeapon )
{
// Write the weapon slot
SWeaponSlotSync slot;
slot.data.uiSlot = pSourcePlayer->GetWeaponSlot ();
BitStream.Write ( &slot );
if ( flags.data.bIsDoingGangDriveby && CWeaponNames::DoesSlotHaveAmmo ( slot.data.uiSlot ) )
{
// Write the ammo states
SWeaponAmmoSync ammo ( ucWeaponType, false, true );
ammo.data.usAmmoInClip = pSourcePlayer->GetWeaponAmmoInClip ();
BitStream.Write ( &ammo );
//.........这里部分代码省略.........
示例4: Write
//.........这里部分代码省略.........
unsigned char ucNameLength = static_cast < unsigned char > ( strlen ( szName ) );
BitStream.Write ( ucNameLength );
BitStream.Write ( szName, ucNameLength );
pArgument->WriteToBitStream ( BitStream );
}
}
// Grab its name
char szEmpty [1];
szEmpty [0] = 0;
const char* szName = pElement->GetName ().c_str ();
if ( !szName )
szName = szEmpty;
// Write the name. It can be empty.
unsigned short usNameLength = static_cast < unsigned short > ( strlen ( szName ) );
BitStream.WriteCompressed ( usNameLength );
if ( usNameLength > 0 )
{
BitStream.Write ( const_cast < char * > ( szName ), usNameLength );
}
// Write the sync time context
BitStream.Write ( pElement->GetSyncTimeContext () );
// Write the rest depending on the type
switch ( ucEntityTypeID )
{
case CElement::OBJECT:
{
CObject* pObject = static_cast < CObject* > ( pElement );
// Position
position.data.vecPosition = pObject->GetPosition ();
BitStream.Write ( &position );
// Rotation
SRotationRadiansSync rotationRadians ( false );
pObject->GetRotation ( rotationRadians.data.vecRotation );
BitStream.Write ( &rotationRadians );
// Object id
BitStream.WriteCompressed ( pObject->GetModel () );
// Alpha
SEntityAlphaSync alpha;
alpha.data.ucAlpha = pObject->GetAlpha ();
BitStream.Write ( &alpha );
// Double sided
bool bIsDoubleSided = pObject->IsDoubleSided ();
BitStream.WriteBit ( bIsDoubleSided );
// Moving
const CPositionRotationAnimation* pMoveAnimation = pObject->GetMoveAnimation ();
if ( pMoveAnimation )
{
BitStream.WriteBit ( true );
pMoveAnimation->ToBitStream ( BitStream, true );
}
else
{
BitStream.WriteBit ( false );
}
// Scale
示例5: DoVehicleRespawning
void CMapManager::DoVehicleRespawning ( void )
{
CVehicleSpawnPacket VehicleSpawnPacket;
// Loop through all vehicles with respawn enabled
list < CVehicle* >& respawnEnabledList = m_pVehicleManager->GetRespawnEnabledVehicles ( );
list < CVehicle* > ::const_iterator iter = respawnEnabledList.begin ( );
for ( ; iter != respawnEnabledList.end ( ); ++iter )
{
CVehicle* pVehicle = *iter;
// No need to respawn vehicles if they're being deleted anyway
if ( pVehicle->IsBeingDeleted ( ) )
continue;
// Did we get deserted?
bool bDeserted = ( !pVehicle->GetFirstOccupant ( ) );
bool bRespawn = false;
bool bExploded = false;
if ( bDeserted )
{
// If moved, or idle timer not running, restart idle timer
if ( !pVehicle->IsStationary ( ) || !pVehicle->IsIdleTimerRunning ( ) )
pVehicle->RestartIdleTimer ( );
}
else
{
// Stop idle timer if car is occupied
pVehicle->StopIdleTimer ( );
}
// Been blown long enough?
if ( pVehicle->IsBlowTimerFinished ( ) )
{
bRespawn = true;
bExploded = true;
}
// Been deserted long enough?
else if ( bDeserted && pVehicle->IsIdleTimerFinished ( ) )
{
// Check is far enough away from respawn point (Ignore first 20 units on z)
CVector vecDif = pVehicle->GetRespawnPosition ( ) - pVehicle->GetPosition ( );
vecDif.fZ = Max ( 0.f, fabsf ( vecDif.fZ ) - 20.f );
if ( vecDif.LengthSquared ( ) > 2 * 2 )
bRespawn = true;
pVehicle->StopIdleTimer ( );
}
// Need to respawn?
if ( bRespawn )
{
// Respawn it and add it to the packet
pVehicle->Respawn ( );
VehicleSpawnPacket.Add ( pVehicle );
// Call the respawn event
CLuaArguments Arguments;
Arguments.PushBoolean ( bExploded );
pVehicle->CallEvent ( "onVehicleRespawn", Arguments );
}
}
// Send it
m_pPlayerManager->BroadcastOnlyJoined ( VehicleSpawnPacket );
}