当前位置: 首页>>代码示例>>C++>>正文


C++ CVehicle类代码示例

本文整理汇总了C++中CVehicle的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle类的具体用法?C++ CVehicle怎么用?C++ CVehicle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CVehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateCollisionReaction

void CRigidBody::UpdateCollisionReaction()
{
	CVehicle* Car = (CVehicle*)this;

	Vector3f OldPosition = m_vPosition;

	// update reflection motion
	m_vReflection *= RIGIDBODY_REFLECTION_ENTROPY_FACTOR;
	m_vPosition = m_translate + m_vReflection;
	m_vDirectionWhenDisturbed = m_vPosition - OldPosition;
	m_translate = m_vPosition;
	m_box.Center() = m_vPosition;
	m_sphere.Center() = m_vPosition;

	Car->SetVehiclePositionLC(Vector3f(m_vPosition.X(), m_vPosition.Z(), m_vPosition.Y()));

	// update angular velocity
	m_vRotation *= RIGIDBODY_ROTATION_ENTROPY_FACTOR;
	Car->GetRotationLC().Z() += m_vRotation.Y();

	// see if reflection has dissipated enough to stop
	if (m_vReflection.Length() < RIGIDBODY_REFLECTION_DEATH_FACTOR) {
		disturbed = false;
	}

}
开发者ID:BackupTheBerlios,项目名称:bos-ssracer,代码行数:26,代码来源:rigidbody.cpp

示例2: if

CClientProjectile* CClientProjectileManager::Create(CClientEntity* pCreator, eWeaponType eWeapon, CVector& vecOrigin, float fForce, CVector* target,
                                                    CClientEntity* pTargetEntity)
{
    m_bCreating = true;
    m_pLastCreated = NULL;
    CEntity* pGameCreator = pCreator->GetGameEntity();
    CEntity* pGameTargetEntity = NULL;
    if (pTargetEntity)
        pGameTargetEntity = pTargetEntity->GetGameEntity();
    if (pGameCreator)
    {
        // Peds and players
        if (pCreator->GetType() == CCLIENTPED || pCreator->GetType() == CCLIENTPLAYER)
        {
            CPed* pPed = dynamic_cast<CPed*>(pGameCreator);
            if (pPed)
                pPed->AddProjectile(eWeapon, vecOrigin, fForce, target, pGameTargetEntity);
        }
        // Vehicles
        else if (pCreator->GetType() == CCLIENTVEHICLE)
        {
            CVehicle* pVehicle = dynamic_cast<CVehicle*>(pGameCreator);
            if (pVehicle)
                pVehicle->AddProjectile(eWeapon, vecOrigin, fForce, target, pGameTargetEntity);
        }
    }
    m_bCreating = false;
    return m_pLastCreated;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:29,代码来源:CClientProjectileManager.cpp

示例3: EmptyVehicleSync

void CServerRPCHandler::EmptyVehicleSync(CBitStream * pBitStream, CPlayerSocket * pSenderSocket)
{
	// Ensure we have a valid bit stream
	if(!pBitStream)
		return;

	EntityId playerId = pSenderSocket->playerId;

	if(CVAR_GET_BOOL("frequentevents"))
	{
		CSquirrelArguments pArguments;
		pArguments.push(playerId);

		if(g_pEvents->Call("playerEmptyVehicleSyncReceived", &pArguments).GetInteger() != 1 || g_pEvents->Call("playerSyncReceived", &pArguments).GetInteger() != 1)
			return;
	}

	CBitStream bsSend;
	EMPTYVEHICLESYNCPACKET syncPacket;

	if(!pBitStream->Read((PCHAR)&syncPacket, sizeof(EMPTYVEHICLESYNCPACKET)))
		return;

	CVehicle * pVehicle = g_pVehicleManager->GetAt(syncPacket.vehicleId);
	if(pVehicle && g_pVehicleManager->DoesExist(syncPacket.vehicleId))
		pVehicle->StoreEmptyVehicle(&syncPacket);

	//bsSend.Write((char *)&syncPacket, sizeof(EMPTYVEHICLESYNCPACKET));
	//g_pNetworkManager->RPC(RPC_EmptyVehicleSync, &bsSend, PRIORITY_LOW, RELIABILITY_UNRELIABLE_SEQUENCED, playerId, false);
}
开发者ID:JamesConway69,项目名称:ivmultiplayer,代码行数:30,代码来源:CServerRPCHandler.cpp

示例4: ForceAddUpgrade

void CVehicleUpgrades::ForceAddUpgrade ( unsigned short usUpgrade )
{
    unsigned char ucSlot;
    if ( GetSlotFromUpgrade ( usUpgrade, ucSlot ) )
    {
        CVehicle* pVehicle = m_pVehicle->GetGameVehicle ();
        if ( pVehicle )
        {
            // Grab the upgrade model
            CModelInfo* pModelInfo = g_pGame->GetModelInfo ( usUpgrade );
            if ( pModelInfo )
            {
                if ( !g_pGame->IsASyncLoadingEnabled () || !pModelInfo->IsLoaded () )
                {
                    // Request and load now
                    pModelInfo->RequestVehicleUpgrade ();

                    g_pGame->GetStreaming()->LoadAllRequestedModels ();
                }
                // Add the upgrade
                pVehicle->AddVehicleUpgrade ( usUpgrade );
            }
        }

        // Add it to the slot
        m_SlotStates [ ucSlot ] = usUpgrade;
    }
}
开发者ID:EagleShen,项目名称:MTA,代码行数:28,代码来源:CVehicleUpgrades.cpp

示例5: Write

bool CLightsyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    bool bSyncPosition;

    if (Count() == 0)
        return false;

    for (std::vector<CPlayer*>::const_iterator iter = m_players.begin(); iter != m_players.end(); ++iter)
    {
        CPlayer*                       pPlayer = *iter;
        CPlayer::SLightweightSyncData& data = pPlayer->GetLightweightSyncData();
        CVehicle*                      pVehicle = pPlayer->GetOccupiedVehicle();

        // Find the difference between now and the time the position last changed for the player
        long long llTicksDifference = GetTickCount64_() - pPlayer->GetPositionLastChanged();

        // Right we need to sync the position if there is no vehicle or he's in a vehicle and the difference between setPosition is less than or equal to the
        // slow sync rate i.e. make sure his position has been updated more than 0.001f in the last 1500ms plus a small margin for error (probably not needed).
        // This will ensure we only send positions when the position has changed.
        bSyncPosition = (!pVehicle || pPlayer->GetOccupiedVehicleSeat() == 0) && llTicksDifference <= g_TickRateSettings.iLightSync + 100;

        BitStream.Write(pPlayer->GetID());
        BitStream.Write((unsigned char)pPlayer->GetSyncTimeContext());

        unsigned short usLatency = pPlayer->GetPing();
        BitStream.WriteCompressed(usLatency);

        BitStream.WriteBit(data.health.bSync);
        if (data.health.bSync)
        {
            SPlayerHealthSync health;
            health.data.fValue = pPlayer->GetHealth();
            BitStream.Write(&health);

            SPlayerArmorSync armor;
            armor.data.fValue = pPlayer->GetArmor();
            BitStream.Write(&armor);
        }

        BitStream.WriteBit(bSyncPosition);
        if (bSyncPosition)
        {
            SLowPrecisionPositionSync pos;
            pos.data.vecPosition = pPlayer->GetPosition();
            BitStream.Write(&pos);

            bool bSyncVehicleHealth = data.vehicleHealth.bSync && pVehicle;
            BitStream.WriteBit(bSyncVehicleHealth);
            if (bSyncVehicleHealth)
            {
                SLowPrecisionVehicleHealthSync health;
                health.data.fValue = pVehicle->GetHealth();
                BitStream.Write(&health);
            }
        }
    }

    return true;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:59,代码来源:CLightsyncPacket.cpp

示例6: LinkupElements

void CMapManager::LinkupElements ( void )
{
    // * Link up all the attaching elements
    list < CVehicle* > ::const_iterator iterVehicles = m_pVehicleManager->IterBegin ();
    for ( ; iterVehicles != m_pVehicleManager->IterEnd (); iterVehicles++ )
    {
        CVehicle* pVehicle = *iterVehicles;

        char* szAttachToID = pVehicle->GetAttachToID ();
        if ( szAttachToID [ 0 ] )
        {
            CElement* pElement = g_pGame->GetMapManager ()->GetRootElement ()->FindChild ( szAttachToID, 0, true );
            if ( pElement )
                pVehicle->AttachTo ( pElement );
        }
    }

    list < CPlayer* > ::const_iterator iterPlayers = m_pPlayerManager->IterBegin ();
    for ( ; iterPlayers != m_pPlayerManager->IterEnd (); iterPlayers++ )
    {
        CPlayer* pPlayer = *iterPlayers;
        // Link up all the attaching elements
        char* szAttachToID = pPlayer->GetAttachToID ();
        if ( szAttachToID [ 0 ] )
        {
            CElement* pElement = g_pGame->GetMapManager ()->GetRootElement ()->FindChild ( szAttachToID, 0, true );
            if ( pElement )
                pPlayer->AttachTo ( pElement );
        }
    }

    CObjectListType::const_iterator iterObjects = m_pObjectManager->IterBegin ();
    for ( ; iterObjects != m_pObjectManager->IterEnd (); iterObjects++ )
    {
        CObject* pObject = *iterObjects;
        // Link up all the attaching elements
        char* szAttachToID = pObject->GetAttachToID ();
        if ( szAttachToID [ 0 ] )
        {
            CElement* pElement = g_pGame->GetMapManager ()->GetRootElement ()->FindChild ( szAttachToID, 0, true );
            if ( pElement )
                pObject->AttachTo ( pElement );
        }
    }

    list < CBlip* > ::const_iterator iterBlips = m_pBlipManager->IterBegin ();
    for ( ; iterBlips != m_pBlipManager->IterEnd (); iterBlips++ )
    {
        CBlip* pBlip = *iterBlips;
        // Link up all the attaching elements
        char* szAttachToID = pBlip->GetAttachToID ();
        if ( szAttachToID [ 0 ] )
        {
            CElement* pElement = g_pGame->GetMapManager ()->GetRootElement ()->FindChild ( szAttachToID, 0, true );
            if ( pElement )
                pBlip->AttachTo ( pElement );
        }
    }
}
开发者ID:EagleShen,项目名称:MTA,代码行数:59,代码来源:CMapManager.cpp

示例7: main

int main ()
{
	CVehicle *vehicle = new CShip("1234,887 @", 2005, "Spb", 30);
	Coord coord = {123.45, 65.56};
	vehicle->setCoord(coord);
	vehicle->setSpeed(456.9);
	vehicle->printParam();
}
开发者ID:lmikheevskaya,项目名称:LevelUP_Junior,代码行数:8,代码来源:Vehicle.cpp

示例8: ProcessMouseMove

////////////////////////////////////////////////////
//
//  CMouseControl::ProcessMouseMove
//
//  Process a windows mouse movement message and turn it into control
//
////////////////////////////////////////////////////
bool CMouseControl::ProcessMouseMove ( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    if ( uMsg != WM_MOUSEMOVE )
        return false;

    if ( g_pCore->GetGame ()->GetSystemState () != 9 )
        return false;

    // HACK:  Grab our local player, and check his vehicle
    CPed* pPed = g_pCore->GetGame ()->GetPools ()->GetPedFromRef ( (DWORD)1 );
    if ( !pPed )
        return false;

    CVehicle* pVehicle = pPed->GetVehicle ();
    if ( !pVehicle )
        return false;

    CModelInfo* pModelInfo = g_pCore->GetGame ()->GetModelInfo( pVehicle->GetModelIndex() );

    bool bVar;
    CVARS_GET ( "fly_with_mouse", bVar );
    if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() && !bVar ) // Are we in a plane, but not have mouse flight enabled?
        return false;

    CVARS_GET ( "steer_with_mouse", bVar );
    if ( !bVar )  // Are we in another type of vehicle, but not have mouse steering enabled?
        return false;


    // Let's calculate our mouse movement directions
    CVector2D resolution = g_pCore->GetGUI()->GetResolution();
    int iX = LOWORD ( lParam ), iY = HIWORD ( lParam );
    float fX = (iX - resolution.fX*0.5f)/resolution.fX;

    fX *= MOUSE_CONTROL_MULTIPLIER;

    float fMouseSensitivity = g_pCore->GetGame ( )->GetSettings()->GetMouseSensitivity ();
    fX *= fMouseSensitivity;

    m_usLeftStickX += fX*128;
    m_usLeftStickX  = Clamp < const short > ( -128, m_usLeftStickX, 128 );

    // Only process Y input if we're in a vehicle that requires it
    if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() || pModelInfo->IsBike() || pModelInfo->IsBmx() || pModelInfo->IsQuadBike() )
    {
        float fY = (resolution.fY*0.5f - iY)/resolution.fY;
        fY *= MOUSE_CONTROL_MULTIPLIER;
        fY *= fMouseSensitivity;

        CVARS_GET ( "invert_mouse", bVar );
        fY = bVar ? -fY : fY;

        m_usLeftStickY += fY*128;
        m_usLeftStickY  = Clamp < const short > ( -128, m_usLeftStickY, 128 );
    }

    return true;
}
开发者ID:ntauthority,项目名称:openvice,代码行数:65,代码来源:CMouseControl.cpp

示例9: GetVehicle

//------------------------------------------------------------------------
int CScriptBind_Vehicle::OnUsed(IFunctionHandler* pH, ScriptHandle userHandle, int index)
{
	CVehicle* pVehicle = GetVehicle(pH);
	if (!pVehicle || !userHandle.n)
		return pH->EndFunction(0);

	int ret = pVehicle->OnUsed((EntityId)userHandle.n, index);
	return pH->EndFunction(ret);
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:10,代码来源:ScriptBind_Vehicle.cpp

示例10: GetRespawnDelay

int CVehicleModuleNatives::GetRespawnDelay(EntityId vehicleId)
{
    CVehicle * pVehicle = g_pVehicleManager->GetAt(vehicleId);

    if(pVehicle)
        return pVehicle->GetRespawnDelay();

    return -1;
}
开发者ID:mat27,项目名称:ivmultiplayer,代码行数:9,代码来源:VehicleModuleNatives.cpp

示例11: Script_popVehicleTrunk

// popVehicleTrunk
void Script_popVehicleTrunk(RakNet::BitStream *bitStream, Packet *packet)
{
	BYTE vehicle;

	bitStream->Read(vehicle);
	
	CVehicle *pVehicle = pNetowkManager->GetVehicleManager()->GetAt(vehicle);
	pVehicle->PopTrunk();
}
开发者ID:Tonyx97,项目名称:vice-players,代码行数:10,代码来源:netrpc.cpp

示例12: GetDimension

int CVehicleModuleNatives::GetDimension(EntityId vehicleId)
{
    CVehicle * pVehicle = g_pVehicleManager->GetAt(vehicleId);

    if(pVehicle)
        return pVehicle->GetDimension();

    return -1;
}
开发者ID:mat27,项目名称:ivmultiplayer,代码行数:9,代码来源:VehicleModuleNatives.cpp

示例13: LockSimSystem

///////////////////////////////////////////////////////////////////////////
//
// CSimPlayerManager::UpdateSimPlayer
//
// Thread:              main
// CS should be locked: no
//
// Update matching sim player object with new datum
//
///////////////////////////////////////////////////////////////////////////
void CSimPlayerManager::UpdateSimPlayer ( CPlayer* pPlayer )
{
    LockSimSystem ();     // TODO - only lock the CSimPlayer

    // Get matching sim player
    CSimPlayer* pSim = pPlayer->m_pSimPlayer;

    // Validate
    if ( !pSim )
    {
        UnlockSimSystem ();
        return;
    }

    //
    // Copy relevant data
    //
    CVehicle* pVehicle = pPlayer->GetOccupiedVehicle ();

    pSim->m_iStatus                 = pPlayer->GetStatus ();
    pSim->m_usBitStreamVersion      = pPlayer->GetBitStreamVersion ();
    pSim->m_bHasOccupiedVehicle     = pVehicle != NULL;
    pSim->m_PlayerID                = pPlayer->GetID ();
    pSim->m_usLatency               = pPlayer->GetPing ();
    pSim->m_ucWeaponType            = pPlayer->GetWeaponType ();
    pSim->m_usVehicleModel          = pVehicle ? pVehicle->GetModel () : 0;
    pSim->m_ucSyncTimeContext       = pPlayer->GetSyncTimeContext ();
    pSim->m_ucOccupiedVehicleSeat   = pPlayer->GetOccupiedVehicleSeat ();
    pSim->m_fWeaponRange            = pPlayer->GetWeaponRangeFromSlot();
    pSim->m_bVehicleHasHydraulics   = pVehicle ? pVehicle->GetUpgrades ()->HasUpgrade ( 1087 ) : false;
    pSim->m_bVehicleIsPlaneOrHeli   = pVehicle ? pVehicle->GetVehicleType () == VEHICLE_PLANE || pVehicle->GetVehicleType () == VEHICLE_HELI : false;
    pSim->m_sharedControllerState.Copy ( pPlayer->GetPad ()->GetCurrentControllerState () );
    pSim->m_fCameraRotation         = pPlayer->GetCameraRotation ();
    pSim->m_fPlayerRotation         = pPlayer->GetRotation ();

    // Update Puresync send list
    if ( pPlayer->m_bPureSyncSimSendListDirty )
    {
        pPlayer->m_bPureSyncSimSendListDirty = false;
        pSim->m_PuresyncSendListFlat.clear ();
        pSim->m_bSendListChanged = true;
        for ( CFastHashSet < CPlayer* > ::const_iterator iter = pPlayer->m_PureSyncSimSendList.begin (); iter != pPlayer->m_PureSyncSimSendList.end (); ++iter )
        {
            CSimPlayer* pSendSimPlayer = (*iter)->m_pSimPlayer;
            if ( pSendSimPlayer && pSendSimPlayer->m_bDoneFirstUpdate )
                pSim->m_PuresyncSendListFlat.push_back ( pSendSimPlayer );
            else
                pPlayer->m_bPureSyncSimSendListDirty = true;    // Retry next time
        }
    }

    // Set this flag
    pSim->m_bDoneFirstUpdate = true;

    UnlockSimSystem ();
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:66,代码来源:CSimPlayerManager.cpp

示例14: DoubleCarSpeed

static void DoubleCarSpeed(void)
{
	CPlayerPed* pLocalPlayer = pGame->FindPlayerPed();
	if (pLocalPlayer->IsInVehicle())
	{
		CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
		CVehicle* pVehicle = pVehiclePool->GetAt(pVehiclePool->FindIDFromGtaPtr(pLocalPlayer->GetGtaVehicle()));
		pVehicle->DoubleSpeed();
	}
}
开发者ID:LBRGeorge,项目名称:jmnvc,代码行数:10,代码来源:subclass.cpp

示例15: GetTaxiLights

bool CVehicleModuleNatives::GetTaxiLights(EntityId vehicleId)
{
    CVehicle * pVehicle = g_pVehicleManager->GetAt(vehicleId);

    if(pVehicle)
    {
        return pVehicle->GetTaxiLights();
    }
    return false;
}
开发者ID:mat27,项目名称:ivmultiplayer,代码行数:10,代码来源:VehicleModuleNatives.cpp


注:本文中的CVehicle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。