コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayer_Control::ControlActivate( void )
{
	m_bActive			= true;
	AddEffects( EF_NODRAW );
	m_nPClipTraceDir	= PC_TRACE_LAST;
	m_flCurrMinClipDist = PCONTROL_CLIP_DIST;

	SetNextThink( gpGlobals->curtime );

	CHL2_Player*	pPlayer		= (CHL2_Player*)UTIL_GetLocalPlayer();

	Assert( pPlayer );

	// Save Data
	m_nSaveFOV			= pPlayer->GetFOV();
	m_vSaveOrigin		= pPlayer->GetLocalOrigin();
	m_vSaveAngles		= pPlayer->pl.v_angle.Get();				//TGB: 0000069 spectator first person fix (not really necessary but tidier)
	m_nSaveMoveType		= pPlayer->GetMoveType();
	m_nSaveMoveCollide	= pPlayer->GetMoveCollide();
	m_vSaveViewOffset	= pPlayer->GetViewOffset();
	m_pSaveWeapon		= pPlayer->GetActiveWeapon();

	pPlayer->AddSolidFlags( FSOLID_NOT_SOLID );
	pPlayer->SetLocalOrigin( GetLocalOrigin() );
	pPlayer->pl.v_angle.GetForModify()	= GetLocalAngles();			//TGB: 0000069 spectator first person fix (see above)
	pPlayer->SetViewOffset( vec3_origin );

	DispatchUpdateTransmitState();
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPointDevShotCamera::DevShotThink_Setup( void )
{
	// Move the player to the devshot camera
	CBasePlayer *pPlayer = UTIL_GetLocalPlayerOrListenServerHost();
	if ( !pPlayer )
		return;

	// Hide stuff
	engine->ClientCommand( pPlayer->edict(), "developer 0" );
	engine->ClientCommand( pPlayer->edict(), "cl_drawhud 0" );
	engine->ClientCommand( pPlayer->edict(), "sv_cheats 1" );
	engine->ClientCommand( pPlayer->edict(), "god" );
	engine->ClientCommand( pPlayer->edict(), "notarget" );

	pPlayer->AddSolidFlags( FSOLID_NOT_SOLID );
	pPlayer->EnableControl(FALSE);
	pPlayer->SetViewEntity( this );
	pPlayer->SetFOV( this, m_iFOV );

	// Hide the player's viewmodel
	if ( pPlayer->GetActiveWeapon() )
	{
		pPlayer->GetActiveWeapon()->AddEffects( EF_NODRAW );
	}

	DispatchUpdateTransmitState();

	// Now take the shot next frame
	SetThink( &CPointDevShotCamera::DevShotThink_TakeShot );
	SetNextThink( gpGlobals->curtime );
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CASW_Broadcast_Camera::Disable( void )
{
	RestoreAllPlayerViews();
	//if ( m_hPlayer && m_hPlayer->IsAlive() )
	//{
		//if ( HasSpawnFlags( SF_CAMERA_PLAYER_NOT_SOLID ) )
		//{
			//m_hPlayer->RemoveSolidFlags( FSOLID_NOT_SOLID );
		//}

		//((CBasePlayer*)m_hPlayer.Get())->SetViewEntity( m_hPlayer );
		//((CBasePlayer*)m_hPlayer.Get())->EnableControl(TRUE);

		// Restore the player's viewmodel
		//if ( ((CBasePlayer*)m_hPlayer.Get())->GetActiveWeapon() )
		//{
			//((CBasePlayer*)m_hPlayer.Get())->GetActiveWeapon()->RemoveEffects( EF_NODRAW );
		//}
	//}

	m_state = USE_OFF;
	m_flReturnTime = gpGlobals->curtime;
	SetThink( NULL );

	m_OnEndFollow.FireOutput(this, this); // dvsents2: what is the best name for this output?
	SetLocalAngularVelocity( vec3_angle );

	DispatchUpdateTransmitState();
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayer_Control::ControlDeactivate( void )
{
	m_bActive = false;
	RemoveEffects( EF_NODRAW );

	SetThink(NULL);
	SetTouch(NULL);

	CHL2_Player*	pPlayer  = (CHL2_Player*)UTIL_GetLocalPlayer();

	Assert( pPlayer );
	
	// Restore Data
	pPlayer->SetFOV( this, m_nSaveFOV );
	pPlayer->RemoveSolidFlags( FSOLID_NOT_SOLID );
	pPlayer->SetLocalOrigin( m_vSaveOrigin );
	pPlayer->SetLocalAngles( m_vSaveAngles );	// Note: Set GetLocalAngles(), not pl->v_angle
	pPlayer->SnapEyeAngles( m_vSaveAngles );
	pPlayer->StopFollowingEntity();
	pPlayer->SetMoveType( m_nSaveMoveType, m_nSaveMoveCollide );
	pPlayer->SetViewOffset( m_vSaveViewOffset );
	pPlayer->SetControlClass( CLASS_NONE );

	DispatchUpdateTransmitState();
}
コード例 #5
0
void CPointHoloObjective::InputSetStateActive( inputdata_t &inputdata )
{
	if ( m_iObjectiveState != OBJECTIVESTATE_ACTIVE )
	{
		m_iObjectiveState = OBJECTIVESTATE_ACTIVE;
		m_OnObjectiveActive.FireOutput( inputdata.pActivator, inputdata.pCaller );
		DispatchUpdateTransmitState();
	}
}
コード例 #6
0
void CPointHoloObjective::InputSetStateDisabled( inputdata_t &inputdata )
{
	if ( m_iObjectiveState != OBJECTIVESTATE_DISABLED )
	{
		m_iObjectiveState = OBJECTIVESTATE_DISABLED;
		m_OnObjectiveDisabled.FireOutput( inputdata.pActivator, inputdata.pCaller );
		DispatchUpdateTransmitState();
	}
}
コード例 #7
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bAttached - 
//-----------------------------------------------------------------------------
void CVGuiScreen::SetAttachedToViewModel( bool bAttached )
{
	if (bAttached != IsActive())
	{
		if (!bAttached)
		{
			m_fScreenFlags &= ~VGUI_SCREEN_ATTACHED_TO_VIEWMODEL;
		}
		else
		{
			m_fScreenFlags.Set( m_fScreenFlags | VGUI_SCREEN_ATTACHED_TO_VIEWMODEL );

			// attached screens have different transmit rules
			DispatchUpdateTransmitState();
		}

		// attached screens have different transmit rules
		DispatchUpdateTransmitState();
	}
}
コード例 #8
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPointCamera::SetActive( bool bActive )
{
	// If the mapmaker's told the camera it's off, it enforces inactive state
	if ( !m_bIsOn )
	{
		bActive = false;
	}

	if ( m_bActive != bActive )
	{
		m_bActive = bActive;
		DispatchUpdateTransmitState();
	}
}
コード例 #9
0
ファイル: CDefLight.cpp プロジェクト: InfoSmart/InSource
void CDeferredLight::Activate()
{
	BaseClass::Activate();

	SetSolid( SOLID_NONE );
	AddEffects( EF_NODRAW );

	m_iDefFlags = GetSpawnFlags();

	m_bShouldTransmit = GetParent() != NULL ||
		Q_strlen( GetEntityNameAsCStr() ) > 0;

	SetMoveType( (GetParent() != NULL) ? MOVETYPE_PUSH : MOVETYPE_NONE );

	DispatchUpdateTransmitState();

	const char *pszCookie = STRING( m_str_CookieString );

	if ( m_iDefFlags & DEFLIGHT_COOKIE_ENABLED &&
		pszCookie != NULL && Q_strlen( pszCookie ) > 0 )
		m_iCookieIndex = GetDeferredManager()->AddCookieTexture( pszCookie );
	else
		m_iCookieIndex = 0;

	Assert( m_iCookieIndex >= 0 && m_iCookieIndex < MAX_COOKIE_TEXTURES );

	m_vecColor_Diff.GetForModify() = stringColToVec( STRING( m_str_Diff ) );
	m_vecColor_Ambient.GetForModify() = stringColToVec( STRING( m_str_Ambient ) );

	if ( !m_bShouldTransmit )
	{
		if ( m_iDefFlags & DEFLIGHT_ENABLED &&
			( m_vecColor_Diff.Get().LengthSqr() > 0 || m_vecColor_Ambient.Get().LengthSqr() > 0 ) &&
			m_flSpotConeOuter > 0.01f && m_flRadius > 0 )
		{
			GetDeferredManager()->AddWorldLight( this );
		}
		else
			AssertMsg( 0, "I'm turned off and nobody can turn me on :(" );

		UTIL_Remove( this );
	}
	else
	{
		UpdateSize();
	}
}
コード例 #10
0
void CASW_Broadcast_Camera::Spawn( void )
{
	BaseClass::Spawn();

	SetMoveType( MOVETYPE_NOCLIP );
	SetSolid( SOLID_NONE );								// Remove model & collisions
	SetRenderAlpha( 0 );								// The engine won't draw this model if this is set to 0 and blending is on
	m_nRenderMode = kRenderTransTexture;

	m_state = USE_OFF;
	
	m_initialSpeed = m_flSpeed;

	if ( m_acceleration == 0 )
		m_acceleration = 500;

	if ( m_deceleration == 0 )
		m_deceleration = 500;

	DispatchUpdateTransmitState();
}
コード例 #11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CASW_Broadcast_Camera::Enable( void )
{
	m_state = USE_ON;

	//if ( !m_hPlayer || !m_hPlayer->IsPlayer() )
	//{
		//m_hPlayer = UTIL_GetLocalPlayer();
	//}

	//if ( !m_hPlayer )
	//{
		//DispatchUpdateTransmitState();
		//return;
	//}

	//if ( m_hPlayer->IsPlayer() )
	//{
		 //m_nPlayerButtons = ((CBasePlayer*)m_hPlayer.Get())->m_nButtons;
	//}
	
	//if ( HasSpawnFlags( SF_CAMERA_PLAYER_NOT_SOLID ) )
	//{
		//m_hPlayer->AddSolidFlags( FSOLID_NOT_SOLID );
	//}
	
	m_flReturnTime = gpGlobals->curtime + m_flWait;
	m_flSpeed = m_initialSpeed;
	m_targetSpeed = m_initialSpeed;

	if ( HasSpawnFlags( SF_CAMERA_PLAYER_SNAP_TO ) )
	{
		m_bSnapToGoal = true;
	}

	//if ( HasSpawnFlags(SF_CAMERA_PLAYER_TARGET ) )
	//{
		//m_hTarget = m_hPlayer;
	//}
	//else
	//{
		m_hTarget = GetNextTarget();
	//}

	// If we don't have a target, ignore the attachment / etc
	if ( m_hTarget )
	{
		m_iAttachmentIndex = 0;
		if ( m_iszTargetAttachment != NULL_STRING )
		{
			if ( !m_hTarget->GetBaseAnimating() )
			{
				Warning("%s tried to target an attachment (%s) on target %s, which has no model.\n", GetClassname(), STRING(m_iszTargetAttachment), STRING(m_hTarget->GetEntityName()) );
			}
			else
			{
				m_iAttachmentIndex = m_hTarget->GetBaseAnimating()->LookupAttachment( STRING(m_iszTargetAttachment) );
				if ( !m_iAttachmentIndex )
				{
					Warning("%s could not find attachment %s on target %s.\n", GetClassname(), STRING(m_iszTargetAttachment), STRING(m_hTarget->GetEntityName()) );
				}
			}
		}
	}

	//if (HasSpawnFlags(SF_CAMERA_PLAYER_TAKECONTROL ) )
	//{
		//((CBasePlayer*)m_hPlayer.Get())->EnableControl(FALSE);
	//}

	if ( m_sPath != NULL_STRING )
	{
		m_pPath = gEntList.FindEntityByName( NULL, m_sPath, NULL); //, m_hPlayer );
	}
	else
	{
		m_pPath = NULL;
	}

	m_flStopTime = gpGlobals->curtime;
	if ( m_pPath )
	{
		if ( m_pPath->m_flSpeed != 0 )
			m_targetSpeed = m_pPath->m_flSpeed;
		
		m_flStopTime += m_pPath->GetDelay();
		m_vecMoveDir = m_pPath->GetLocalOrigin() - GetLocalOrigin();
		m_moveDistance = VectorNormalize( m_vecMoveDir );
		m_flStopTime = gpGlobals->curtime + m_pPath->GetDelay();
	}
	else
	{
		m_moveDistance = 0;
	}
	/*
	if ( m_pPath )
	{
		if ( m_pPath->m_flSpeed != 0 )
			m_targetSpeed = m_pPath->m_flSpeed;
		
		Msg("target speed is %f\n", m_targetSpeed);
		m_flStopTime += m_pPath->GetDelay();
	}
	*/

	// copy over player information
	//if (HasSpawnFlags(SF_CAMERA_PLAYER_POSITION ) )
	//{
		//UTIL_SetOrigin( this, m_hPlayer->EyePosition() );
		//SetLocalAngles( QAngle( m_hPlayer->GetLocalAngles().x, m_hPlayer->GetLocalAngles().y, 0 ) );
		//SetAbsVelocity( m_hPlayer->GetAbsVelocity() );
	//}
	//else
	//{
		SetAbsVelocity( vec3_origin );
	//}

	UpdateAllPlayers();
	//((CBasePlayer*)m_hPlayer.Get())->SetViewEntity( this );

	// Hide the player's viewmodel
	//if ( ((CBasePlayer*)m_hPlayer.Get())->GetActiveWeapon() )
	//{
		//((CBasePlayer*)m_hPlayer.Get())->GetActiveWeapon()->AddEffects( EF_NODRAW );
	//}

	// Only track if we have a target
	if ( m_hTarget )
	{
		// follow the player down
		SetThink( &CASW_Broadcast_Camera::FollowTarget );
		SetNextThink( gpGlobals->curtime );
	}

	//m_moveDistance = 0;
	m_vecLastPos = GetAbsOrigin();
	Move();

	DispatchUpdateTransmitState();
}