Beispiel #1
0
	void CreateView()
	{
		if (gEnv->pGame == NULL)
			return;

		IGameFramework* pGF = gEnv->pGame->GetIGameFramework();

		if (pGF == NULL)
			return;

		m_pViewSystem = pGF->GetIViewSystem();

		if (m_pViewSystem == NULL)
			return;
		//if the game has a clientactor, cache the view
		if (pGF->GetClientActor())
		{
			m_pLocalPlayerView = m_pViewSystem->GetViewByEntityId(pGF->GetClientActor()->GetEntityId());
		}



		if (m_pLocalPlayerView && (m_pViewSystem->GetActiveView() != m_pLocalPlayerView))
			m_pViewSystem->SetActiveView(m_pLocalPlayerView);

		if (m_pView == NULL)
			m_pView = m_pViewSystem->CreateView();
	}
Beispiel #2
0
	//----------------------------------------------------------------------
	IView* GetView( SActivationInfo* pActInfo )
	{
		SInputParams inputParams;
		ReadCurrentInputParams( pActInfo, inputParams );
		IGameFramework* pGF         = gEnv->pGame->GetIGameFramework();
		IView*          pView       = 0;
		IView*          pActiveView = pGF->GetIViewSystem()->GetActiveView();
		eViewType       viewType    = inputParams.view;
		if (viewType == VT_FirstPerson) // use player's view
		{
			IActor* pActor = pGF->GetClientActor();
			if (pActor == 0)
				return NULL;

			eRestriction restriction = inputParams.restriction;
			if (restriction != ER_None)
			{
				IVehicle* pVehicle = pActor->GetLinkedVehicle();
				if (restriction == ER_InVehicle && pVehicle == 0)
					return NULL;
				if (restriction == ER_NoVehicle && pVehicle != 0 /* && pVehicle->GetSeatForPassenger(entityId) != 0 */)
					return NULL;
			}

			EntityId entityId = pActor->GetEntityId();
			pView = pGF->GetIViewSystem()->GetViewByEntityId(entityId);
		}
		else                            // active view
		{
			pView = pActiveView;
		}
		if (pView != pActiveView)
			return NULL;

		return pView;
	}
Beispiel #3
0
	virtual void ProcessEvent( EFlowEvent event,SActivationInfo* pActInfo )
	{
		if (event != eFE_Activate)
			return;

		if (!InputEntityIsLocalPlayer( pActInfo ))
			return;

		const bool bTriggered     = IsPortActive(pActInfo, EIP_Trigger);
		const bool bFreqTriggered = IsPortActive(pActInfo, EIP_Frequency);
		if (bTriggered == false && bFreqTriggered == false)
			return;

		IGameFramework* pGF         = gEnv->pGame->GetIGameFramework();
		IView*          pView       = 0;
		IView*          pActiveView = pGF->GetIViewSystem()->GetActiveView();
		int             viewType    = GetPortInt(pActInfo, EIP_ViewType);
		if (viewType == VT_FirstPerson)                                // use player's view
		{
			IActor* pActor = pGF->GetClientActor();
			if (pActor == 0)
				return;

			const int restriction = GetPortInt(pActInfo, EIP_Restriction);
			if (restriction != ER_None)
			{
				IVehicle* pVehicle = pActor->GetLinkedVehicle();
				if (restriction == ER_InVehicle && pVehicle == 0)
					return;
				if (restriction == ER_NoVehicle && pVehicle != 0 /* && pVehicle->GetSeatForPassenger(entityId) != 0 */)
					return;
			}

			EntityId entityId = pActor->GetEntityId();
			pView = pGF->GetIViewSystem()->GetViewByEntityId(entityId);
		}
		else                                                           // active view
		{
			pView = pActiveView;
		}
		if (pView == 0 || pView != pActiveView)
			return;

		const bool  bGroundOnly = GetPortBool(pActInfo, EIP_GroundOnly);
		Ang3        angles      = Ang3(DEG2RAD(GetPortVec3(pActInfo, EIP_Angle)));
		Vec3        shift       = GetPortVec3(pActInfo, EIP_Shift);
		const float duration    = GetPortFloat(pActInfo, EIP_Duration);
		float       freq        = GetPortFloat(pActInfo, EIP_Frequency);
		if (iszero(freq) == false)
			freq = 1.0f / freq;
		const float       randomness  = GetPortFloat(pActInfo, EIP_Randomness);
		static const bool bFlip       = true;                          // GetPortBool(pActInfo, EIP_Flip);
		const bool        bUpdateOnly = !bTriggered && bFreqTriggered; // it's an update if and only if Frequency has been changed

		const float distance = GetPortFloat(pActInfo, EIP_Distance);
		const float rangeMin = GetPortFloat(pActInfo, EIP_RangeMin);
		const float rangeMax = GetPortFloat(pActInfo, EIP_RangeMax);
		float       amount   = min(1.f, max(0.f, (rangeMax - distance) / (rangeMax - rangeMin)));

		angles *= amount;
		shift  *= amount;

		pView->SetViewShake(angles, shift, duration, freq, randomness, FLOWGRAPH_SHAKE_ID, bFlip, bUpdateOnly, bGroundOnly);
	}