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


C++ CElement::GetType方法代码示例

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


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

示例1: SetWeaponAmmo

int CLuaFunctionDefs::SetWeaponAmmo ( lua_State* luaVM )
{
    // bool setWeaponAmmo ( player thePlayer, int weapon, int totalAmmo, [int ammoInClip = 0] )
    CElement* pElement;
    eWeaponType weaponType;
    ushort usAmmo;
    ushort usAmmoInClip;
    CCustomWeapon * pWeapon = NULL;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pElement );

    if ( !argStream.HasErrors () )
    {
        if ( pElement->GetType () != CElement::WEAPON )
        {
            argStream.ReadEnumStringOrNumber ( weaponType );
            argStream.ReadNumber ( usAmmo );
            argStream.ReadNumber ( usAmmoInClip, 0 );

            if ( !argStream.HasErrors () )
            {
                if ( CStaticFunctionDefinitions::SetWeaponAmmo ( pElement, weaponType, usAmmo, usAmmoInClip ) )
                {
                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
            else
                m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
        }
        else
        {
            pWeapon = static_cast <CCustomWeapon *> ( pElement );
            argStream.ReadNumber ( usAmmo );

            if ( !argStream.HasErrors () )
            {
                if ( CStaticFunctionDefinitions::SetWeaponAmmo ( pWeapon, usAmmo ) )
                {
                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
            else
                m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:F420,项目名称:mtasa-blue,代码行数:54,代码来源:CLuaFunctionDefs.Weapon.cpp

示例2: switch

CElementGroup::~CElementGroup()
{
    // Delete all the elements
    if (!m_elements.empty())
    {
        if (!g_pGame->IsBeingDeleted())
        {
            CEntityRemovePacket removePacket;

            for (CFastList<CElement*>::iterator iter = m_elements.begin(); iter != m_elements.end(); iter++)
            {
                CElement* pElement = (*iter);

                switch (pElement->GetType())
                {
                    case CElement::DATABASE_CONNECTION:
                    case CElement::SCRIPTFILE:
                        continue;
                    default:
                        break;
                }
                // Tell everyone to destroy it if this is not a per-player entity
                if (pElement->IsPerPlayerEntity())
                {
                    // Unsync it (will destroy it for those that know about it)
                    CPerPlayerEntity* pEntity = static_cast<CPerPlayerEntity*>(pElement);
                    pEntity->Sync(false);
                }
                else
                {
                    // Tell everyone to destroy it
                    removePacket.Add(pElement);
                }
            }

            g_pGame->GetPlayerManager()->BroadcastOnlyJoined(removePacket);
        }

        CElementDeleter* deleter = g_pGame->GetElementDeleter();
        CElement*        pElement = NULL;
        for (CFastList<CElement*>::iterator iter = m_elements.begin(); iter != m_elements.end(); iter++)
        {
            pElement = *iter;
            pElement->SetElementGroup(NULL);
            pElement->DeleteAllEvents();
            deleter->Delete(pElement, true, false);
        }

        // Do this at the end for speed
        g_pGame->GetMapManager()->GetRootElement()->UpdatePerPlayerEntities();
    }
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:52,代码来源:CElementGroup.cpp

示例3: DoHitDetectionForColShape

//
// Handle the changing state of collision between one colshape and any entity
//
void CColManager::DoHitDetectionForColShape ( CColShape* pShape )
{
    // Ensure colshape is enabled and not being deleted
    if ( pShape->IsBeingDeleted () || !pShape->IsEnabled () )
        return;

    std::map < CElement*, int > entityList;

    // Get all entities within the sphere
    CSphere querySphere = pShape->GetWorldBoundingSphere ();
    CElementResult result;
    GetSpatialDatabase()->SphereQuery ( result, querySphere );
 
    // Extract relevant types
    for ( CElementResult::const_iterator it = result.begin () ; it != result.end (); ++it )
    {
        CElement* pEntity = *it;
        switch ( pEntity->GetType () )
        {
            case CElement::COLSHAPE:
            case CElement::SCRIPTFILE:
            case CElement::RADAR_AREA:
            case CElement::CONSOLE:
            case CElement::TEAM:
            case CElement::BLIP:
            case CElement::DUMMY:
                break;
            default:
                if ( pEntity->GetParentEntity () )
                    entityList[ pEntity ] = 1;
        }
    }

    // Add existing colliders, so they can be disconnected if required
    for ( list < CElement* > ::const_iterator it = pShape->CollidersBegin () ; it != pShape->CollidersEnd (); ++it )
    {
       entityList[ *it ] = 1;
    }

    // Test each entity against the colshape
    for ( std::map < CElement*, int > ::const_iterator it = entityList.begin () ; it != entityList.end (); ++it )
    {
        CElement* pEntity = it->first;
        CVector vecPosition =
        pEntity->GetPosition ();

        // Collided?
        bool bHit = pShape->DoHitDetection ( vecPosition );
        HandleHitDetectionResult ( bHit, pShape, pEntity );
    }
}
开发者ID:pombredanne,项目名称:openvice,代码行数:54,代码来源:CColManager.cpp

示例4: RequestStealthKill

void CRPCFunctions::RequestStealthKill ( NetBitStreamInterface & bitStream )
{
    ElementID ID;
    bitStream.ReadCompressed ( ID );
    CElement * pElement = CElementIDs::GetElement ( ID );
    if ( pElement )
    {
        int elementType = pElement->GetType ();
        if ( elementType == CElement::PLAYER || elementType == CElement::PED )
        {
            CPed * pTarget = static_cast < CPed * > ( pElement );

            // Are they both alive?
            if ( !m_pSourcePlayer->IsDead () && !pTarget->IsDead () )
            {
                //Do we have any record of the killer currently having a knife?
                if ( m_pSourcePlayer->GetWeaponType( 1 ) == 4 )
                {
                    // Are they close enough?
                    if ( DistanceBetweenPoints3D ( m_pSourcePlayer->GetPosition (), pTarget->GetPosition () ) <= STEALTH_KILL_RANGE )
                    {
                        CLuaArguments Arguments;
                        Arguments.PushElement ( pTarget );
                        if ( m_pSourcePlayer->CallEvent ( "onPlayerStealthKill", Arguments, false ) )
                        {
                            // Start the stealth kill
                            CStaticFunctionDefinitions::KillPed ( pTarget, m_pSourcePlayer, 4 /*WEAPONTYPE_KNIFE*/, 9/*BODYPART_HEAD*/, true );
                        }
                    }
                }
                else
                {
                    //You shouldn't be able to get here without cheating to get a knife.
                    if ( !g_pGame->GetConfig ()->IsDisableAC ( "2" ) )
                    {
                        CStaticFunctionDefinitions::KickPlayer ( m_pSourcePlayer, NULL, "AC #2: You were kicked from the game" );
                    }
                }
            }
        }
    }
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例5: ExecuteCommandHandler

int CLuaFunctionDefs::ExecuteCommandHandler ( lua_State* luaVM )
{
    //  bool executeCommandHandler ( string commandName, player thePlayer, [ string args ] )
    SString strKey; CElement* pElement; SString strArgs;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadString ( strKey );
    argStream.ReadUserData ( pElement );
    argStream.ReadString ( strArgs, "" );

    if ( !argStream.HasErrors () )
    {

        // Grab our VM
        CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
        if ( pLuaMain )
        {
            CClient* pClient = NULL;
            if ( pElement->GetType () == CElement::PLAYER )
                pClient = static_cast <CClient*> ( static_cast <CPlayer*> ( pElement ) );

            if ( pClient )
            {

                // Call it
                if ( m_pRegisteredCommands->ProcessCommand ( strKey, strArgs, pClient ) )
                {
                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:39,代码来源:CLuaFunctionDefs.Server.cpp

示例6: BroadcastElementChildren

void CMapManager::BroadcastElementChildren ( CElement* pElement, CEntityAddPacket &Packet, list < CPerPlayerEntity* > &pPerPlayerList, bool bBroadcastAll )
{
    CElement * pTemp;
    CChildListType ::const_iterator iter = pElement->IterBegin ();
    for ( ; iter != pElement->IterEnd(); iter++ )
    {
        pTemp = *iter;
        // Is this a map created entity or our resource's root element
        if ( bBroadcastAll || ( pTemp->IsMapCreated () || ( pTemp->GetType () == CElement::DUMMY && !strcmp ( pTemp->GetTypeName ().c_str (), "map" ) ) ) )
        {
            // Is it a per-player entity
            if ( pTemp->IsPerPlayerEntity () )
            {
                pPerPlayerList.push_back ( static_cast < CPerPlayerEntity* > ( pTemp ) );
            }
            else
            {
                Packet.Add ( pTemp );
            }
        }
        if ( pTemp->CountChildren() > 0 ) BroadcastElementChildren ( pTemp, Packet, pPerPlayerList, bBroadcastAll );
    }
}
开发者ID:EagleShen,项目名称:MTA,代码行数:23,代码来源:CMapManager.cpp

示例7: Write

bool CEntityAddPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    SPositionSync position ( false );

    // Check that we have any entities
    if ( m_Entities.size () > 0 )
    {
        // Write the number of entities
        unsigned int NumElements = m_Entities.size ();
        BitStream.WriteCompressed ( NumElements );

        // For each entity ...
        CVector vecTemp;
        vector < CElement* > ::const_iterator iter = m_Entities.begin ();
        for ( ; iter != m_Entities.end (); iter++ )
        {
            // Entity id
            CElement* pElement = *iter;
            BitStream.Write ( pElement->GetID () );

            // Entity type id
            unsigned char ucEntityTypeID = static_cast < unsigned char > ( pElement->GetType () );
            BitStream.Write ( ucEntityTypeID );

            // Entity parent
            CElement* pParent = pElement->GetParentEntity ();
            ElementID ParentID = INVALID_ELEMENT_ID;
            if ( pParent )
                ParentID = pParent->GetID ();
            BitStream.Write ( ParentID );

            // Entity interior
            BitStream.Write ( pElement->GetInterior () );

            // Entity dimension
            BitStream.WriteCompressed ( pElement->GetDimension () );

            // Entity attached to
            CElement* pElementAttachedTo = pElement->GetAttachedToElement ();
            if ( pElementAttachedTo )
            {
                BitStream.WriteBit ( true );
                BitStream.Write ( pElementAttachedTo->GetID () );

                // Attached position and rotation
                SPositionSync attachedPosition ( false );
                SRotationDegreesSync attachedRotation ( false );
                pElement->GetAttachedOffsets ( attachedPosition.data.vecPosition,
                                               attachedRotation.data.vecRotation );
                BitStream.Write ( &attachedPosition );
                BitStream.Write ( &attachedRotation );
            }
            else
                BitStream.WriteBit ( false );

            // Entity collisions enabled
            bool bCollisionsEnabled = true;

            switch ( pElement->GetType() )
            {
                case CElement::VEHICLE:
                {
                    CVehicle* pVehicle = static_cast < CVehicle* > ( pElement );
                    bCollisionsEnabled = pVehicle->GetCollisionEnabled ( );
                    break;
                }
                case CElement::OBJECT:
                {
                    CObject* pObject = static_cast < CObject* > ( pElement );
                    bCollisionsEnabled = pObject->GetCollisionEnabled ( );
                    break;
                }
                case CElement::PED:
                case CElement::PLAYER:
                {
                    CPed* pPed = static_cast < CPed* > ( pElement );
                    bCollisionsEnabled = pPed->GetCollisionEnabled ( );
                    break;
                }
            }

            BitStream.WriteBit ( bCollisionsEnabled );
            
            // Write custom data
            CCustomData* pCustomData = pElement->GetCustomDataPointer ();
            assert ( pCustomData );
            BitStream.WriteCompressed ( pCustomData->CountOnlySynchronized () );
            map < string, SCustomData > :: const_iterator iter = pCustomData->IterBegin ();
            for ( ; iter != pCustomData->IterEnd (); iter++ )
            {
                const char* szName = iter->first.c_str ();
                const CLuaArgument* pArgument = &iter->second.Variable;
                bool bSynchronized = iter->second.bSynchronized;

                if ( bSynchronized )
                {
                    unsigned char ucNameLength = static_cast < unsigned char > ( strlen ( szName ) );
                    BitStream.Write ( ucNameLength );
                    BitStream.Write ( szName, ucNameLength );
                    pArgument->WriteToBitStream ( BitStream );
//.........这里部分代码省略.........
开发者ID:qaisjp,项目名称:green-candy,代码行数:101,代码来源:CEntityAddPacket.cpp


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