void GameStateManager::NewState(GameStates state){ if(onStateChange!=0){ (_setting->*this->onStateChange)(CurrentState(), state); } _states.clear(); _states.push_back(state); }
void LocalLinearTrendModule::ObserveDraws( const ScalarStateSpaceModelBase &model) { auto state = CurrentState(model); trend_draws_.row(cursor()) = state.row(0); sigma_level_draws_[cursor()] = sqrt(trend_model_->Sigma()(0, 0)); sigma_slope_draws_[cursor()] = sqrt(trend_model_->Sigma()(1, 1)); }
void UnitStateMgr::DropAction(UnitActionPriority priority) { // Don't remove action with NONE priority - static if (priority < UNIT_ACTION_PRIORITY_IDLE) return; UnitActionStorage::iterator itr = m_actions.find(priority); if (itr != m_actions.end()) { bool bActiveActionChanged = false; ActionInfo* oldInfo = CurrentState(); UnitActionPtr oldAction = oldInfo ? oldInfo->Action() : UnitActionPtr(); // if dropped current active state... if (oldInfo && itr->second.Action() == oldInfo->Action() && !oldInfo->HasFlag(ACTION_STATE_FINALIZED)) bActiveActionChanged = true; // in first - erasing current action, if his active if (itr->second.Action() == m_oldAction) m_oldAction = UnitActionPtr(NULL); // Possible erasing by iterator more fast and logic, but by Key much more safe m_actions.erase(priority); // Finalized not ActionInfo, but real action (saved before), due to ActionInfo wrapper already deleted. if (bActiveActionChanged && oldAction) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "DropAction: %s finalize (direct) action %s", GetOwnerStr().c_str(), oldAction->Name()); oldAction->Finalize(*GetOwner()); } // in this point we delete last link to UnitActionPtr, after this UnitAction be auto-deleted... } }
void UnitStateMgr::Update(uint32 diff) { if (m_needReinit) { m_needReinit = false; InitDefaults(true); } ActionInfo* state = CurrentState(); if (!m_oldAction) m_oldAction = state->Action(); else if (m_oldAction && m_oldAction != state->Action()) { if (ActionInfo* oldAction = GetAction(m_oldAction)) { if (oldAction->HasFlag(ACTION_STATE_ACTIVE) && !oldAction->HasFlag(ACTION_STATE_FINALIZED) && !oldAction->HasFlag(ACTION_STATE_INTERRUPTED)) oldAction->Interrupt(this); } // else do nothing - action be deleted without interrupt/finalize (may be need correct?) m_oldAction = state->Action(); } if (!state->Update(this, diff)) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "UnitStateMgr: %s finished action %s", GetOwnerStr().c_str(), state->TypeName()); DropAction(state->priority); } }
void MapMode::Reset() { _current_instance = this; // Reload the active and inactive status effects if necessary if (!_activated) _status_effect_supervisor.LoadStatusEffects(); _activated = true; // Reset video engine context properties VideoManager->SetStandardCoordSys(); VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0); // Make the map location known globally to other code that may need to know this information GlobalManager->SetMap(_map_data_filename, _map_script_filename, _map_image.GetFilename(), _map_hud_name.GetString()); _ResetMusicState(); // Restart ambient sounds _object_supervisor->RestartSoundObjects(); _intro_timer.Run(); // Reset potential map scripts GetScriptSupervisor().Reset(); // If the sprite is based on the battle formation, we'd better refresh the data now // if the game in in the default mode. // Still, we won't change the sprite in the middle of a scene for instance. // I.e: When going out of the menu mode. if(CurrentState() == private_map::STATE_EXPLORE) _object_supervisor->ReloadVisiblePartyMember(); }
void GameCamera::TerminateMovements() { GameCameraState state = CurrentState(); start_ = state; end_ = state; if (percent_.Valid()) { percent_.SetTarget(motive::Current1f(1.0f)); } movements_ = std::queue<GameCameraMovement>(); }
bool CScriptProxy::GotoState( int nState ) { if (nState == m_nCurrStateId) return true; // Already in this state. SScriptState* pState = m_pScript->GetState( nState ); // Call End state event. m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnEndState ); // If state changed kill all old timers. m_pEntity->KillTimer(-1); SEntityEvent levent; levent.event = ENTITY_EVENT_LEAVE_SCRIPT_STATE; levent.nParam[0] = m_nCurrStateId; levent.nParam[1] = 0; m_pEntity->SendEvent( levent ); m_nCurrStateId = nState; // Call BeginState event. m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnBeginState ); ////////////////////////////////////////////////////////////////////////// // Repeat check if update script function is implemented. m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate); /* ////////////////////////////////////////////////////////////////////////// // Check if need ResolveCollisions for OnContact script function. m_bUpdateOnContact = IsStateFunctionImplemented(ScriptState_OnContact); ////////////////////////////////////////////////////////////////////////// */ SEntityEvent eevent; eevent.event = ENTITY_EVENT_ENTER_SCRIPT_STATE; eevent.nParam[0] = nState; eevent.nParam[1] = 0; m_pEntity->SendEvent( eevent ); return true; }
void BootManagerController::Previous(WizardView* wizard) { if (CurrentState() != kStateEntry) WizardController::Previous(wizard); else { fSettings.ReplaceBool("install", false); WizardController::Next(wizard); } }
NFCStateMachine::NFCStateMachine(const NFGUID& self, NFIAIModule* pControl) : mOwnerID(self), meCurrentState(PatrolState), // 默认一开始就巡逻 meLastState(IdleState), m_pAIControlInterface(pControl) { NFIState* pState = m_pAIControlInterface->GetState(CurrentState()); mfHeartBeatTime = pState->GetHeartBeatTime(); m_pKernelModule = pControl->GetKernelModule(); assert(NULL != m_pKernelModule); }
int Robot::goToLocation(int currentFrame, Eigen::Vector3d location) { currentTime = 0.2; desiredLocation = location; initialLocation = CurrentState(); controller = PIDController(); _maxVelocity = PIDController::MAX_TRANS_VEL; _maxAngularVelocity = PIDController::MAX_ROT_VEL; return execute(); }
void GameCamera::ExecuteMovement(const GameCameraMovement& movement) { // We interpolate between start_ and end_, so start_ should be the current // values. start_ = CurrentState(); end_ = movement.end; // Initialize the Motivator. percent_.InitializeWithTarget( movement.init, engine_, motive::CurrentToTarget1f(0.0f, movement.start_velocity, 1.0f, 0.0f, movement.time)); }
int Robot::dribbleToLocation(Eigen::Vector3d location) { _maxVelocity = PIDController::MAX_TRANS_VEL/10; _maxAngularVelocity = PIDController::MAX_ROT_VEL/ 10; currentTime = 0.2; desiredLocation = location; initialLocation = CurrentState(); controller = PIDController(); return execute(); }
void MapMode::DrawPostEffects() { VideoManager->PushState(); VideoManager->SetStandardCoordSys(); VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0); // Halos are additive blending made, so they should be applied // as post-effects but before the GUI. _object_supervisor->DrawLights(); GetScriptSupervisor().DrawPostEffects(); // Draw the gui, unaffected by potential fading effects. _DrawGUI(); if(CurrentState() == STATE_DIALOGUE) _dialogue_supervisor->Draw(); // Draw the treasure menu if necessary if(CurrentState() == STATE_TREASURE) _treasure_supervisor->Draw(); VideoManager->PopState(); }
void GameCamera::AdvanceFrame(WorldTime /*delta_time*/) { // Update the directional vectors. GameCameraState current = CurrentState(); forward_ = (current.target - current.position).Normalized(); side_ = vec3::CrossProduct(mathfu::kAxisY3f, forward_); // If the camera has finished zooming in, transition to zoom out. // Transition to next movement that's been queued. if (!movements_.empty() && (!percent_.Valid() || percent_.Difference() == 0.0f)) { ExecuteMovement(movements_.front()); movements_.pop(); } }
void GameStateManager::BackState(unsigned int count){ if(_states.size() <= count){ CleanUp(); } else { for(unsigned int i = 0; i < count; i++){ if(onStateChange!=0){ (_setting->*this->onStateChange)(CurrentState(), (_states.size() > 1) ? _states.at(_states.size() - 2) : GSNone); } _states.pop_back(); } } }
BOOL COrnament::PositionChanged(CPropertyState* pState) const { COrnamentState* pCurrent = CurrentState(); COrnamentState* pCompare = StateType(pState); if (!PropertySet(pState)) { return FALSE; } return (pState == NULL) || (pCurrent->m_cpPosition != pCompare->m_cpPosition); }
void CScriptProxy::SendScriptEvent( int Event, int nParam, bool* pRet ) { SScriptState* pState = CurrentState(); for (int i = 0; i < NUM_STATES; i++) { if (m_pScript->ShouldExecuteCall(i) && pState->pStateFuns[i] && pState->pStateFuns[i]->pFunction[ScriptState_OnEvent]) { if (pRet) Script::CallReturn( GetIScriptSystem(),pState->pStateFuns[i]->pFunction[ScriptState_OnEvent],m_pThis,Event,nParam,*pRet ); else Script::Call( GetIScriptSystem(),pState->pStateFuns[i]->pFunction[ScriptState_OnEvent],m_pThis,Event,nParam ); pRet = 0; } } }
void CScriptProxy::Initialize( const SComponentInitializer &init ) { assert(init.m_pEntity); if (m_pEntity == NULL) { m_pEntity = (CEntity*)init.m_pEntity; m_pScript = static_cast<const SComponentInitializerScriptProxy &> (init).m_pScript; // New object must be created here. CreateScriptTable(static_cast<const SComponentInitializerScriptProxy &> (init).m_pSpawnParams); m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate); } }
BOOL COrnament::SizeChanged(CPropertyState* pState) const { COrnamentState* pCurrent = CurrentState(); COrnamentState* pCompare = StateType(pState); if (!PropertySet(pState)) { return FALSE; } return (pState == NULL) || (pCurrent->m_dwStyle != pCompare->m_dwStyle) || (pCurrent->m_czExtent != pCompare->m_czExtent); }
// ---------------------------------------------------------------------------- // CSIPSecAgreement::HandleRequestL // ---------------------------------------------------------------------------- // void CSIPSecAgreement::HandleRequestL( TSIPTransportParams& aTransportParams, CSIPRequest& aRequest, const CUri8& aRemoteTarget, const TDesC8& aOutboundProxy, MSIPSecUser& aUser, TRegistrationId aRegistrationId ) { __TEST_INVARIANT; AddUserIfNotStoredL( aUser ); RStringF secClient = SIPStrings::StringF( SipStrConsts::ESecurityClientHeader ); switch ( CurrentState() ) { case EWaitResponse: if ( aRequest.HasHeader( secClient ) ) { ProcessSecurityClientL( aRequest ); } break; case EMechanismSelected: CreateSecurityVerifyL(); //lint -fallthrough case EVerified: default: if ( !SipSecUtils::Match( SipStrConsts::ERegister, aRequest.Method() ) ) { aRequest.DeleteHeaders( secClient ); } iMechanism->ProcessSecurityVerifyL( aTransportParams, aRequest, iNextHopAddr, aRemoteTarget, aOutboundProxy, &aUser, aRegistrationId, iSecurityServer, iSecurityVerify ); CopySecurityVerifyToRequestL( aRequest ); } __TEST_INVARIANT; }
void UnitStateMgr::PushAction(UnitActionId actionId, UnitActionPtr state, UnitActionPriority priority, eActionType restoreable) { ActionInfo* oldInfo = CurrentState(); UnitActionPriority _priority = oldInfo ? oldInfo->priority : UNIT_ACTION_PRIORITY_IDLE; // Only interrupt action, if not drop his below and action lower by priority if (oldInfo && oldInfo->HasFlag(ACTION_STATE_ACTIVE) && oldInfo->Id != actionId && _priority < priority) oldInfo->Interrupt(this); if (_priority > UNIT_ACTION_PRIORITY_IDLE) { // Some speedup - testing - not need drop Idle/None actions DropAction(actionId, priority); DropAction(priority); } bool needInsert = true; if (restoreable != ACTION_TYPE_NONRESTOREABLE) { // Don't replace (only interrupt and reset!) restoreable actions UnitActionStorage::iterator itr = m_actions.find(priority); if (itr != m_actions.end()) { if (itr->second.Id == actionId) { itr->second.Reset(this); needInsert = false; } } } if (needInsert) m_actions.insert(UnitActionStorage::value_type(priority,ActionInfo(actionId, state, priority, restoreable))); IncreaseCounter(actionId); /* ActionInfo* newInfo = CurrentState(); if (newInfo && newInfo != oldInfo) { if (!newInfo->HasFlag(ACTION_STATE_INITIALIZED)) newInfo->Initialize(this); } */ }
BOOL COrnament::Contains(const CPoint& cpLocation) { BOOL fContains = FALSE; // Make sure the object has been initialized. if (!CommitNeeded()) { if (CurrentState()->m_crBounds.PtInRect(cpLocation)) { fContains = TRUE; } } return fContains; }
NFCStateMachine::NFCStateMachine(const NFGUID& self, NFIPluginManager* p) : mOwnerID(self), meCurrentState(PatrolState), meLastState(IdleState) { pPluginManager = p; NFIState* pState = GetState(CurrentState()); mfHeartBeatTime = pState->GetHeartBeatTime(); m_pKernelModule = pPluginManager->FindModule<NFIKernelModule>(); m_pAIModule = pPluginManager->FindModule<NFIAIModule>(); m_pMoveModule = pPluginManager->FindModule<NFIMoveModule>(); m_pElementModule = pPluginManager->FindModule<NFIElementModule>(); m_pHateModule = pPluginManager->FindModule<NFIHateModule>(); }
// ---------------------------------------------------------------------------- // CSIPSecAgreement::ResponseReceivedL // If a security-agreement related response containing Security-Server is // received, (re)select the mechanism. // Response is not received in EMechanismSelected state, as when the updated // request is sent, agreement enters EVerified state. // ---------------------------------------------------------------------------- // void CSIPSecAgreement::ResponseReceivedL( CSIPResponse& aResponse, const MSIPSecUser& aUser, TBool aUseSecurityServerHeaders ) { __TEST_INVARIANT; AddUserIfNotStoredL( aUser ); TBool hasSecurityServer = aResponse.HasHeader( SIPStrings::StringF( SipStrConsts::ESecurityServerHeader ) ); if ( hasSecurityServer && IsSecAgreeResponse( aResponse.ResponseCode() ) && aUseSecurityServerHeaders ) { // Clear old Security-Verify and mechanism, causing agreement enter // EWaitResponse state. iSecurityVerify.ResetAndDestroy(); iMechanism = NULL; } if ( CurrentState() == EWaitResponse ) { // Don't accept a direct 2xx to the initial request which had // Security-Client and thus expects a challenge. __ASSERT_ALWAYS( aResponse.Type() != CSIPResponse::E2XX, User::Leave( KErrNotFound ) ); if ( IsSecAgreeResponse( aResponse.ResponseCode() ) ) { // Security-Server required, as request had Security-Client. __ASSERT_ALWAYS( hasSecurityServer, User::Leave( KErrNotFound ) ); if ( aUseSecurityServerHeaders ) { ChooseMechanismL( aResponse ); // Check if server initiated sec-agree is allowed if ( iClientMechanisms->IsEmpty() && !iMechanism->IsServerInitiatedSecAgreeAllowed() ) { User::Leave( KErrNotSupported ); } } } } __TEST_INVARIANT; }
void CScriptProxy::ChangeScript( IEntityScript* pScript, SEntitySpawnParams* params ) { if (pScript) { // Release current SAFE_RELEASE(m_pThis); m_pScript = static_cast<CEntityScript*>(pScript); m_nCurrStateId = 0; m_fScriptUpdateRate = 0; m_fScriptUpdateTimer = 0; m_bEnableSoundAreaEvents = false; m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate); // New object must be created here. CreateScriptTable(params); } }
void CScriptProxy::Update( SEntityUpdateContext &ctx ) { // Update`s script function if present. if (m_bUpdateScript) { // Shouldn't be the case, but we must not call Lua with a 0 frametime to avoid potential FPE assert(ctx.fFrameTime > FLT_EPSILON); if (CVar::pUpdateScript->GetIVal()) { m_fScriptUpdateTimer -= ctx.fFrameTime; if (m_fScriptUpdateTimer <= 0) { ENTITY_PROFILER m_fScriptUpdateTimer = m_fScriptUpdateRate; ////////////////////////////////////////////////////////////////////////// // Script Update. m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnUpdate,ctx.fFrameTime ); } } } }
void CScriptProxy::Reload( IEntity* pEntity,SEntitySpawnParams ¶ms ) { FUNCTION_PROFILER( GetISystem(), PROFILE_ENTITY ); IEntityClass* pClass = (pEntity ? pEntity->GetClass() : NULL); CEntityScript* pEntityScript = (pClass ? (CEntityScript*)pClass->GetIEntityScript() : NULL); if (pEntityScript && pEntityScript->LoadScript()) { // Release current SAFE_RELEASE(m_pThis); m_pEntity = (CEntity*)pEntity; m_pScript = pEntityScript; m_nCurrStateId = 0; m_fScriptUpdateRate = 0; m_fScriptUpdateTimer = 0; m_bEnableSoundAreaEvents = false; m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate); // New object must be created here. CreateScriptTable(¶ms); } }
UnitActionPtr UnitStateMgr::CurrentAction() { ActionInfo* action = CurrentState(); return action ? action->Action() : UnitActionPtr(NULL); }
CBitmap* COrnament::GetImage(void) { CDC *pDC = m_pContext->GetDC(); ASSERT(pDC != NULL); // If the image bitmap is not valid give the current state, free the // current bitmap and build the new one. if (ImageNeeded()) { m_bmImage.DeleteObject(); } // Check if we need to build a new bitmap. if (m_bmImage.GetSafeHandle() == NULL) { // Create the bitmap for the image. CRect crImage(0, 0, Max(CurrentState()->m_czExtent.cx, 1), Max(CurrentState()->m_czExtent.cy, 1)); if (m_bmImage.CreateCompatibleBitmap(pDC, crImage.Width(), crImage.Height())) { // Create a memory compatible DC and select the new bitmap into it. CDC ImageDC; if (ImageDC.CreateCompatibleDC(pDC)) { CBrush cbTransparent(RGB(0,0,0)); int nContext; if ((nContext = ImageDC.SaveDC()) != 0) { ImageDC.SetMapMode(MM_TEXT); if (ImageDC.SelectObject(&m_bmImage) != NULL) { // Create the image. Pixels that are transparent should be set to sero (black). ImageDC.FillRect(&crImage, &cbTransparent); DrawImage(&ImageDC); ClearImageNeeded(); } ImageDC.RestoreDC(nContext); } } } } m_pContext->ReleaseDC(); ASSERT(m_bmImage.GetSafeHandle() != NULL); if (m_bmImage.GetSafeHandle() == NULL) { return NULL; } return &m_bmImage; }
CBitmap* COrnament::GetMask(void) { CDC *pDC = m_pContext->GetDC(); ASSERT(pDC != NULL); // If the mask bitmap is not valid give the current state, free the // current bitmap and build the new one. if (MaskNeeded()) { m_bmMask.DeleteObject(); } // Check if we need to build a new bitmap. if (m_bmMask.GetSafeHandle() == NULL) { // Create the bitmap for the mask. CRect crMask(0, 0, Max(CurrentState()->m_czExtent.cx, 1), Max(CurrentState()->m_czExtent.cy, 1)); if (m_bmMask.CreateBitmap(crMask.Width(), crMask.Height(), 1, 1, NULL)) { // Create a memory compatible DC and select the new bitmap into it. CDC MaskDC; if (MaskDC.CreateCompatibleDC(pDC)) { CBrush cbTransparent(RGB(255,255,255)); int nContext; if ((nContext = MaskDC.SaveDC()) != 0) { MaskDC.SetMapMode(MM_TEXT); if (MaskDC.SelectObject(&m_bmMask) != NULL) { // Create the mask image. Pixels that should be masked out should // be set to zero (black). Pixels that should be transparent should // be set to one (white). MaskDC.FillRect(&crMask, &cbTransparent); DrawMask(&MaskDC); ClearMaskNeeded(); } MaskDC.RestoreDC(nContext); } } } } m_pContext->ReleaseDC(); ASSERT(m_bmMask.GetSafeHandle() != NULL); if (m_bmMask.GetSafeHandle() == NULL) { return NULL; } return &m_bmMask; }