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 CAIContainer::Tick(time_point _tick) { m_PrevTick = m_Tick; m_Tick = _tick; //#TODO: timestamp in the event? EventHandler.triggerListener("TICK", PEntity); PEntity->Tick(_tick); //#TODO: check this in the controller instead maybe? (might not want to check every tick) ActionQueue.checkAction(_tick); // check pathfinding only if there is no controller to do it 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()) { auto state = std::move(m_stateStack.top()); m_stateStack.pop(); state->Cleanup(_tick); } } PEntity->PostTick(); }