//------------------------------------------------------------------------- bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value) { COffHand * offHandWeapon = NULL; bool isOffHandSelected = false; GetOffHandInfo(this,isOffHandSelected,&offHandWeapon); if (!IsBusy() && !isOffHandSelected) { if (m_fm) m_fm->StopFire(); if(m_zm && m_zm->IsZoomed()) m_zm->StopZoom(); if(m_weaponRaised) RaiseWeapon(false,true); if (m_modifying && !m_transitioning) { StopLayer(g_pItemStrings->modify_layer, eIPAF_Default, false); PlayAction(g_pItemStrings->leave_modify, 0); m_dofSpeed = -1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f); m_dofValue = 1.0f; m_focusValue = -1.0f; GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Leave>::Create(this), false); m_transitioning = true; SAFE_HUD_FUNC(WeaponAccessoriesInterface(false)); m_modifying = false; GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer); } else if (!m_modifying && !m_transitioning) { gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 5.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 20.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.0f); PlayAction(g_pItemStrings->enter_modify, 0, false, eIPAF_Default | eIPAF_RepeatLastFrame); m_dofSpeed = 1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f); m_dofValue = 0.0f; m_transitioning = true; GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Enter>::Create(this), false); m_modifying = true; GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer); } } return true; }
emConfigModel::emConfigModel(emContext & context, const emString & name) : emModel(context,name), Link(*this), AutoSaveTimer(GetScheduler()) { Unsaved=false; AutoSaveDelaySeconds=-1; AddWakeUpSignal(AutoSaveTimer.GetSignal()); }
bool emGUIFramework::AutoTerminatorClass::Cycle() { if (IsSignaled(Screen->GetWindowsSignal())) { if (Screen->GetWindows().GetCount()<=0) { GetScheduler().InitiateTermination(0); } } return false; }
emAlarmClockModel::emAlarmClockModel(emView & view, const emString & name) : emModel(view,name), BeepTimer(GetScheduler()), VisitTimer(GetScheduler()) { View=&view; TimeZonesModel=emTimeZonesModel::Acquire(GetRootContext()); AlarmSecOfDay=0; PreventAlarmSecs=0; AlarmDurationSecs=0; BeepIntervalMillisecs=0; AlarmEnabled=false; AlarmTrigger=false; Alarming=false; AddWakeUpSignal(BeepTimer.GetSignal()); AddWakeUpSignal(VisitTimer.GetSignal()); AddWakeUpSignal(TimeZonesModel->GetTimeSignal()); }
//================================================= void CRocketLauncher::AutoDrop() { if(m_zm && m_zm->IsZoomed()) { GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndZoomOutAction>::Create(EndZoomOutAction(this)), true); } else if(m_fm) { m_firedRockets--; CActor* pOwner = GetOwnerActor(); // no need to auto-drop for AI if(pOwner && !pOwner->IsPlayer()) return; if((GetAmmoCount(m_fm->GetAmmoType()) + GetInventoryAmmoCount(m_fm->GetAmmoType()) <= 0)&&(m_firedRockets<=0)) { PlayAction(g_pItemStrings->deselect); GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndDropAction>::Create(EndDropAction(this)), true); } } }
//------------------------------------------------------------------------- void CAIGrenade::StartFire(const SProjectileLaunchParams &launchParams) { if(!m_fm) return; m_fm->SetProjectileLaunchParams(launchParams); m_fm->StartFire(); m_fm->StopFire(); // Adjust this time value to work with the delay values in the scripts!! (must be a greater delay) // Schedule to revert back to main weapon. GetScheduler()->TimerAction(2500, CSchedulerAction<FinishGrenadeAction>::Create(FinishGrenadeAction(this)), false); }
//-------------------------------------------------------- void CWeapon::OnAnimationEventStartFire(const char* szCustomParameter) { if (!m_animationFiringLocator.IsSet()) { const float fAutoStopTimer = szCustomParameter ? static_cast<float>(atof(szCustomParameter)) : 0.0f; m_animationFiringLocator.Set(); StartFire(); // If the parameter is a negative value the fire is not automatically stopped. This is dangerous, but could be useful // in some cases when we know the anim can't be interrupted before the following OnAnimationEventStopFire if (fAutoStopTimer >= 0.0f) GetScheduler()->TimerAction(fAutoStopTimer, CSchedulerAction<AnimationEventFireAutoStop>::Create(AnimationEventFireAutoStop(*this)), false); } }
void CFists::RaiseWeapon(bool raise, bool faster /*= false*/) { //Only when colliding something while running if(raise && (GetCurrentAnimState()==eFAS_RUNNING || GetCurrentAnimState()==eFAS_JUMPING) && !IsWeaponRaised()) { if((m_fm && m_fm->IsFiring())||(m_melee && m_melee->IsFiring())) return; PlayAction(g_pItemStrings->raise); SetDefaultIdleAnimation( eIGS_FirstPerson,g_pItemStrings->idle_relaxed); SetWeaponRaised(true); //Also give the player some impulse into the opposite direction CActor *pPlayer = GetOwnerActor(); Vec3 pos; if(pPlayer) { IPhysicalEntity* playerPhysics = pPlayer->GetEntity()->GetPhysics(); if(playerPhysics) { IMovementController *pMC = pPlayer->GetMovementController(); if(pMC) { SMovementState state; pMC->GetMovementState(state); pe_action_impulse impulse; impulse.iApplyTime = 1; impulse.impulse = -state.eyeDirection*600.0f; playerPhysics->Action(&impulse); pos = state.eyePosition + state.eyeDirection*0.5f; } } } GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true); //Sound and FX feedback CollisionFeeback(pos,m_currentAnimState); } else if(!raise) SetWeaponRaised(false); }
emMainPanel::emMainPanel( ParentArg parent, const emString & name, double controlTallness ) : emPanel(parent, name), SliderTimer(GetScheduler()) { MainConfig=emMainConfig::Acquire(GetRootContext()); ControlEdgesColor=emTkLook().GetBgColor(); ControlEdgesImage=emGetInsResImage(GetRootContext(),"emMain","ControlEdges.tga"); ControlViewPanel=new emSubViewPanel(this,"control view"); ContentViewPanel=new emSubViewPanel(this,"content view"); Slider=new SliderPanel(*this,"slider"); GetControlView().SetViewFlags( emView::VF_POPUP_ZOOM | emView::VF_ROOT_SAME_TALLNESS | emView::VF_NO_ACTIVE_HIGHLIGHT ); GetControlView().SetBackgroundColor(emTkLook().GetBgColor()); GetContentView().SetViewFlags( emView::VF_ROOT_SAME_TALLNESS ); ControlTallness=controlTallness; UnifiedSliderPos=MainConfig->ControlViewSize; FullscreenOn=false; OldMouseX=0.0; OldMouseY=0.0; ContentViewPanel->ActivateLater(); AddWakeUpSignal(GetControlView().GetEOISignal()); AddWakeUpSignal(SliderTimer.GetSignal()); if (GetWindow()) AddWakeUpSignal(GetWindow()->GetWindowFlagsSignal()); UpdateCoordinates(); UpdateFullscreen(); UpdateSliderHiding(false); }
void PauseMenu::DoRestart() { auto engine = STGEngine::GetInstance(); auto scene = (GameScene*)Game::GetInstance()->GetScene().Get(); scene->STGFadeOut(30); auto scheduler = scene->GetScheduler(); Ptr<FrameTimer> timer = Ptr<FrameTimer>::New(); timer->SetFrame(30); timer->run = [this, scene, engine]() { scene->Restart(); Clear(); Resume(); }; scheduler->AddFrameTimer(timer); EventSystem::GetInstance()->UnRegisterKeyDownListener(this); }
//======================================== void CRocketLauncher::Drop(float impulseScale, bool selectNext, bool byDeath) { CActor* pOwner = GetOwnerActor(); //Don't let the player drop it if it has not been opened if(m_stats.first_selection && pOwner && pOwner->IsPlayer() && pOwner->GetHealth()>0 && !byDeath) return; if(pOwner && !pOwner->IsPlayer()) { //In this case goes to the clip, no the inventory for(TAmmoMap::const_iterator it = m_minDroppedAmmo.begin();it!=m_minDroppedAmmo.end();it++) m_ammo[it->first] = it->second; m_minDroppedAmmo.clear(); } PlayAction(g_pItemStrings->deselect); GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndDropAction>::Create(EndDropAction(this)), true); }
//------------------------------------------------------------------------ void CWeapon::OnStartReload(EntityId shooterId, IEntityClass* pAmmoType) { BROADCAST_WEAPON_EVENT(OnStartReload, (this, shooterId, pAmmoType)); if (CActor *pActor = GetOwnerActor()) { if (IAIObject *pAIObject=pActor->GetEntity()->GetAI()) if (gEnv->pAISystem) gEnv->pAISystem->SendSignal( SIGNALFILTER_SENDER, 1, "OnReload", pAIObject); if(pActor->IsClient()) { if (gEnv->bMultiplayer && pActor->IsCloaked()) { CPersistantStats::GetInstance()->IncrementClientStats(EIPS_CloakedReloads); } if(m_weaponsharedparams->bulletBeltParams.numBullets > 0) { const uint32 refillTime = (uint32)(GetCurrentAnimationTime(eIGS_Owner) * m_weaponsharedparams->bulletBeltParams.beltRefillReloadFraction); GetScheduler()->TimerAction(refillTime, CSchedulerAction<RefillBeltAction>::Create(RefillBeltAction(this)), false); } } } IFireMode *pFireMode = GetFireMode(GetCurrentFireMode()); if (pFireMode) { if(GetInventoryAmmoCount(pAmmoType) < pFireMode->GetClipSize()) { BATTLECHATTER(BC_LowAmmo, shooterId); } else { BATTLECHATTER(BC_Reloading, shooterId); } } }
//----------------------------------------------------------------------- bool CBinocular::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (activationMode == eAAM_OnPress) { if(m_bZoomed == false) { PlayAction(g_pItemStrings->raise); SetWeaponRaised(true); GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true); } else { if(m_zm && m_zm->IsZoomed()) { PlayAction(g_pItemStrings->lower); m_zm->ExitZoom(); } ResetState(); } } return true; }
//------------------------------------------------------------------------- bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (IsZoomed() || IsZoomingInOrOut()) return false; if (CanModify() && ((!IsReloading() && !IsBusy()) || AreAnyItemFlagsSet(eIF_Modifying))) { if (m_fm) m_fm->StopFire(); if (AreAnyItemFlagsSet(eIF_Modifying)) { m_enterModifyAction = 0; PlayAction(GetFragmentIds().leave_modify, 0); s_dofSpeed = fres(-g_pGameCVars->i_weapon_customisation_transition_time); s_dofValue = 1.0f; s_focusValue = -1.0f; GetScheduler()->TimerAction(g_pGameCVars->i_weapon_customisation_transition_time, CSchedulerAction<ScheduleLayer_Leave>::Create(this), false); SetItemFlags( eIF_Transitioning ); ClearItemFlags( eIF_Modifying ); GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer); } else { gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.5f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 1.5f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMinZ", 0.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMinZScale", 0.0f); m_itemLowerMode = eILM_Raised; TagState tagState = TAG_STATE_EMPTY; m_enterModifyAction = new CItemAction(PP_PlayerAction, GetFragmentIds().enter_modify, tagState); PlayFragment(m_enterModifyAction); s_dofSpeed = fres(g_pGameCVars->i_weapon_customisation_transition_time); s_dofValue = 0.0f; SetItemFlags(eIF_Transitioning); GetScheduler()->TimerAction(g_pGameCVars->i_weapon_customisation_transition_time, CSchedulerAction<ScheduleLayer_Enter>::Create(this), false); SetItemFlags(eIF_Modifying); CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor()); if (pPlayer) { SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats()); assert(pStats); pStats->bIgnoreSprinting = true; } GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer); } } return true; }
void CHeavyMountedWeapon::PerformRipOff(CActor* pOwner) { ExitZoom(true); UnlinkMountedGun(); SetUnMountedConfiguration(); // This needs to come after the call to UnlinkMountedGun otherwise killcam doesn't work properly AttachToHand(true); StopFire(); Physicalize(false, false); if (pOwner) { HandleHeavyWeaponPro(*pOwner); float speedOverride = 1.0f; if(pOwner->IsPlayer()) { CPlayer* pOwnerPlayer = static_cast<CPlayer*>(pOwner); speedOverride = pOwnerPlayer->GetModifiableValues().GetValue(kPMV_HeavyWeaponRipOffSpeedOverride); } PlayAction(GetFragmentIds().rip_off, 0, false, eIPAF_Default, speedOverride); m_rippingOff = true; m_stats.dropped = false; DoRipOffPrompt(GetOwnerId(), false); int timeDelay = GetCurrentAnimationTime(eIGS_Owner); timeDelay = (timeDelay > 0) ? timeDelay : 2000; int removeViewLimitDelay = int(timeDelay * 0.65f); GetScheduler()->TimerAction(timeDelay, CSchedulerAction<EndRippingOff>::Create(EndRippingOff(this)), false); GetScheduler()->TimerAction(removeViewLimitDelay, CSchedulerAction<RemoveViewLimitsAction>::Create(RemoveViewLimitsAction(this)), false); if(!pOwner->IsThirdPerson() && !(m_stats.viewmode&eIVM_FirstPerson)) { SetViewMode(eIVM_FirstPerson); } //Lock view in place during rip off SActorParams ¶ms = pOwner->GetActorParams(); Vec3 limitDir(ZERO); bool bUseMovementState = true; if (pOwner->IsClient() && (g_pGame->GetHostMigrationState() != CGame::eHMS_NotMigrating)) { // If this happens during a host migration, our aim direction may not have made it into the movement // controller yet, get it from the saved migration params instead const CGameRules::SHostMigrationClientControlledParams *pHostMigrationParams = g_pGame->GetGameRules()->GetHostMigrationClientParams(); if (pHostMigrationParams) { limitDir = pHostMigrationParams->m_aimDirection; bUseMovementState = false; } } if (bUseMovementState) { IMovementController *pMovementController = pOwner->GetMovementController(); SMovementState state; pMovementController->GetMovementState(state); limitDir = state.aimDirection; } params.viewLimits.SetViewLimit(limitDir, 0.01f, 0.01f, 0.01f, 0.01f, SViewLimitParams::eVLS_Item); pOwner->SetSpeedMultipler(SActorParams::eSMR_Item, 0.0f); if(!gEnv->bMultiplayer) pOwner->LockInteractor(GetEntityId(), false); } TriggerRespawn(); if (pOwner) { if (CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem()) { pRecordingSystem->OnWeaponRippedOff(this); } BATTLECHATTER(BC_Ripoff, GetOwnerId()); if(pOwner->IsClient()) { g_pGame->GetPersistantStats()->IncrementClientStats(EIPS_RipOffMountedWeapon); ClearInputFlag(eWeaponAction_Zoom); } } else { //--- If ripped off without an actor we should finish instantly m_rippingOff = false; m_rippedOff = true; } }
void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft) { // global reset for all instances of the given map MapEntry const *mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry->Instanceable()) return; time_t now = time(NULL); time_t today = (now / DAY) * DAY; if (!warn) { MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); if (!mapDiff || !mapDiff->resetTime) { sLog.outError("InstanceSaveManager::ResetOrWarnAll: not valid difficulty or no reset delay for map %d", mapid); return; } // remove all binds to instances of the given map for(InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end();) { if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty) _ResetSave(itr); else ++itr; } // delete them from the DB, even if not loaded CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("DELETE FROM character_instance USING character_instance LEFT JOIN instance ON character_instance.instance = id WHERE map = '%u'", mapid); CharacterDatabase.PExecute("DELETE FROM group_instance USING group_instance LEFT JOIN instance ON group_instance.instance = id WHERE map = '%u'", mapid); CharacterDatabase.PExecute("DELETE FROM instance WHERE map = '%u'", mapid); CharacterDatabase.CommitTransaction(); // calculate the next reset time time_t next_reset = InstanceResetScheduler::CalculateNextResetTime(mapDiff, now + timeLeft); // update it in the DB CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", (uint64)next_reset, mapid, difficulty); GetScheduler().SetResetTimeFor(mapid,difficulty,(uint64)next_reset); GetScheduler().ScheduleReset(true, next_reset-3600, InstanceResetEvent(RESET_EVENT_INFORM_1, mapid, difficulty, -1)); } // note: this isn't fast but it's meant to be executed very rarely Map const *map = sMapMgr.CreateBaseMap(mapid); // _not_ include difficulty MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps(); MapInstanced::InstancedMaps::iterator mitr; for(mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr) { Map *map2 = mitr->second; if (!map2->IsDungeon()) continue; if (warn) ((InstanceMap*)map2)->SendResetWarnings(timeLeft); else ((InstanceMap*)map2)->Reset(INSTANCE_RESET_GLOBAL); } // TODO: delete creature/gameobject respawn times even if the maps are not loaded }
static Scheduler* ScheduleOnce(SchedulerUpdate Update, float intervalTime) { Scheduler* scheduler = GetScheduler(Update, intervalTime); scheduler->isCancel = true; return scheduler; }
void emX11WindowPort::PostConstruct() { int i,r; if ((GetWindowFlags()&( emWindow::WF_POPUP|emWindow::WF_UNDECORATED|emWindow::WF_FULLSCREEN ))!=0) { XMutex.Lock(); XMapRaised(Disp,Win); XMutex.Unlock(); } else { XMutex.Lock(); XMapWindow(Disp,Win); XMutex.Unlock(); } if (Focused) { if (MakeViewable()) { if ((GetWindowFlags()&emWindow::WF_MODAL)!=0 && Owner) { XMutex.Lock(); XSetInputFocus(Disp,Win,RevertToParent,CurrentTime); XMutex.Unlock(); } else { XMutex.Lock(); XSetInputFocus(Disp,Win,RevertToNone,CurrentTime); XMutex.Unlock(); } } else { Focused=false; SetViewFocused(false); } } if ( (GetWindowFlags()&emWindow::WF_FULLSCREEN)!=0 || ( (GetWindowFlags()&emWindow::WF_POPUP)!=0 && ( !Screen.GrabbingWinPort || (Screen.GrabbingWinPort->GetWindowFlags()&emWindow::WF_FULLSCREEN)==0 ) ) ) { if (MakeViewable()) { for (i=0; ; i++) { XMutex.Lock(); r=XGrabKeyboard( Disp, Win, True, GrabModeSync, GrabModeAsync, CurrentTime ); XMutex.Unlock(); if (r==GrabSuccess) break; if (i>10) emFatalError("XGrabKeyboard failed."); emWarning("XGrabKeyboard failed - trying again..."); emSleepMS(50); } for (i=0; ; i++) { XMutex.Lock(); r=XGrabPointer( Disp, Win, True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask| ButtonMotionMask|EnterWindowMask|LeaveWindowMask, GrabModeSync, GrabModeAsync, (GetWindowFlags()&emWindow::WF_FULLSCREEN)!=0 ? Win : None, None, CurrentTime ); XMutex.Unlock(); if (r==GrabSuccess) break; if (i>10) emFatalError("XGrabPointer failed."); emWarning("XGrabPointer failed - trying again..."); emSleepMS(50); } XMutex.Lock(); XAllowEvents(Disp,SyncPointer,CurrentTime); XMutex.Unlock(); Screen.GrabbingWinPort=this; } } if ((GetWindowFlags()&emWindow::WF_FULLSCREEN)!=0) { FullscreenUpdateTimer=new emTimer(GetScheduler()); AddWakeUpSignal(FullscreenUpdateTimer->GetSignal()); FullscreenUpdateTimer->Start(500,true); } if ((GetWindowFlags()&emWindow::WF_MODAL)!=0) { SetModalState(true); } }
void CItem::ScheduleAttachAccessory(const ItemString &accessoryName, bool attach) { GetScheduler()->ScheduleAction(CSchedulerAction<ScheduleAttachClassItem>::Create(ScheduleAttachClassItem(accessoryName, attach))); }