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(); }
//------------------------------------------------------------------------ void CWeaponSystem::RefGun(IConsoleCmdArgs *args) { IGameFramework *pGF = gEnv->pGame->GetIGameFramework(); IItemSystem *pItemSystem = pGF->GetIItemSystem(); IActor *pActor = pGF->GetClientActor(); if(!pActor || !pActor->IsPlayer()) return; IInventory *pInventory = pActor->GetInventory(); if(!pInventory) return; // give & select the refgun EntityId itemId = pInventory->GetItemByClass(CItem::sRefWeaponClass); if(0 == itemId) { // if actor doesn't have it, only give it in editor if(!gEnv->IsEditor()) return; itemId = pItemSystem->GiveItem(pActor, CItem::sRefWeaponClass->GetName(), false, true, true); } pItemSystem->SetActorItem(pActor, itemId, true); }
//------------------------------------------------------------------------ IEntity * CEditorGame::GetPlayer() { IGameFramework * pGameFramework = m_pGame->GetIGameFramework(); if(!m_pGame) return 0; IActor * pActor = pGameFramework->GetClientActor(); return pActor? pActor->GetEntity() : NULL; }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate) { IGameFramework* pGF = gEnv->pGame->GetIGameFramework(); IActor * pActor = pGF->GetClientActor(); if (!pActor) return; const bool bHolster = IsPortActive(pActInfo, 0); pActor->HolsterItem(bHolster); ActivateOutput(pActInfo, 0, true); } }
//-------------------------------------------------------------------------------------------------- // Name: IsEntity3rdPerson // Desc: Returns 3rd person state //-------------------------------------------------------------------------------------------------- bool CGameEffect::IsEntity3rdPerson(EntityId entityId) { bool bIs3rdPerson = true; IGame* pGame = gEnv->pGame; if(pGame) { IGameFramework* pGameFramework = pGame->GetIGameFramework(); if(pGameFramework) { EntityId clientEntityId = pGameFramework->GetClientActorId(); if(clientEntityId == entityId) { bIs3rdPerson = pGameFramework->GetClientActor()->IsThirdPerson(); } } } return bIs3rdPerson; }//-------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------- 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; }
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); }