/** * Called when the current state has finished and is ready to transition * into the next state */ void StateComplete(int state = -1) { _round->BeforeStateTransition(); Log tmp = _next_state_log; _next_state_log = Log(); if((_cycle_state == GetCurrentState()->GetState()) && (state == -1)) { qDebug() << "In" << _round->ToString() << "ending phase"; if(!_round->CycleComplete()) { return; } _log = Log(); IncrementPhase(); } if(state == -1) { qDebug() << "In" << _round->ToString() << "ending:" << StateToString(GetCurrentState()->GetState()) << "starting:" << StateToString(GetNextState()->GetState()); _current_sm_state = GetNextState(); } else { qDebug() << "In" << _round->ToString() << "ending:" << StateToString(GetCurrentState()->GetState()) << "starting:" << StateToString(_states[state]->GetState()); _current_sm_state = _states[state]; } (_round->*GetCurrentState()->GetTransitionCallback())(); for(int idx = 0; idx < tmp.Count(); idx++) { QPair<QByteArray, Id> entry = tmp.At(idx); ProcessData(entry.second, entry.first); } }
bool CAIContainer::Internal_Engage(uint16 targetid) { //#TODO: pet engage/disengage auto entity {dynamic_cast<CBattleEntity*>(PEntity)}; if (entity && entity->PAI->IsEngaged()) { if (entity->GetBattleTargetID() != targetid) { ChangeTarget(targetid); return true; } return false; } //#TODO: use valid target stuff from spell if (entity) { //#TODO: remove m_battleTarget if possible (need to check disengage) if (CanChangeState() || (GetCurrentState() && GetCurrentState()->IsCompleted())) { if (ForceChangeState<CAttackState>(entity, targetid)) { entity->OnEngage(*static_cast<CAttackState*>(m_stateStack.top().get())); } } return true; } return false; }
bool CAIContainer::Internal_Engage(uint16 targetid) { //#TODO: pet engage/disengage auto PTarget {dynamic_cast<CBattleEntity*>(PEntity->GetEntity(targetid))}; auto entity {dynamic_cast<CBattleEntity*>(PEntity)}; if (entity && entity->PAI->IsEngaged() && entity->GetBattleTargetID() != targetid) { ChangeTarget(targetid); return true; } //#TODO: use valid target stuff from spell if (entity && PTarget && !PTarget->isDead()) { //#TODO: remove m_battleTarget if possible (need to check disengage) entity->SetBattleTargetID(targetid); entity->SetBattleStartTime(server_clock::now()); if (CanChangeState() || (GetCurrentState() && GetCurrentState()->IsCompleted())) { ForceChangeState<CAttackState>(entity, targetid); } return true; } return false; }
void JankyAutoSequencer::EndSequence(){ printf("Current Entry: %s \n", names[GetCurrentState()]); frc::SmartDashboard::PutString("Current Entry", names[GetCurrentState()]); if(entries[GetCurrentState()]){ entries[GetCurrentState()]->Abort(); printf("Aborted Entry: %s \n", names[GetCurrentState()]); } Pause(); }
boost::numeric::ublas::vector<double> ribi::kalman::StandardWhiteNoiseSystem::Measure() const noexcept { const auto sz = GetCurrentState().size(); assert(GetCurrentState().size() == m_parameters->GetMeasurementNoise().size()); boost::numeric::ublas::vector<double> measured(sz); for (std::size_t i = 0; i!=sz; ++i) { measured(i) = GetRandomNormal(GetCurrentState()(i),m_parameters->GetMeasurementNoise()(i)); } return measured; }
mitk::ProcessEventMode mitk::DataInteractor::GetMode() const { if (GetCurrentState()->GetMode() == "PREFER_INPUT") { return PREFERINPUT; } if (GetCurrentState()->GetMode() == "GRAB_INPUT") { return GRABINPUT; } return REGULAR; }
void ribi::kalman::StandardWhiteNoiseSystem::GoToNextState() { //Create a no-input vector const auto sz = GetCurrentState().size(); boost::numeric::ublas::vector<double> input(sz,0.0); return GoToNextState(input); }
void Player::Update() { // animate sprite m_Sprite->Animate(); // move the sprite with the hitbox glm::vec2 pos; pos.x = m_Hitbox.GetCenterPosition().x - (m_Sprite->GetSize().x / 2.f); pos.y = m_Hitbox.m_Position.y + m_Hitbox.m_Size.y - m_Sprite->GetSize().y; m_Sprite->SetPosition(pos); // update the weapon... if( IsAttacking() ) { Weapon::WEAPON_STATE w_state; switch( GetCurrentState() ) { case ATTACKING : w_state = Weapon::ATTACKING; break; case ATTACKING_UP : w_state = Weapon::ATTACKING_UP; break; case ATTACKING_DOWN : w_state = Weapon::ATTACKING_DOWN; break; } m_Weapons[m_CurrentWeaponIndex]->SetState(w_state); m_Weapons[m_CurrentWeaponIndex]->UseFrame(m_Sprite); } }
void VtolLandFSM::Update() { runState(); if (GetCurrentState() != PFFSM_STATE_INACTIVE) { runAlways(); } }
nsresult nsListCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) { nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(editor, NS_NOINTERFACE); bool inList; // Need to use mTagName???? nsresult rv; nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); if (NS_FAILED(rv) || !params) return rv; rv = GetCurrentState(aEditor, mTagName, params); rv = params->GetBooleanValue(STATE_ALL,&inList); NS_ENSURE_SUCCESS(rv, rv); nsAutoString listType; listType.AssignWithConversion(mTagName); if (inList) rv = editor->RemoveList(listType); else { rv = editor->MakeOrChangeList(listType, false, EmptyString()); } return rv; }
BEGIN_GAME_GUI void updateStatistics(const TGameStatistics& statistics, const TLevel& level) { string header = "Game over!"; if ((GetCurrentState() == AppState::Level) && (level.GetProgress().isStageCompleted())) { header = "Stage clear!"; } statisticsWindow->SetTitle(header); std::array<TextString> statisticsOutput = { "Score: " + level.GetProgress().GetPoints(), "Buildings: " + statistics.GetMetric(Metric.buildingsCreated).as<int>(), "Credis spent: " + statistics.GetMetric(Metric.creditsSpent).as<int>(), "Credits earned: " + statistics.GetMetric(Metric.creditsEarned).as<int>(), "Mobs: " + (statistics.GetMetric(Metric.mobsKilled).as<int>() + gameStatistics.GetMetric(Metric.mobsPassed).as<int>()), " passed: " + statistics.GetMetric(Metric.mobsPassed).as<int>(), " killed: " + statistics.GetMetric(Metric.mobsKilled).as<int>(), "Press any key to continue..." }; string statisticsText = "Results:"; for (size_t i = 0, iend = statisticsOutput.size(); i != iend; ++i) { statisticsText += std::endl + statisticsOutput[i]; } }
SmartPointer<const ExecutionEvent> HandlerService::CreateExecutionEvent(const SmartPointer<const Command>& command, const SmartPointer<const UIElement>& trigger) { ExecutionEvent::Pointer event(new ExecutionEvent(command, ExecutionEvent::ParameterMap(), trigger, Object::Pointer(GetCurrentState()))); return event; }
void CAIContainer::Tick(time_point _tick) { m_PrevTick = m_Tick; m_Tick = _tick; PEntity->Tick(_tick); //#TODO: check this in the controller instead maybe? (might not want to check every tick) - same for pathfind ActionQueue.checkAction(_tick); // check pathfinding if (!Controller && CanFollowPath()) { PathFind->FollowPath(); if (PathFind->OnPoint()) { luautils::OnPath(PEntity); } } if (Controller && Controller->canUpdate) { Controller->Tick(_tick); } CState* top = nullptr; while (!m_stateStack.empty() && (top = m_stateStack.top().get())->DoUpdate(_tick)) { if (top == GetCurrentState()) { m_stateStack.top()->Cleanup(_tick); m_stateStack.pop(); } } PEntity->UpdateEntity(); }
void Move::SetAxisCompensation(int8_t axis, float tangent) { float currentPositions[DRIVES+1]; if(!GetCurrentState(currentPositions)) { platform->Message(HOST_MESSAGE, "Setting bed equation - can't get position!"); return; } switch(axis) { case X_AXIS: tanXY = tangent; break; case Y_AXIS: tanYZ = tangent; break; case Z_AXIS: tanXZ = tangent; break; default: platform->Message(HOST_MESSAGE, "SetAxisCompensation: dud axis.\n"); } Transform(currentPositions); SetPositions(currentPositions); }
nsresult nsListCommand::ToggleState(nsIEditor *aEditor) { nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(editor, NS_NOINTERFACE); nsresult rv; nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); if (NS_FAILED(rv) || !params) return rv; rv = GetCurrentState(aEditor, params); NS_ENSURE_SUCCESS(rv, rv); bool inList; rv = params->GetBooleanValue(STATE_ALL,&inList); NS_ENSURE_SUCCESS(rv, rv); nsDependentAtomString listType(mTagName); if (inList) { rv = editor->RemoveList(listType); } else { rv = editor->MakeOrChangeList(listType, false, EmptyString()); } return rv; }
void FreePause(void) { FreeSprite(PauseText); FreeSprite(SFXSliderGuide); FreeSprite(BGMSliderGuide); FreeSprite(SFXSliderBack); FreeSprite(BGMSliderBack); FreeSprite(PauseBackground); FreeSprite(EnableCheats); FreeSprite(CheckMark); FreeButton(CheatsButton); FreeSprite(EnableLookAt); FreeSprite(LookAtCheckMark); FreeButton(LookAtButton); FreeButton(SFXSlider); FreeButton(BGMSlider); FreeButton(ResumeButton); FreeButton(MainMenuButton); if(GetCurrentState() != GS_MapLevel) FreeButton(RestartButton); FreeText(SFXText); FreeText(BGMText); FreeText(SFXLabel); FreeText(BGMLabel); FreeMyAlloc(volumestring); ReleaseSound(BackgroundSnd.Sound); //Keep this here otherwise sound exists foreverrrrrrrr }
void LevelCompletion(void) { WhiteOverlay->Position.x = GetCameraXPosition(); BlackOverlay->Position.x = GetCameraXPosition(); if (WhiteOverlay->Alpha > 1) { //Allow player to upgrade their player if upgrades are available if (UpgradeComplete) { //Continue onto the map if (BlackOverlay->Alpha > 1) { if(GetCurrentState() == GS_Level1) SetNextState(GS_Narr1); else SetNextState(GS_MapLevel); } else BlackOverlay->Alpha += GetDeltaTime(); } else if (!UpgradeComplete) UpdateUpgradeScreenObjects(); } else WhiteOverlay->Alpha += 2 * GetDeltaTime(); }
DWORD CNetServiceBase::SerHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData) { // Handle the requested control code. switch (dwControl){ case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_SHUTDOWN: // 关闭服务 OutputDebugStr(_T("服务端接收到关闭命令\n")); SetExitEvent(); break; case SERVICE_CONTROL_INTERROGATE: break; case SERVICE_CONTROL_PAUSE: break; case SERVICE_CONTROL_CONTINUE: break; // invalid control code default: // update the service status. SetCurrentState(GetCurrentState()); return ERROR_CALL_NOT_IMPLEMENTED; break; } return NO_ERROR; }
int StateMachine::Execute(float dt) { DataCache::Instance()->freeGameData(); // can probably do without this line as pop takes care of it if (m_stateStack.empty()) return -1; GetCurrentState()->playMusic(); if ( GetCurrentState()->Execute(dt) == -1) { PopState(); }; return 0; }
void Move::SetProbedBedEquation() { float currentPositions[DRIVES+1]; if(!GetCurrentState(currentPositions)) { platform->Message(HOST_MESSAGE, "Setting bed equation - can't get position!"); return; } if(NumberOfProbePoints() >= 3) { secondDegreeCompensation = (NumberOfProbePoints() == 4); if(secondDegreeCompensation) { /* * Transform to a ruled-surface quadratic. The corner points for interpolation are indexed: * * ^ [1] [2] * | * Y * | * | [0] [3] * -----X----> * * These are the scaling factors to apply to x and y coordinates to get them into the * unit interval [0, 1]. */ xRectangle = 1.0/(xBedProbePoints[3] - xBedProbePoints[0]); yRectangle = 1.0/(yBedProbePoints[1] - yBedProbePoints[0]); Transform(currentPositions); SetPositions(currentPositions); return; } } else { platform->Message(HOST_MESSAGE, "Attempt to set bed compensation before all probe points have been recorded."); return; } float xkj, ykj, zkj; float xlj, ylj, zlj; float a, b, c, d; // Implicit plane equation - what we need to do a proper job xkj = xBedProbePoints[1] - xBedProbePoints[0]; ykj = yBedProbePoints[1] - yBedProbePoints[0]; zkj = zBedProbePoints[1] - zBedProbePoints[0]; xlj = xBedProbePoints[2] - xBedProbePoints[0]; ylj = yBedProbePoints[2] - yBedProbePoints[0]; zlj = zBedProbePoints[2] - zBedProbePoints[0]; a = ykj*zlj - zkj*ylj; b = zkj*xlj - xkj*zlj; c = xkj*ylj - ykj*xlj; d = -(xBedProbePoints[1]*a + yBedProbePoints[1]*b + zBedProbePoints[1]*c); aX = -a/c; aY = -b/c; aC = -d/c; Transform(currentPositions); SetPositions(currentPositions); }
void CGameStateStack::PopCurrentState() { IEventHandler* state = GetCurrentState(); if(state) { state->HandleEvent( EVT_DESTROY, NULL, 0 ); m_stateStack.RemoveItem(state); } }
nsresult nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor) { nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE); //create some params now... nsresult rv; nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); if (NS_FAILED(rv) || !params) return rv; // tags "href" and "name" are special cases in the core editor // they are used to remove named anchor/link and shouldn't be used for insertion bool doTagRemoval; if (mTagName == nsGkAtoms::href || mTagName == nsGkAtoms::name) { doTagRemoval = true; } else { // check current selection; set doTagRemoval if formatting should be removed rv = GetCurrentState(aEditor, params); NS_ENSURE_SUCCESS(rv, rv); rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval); NS_ENSURE_SUCCESS(rv, rv); } if (doTagRemoval) { // Also remove equivalent properties (bug 317093) if (mTagName == nsGkAtoms::b) { rv = RemoveTextProperty(htmlEditor, NS_LITERAL_STRING("strong")); NS_ENSURE_SUCCESS(rv, rv); } else if (mTagName == nsGkAtoms::i) { rv = RemoveTextProperty(htmlEditor, NS_LITERAL_STRING("em")); NS_ENSURE_SUCCESS(rv, rv); } else if (mTagName == nsGkAtoms::strike) { rv = RemoveTextProperty(htmlEditor, NS_LITERAL_STRING("s")); NS_ENSURE_SUCCESS(rv, rv); } rv = RemoveTextProperty(htmlEditor, nsDependentAtomString(mTagName)); } else { // Superscript and Subscript styles are mutually exclusive aEditor->BeginTransaction(); nsDependentAtomString tagName(mTagName); if (mTagName == nsGkAtoms::sub || mTagName == nsGkAtoms::sup) { rv = RemoveTextProperty(htmlEditor, tagName); } if (NS_SUCCEEDED(rv)) rv = SetTextProperty(htmlEditor, tagName); aEditor->EndTransaction(); } return rv; }
void PathFinder::FindNextMove( const Vector2& from, const Vector2& to, float arrivalDist, PathFinderMove& move ) { _currentPos = from; _currentDest = to; _arrivalDist = arrivalDist; move.LastResult = PathFinder::PFMR_PATH_FOUND; while(!GetCurrentState()->Update( move ) ); }
nsresult nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) { nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE); //create some params now... nsresult rv; nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); if (NS_FAILED(rv) || !params) return rv; // tags "href" and "name" are special cases in the core editor // they are used to remove named anchor/link and shouldn't be used for insertion nsAutoString tagName; tagName.AssignWithConversion(aTagName); bool doTagRemoval; if (tagName.EqualsLiteral("href") || tagName.EqualsLiteral("name")) doTagRemoval = true; else { // check current selection; set doTagRemoval if formatting should be removed rv = GetCurrentState(aEditor, aTagName, params); NS_ENSURE_SUCCESS(rv, rv); rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval); NS_ENSURE_SUCCESS(rv, rv); } if (doTagRemoval) rv = RemoveTextProperty(aEditor, tagName.get(), nsnull); else { // Superscript and Subscript styles are mutually exclusive nsAutoString removeName; aEditor->BeginTransaction(); if (tagName.EqualsLiteral("sub")) { removeName.AssignLiteral("sup"); rv = RemoveTextProperty(aEditor,tagName.get(), nsnull); } else if (tagName.EqualsLiteral("sup")) { removeName.AssignLiteral("sub"); rv = RemoveTextProperty(aEditor, tagName.get(), nsnull); } if (NS_SUCCEEDED(rv)) rv = SetTextProperty(aEditor,tagName.get(), nsnull, nsnull); aEditor->EndTransaction(); } return rv; }
State::Ptr_t wxcEditManager::Undo() { // move the last item to the re-do list State::Ptr_t state = m_undoList.back(); m_undoList.pop_back(); m_redoList.push_back(state); SetModified(true); // and return the current state return GetCurrentState(); }
//--------------------------------------------------------------------------- void ribi::gtst::ServerStates::GoToNextState() { ++m_i; assert(m_i >= 0); assert(m_i < boost::numeric_cast<int>(m_v.size())); m_v[m_i]->Start(); m_v[m_i]->ResetTimeLeft(); m_log->LogExperimentStateChanged(GetCurrentState()); }
NS_IMETHODIMP nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *refCon) { nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon); if (editor) return GetCurrentState(editor, aParams); return NS_OK; }
void ribi::kalman::StandardWhiteNoiseSystem::GoToNextState(const boost::numeric::ublas::vector<double>& input) { //First do a perfect transition assert(input.size() == GetCurrentState().size()); assert(m_parameters->GetStateTransition().size1() == GetCurrentState().size()); assert(m_parameters->GetStateTransition().size2() == GetCurrentState().size()); assert(m_parameters->GetControl().size1() == input.size()); assert(m_parameters->GetControl().size2() == input.size()); boost::numeric::ublas::vector<double> new_state = Matrix::Prod(m_parameters->GetStateTransition(),GetCurrentState()) + Matrix::Prod(m_parameters->GetControl(),input); //Add process noise const auto sz = new_state.size(); assert(new_state.size() == m_parameters->GetProcessNoise().size()); for (std::size_t i = 0; i!=sz; ++i) { new_state(i) = GetRandomNormal(new_state(i),m_parameters->GetProcessNoise()(i)); } SetNewCurrentState(new_state); }
IEventHandler* CGameStateStack::GetAvatar() { IEventHandler* avatar = NULL; IEventHandler* state = GetCurrentState(); if( state ) { state->HandleEvent( EVT_GETAVATAR, &avatar, sizeof(void*) ); } return avatar; }
void StateMachine::PushState(State* state) { if (!m_stateStack.empty()) { GetCurrentState()->JustMadeInactive(); }; m_stateStack.push_front(state); state->SetParent(this); state->JustMadeActive(); }