void CSpectator::UpdateCL() { inherited::UpdateCL(); if (GameID() != GAME_SINGLE) { if (Game().local_player && Game().local_player->GameID == ID()) { if (cam_active != eacFreeFly) { if (m_pActorToLookAt && !m_pActorToLookAt->g_Alive()) cam_Set(eacFreeLook); if (!m_pActorToLookAt) { SelectNextPlayerToLook(); if (!m_pActorToLookAt) cam_Set(eacFreeFly); }; } if (Level().CurrentViewEntity() == this) cam_Update(m_pActorToLookAt); return; } }; if (g_pGameLevel->CurrentViewEntity()==this){ if (eacFreeFly!=cam_active){ //------------------------------------- //------------------------------------- int idx = 0; game_PlayerState* P = Game().local_player; if (P&&(P->team>=0)&&(P->team<(int)Level().seniority_holder().teams().size())){ const CTeamHierarchyHolder& T = Level().seniority_holder().team(P->team); for (u32 i=0; i<T.squads().size(); ++i){ const CSquadHierarchyHolder& S = T.squad(i); for (u32 j=0; j<S.groups().size(); ++j){ const CGroupHierarchyHolder& G = S.group(j); for (u32 k=0; k<G.members().size(); ++k){ CActor* A = smart_cast<CActor*>(G.members()[k]); if (A/*&&A->g_Alive()*/){ if(idx==look_idx){ cam_Update (A); return; } ++idx; } } } } } // не найден объект с таким индексом - сбросим на первый объект look_idx = 0; // никого нет за кем смотреть - переключимся на if (0==idx) cam_Set(eacFreeFly); } // по умолчанию eacFreeFly cam_Update (0); } }
void CSpectator::net_Relcase (CObject *O) { if (O != m_pActorToLookAt) return; m_pActorToLookAt = NULL; if (cam_active != eacFreeFly) SelectNextPlayerToLook(); if (!m_pActorToLookAt) cam_Set(eacFreeFly); };
void CSpectator::net_Relcase (CObject *O) { if (O != m_pActorToLookAt) return; if (m_pActorToLookAt != Level().CurrentEntity()) //new spectator was spawned { m_pActorToLookAt = NULL; return; } m_pActorToLookAt = NULL; if (cam_active != eacFreeFly) { SelectNextPlayerToLook(false); if (m_pActorToLookAt == O) //selected to look at player that will be destroyed { m_pActorToLookAt = NULL; } } if (!m_pActorToLookAt) cam_Set(eacFreeFly); };
void CSpectator::IR_OnKeyboardPress(int cmd) { if (Remote()) return; switch(cmd) { case kACCEL: { Accel_mul = START_ACCEL*2; }break; case kCAM_1: { SelectNextPlayerToLook(); if (m_pActorToLookAt) cam_Set (eacFirstEye); else cam_Set (eacFreeFly); }break; case kCAM_2: if (cam_active == eacFreeFly && SelectNextPlayerToLook()) cam_Set (eacLookAt); break; case kCAM_3: if (cam_active == eacFreeFly && SelectNextPlayerToLook()) cam_Set (eacFreeLook); break; case kCAM_4: cam_Set (eacFreeFly); m_pActorToLookAt = NULL; break; case kWPN_FIRE: { if (cam_active != eacFreeFly) { ++look_idx; SelectNextPlayerToLook(); if (cam_active == eacFirstEye && m_pActorToLookAt) FirstEye_ToPlayer(m_pActorToLookAt); } }break; case kWPN_ZOOM: { game_cl_mp* pMPGame = smart_cast<game_cl_mp*> (&Game()); if (!pMPGame) break; game_PlayerState* PS = Game().local_player; if (!PS || PS->GameID != ID()) break; EActorCameras new_camera = EActorCameras((cam_active+1)%eacMaxCam); if (!PS->testFlag(GAME_PLAYER_FLAG_SPECTATOR)) { while (!pMPGame->Is_Spectator_Camera_Allowed(new_camera) && new_camera != eacFreeFly) { new_camera = EActorCameras((new_camera+1)%eacMaxCam); } }; if (new_camera == eacFreeFly) { cam_Set (eacFreeFly); m_pActorToLookAt = NULL; } else { if (!m_pActorToLookAt) SelectNextPlayerToLook(); if (!m_pActorToLookAt) cam_Set (eacFreeFly); else cam_Set (new_camera); } }break; } }
void CSpectator::UpdateCL() { inherited::UpdateCL(); float fPreviousFrameTime = m_timer.GetElapsed_sec(); m_timer.Start(); m_fTimeDelta = 0.3f * m_fTimeDelta + 0.7f * fPreviousFrameTime; if (m_fTimeDelta > 0.1f) m_fTimeDelta = 0.1f; //maximum 10 fps if (m_fTimeDelta < 0.0f) m_fTimeDelta = EPS_S; if (Device.Paused()) { #ifdef DEBUG dbg_update_cl = 0; #endif if (m_pActorToLookAt) { #ifdef DEBUG m_pActorToLookAt->dbg_update_cl = 0; m_pActorToLookAt->dbg_update_shedule = 0; Game().dbg_update_shedule = 0; #endif Device.dwTimeDelta = 0; m_pActorToLookAt->UpdateCL(); m_pActorToLookAt->shedule_Update (0); Game().shedule_Update (0); #ifdef DEBUG m_pActorToLookAt->dbg_update_cl = 0; m_pActorToLookAt->dbg_update_shedule = 0; Game().dbg_update_shedule = 0; #endif } } if (GameID() != eGameIDSingle) { if (Game().local_player && ( (Game().local_player->GameID == ID()) || Level().IsDemoPlay() ) ) { if (cam_active != eacFreeFly) { if (m_pActorToLookAt && !m_pActorToLookAt->g_Alive()) cam_Set(eacFreeLook); if (!m_pActorToLookAt) { SelectNextPlayerToLook(false); if (m_pActorToLookAt) cam_Set(m_last_camera); }; } if (Level().CurrentViewEntity() == this) { cam_Update(m_pActorToLookAt); } return; } }; if (g_pGameLevel->CurrentViewEntity()==this){ if (eacFreeFly!=cam_active){ //------------------------------------- //------------------------------------- int idx = 0; game_PlayerState* P = Game().local_player; if (P&&(P->team>=0)&&(P->team<(int)Level().seniority_holder().teams().size())){ const CTeamHierarchyHolder& T = Level().seniority_holder().team(P->team); for (u32 i=0; i<T.squads().size(); ++i){ const CSquadHierarchyHolder& S = T.squad(i); for (u32 j=0; j<S.groups().size(); ++j){ const CGroupHierarchyHolder& G = S.group(j); for (u32 k=0; k<G.members().size(); ++k){ CActor* A = smart_cast<CActor*>(G.members()[k]); if (A/*&&A->g_Alive()*/){ if(idx==look_idx){ cam_Update (A); return; } ++idx; } } } } } // не найден объект с таким индексом - сбросим на первый объект look_idx = 0; // никого нет за кем смотреть - переключимся на if (0==idx) cam_Set(eacFreeFly); } // по умолчанию eacFreeFly cam_Update (0); } }