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


C++ C_BaseEntity类代码示例

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


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

示例1: Q_snprintf

//-----------------------------------------------------------------------------
// Purpose: Draw function for the element
//-----------------------------------------------------------------------------
void CTargetID::Paint()
{
    // No id if still choosing class
    if ( C_BaseTFPlayer::GetLocalPlayer()->GetClass() == TFCLASS_UNDECIDED )
        return;

    // Get our target's ent index
    int iEntIndex = C_BaseTFPlayer::GetLocalPlayer()->GetIDTarget();
    // Didn't find one?
    if ( !iEntIndex )
    {
        // Check to see if we should clear our ID
        if ( m_flLastChangeTime && (gpGlobals->curtime > (m_flLastChangeTime + 0.5)) )
        {
            m_flLastChangeTime = 0;
            m_sIDString[0] = 0;
            m_iLastEntIndex = 0;
        }
        else
        {
            // Keep re-using the old one
            iEntIndex = m_iLastEntIndex;
        }
    }
    else
    {
        m_flLastChangeTime = gpGlobals->curtime;
    }

    // Is this an entindex sent by the server?
    if ( iEntIndex )
    {
        C_BaseTFPlayer *pPlayer = static_cast<C_BaseTFPlayer*>(cl_entitylist->GetEnt( iEntIndex ));
        C_BaseTFPlayer *pLocalPlayer = C_BaseTFPlayer::GetLocalPlayer();

        // Some entities we always want to check, cause the text may change
        // even while we're looking at it
        // Is it a player?
        if ( IsPlayerIndex( iEntIndex ) )
        {
            if ( pPlayer->InSameTeam(pLocalPlayer) )
            {
                // Check distance to other player, and if the player is on the same team
                float flDistSq = pPlayer->GetRenderOrigin().DistToSqr( pLocalPlayer->GetRenderOrigin() );
                if ( flDistSq < PLAYER_HINT_DISTANCE_SQ )
                {
                    Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nHealth: %.0f percent\nUse to donate resources",
                        pPlayer->GetPlayerName(), ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 );
                }
                else
                {
                    Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nHealth: %.0f percent",
                        pPlayer->GetPlayerName(), ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 );
                }
            }
            else if (( pPlayer->GetHealth() == 0) && (pLocalPlayer->GetClass() == TFCLASS_INFILTRATOR) )
            {
                Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nUse to disguise as this player", pPlayer->GetPlayerName() );
            }
            else
            {
                m_sIDString[0] = 0;
                m_iLastEntIndex = 0;
            }
        }
        else
        {
            // Objects
            C_BaseEntity *pEnt = cl_entitylist->GetEnt( iEntIndex );
            if ( !pEnt || !pEnt->InSameTeam(pLocalPlayer) )
            {
                // This can happen because the object was destroyed
                m_sIDString[0] = 0;
                m_iLastEntIndex = 0;
            }
            else
            {
                // Don't check validity if it's sent by the server
                Q_strncpy( m_sIDString, pEnt->GetIDString(), sizeof(m_sIDString) );
                m_iLastEntIndex = iEntIndex;
            }
        }
    }

    // Draw our ID string
    if ( m_sIDString[0] )
    {
        int width, height;
        int ypos = YRES(300);

        // Messagechars can't handle multiple line strings, so parse out the \n's and give it one line at a time
        char *ch = m_sIDString;
        while ( *ch )
        {
            // Find the next newline
            char *next_line;
            for ( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
//.........这里部分代码省略.........
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:101,代码来源:hud_target_id.cpp

示例2: GetEntIndex

int CClientTools::GetEntIndex( EntitySearchResult entityToAttach )
{
    C_BaseEntity *ent = reinterpret_cast< C_BaseEntity * >( entityToAttach );
    return ent ? ent->entindex() : 0;
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:5,代码来源:entity_client_tools.cpp

示例3: IsNPC

bool CClientTools::IsNPC( EntitySearchResult currentEnt )
{
    C_BaseEntity *ent = reinterpret_cast< C_BaseEntity* >( currentEnt );
    return ent ? ent->IsNPC() : false;
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:5,代码来源:entity_client_tools.cpp

示例4: switch

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_HL2MP_Player::CalculateIKLocks( float currentTime )
{
    if (!m_pIk) 
        return;

    int targetCount = m_pIk->m_target.Count();
    if ( targetCount == 0 )
        return;

    // In TF, we might be attaching a player's view to a walking model that's using IK. If we are, it can
    // get in here during the view setup code, and it's not normally supposed to be able to access the spatial
    // partition that early in the rendering loop. So we allow access right here for that special case.
    SpatialPartitionListMask_t curSuppressed = partition->GetSuppressedLists();
    partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, false );
    CBaseEntity::PushEnableAbsRecomputations( false );

    for (int i = 0; i < targetCount; i++)
    {
        trace_t trace;
        CIKTarget *pTarget = &m_pIk->m_target[i];

        if (!pTarget->IsActive())
            continue;

        switch( pTarget->type)
        {
        case IK_GROUND:
            {
                pTarget->SetPos( Vector( pTarget->est.pos.x, pTarget->est.pos.y, GetRenderOrigin().z ));
                pTarget->SetAngles( GetRenderAngles() );
            }
            break;

        case IK_ATTACHMENT:
            {
                C_BaseEntity *pEntity = NULL;
                float flDist = pTarget->est.radius;

                // FIXME: make entity finding sticky!
                // FIXME: what should the radius check be?
                for ( CEntitySphereQuery sphere( pTarget->est.pos, 64 ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
                {
                    C_BaseAnimating *pAnim = pEntity->GetBaseAnimating( );
                    if (!pAnim)
                        continue;

                    int iAttachment = pAnim->LookupAttachment( pTarget->offset.pAttachmentName );
                    if (iAttachment <= 0)
                        continue;

                    Vector origin;
                    QAngle angles;
                    pAnim->GetAttachment( iAttachment, origin, angles );

                    // debugoverlay->AddBoxOverlay( origin, Vector( -1, -1, -1 ), Vector( 1, 1, 1 ), QAngle( 0, 0, 0 ), 255, 0, 0, 0, 0 );

                    float d = (pTarget->est.pos - origin).Length();

                    if ( d >= flDist)
                        continue;

                    flDist = d;
                    pTarget->SetPos( origin );
                    pTarget->SetAngles( angles );
                    // debugoverlay->AddBoxOverlay( pTarget->est.pos, Vector( -pTarget->est.radius, -pTarget->est.radius, -pTarget->est.radius ), Vector( pTarget->est.radius, pTarget->est.radius, pTarget->est.radius), QAngle( 0, 0, 0 ), 0, 255, 0, 0, 0 );
                }

                if (flDist >= pTarget->est.radius)
                {
                    // debugoverlay->AddBoxOverlay( pTarget->est.pos, Vector( -pTarget->est.radius, -pTarget->est.radius, -pTarget->est.radius ), Vector( pTarget->est.radius, pTarget->est.radius, pTarget->est.radius), QAngle( 0, 0, 0 ), 0, 0, 255, 0, 0 );
                    // no solution, disable ik rule
                    pTarget->IKFailed( );
                }
            }
            break;
        }
    }

    CBaseEntity::PopEnableAbsRecomputations();
    partition->SuppressLists( curSuppressed, true );
}
开发者ID:DreikVal,项目名称:nicksproject,代码行数:84,代码来源:c_hl2mp_player.cpp

示例5: assert

//-----------------------------------------------------------------------------
// Does the dirty deed
//-----------------------------------------------------------------------------
void CMaterialModifyAnimatedProxy::OnBind( void *pEntity )
{
    assert ( m_AnimatedTextureVar );
    if( m_AnimatedTextureVar->GetType() != MATERIAL_VAR_TYPE_TEXTURE )
        return;

    ITexture *pTexture;
    pTexture = m_AnimatedTextureVar->GetTextureValue();

    // Get the modified material vars from the entity input
    IClientRenderable *pRend = (IClientRenderable *)pEntity;
    if ( pRend )
    {
        C_BaseEntity *pBaseEntity = pRend->GetIClientUnknown()->GetBaseEntity();
        if ( pBaseEntity )
        {
            for ( C_BaseEntity *pChild = pBaseEntity->FirstMoveChild(); pChild; pChild = pChild->NextMovePeer() )
            {
                C_MaterialModifyControl *pControl = dynamic_cast<C_MaterialModifyControl*>( pChild );
                if ( !pControl )
                    continue;

                if ( !pControl->HasNewAnimationCommands() )
                    continue;

                // Read the data from the modify entity
                materialanimcommands_t sCommands;
                pControl->GetAnimationCommands( &sCommands );

                m_iFrameStart = sCommands.iFrameStart;
                m_iFrameEnd = sCommands.iFrameEnd;
                m_bCustomWrap = sCommands.bWrap;
                m_flCustomFramerate = sCommands.flFrameRate;
                m_bReachedEnd = false;

                m_flStartTime = gpGlobals->curtime;

                pControl->ClearAnimationCommands();
            }
        }
    }

    // Init all the vars based on whether we're using the base material settings, 
    // or the custom ones from the entity input.
    int numFrames;
    bool bWrapAnimation;
    float flFrameRate;
    int iLastFrame;

    // Do we have a custom frame section from the server?
    if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
    {
        if ( m_iFrameEnd == MATERIAL_MODIFY_ANIMATION_UNSET )
        {
            m_iFrameEnd = pTexture->GetNumAnimationFrames();
        }

        numFrames = (m_iFrameEnd - m_iFrameStart) + 1;
        bWrapAnimation = m_bCustomWrap;
        flFrameRate = m_flCustomFramerate;
        iLastFrame = (m_iFrameEnd - 1);
    }
    else
    {
        numFrames = pTexture->GetNumAnimationFrames();
        bWrapAnimation = m_WrapAnimation;
        flFrameRate = m_FrameRate;
        iLastFrame = (numFrames - 1);
    }

    // Have we already reached the end? If so, stay there.
    if ( m_bReachedEnd && !bWrapAnimation )
    {
        m_AnimatedTextureFrameNumVar->SetIntValue( iLastFrame );
        return;
    }

    // NOTE: Must not use relative time based methods here
    // because the bind proxy can be called many times per frame.
    // Prevent multiple Wrap callbacks to be sent for no wrap mode
    float startTime;
    if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
    {
        startTime = m_flStartTime;
    }
    else
    {
        startTime = GetAnimationStartTime(pEntity);
    }
    float deltaTime = gpGlobals->curtime - startTime;
    float prevTime = deltaTime - gpGlobals->frametime;

    // Clamp..
    if (deltaTime < 0.0f)
        deltaTime = 0.0f;
    if (prevTime < 0.0f)
        prevTime = 0.0f;
//.........这里部分代码省略.........
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:101,代码来源:C_MaterialModifyControl.cpp

示例6: FX_MuzzleEffectAttached

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : scale - 
//			attachmentIndex - 
//			bOneFrame - 
//-----------------------------------------------------------------------------
void FX_MuzzleEffectAttached( 
    float scale, 
    ClientEntityHandle_t hEntity, 
    int attachmentIndex, 
    unsigned char *pFlashColor,
    bool bOneFrame )
{
    VPROF_BUDGET( "FX_MuzzleEffect", VPROF_BUDGETGROUP_PARTICLE_RENDERING );

    // If the material isn't available, let's not do anything.
    if ( g_Mat_SMG_Muzzleflash[0] == NULL )
    {
        return;
    }
    
    CSmartPtr<CLocalSpaceEmitter> pSimple = CLocalSpaceEmitter::Create( "MuzzleFlash", hEntity, attachmentIndex );
    Assert( pSimple );
    if ( pSimple == NULL )
        return;
    
    // Lock our bounding box
    pSimple->GetBinding().SetBBox( -( Vector( 16, 16, 16 ) * scale ), ( Vector( 16, 16, 16 ) * scale ) );
    
    SimpleParticle *pParticle;
    Vector			forward(1,0,0), offset;

    float flScale = random->RandomFloat( scale-0.25f, scale+0.25f );

    if ( flScale < 0.5f )
    {
        flScale = 0.5f;
    }
    else if ( flScale > 8.0f )
    {
        flScale = 8.0f;
    }

    //
    // Flash
    //

    int i;
    for ( i = 1; i < 9; i++ )
    {
        offset = (forward * (i*2.0f*scale));

        pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), g_Mat_SMG_Muzzleflash[random->RandomInt(0,3)], offset );
            
        if ( pParticle == NULL )
            return;

        pParticle->m_flLifetime		= 0.0f;
        pParticle->m_flDieTime		= bOneFrame ? 0.0001f : 0.1f;

        pParticle->m_vecVelocity.Init();

        if ( !pFlashColor )
        {
            pParticle->m_uchColor[0]	= 255;
            pParticle->m_uchColor[1]	= 255;
            pParticle->m_uchColor[2]	= 255;
        }
        else
        {
            pParticle->m_uchColor[0]	= pFlashColor[0];
            pParticle->m_uchColor[1]	= pFlashColor[1];
            pParticle->m_uchColor[2]	= pFlashColor[2];
        }

        pParticle->m_uchStartAlpha	= 255;
        pParticle->m_uchEndAlpha	= 128;

        pParticle->m_uchStartSize	= (random->RandomFloat( 6.0f, 9.0f ) * (12-(i))/9) * flScale;
        pParticle->m_uchEndSize		= pParticle->m_uchStartSize;
        pParticle->m_flRoll			= random->RandomInt( 0, 360 );
        pParticle->m_flRollDelta	= 0.0f;
    }


    if ( !ToolsEnabled() )
        return;

    if ( !clienttools->IsInRecordingMode() )
        return;

    C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( hEntity );
    if ( pEnt )
    {
        pEnt->RecordToolMessage();
    }

    // NOTE: Particle system destruction message will be sent by the particle effect itself.
    int nId = pSimple->AllocateToolParticleEffectId();

//.........这里部分代码省略.........
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:101,代码来源:fx.cpp

示例7: IsCombatCharacter

bool CClientTools::IsCombatCharacter( EntitySearchResult currentEnt )
{
    C_BaseEntity *ent = reinterpret_cast< C_BaseEntity* >( currentEnt );
    return ent ? ent->IsBaseCombatCharacter() : false;
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:5,代码来源:entity_client_tools.cpp

示例8: IsRagdoll

bool CClientTools::IsRagdoll( EntitySearchResult currentEnt )
{
    C_BaseEntity *ent = reinterpret_cast< C_BaseEntity* >( currentEnt );
    C_BaseAnimating *pBaseAnimating = ent ? ent->GetBaseAnimating() : NULL;
    return pBaseAnimating ? pBaseAnimating->IsClientRagdoll() : false;
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:6,代码来源:entity_client_tools.cpp

示例9: ToTFPlayer

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponMedigun::UpdateEffects( void )
{
    CTFPlayer *pFiringPlayer = ToTFPlayer( GetOwnerEntity() );
    if ( !pFiringPlayer )
        return;

    C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
    C_BaseEntity *pEffectOwner = this;
    if ( pLocalPlayer == pFiringPlayer )
    {
        pEffectOwner = pLocalPlayer->GetViewModel();
        if ( !pEffectOwner )
            return;
    }

    // Remove all the effects
    if ( pEffectOwner )
    {
        pEffectOwner->ParticleProp()->StopEmission( m_hHealingTargetEffect.pEffect );
    }
    else
    {
        m_hHealingTargetEffect.pEffect->StopEmission();
    }
    m_hHealingTargetEffect.pTarget = NULL;
    m_hHealingTargetEffect.pEffect = NULL;

    // Don't add targets if the medic is dead
    if ( !pEffectOwner || pFiringPlayer->IsPlayerDead() || !pFiringPlayer->IsPlayerClass( TF_CLASS_MEDIC ) )
        return;

    // Add our targets
    // Loops through the healing targets, and make sure we have an effect for each of them
    if ( m_hHealingTarget )
    {
        if ( m_hHealingTargetEffect.pTarget == m_hHealingTarget )
            return;

        const char *pszEffectName;
        if (m_bChargeRelease)
        {
            switch (GetTeamNumber())
            {
            case TF_TEAM_BLUE:
                pszEffectName = "medicgun_beam_blue_invun";
                break;
            case TF_TEAM_RED:
                pszEffectName = "medicgun_beam_red_invun";
                break;
            case TF_TEAM_GREEN:
                pszEffectName = "medicgun_beam_green_invun";
                break;
            case TF_TEAM_YELLOW:
                pszEffectName = "medicgun_beam_yellow_invun";
                break;
            default:
                pszEffectName = "medicgun_beam_blue";
                break;
            }
        }
        else
        {
            switch (GetTeamNumber())
            {
            case TF_TEAM_BLUE:
                pszEffectName = "medicgun_beam_blue";
                break;
            case TF_TEAM_RED:
                pszEffectName = "medicgun_beam_red";
                break;
            case TF_TEAM_GREEN:
                pszEffectName = "medicgun_beam_green";
                break;
            case TF_TEAM_YELLOW:
                pszEffectName = "medicgun_beam_yellow";
                break;
            default:
                pszEffectName = "medicgun_beam_blue";
                break;
            }
        }


        CNewParticleEffect *pEffect = pEffectOwner->ParticleProp()->Create( pszEffectName, PATTACH_POINT_FOLLOW, "muzzle" );
        pEffectOwner->ParticleProp()->AddControlPoint( pEffect, 1, m_hHealingTarget, PATTACH_ABSORIGIN_FOLLOW, NULL, Vector(0,0,50) );

        m_hHealingTargetEffect.pTarget = m_hHealingTarget;
        m_hHealingTargetEffect.pEffect = pEffect;
    }
}
开发者ID:Navton,项目名称:TF2Classic,代码行数:93,代码来源:tf_weapon_medigun.cpp

示例10: ManageChargeEffect

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponMedigun::ManageChargeEffect( void )
{
    C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
    C_BaseEntity *pEffectOwner = this;

    if ( pLocalPlayer == NULL )
        return;

    if ( pLocalPlayer == GetTFPlayerOwner() )
    {
        pEffectOwner = pLocalPlayer->GetViewModel();
        if ( !pEffectOwner )
            return;
    }

    bool bOwnerTaunting = false;

    if ( GetTFPlayerOwner() && GetTFPlayerOwner()->m_Shared.InCond( TF_COND_TAUNTING ) == true )
    {
        bOwnerTaunting = true;
    }

    if ( GetTFPlayerOwner() && bOwnerTaunting == false && m_bHolstered == false && ( m_flChargeLevel >= 1.0f || m_bChargeRelease == true ) )
    {
        if ( m_pChargeEffect == NULL )
        {
            char *pszEffectName = NULL;

            switch( GetTFPlayerOwner()->GetTeamNumber() )
            {
            case TF_TEAM_BLUE:
                pszEffectName = "medicgun_invulnstatus_fullcharge_blue";
                break;
            case TF_TEAM_RED:
                pszEffectName = "medicgun_invulnstatus_fullcharge_red";
                break;
            case TF_TEAM_GREEN:
                pszEffectName = "medicgun_invulnstatus_fullcharge_green";
                break;
            case TF_TEAM_YELLOW:
                pszEffectName = "medicgun_invulnstatus_fullcharge_yellow";
                break;
            default:
                pszEffectName = "";
                break;
            }

            m_pChargeEffect = pEffectOwner->ParticleProp()->Create( pszEffectName, PATTACH_POINT_FOLLOW, "muzzle" );
        }

        if ( m_pChargedSound == NULL )
        {
            CLocalPlayerFilter filter;

            CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();

            m_pChargedSound = controller.SoundCreate( filter, entindex(), "WeaponMedigun.Charged" );
            controller.Play( m_pChargedSound, 1.0, 100 );
        }
    }
    else
    {
        if ( m_pChargeEffect != NULL )
        {
            pEffectOwner->ParticleProp()->StopEmission( m_pChargeEffect );
            m_pChargeEffect = NULL;
        }

        if ( m_pChargedSound != NULL )
        {
            CSoundEnvelopeController::GetController().SoundDestroy( m_pChargedSound );
            m_pChargedSound = NULL;
        }
    }
}
开发者ID:Navton,项目名称:TF2Classic,代码行数:78,代码来源:tf_weapon_medigun.cpp

示例11: clamp

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : int - 
//-----------------------------------------------------------------------------
int	C_GunshipFX::DrawModel( int )
{
    static color32 white = {255,255,255,255};
    Vector params[GUNSHIPFX_PARAMETERS];
    bool hasParam[GUNSHIPFX_PARAMETERS];

    if ( !m_active )
        return 1;

    C_BaseEntity *ent = cl_entitylist->GetEnt( m_entityIndex );
    if ( ent )
    {
        QAngle angles;
        ent->GetAttachment( m_attachment, m_worldPosition, angles );
    }

    Vector test;
    m_t += gpGlobals->frametime;
    if ( m_tMax > 0 )
    {
        m_t = clamp( m_t, 0, m_tMax );
        m_beamEndPosition = m_worldPosition;
    }
    float t = m_t;

    bool hasAny = false;
    memset( hasParam, 0, sizeof(hasParam) );
    for ( int i = 0; i < GUNSHIPFX_PARAMETERS; i++ )
    {
        hasParam[i] = g_GunshipCannonEnvelope.m_parameters[i].Interp( params[i], t );
        hasAny = hasAny || hasParam[i];
    }

    // draw the narrow beam
    if ( hasParam[GUNSHIPFX_NARROW_BEAM_COLOR] && hasParam[GUNSHIPFX_NARROW_BEAM_SIZE] )
    {
        IMaterial *pMat = materials->FindMaterial( "sprites/bluelaser1", TEXTURE_GROUP_CLIENT_EFFECTS );
        float width = NARROW_BEAM_WIDTH * params[GUNSHIPFX_NARROW_BEAM_SIZE].x;
        color32 color;
        float bright = params[GUNSHIPFX_NARROW_BEAM_COLOR].x;
        ScaleColor( color, white, bright );

        //Gunship_DrawLine( m_beamEndPosition, m_targetPosition, width, pMat, color );
        FX_DrawLine( m_beamEndPosition, m_targetPosition, width, pMat, color );
    }

    // glowy blue flare sprite
    if ( hasParam[GUNSHIPFX_FLARE_COLOR] && hasParam[GUNSHIPFX_FLARE_SIZE] )
    {
        IMaterial *pMat = materials->FindMaterial( "effects/blueblackflash", TEXTURE_GROUP_CLIENT_EFFECTS );
        float size = FLARE_SIZE * params[GUNSHIPFX_FLARE_SIZE].x;
        color32 color;
        float bright = params[GUNSHIPFX_FLARE_COLOR].x;
        ScaleColor( color, white, bright );
        color.a = (int)(255 * params[GUNSHIPFX_DARKNESS].x);
        materials->Bind( pMat, (IClientRenderable*)this );
        Gunship_DrawSprite( m_worldPosition, size, color, true );
    }

    if ( hasParam[GUNSHIPFX_AFTERGLOW_COLOR] )
    {
        // Muzzle effect
        dlight_t *dl = effects->CL_AllocDlight( m_entityIndex );
        dl->origin = m_worldPosition;
        dl->color.r = 40*params[GUNSHIPFX_AFTERGLOW_COLOR].x;
        dl->color.g = 60*params[GUNSHIPFX_AFTERGLOW_COLOR].x;
        dl->color.b = 255*params[GUNSHIPFX_AFTERGLOW_COLOR].x;
        dl->color.exponent = 5;
        dl->radius = 128.0f;
        dl->die = gpGlobals->curtime + 0.001;
    }

    if ( m_t >= 4.0 && !hasAny )
    {
        EffectShutdown();
    }

    return 1;
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:83,代码来源:c_npc_combinegunship.cpp

示例12: ToBasePlayer

//-----------------------------------------------------------------------------
// Purpose: First-person function call after viewmodel has been drawn
//-----------------------------------------------------------------------------
void CWeaponGravityGun::ViewModelDrawn( C_BaseViewModel *pBaseViewModel )
{
    if ( !m_active )
        return;

    // Render our effects
    C_BasePlayer *pOwner = ToBasePlayer( GetOwner() );

    if ( !pOwner )
        return;

    Vector points[3];
    QAngle tmpAngle;

    C_BaseEntity *pObject = m_hObject;
    //if ( pObject == NULL )
    //	return;

    pBaseViewModel->GetAttachment( 1, points[0], tmpAngle );

    // a little noise 11t & 13t should be somewhat non-periodic looking
    //points[1].z += 4*sin( gpGlobals->curtime*11 ) + 5*cos( gpGlobals->curtime*13 );
    if ( pObject == NULL )
    {
        //points[2] = m_targetPosition;
        trace_t tr;
        TraceLine( &tr );
        points[2] = tr.endpos;
    }
    else
    {
        pObject->EntityToWorldSpace(m_worldPosition, &points[2]);
    }

    Vector forward, right, up;
    QAngle playerAngles = pOwner->EyeAngles();
    AngleVectors( playerAngles, &forward, &right, &up );
    Vector vecSrc = pOwner->Weapon_ShootPosition( );
    points[1] = vecSrc + 0.5f * (forward * points[2].DistTo(points[0]));
    
    IMaterial *pMat = materials->FindMaterial( "sprites/physbeam1", TEXTURE_GROUP_CLIENT_EFFECTS );
    if ( pObject )
        pMat = materials->FindMaterial( "sprites/physbeam", TEXTURE_GROUP_CLIENT_EFFECTS );
    Vector color;
    color.Init(1,1,1);

    // Now draw it.
    CViewSetup beamView = *view->GetPlayerViewSetup();

    Frustum dummyFrustum;
    render->Push3DView( beamView, 0, NULL, dummyFrustum );

    float scrollOffset = gpGlobals->curtime - (int)gpGlobals->curtime;
    CMatRenderContextPtr pRenderContext( materials );
    pRenderContext->Bind( pMat );
#if 1
    // HACK HACK:  Munge the depth range to prevent view model from poking into walls, etc.
    // Force clipped down range
    pRenderContext->DepthRange( 0.1f, 0.2f );
#endif
    DrawBeamQuadratic( points[0], points[1], points[2], pObject ? 13/3.0f : 13/5.0f, color, scrollOffset );
    DrawBeamQuadratic( points[0], points[1], points[2], pObject ? 13/3.0f : 13/5.0f, color, -scrollOffset );

    IMaterial *pMaterial = materials->FindMaterial( "sprites/physglow", TEXTURE_GROUP_CLIENT_EFFECTS );

    color32 clr={0,64,255,255};
    if ( pObject )
    {
        clr.r = 186;
        clr.g = 253;
        clr.b = 247;
        clr.a = 255;
    }

    float scale = random->RandomFloat( 3, 5 ) * ( pObject ? 3 : 2 );

    // Draw the sprite
    pRenderContext->Bind( pMaterial );
    for ( int i = 0; i < 3; i++ )
    {
        DrawSprite( points[2], scale, scale, clr );
    }
#if 1
    pRenderContext->DepthRange( 0.0f, 1.0f );
#endif

    render->PopView( dummyFrustum );

    // Pass this back up
    BaseClass::ViewModelDrawn( pBaseViewModel );
}
开发者ID:SCell555,项目名称:source-sdk-2013,代码行数:94,代码来源:weapon_physgun.cpp

示例13: FX_ThumperDust

void FX_ThumperDust( const CEffectData &data )
{
    Vector vecDustColor;
    vecDustColor.x = 0.85f;
    vecDustColor.y = 0.75f;
    vecDustColor.z = 0.52f;

    CSmartPtr<ThumperDustEmitter> pSimple = ThumperDustEmitter::Create( "thumperdust" );

    C_BaseEntity *pEnt = C_BaseEntity::Instance( data.m_hEntity );
    if ( pEnt )
    {
        Vector vWorldMins, vWorldMaxs;
        float scale = pEnt->CollisionProp()->BoundingRadius();
        vWorldMins[0] = data.m_vOrigin[0] - scale;
        vWorldMins[1] = data.m_vOrigin[1] - scale;
        vWorldMins[2] = data.m_vOrigin[2] - scale;
        vWorldMaxs[0] = data.m_vOrigin[0] + scale;
        vWorldMaxs[1] = data.m_vOrigin[1] + scale;
        vWorldMaxs[2] = data.m_vOrigin[2] + scale;
        pSimple->GetBinding().SetBBox( vWorldMins, vWorldMaxs, true );
    }

    pSimple->SetSortOrigin( data.m_vOrigin );
    pSimple->SetNearClip( 32, 64 );

    SimpleParticle	*pParticle = NULL;

    Vector	offset;

    //int	numPuffs = IsXbox() ? THUMPER_MAX_PARTICLES/2 : THUMPER_MAX_PARTICLES;
    int	numPuffs = THUMPER_MAX_PARTICLES;

    float flYaw = 0;
    float flIncr = (2*M_PI) / (float) numPuffs; // Radians
    Vector forward;
    Vector vecColor;
    int i = 0;

    float flScale = min( data.m_flScale, 255 );

    // Setup the color for these particles
    engine->ComputeLighting( data.m_vOrigin, NULL, true, vecColor );
    VectorLerp( vecColor, vecDustColor, 0.5, vecColor );
    vecColor *= 255;

    for ( i = 0; i < numPuffs; i++ )
    {
        flYaw += flIncr;
        SinCos( flYaw, &forward.y, &forward.x );	
        forward.z = 0.0f;

        offset = ( RandomVector( -4.0f, 4.0f ) + data.m_vOrigin ) + ( forward * 128.0f );

        pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof(SimpleParticle), g_Mat_DustPuff[random->RandomInt(0,1)], offset );
        if ( pParticle != NULL )
        {	
            pParticle->m_flLifetime		= 0.0f;
            pParticle->m_flDieTime		= 1.5f;
    
            Vector dir = (offset - data.m_vOrigin);
            float length = dir.Length();
            VectorNormalize( dir );

            pParticle->m_vecVelocity	= dir * ( length * 2.0f );
            pParticle->m_vecVelocity[2]	= data.m_flScale / 3;

            pParticle->m_uchColor[0]	= vecColor[0];
            pParticle->m_uchColor[1]	= vecColor[1];
            pParticle->m_uchColor[2]	= vecColor[2];

            pParticle->m_uchStartAlpha	= random->RandomInt( 64, 96 );
            pParticle->m_uchEndAlpha	= 0;

            pParticle->m_uchStartSize	= flScale * 0.25f;
            pParticle->m_uchEndSize		= flScale * 0.5f;

            pParticle->m_flRoll			= random->RandomInt( 0, 360 );
            pParticle->m_flRollDelta	= random->RandomFloat( -6.0f, 6.0f );
        }
    }
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:82,代码来源:c_thumper_dust.cpp

示例14: IsViewModelOrAttachment

bool CClientTools::IsViewModelOrAttachment( EntitySearchResult currentEnt )
{
    C_BaseEntity *ent = reinterpret_cast< C_BaseEntity* >( currentEnt );
    C_BaseAnimating *pBaseAnimating = ent ? ent->GetBaseAnimating() : NULL;
    return pBaseAnimating ? pBaseAnimating->IsViewModelOrAttachment() : false;
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:6,代码来源:entity_client_tools.cpp

示例15: TFExplosionCallback

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void TFExplosionCallback( const Vector &vecOrigin, const Vector &vecNormal, int iWeaponID, ClientEntityHandle_t hEntity, C_TFPlayer *pPlayer, int iTeam, bool bCrit, int iItemID )
{
    // Get the weapon information.
    CTFWeaponInfo *pWeaponInfo = NULL;
    switch ( iWeaponID )
    {
    case TF_WEAPON_GRENADE_PIPEBOMB:
    case TF_WEAPON_GRENADE_DEMOMAN:
        pWeaponInfo = GetTFWeaponInfo( TF_WEAPON_PIPEBOMBLAUNCHER );
        break;
    default:
        pWeaponInfo = GetTFWeaponInfo( iWeaponID );
        break;
    }

    bool bIsPlayer = false;
    if ( hEntity.Get() )
    {
        C_BaseEntity *pEntity = C_BaseEntity::Instance( hEntity );
        if ( pEntity && pEntity->IsPlayer() )
        {
            bIsPlayer = true;
        }
    }

    // Calculate the angles, given the normal.
    bool bIsWater = ( UTIL_PointContents( vecOrigin ) & CONTENTS_WATER );
    bool bInAir = false;
    QAngle angExplosion( 0.0f, 0.0f, 0.0f );

    // Cannot use zeros here because we are sending the normal at a smaller bit size.
    if ( fabs( vecNormal.x ) < 0.05f && fabs( vecNormal.y ) < 0.05f && fabs( vecNormal.z ) < 0.05f )
    {
        bInAir = true;
        angExplosion.Init();
    }
    else
    {
        VectorAngles( vecNormal, angExplosion );
        bInAir = false;
    }

    bool bDeathmatchOverride = ( pPlayer && TFGameRules()->IsDeathmatch() );

    // Base explosion effect and sound.
    const char *pszEffect = "explosion";
    const char *pszSound = "BaseExplosionEffect.Sound";

    if ( pWeaponInfo )
    {
        // Explosions.
        if ( bIsWater )
        {
            if ( bCrit && pWeaponInfo->m_szExplosionWaterEffect_Crit[0] )
            {
                pszEffect = ConstructTeamParticle( pWeaponInfo->m_szExplosionWaterEffect_Crit, iTeam, bDeathmatchOverride );
            }
            else if ( pWeaponInfo->m_szExplosionWaterEffect[0] )
            {
                pszEffect = pWeaponInfo->m_szExplosionWaterEffect;
            }
        }
        else
        {
            if ( bIsPlayer || bInAir )
            {
                if ( bCrit && pWeaponInfo->m_szExplosionPlayerEffect_Crit[0] )
                {
                    pszEffect = ConstructTeamParticle( pWeaponInfo->m_szExplosionPlayerEffect_Crit, iTeam, bDeathmatchOverride );
                }
                else if ( pWeaponInfo->m_szExplosionPlayerEffect[0] )
                {
                    pszEffect = pWeaponInfo->m_szExplosionPlayerEffect;
                }
            }
            else
            {
                if ( bCrit && pWeaponInfo->m_szExplosionEffect_Crit[0] )
                {
                    pszEffect = ConstructTeamParticle( pWeaponInfo->m_szExplosionEffect_Crit, iTeam, bDeathmatchOverride );
                }
                else if ( pWeaponInfo->m_szExplosionEffect[0] )
                {
                    pszEffect = pWeaponInfo->m_szExplosionEffect;
                }
            }
        }

        // Sound.
        if ( pWeaponInfo->m_szExplosionSound[0] != '\0' )
        {
            pszSound = pWeaponInfo->m_szExplosionSound;
        }
    }

    // Allow schema to override explosion sound.
    if ( iItemID >= 0 )
//.........这里部分代码省略.........
开发者ID:Deathreus,项目名称:TF2Classic,代码行数:101,代码来源:tf_fx_explosions.cpp


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