示例#1
0
void CheckAutoTransparentProps(const Vector &pos, const QAngle &ang)
{
	float opacity = clamp(cl_goal_opacity.GetFloat(), 0.0f, 1.0f);

	for (int i = gpGlobals->maxClients; i <= ClientEntityList().GetHighestEntityIndex(); i++)
	{
		C_BaseEntity *pEnt = ClientEntityList().GetBaseEntity(i);
		if(!dynamic_cast<C_AutoTransparentProp *>(pEnt))
			continue;

		// Check if the camera is behind the goal line and close to the goal. Use an additional offset so the goal post doesn't get in the way.
		if (opacity != 1.0f
			&& (pos.y <= SDKGameRules()->m_vFieldMin.GetY() + cl_goal_opacity_fieldoffset.GetFloat() && pEnt->GetLocalOrigin().y < SDKGameRules()->m_vKickOff.GetY()
				|| pos.y >= SDKGameRules()->m_vFieldMax.GetY() - cl_goal_opacity_fieldoffset.GetFloat() && pEnt->GetLocalOrigin().y > SDKGameRules()->m_vKickOff.GetY())
			&& pos.x >= SDKGameRules()->m_vKickOff.GetX() - 500 && pos.x <= SDKGameRules()->m_vKickOff.GetX() + 500)
		{
			pEnt->SetRenderMode(kRenderTransColor);
			pEnt->SetRenderColorA(opacity * 255);
		}
		else
		{
			pEnt->SetRenderMode(kRenderNormal);
		}
	}
}
C_BaseEntity* C_AllBaseEntityIterator::Next()
{
	if ( m_CurBaseEntity == ClientEntityList().m_BaseEntities.InvalidIndex() )
		return NULL;

	C_BaseEntity *pRet = ClientEntityList().m_BaseEntities[m_CurBaseEntity];
	m_CurBaseEntity = ClientEntityList().m_BaseEntities.Next( m_CurBaseEntity );
	return pRet;
}
示例#3
0
void ResetAutoTransparentProps()
{
	for (int i = gpGlobals->maxClients; i <= ClientEntityList().GetHighestEntityIndex(); i++)
	{
		C_BaseEntity *pEnt = ClientEntityList().GetBaseEntity(i);
		if(!dynamic_cast<C_AutoTransparentProp *>(pEnt))
			continue;

		pEnt->SetRenderMode(kRenderNormal);
	}
}
//-----------------------------------------------------------------------------
// Purpose: Validates existing entities
//-----------------------------------------------------------------------------
void CheckEntities( PyClientClassBase *pCC, boost::python::object pyClass )
{
	int iHighest = ClientEntityList().GetHighestEntityIndex();
	for ( int i=0; i <= iHighest; i++ )
	{
		C_BaseEntity *pEnt = ClientEntityList().GetBaseEntity( i );
		if ( !pEnt || pEnt->GetClientClass() != pCC || pEnt->GetPyInstance().ptr() == Py_None )
			continue;

		pEnt->GetPyInstance().attr("__setattr__")("__class__", pyClass);
	}
}
C_BaseEntity* C_BaseEntityIterator::Next()
{
	// Skip dormant entities
	while ( m_CurBaseEntity != ClientEntityList().m_BaseEntities.InvalidIndex() )
	{
		C_BaseEntity *pRet = ClientEntityList().m_BaseEntities[m_CurBaseEntity];
		m_CurBaseEntity = ClientEntityList().m_BaseEntities.Next( m_CurBaseEntity );

		if (!pRet->IsDormant())
			return pRet;
	}

	return NULL;
}
示例#6
0
void C_HLTVCamera::FixupMovmentParents()
{
	// Find resource zone
	
	for (	ClientEntityHandle_t e = ClientEntityList().FirstHandle();
			e != ClientEntityList().InvalidHandle(); e = ClientEntityList().NextHandle( e ) )
	{
		C_BaseEntity *ent = C_BaseEntity::Instance( e );

		if ( !ent )
			continue;

		ent->HierarchyUpdateMoveParent();
	}
}
void CClientThinkList::PerformThinkFunctions()
{
	float curtime = gpGlobals->curtime;

	unsigned long iNext;
	for ( unsigned long iCur=m_ThinkEntries.Head(); iCur != m_ThinkEntries.InvalidIndex(); iCur = iNext )
	{
		iNext = m_ThinkEntries.Next( iCur );

		CThinkEntry *pEntry = &m_ThinkEntries[iCur];
		
		IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( pEntry->m_hEnt );
		if ( pThink )
		{
			if ( pEntry->m_flNextClientThink == CLIENT_THINK_ALWAYS )
			{
				// NOTE: The Think function here could call SetNextClientThink
				// which would cause it to be removed + readded into the list
				pThink->ClientThink();

				// NOTE: The Think() call can cause other things to be added to the Think
				// list, which could reallocate memory and invalidate the pEntry pointer
				pEntry = &m_ThinkEntries[iCur];
			}
			else if ( pEntry->m_flNextClientThink < curtime )
			{
				pEntry->m_flNextClientThink = curtime;

				// NOTE: The Think function here could call SetNextClientThink
				// which would cause it to be readded into the list
				pThink->ClientThink();

				// NOTE: The Think() call can cause other things to be added to the Think
				// list, which could reallocate memory and invalidate the pEntry pointer
				pEntry = &m_ThinkEntries[iCur];

				// If they haven't changed the think time, then it should be removed.
				if ( pEntry->m_flNextClientThink == curtime )
				{
					RemoveThinkable( pEntry->m_hEnt );
				}
			}

			Assert( pEntry == &m_ThinkEntries[iCur] );

			// Set this after the Think calls in case they look at LastClientThink
			m_ThinkEntries[iCur].m_flLastClientThink = curtime;
		}
		else
		{
			// This should be almost impossible. When ClientEntityHandle_t's are versioned,
			// this should be totally impossible.
			Assert( false );
			m_ThinkEntries.Remove( iCur );
		}
	}

	// Clear out the client-side entity deletion list.
	CleanUpDeleteList();
}
示例#8
0
//------------------------------------------------------------------------------
void C_BeamSpotLight::SpotlightCreate(void)
{
	m_vSpotlightTargetPos = SpotlightCurrentPos();

	{
		//C_Beam *beam = CBeam::BeamCreate( "sprites/spotlight.vmt", m_flSpotlightGoalWidth );
		C_Beam *beam = C_Beam::BeamCreate( "sprites/glow_test02.vmt", m_flSpotlightGoalWidth );
		// Beam only exists client side
		ClientEntityList().AddNonNetworkableEntity( beam );
		m_hSpotlight = beam;
	}

	// Set the temporary spawnflag on the beam so it doesn't save (we'll recreate it on restore)
	m_hSpotlight->SetHDRColorScale( m_flHDRColorScale );
	const color24 c = GetRenderColor();
	m_hSpotlight->SetColor( c.r, c.g, c.b ); 
	m_hSpotlight->SetHaloTexture(m_nHaloIndex);
	m_hSpotlight->SetHaloScale(60);
	m_hSpotlight->SetEndWidth(m_flSpotlightGoalWidth);
	m_hSpotlight->SetBeamFlags( (FBEAM_SHADEOUT|FBEAM_NOTILE) );
	m_hSpotlight->SetBrightness( 64 );
	m_hSpotlight->SetNoise( 0 );

	m_hSpotlight->PointsInit( GetAbsOrigin(), m_vSpotlightTargetPos );
}
void C_BaseNetworkable::Term()
{
	// Detach from the server list.
	if ( m_ClientHandle != ClientEntityList().InvalidHandle() )
	{
		// Remove from the think list.
		ClientThinkList()->RemoveThinkable( m_ClientHandle );

		ClientEntityList().RemoveEntity( GetRefEHandle() );
		
		index = 0xFFFF;
		
		// RemoveEntity should have done this.
		Assert( m_ClientHandle == ClientEntityList().InvalidHandle() );
	}
}
void C_BaseNetworkable::Init( int entnum, int iSerialNum )
{
	Assert( index == 0xFFFF );
	index = entnum;

	m_ClientHandle = ClientEntityList().AddNetworkableEntity( GetIClientUnknown(), entnum, iSerialNum );
}
void CClientThinkList::SetNextClientThink( ClientEntityHandle_t hEnt, float nextTime )
{
	if ( nextTime == CLIENT_THINK_NEVER )
	{
		RemoveThinkable( hEnt );
	}
	else
	{
		IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( hEnt );
		if ( pThink )
		{
			ClientThinkHandle_t hThink = pThink->GetThinkHandle();

			// Add it to the list if it's not already in there.
			if ( hThink == INVALID_THINK_HANDLE )
			{
				hThink = (ClientThinkHandle_t)m_ThinkEntries.AddToTail();
				pThink->SetThinkHandle( hThink );

				GetThinkEntry( hThink )->m_hEnt = hEnt;
			}

			// Set the next think time..
			GetThinkEntry( hThink )->m_flNextClientThink = nextTime;
		}
	}
}
示例#12
0
void C_HLTVCamera::SetPrimaryTarget( int nEntity ) 
{
 	if ( m_iTraget1 == nEntity )
		return;

	m_iTraget1 = nEntity;

	if ( GetMode() == OBS_MODE_ROAMING )
	{
		Vector vOrigin;
		QAngle aAngles;
		float flFov;

		CalcChaseCamView( vOrigin,  aAngles, flFov );
	}
	else if ( GetMode() == OBS_MODE_CHASE )
	{
		C_BaseEntity* target = ClientEntityList().GetEnt( m_iTraget1 );
		if ( target )
		{
			QAngle eyeAngle = target->EyeAngles();
			prediction->SetViewAngles( eyeAngle );
		}
	}

	m_flLastDistance = m_flDistance;
	m_flLastAngleUpdateTime = -1;
}
示例#13
0
//-----------------------------------------------------------------------------
// Performs the think function
//-----------------------------------------------------------------------------
void CClientThinkList::PerformThinkFunction( ThinkEntry_t *pEntry, float flCurtime )
{
	IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( pEntry->m_hEnt );
	if ( !pThink )
	{
		RemoveThinkable( pEntry->m_hEnt );
		return;
	}

	if ( pEntry->m_flNextClientThink == CLIENT_THINK_ALWAYS )
	{
		// NOTE: The Think function here could call SetNextClientThink
		// which would cause it to be removed + readded into the list
		pThink->ClientThink();
	}
	else if ( pEntry->m_flNextClientThink == FLT_MAX )
	{
		// This is an entity that doesn't need to think again; remove it
		RemoveThinkable( pEntry->m_hEnt );
	}
	else
	{
		Assert( pEntry->m_flNextClientThink <= flCurtime );

		// Indicate we're not going to think again
		pEntry->m_flNextClientThink = FLT_MAX;

		// NOTE: The Think function here could call SetNextClientThink
		// which would cause it to be readded into the list
		pThink->ClientThink();
	}

	// Set this after the Think calls in case they look at LastClientThink
	pEntry->m_flLastClientThink = flCurtime;
}
示例#14
0
//-----------------------------------------------------------------------------
// Purpose: Tesla effect
//-----------------------------------------------------------------------------
void FX_BuildTeslaHitbox( const CEffectData &data )
{
	Vector vColor( 1, 1, 1 );

	C_BaseEntity *pEntity = ClientEntityList().GetEnt( data.entindex() );
	C_BaseAnimating *pAnimating = pEntity ? pEntity->GetBaseAnimating() : NULL;
	if (!pAnimating)
		return;

	studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
	if (!pStudioHdr)
		return;

	mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
	if ( !set )
		return;

	matrix3x4_t	*hitboxbones[MAXSTUDIOBONES];
	if ( !pAnimating->HitboxToWorldTransforms( hitboxbones ) )
		return;

	int nBeamCount = (int)(data.m_flMagnitude + 0.5f);
	for ( int i = 0; i < nBeamCount; ++i )
	{
		int nStartHitBox = random->RandomInt( 1, set->numhitboxes );
		int nEndHitBox = random->RandomInt( 1, set->numhitboxes );
		FX_BuildTeslaHitbox( pEntity, nStartHitBox, nEndHitBox, data.m_flScale, vColor, random->RandomFloat( 0.05f, 0.2f ) );
	}
}
示例#15
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientsideProjectileSyringeCallback( const CEffectData &data )
{
	// Get the syringe and add it to the client entity list, so we can attach a particle system to it.
	C_TFPlayer *pPlayer = dynamic_cast<C_TFPlayer*>( ClientEntityList().GetBaseEntityFromHandle( data.m_hEntity ) );
	if ( pPlayer )
	{
		C_LocalTempEntity *pSyringe = ClientsideProjectileCallback( data, SYRINGE_GRAVITY );
		if ( pSyringe )
		{
			switch (pPlayer->GetTeamNumber())
			{
			case TF_TEAM_RED:
				pSyringe->m_nSkin = 0;
				break;
			case TF_TEAM_BLUE:
				pSyringe->m_nSkin = 1;
				break;
			case TF_TEAM_GREEN:
				pSyringe->m_nSkin = 2;
				break;
			case TF_TEAM_YELLOW:
				pSyringe->m_nSkin = 3;
				break;
			}
			bool bCritical = ( ( data.m_nDamageType & DMG_CRITICAL ) != 0 );
			pPlayer->m_Shared.SetParticleToMercColor(
				pSyringe->AddParticleEffect(GetSyringeTrailParticleName(pPlayer->GetTeamNumber(), bCritical))
				);
			pSyringe->AddEffects( EF_NOSHADOW );
			pSyringe->flags |= FTENT_USEFASTCOLLISIONS;
		}
	}
}
	virtual void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore )
	{
		CBaseEntity *pOwnerEntity = pRestore->GetGameSaveRestoreInfo()->GetCurrentEntityContext();

		bool bFoundEntity = true;
		
		if ( IsValidEntityPointer(pOwnerEntity) == false )
		{
			bFoundEntity = false;

#if defined( CLIENT_DLL )
			pOwnerEntity = ClientEntityList().GetBaseEntityFromHandle( pOwnerEntity->GetRefEHandle() );

			if ( pOwnerEntity  )
			{
				bFoundEntity = true;
			}
#endif
		}

		AssertMsg( pOwnerEntity && bFoundEntity == true, "Physics save/load is only suitable for entities" );

		if ( m_type == PIID_UNKNOWN )
		{
			AssertMsg( 0, "Unknown physics save/load type");
			return;
		}
		
		g_PhysSaveRestoreBlockHandler.QueueRestore( pOwnerEntity, fieldInfo.pTypeDesc, (void **)fieldInfo.pField, m_type );
	}
示例#17
0
IterationRetval_t CRagdollEnumerator::EnumElement( IHandleEntity *pHandleEntity )
{
	C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() );
	if ( pEnt == NULL )
		return ITERATION_CONTINUE;

	C_BaseAnimating *pModel = static_cast< C_BaseAnimating * >( pEnt );

	// If the ragdoll was created on this tick, then the forces were already applied on the server
	if ( pModel == NULL || WasRagdollCreatedOnCurrentTick( pEnt ) )
		return ITERATION_CONTINUE;

	IPhysicsObject *pPhysicsObject = pModel->VPhysicsGetObject();
	if ( pPhysicsObject == NULL )
		return ITERATION_CONTINUE;

	trace_t tr;
	enginetrace->ClipRayToEntity( m_rayShot, MASK_SHOT, pModel, &tr );

	if ( tr.fraction < 1.0 )
	{
		pModel->ImpactTrace( &tr, m_iDamageType, NULL );
		m_bHit = true;

		//FIXME: Yes?  No?
		return ITERATION_STOP;
	}

	return ITERATION_CONTINUE;
}
示例#18
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientsideProjectileNailCallback(const CEffectData &data)
{
	C_TFPlayer *pPlayer = dynamic_cast<C_TFPlayer*>(ClientEntityList().GetBaseEntityFromHandle(data.m_hEntity));
	if (pPlayer)
	{
		C_LocalTempEntity *pNail = ClientsideProjectileCallback(data, NAILGUN_NAIL_GRAVITY);
		if (pNail)
		{
			switch (pPlayer->GetTeamNumber())
			{
			case TF_TEAM_RED:
				pNail->m_nSkin = 0;
				break;
			case TF_TEAM_BLUE:
				pNail->m_nSkin = 1;
				break;
			case TF_TEAM_GREEN:
				pNail->m_nSkin = 2;
				break;
			case TF_TEAM_YELLOW:
				pNail->m_nSkin = 3;
				break;
			}
			bool bCritical = ((data.m_nDamageType & DMG_CRITICAL) != 0);
			pPlayer->m_Shared.SetParticleToMercColor(
				pNail->AddParticleEffect(GetNailTrailParticleName(pPlayer->GetTeamNumber(), bCritical))
				);
			pNail->AddEffects(EF_NOSHADOW);
			pNail->flags |= FTENT_USEFASTCOLLISIONS;
		}
	}
}
示例#19
0
void CViewAngleAnimation::Spawn( void )
{
	m_iFlags = 0;
	QAngle angles;
	engine->GetViewAngles( angles );	

	/*
	if ( m_iFlags & VIEWANIM_RELATIVE )
	{
		AddKeyFrame( new CViewAngleKeyFrame( vec3_angle, 0.0, 0 ) );

		// seed this so we can add keyframes and have them calc the delta properly
		m_vecBaseAngles = angles;
	}
	else
	{
		AddKeyFrame( new CViewAngleKeyFrame( angles, 0.0, 0 ) );
	}
	*/

	m_bFinished = true;	// don't run right away

	ClientEntityList().AddNonNetworkableEntity(	this );
	SetNextClientThink( CLIENT_THINK_ALWAYS );
}
示例#20
0
//-----------------------------------------------------------------------------
// Purpose: Make a tracer effect
//-----------------------------------------------------------------------------
void UTIL_Tracer( const Vector &vecStart, const Vector &vecEnd, int iEntIndex, int iAttachment, float flVelocity, bool bWhiz, char *pCustomTracerName )
{
	CEffectData data;
	data.m_vStart = vecStart;
	data.m_vOrigin = vecEnd;
	data.m_hEntity = ClientEntityList().EntIndexToHandle( iEntIndex );
	data.m_flScale = flVelocity;

	// Flags
	if ( bWhiz )
	{
		data.m_fFlags |= TRACER_FLAG_WHIZ;
	}
	if ( iAttachment != TRACER_DONT_USE_ATTACHMENT )
	{
		data.m_fFlags |= TRACER_FLAG_USEATTACHMENT;
		// Stomp the start, since it's not going to be used anyway
		data.m_vStart[0] = iAttachment;
	}

	// Fire it off
	if ( pCustomTracerName )
	{
		DispatchEffect( pCustomTracerName, data );
	}
	else
	{
		DispatchEffect( "Tracer", data );
	}
}
示例#21
0
//-----------------------------------------------------------------------------
// Add entity to frame think list
//-----------------------------------------------------------------------------
void CClientThinkList::AddEntityToFrameThinkList( ThinkEntry_t *pEntry, bool bAlwaysChain, int &nCount, ThinkEntry_t **ppFrameThinkList )
{
	// We may already have processed this owing to hierarchy rules
	if ( pEntry->m_nIterEnum == m_nIterEnum )
		return;

	// If we're not thinking this frame, we don't have to worry about thinking after our parents
	bool bThinkThisInterval = ( pEntry->m_flNextClientThink == CLIENT_THINK_ALWAYS ) ||
								( pEntry->m_flNextClientThink <= gpGlobals->curtime );

	// This logic makes it so that if a child thinks,
	// *all* hierarchical parents + grandparents will think first, even if some
	// of the parents don't need to think this frame
	if ( !bThinkThisInterval && !bAlwaysChain )
		return;

	// Respect hierarchy
	C_BaseEntity *pEntity = ClientEntityList().GetBaseEntityFromHandle( pEntry->m_hEnt );
	if ( pEntity )
	{
		C_BaseEntity *pParent = pEntity->GetMoveParent();
		if ( pParent && (pParent->GetThinkHandle() != INVALID_THINK_HANDLE) )
		{
			ThinkEntry_t *pParentEntry = GetThinkEntry( pParent->GetThinkHandle() );
			AddEntityToFrameThinkList( pParentEntry, true, nCount, ppFrameThinkList );
		}
	}

	if ( !bThinkThisInterval )
		return;

	// Add the entry into the list
	pEntry->m_nIterEnum = m_nIterEnum;
	ppFrameThinkList[nCount++] = pEntry;
}
示例#22
0
void C_ASW_Door::ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName )
{
	Assert( pTrace->m_pEnt );

	CBaseEntity *pEntity = pTrace->m_pEnt;
 
	// Build the impact data
	CEffectData data;
	data.m_vOrigin = pTrace->endpos;
	data.m_vStart = pTrace->startpos;
	data.m_nSurfaceProp = pTrace->surface.surfaceProps;	
	if (!m_bShootable)
		data.m_nSurfaceProp = physprops->GetSurfaceIndex("metal");
	data.m_nDamageType = iDamageType;
	data.m_nHitBox = pTrace->hitbox;
#ifdef CLIENT_DLL
	data.m_hEntity = ClientEntityList().EntIndexToHandle( pEntity->entindex() );
#else
	data.m_nEntIndex = pEntity->entindex();
#endif

	// Send it on its way
	if ( !pCustomImpactName )
	{
		DispatchEffect( "Impact", data );
	}
	else
	{
		DispatchEffect( pCustomImpactName, data );
	}
}
// Actual work code
IterationRetval_t CASW_Scanner_Objects_Enumerator::EnumElement( IHandleEntity *pHandleEntity )
{
#ifndef CLIENT_DLL
		CBaseEntity *pEnt = gEntList.GetBaseEntity( pHandleEntity->GetRefEHandle() );
#else
		C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() );
#endif
	
	if ( pEnt == NULL )
		return ITERATION_CONTINUE;

	if (!ValidScannerObject(pEnt))
		return ITERATION_CONTINUE;	

	Vector deltaPos = pEnt->GetAbsOrigin() - m_vecScannerCenter;
	if ( deltaPos.LengthSqr() > m_flRadiusSquared )
		return ITERATION_CONTINUE;

	if ( m_vecScannerCenter.z - pEnt->GetAbsOrigin().z > m_flRadius / 3 )
		return ITERATION_CONTINUE;
	
	CHandle< CBaseEntity > h;
	h = pEnt;
	m_Objects.AddToTail( h );

	return ITERATION_CONTINUE;
}
示例#24
0
//------------------------------------------------------------------------------
// Purpose : Create leak effect if material requests it
// Input   :
// Output  :
//------------------------------------------------------------------------------
void LeakEffect( trace_t &tr )
{
	Vector			diffuseColor, baseColor;
	Vector			vTraceDir	= (tr.endpos - tr.startpos);
	VectorNormalize(vTraceDir);
	Vector			vTraceStart = tr.endpos - 0.1*vTraceDir;
	Vector			vTraceEnd	= tr.endpos + 0.1*vTraceDir;
	IMaterial*		pTraceMaterial = engine->TraceLineMaterialAndLighting( vTraceStart, vTraceEnd, diffuseColor, baseColor );

	if (!pTraceMaterial)
		return;

	bool			found;
	IMaterialVar	*pLeakVar = pTraceMaterial->FindVar( "$leakamount", &found, false );
	if( !found )
		return;

	C_Splash* pLeak = new C_Splash();
	if (!pLeak)
		return;

	ClientEntityList().AddNonNetworkableEntity( pLeak->GetIClientUnknown() );

	IMaterialVar*	pLeakColorVar = pTraceMaterial->FindVar( "$leakcolor", &found );
	if (found)
	{
		Vector color;
		pLeakColorVar->GetVecValue(color.Base(),3);
		pLeak->m_vStartColor = pLeak->m_vEndColor = color;
	}

	IMaterialVar*	pLeakNoiseVar = pTraceMaterial->FindVar( "$leaknoise", &found );
	if (found)
	{
		pLeak->m_flNoise = pLeakNoiseVar->GetFloatValue();
	}

	IMaterialVar*	pLeakForceVar = pTraceMaterial->FindVar( "$leakforce", &found );
	if (found)
	{
		float flForce = pLeakForceVar->GetFloatValue();
		pLeak->m_flSpeed		 = flForce;
		pLeak->m_flSpeedRange	 = pLeak->m_flNoise * flForce;
	}

	pLeak->m_flSpawnRate		= pLeakVar->GetFloatValue();;
	pLeak->m_flParticleLifetime = 10;
	pLeak->m_flWidthMin			= 1;
	pLeak->m_flWidthMax			= 5;
	pLeak->SetLocalOrigin( tr.endpos );
	
	QAngle angles;
	VectorAngles( tr.plane.normal, angles );
	pLeak->SetLocalAngles( angles );

	pLeak->Start(&g_ParticleMgr, NULL);
	pLeak->m_flStopEmitTime	= gpGlobals->curtime+5.0;
	pLeak->SetNextClientThink(gpGlobals->curtime+20.0);
}
C_BaseNetworkable::C_BaseNetworkable()
{
	m_bDormant = true;
	index = 0xFFFF;
	m_ClientHandle = ClientEntityList().InvalidHandle();
	m_hThink = INVALID_THINK_HANDLE;
	m_DataChangeEventRef = -1;
}
//-----------------------------------------------------------------------------
// Purpose: FIXME: what's the right way to do this?
//-----------------------------------------------------------------------------
void C_FireSmoke::StartClientOnly( void )
{
	Start();

	ClientEntityList().AddNonNetworkableEntity(	this );
	m_Partition = partition->CreateHandle( GetIClientUnknown() );
	view->AddVisibleEntity( this );
}
// Actual work code
IterationRetval_t CASW_UsableObjectsEnumerator::EnumElement( IHandleEntity *pHandleEntity )
{
	if ( !m_pLocal )
		return ITERATION_STOP;

#ifndef CLIENT_DLL
		CBaseEntity *pEnt = gEntList.GetBaseEntity( pHandleEntity->GetRefEHandle() );
#else
		C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() );
#endif
	
	if ( pEnt == NULL )
		return ITERATION_CONTINUE;

	if ( pEnt == m_pLocal )
		return ITERATION_CONTINUE;

	C_ASW_Marine *pMarine = m_pLocal->GetViewMarine();
	if (!pMarine)
		return ITERATION_CONTINUE;

#ifdef CLIENT_DLL
	IASW_Client_Usable_Entity *pUsable = dynamic_cast<IASW_Client_Usable_Entity*>(pEnt);
#else
	IASW_Server_Usable_Entity *pUsable = dynamic_cast<IASW_Server_Usable_Entity*>(pEnt);
#endif

	if (!pUsable || !pUsable->IsUsable(pMarine))
		return ITERATION_CONTINUE;	

	if (pUsable->NeedsLOSCheck())
	{
		trace_t tr;
		Vector vecSrc = pMarine->WorldSpaceCenter();
		Vector vecDest = pEnt->WorldSpaceCenter();
		UTIL_TraceLine(vecSrc, vecDest, MASK_SOLID_BRUSHONLY, pMarine, COLLISION_GROUP_NONE, &tr);
		if (tr.fraction < 1.0f && tr.m_pEnt != pEnt)	// didn't hit our target
		{
#ifdef CLIENT_DLL
			if (asw_debug_hud.GetBool())
				debugoverlay->AddLineOverlay(vecSrc, tr.endpos, 255, 0, 0, true, 0.1f);
#endif
			float dist = (vecSrc - vecDest).Length2D();
			if (dist > 30)	// and too far away
				return ITERATION_CONTINUE;
		}
#ifdef CLIENT_DLL
		if (asw_debug_hud.GetBool())
			debugoverlay->AddLineOverlay(vecSrc, tr.endpos, 0, 255, 0, true, 0.1f);
#endif
	}

	CHandle< C_BaseEntity > h;
	h = pEnt;
	m_Objects.AddToTail( h );

	return ITERATION_CONTINUE;
}
示例#28
0
C_BaseEntity* C_Camera::GetTarget()
{
	if ( m_nTarget <= 0 )
		return NULL;

	C_BaseEntity* target = ClientEntityList().GetEnt( m_nTarget );

	return target;
}
//-----------------------------------------------------------------------------
// Purpose: FIXME: what's the right way to do this?
//-----------------------------------------------------------------------------
void C_FireSmoke::StartClientOnly( void )
{
	Start();

	ClientEntityList().AddNonNetworkableEntity(	this );
	CollisionProp()->CreatePartitionHandle();
	AddEffects( EF_NORECEIVESHADOW | EF_NOSHADOW );
	AddToLeafSystem();
}
static bool IsValidEntityPointer( void *ptr )
{
#if !defined( CLIENT_DLL )
	return gEntList.IsEntityPtr( ptr );
#else
	// Walk entities looking for pointer
	int c = ClientEntityList().GetHighestEntityIndex();
	for ( int i = 0; i <= c; i++ )
	{
		CBaseEntity *e = ClientEntityList().GetBaseEntity( i );
		if ( !e )
			continue;

		if ( e == ptr )
			return true;
	}
	return false;
#endif
}