void CCommandView::showEvent(QShowEvent * e) { //m_pCommandList->SetPos(m_pMenuBtn->geometry().left(),m_pMenuBtn->geometry().top(),m_pMenuBtn->geometry().width()*2.5,0); m_CmdVec.clear(); std::vector<SMenuCommand> CmdList = m_pList->getActiveApp()->getCommandList(); std::vector<SMenuCommand> TmpCmdList; for (unsigned int i = 0; i < CmdList.size(); ++i) { if (0 != CmdList.at(i).i_cmdID && 0 == CmdList.at(i).i_menuID) { AddCommand(CmdList.at(i).i_cmdID,CmdList.at(i).str_menuName,CmdList.at(i).str_ImagePath); }else if (0 == CmdList.at(i).i_cmdID && 0 != CmdList.at(i).i_menuID) { AddMenu(CmdList.at(i).i_menuID,CmdList.at(i).str_menuName); TmpCmdList = m_pList->getActiveApp()->getCommandList(CmdList.at(i).i_menuID); for(unsigned int j = 0; j < TmpCmdList.size(); j++) { AddSubCommand(CmdList.at(i).i_menuID, TmpCmdList.at(j).i_cmdID, TmpCmdList.at(j).str_menuName.data(),TmpCmdList.at(j).str_ImagePath); } } } m_pCurrentMenu = NULL; RefreshCommandList(); AppBase::SetEdlidedText(m_pAppNameLab, m_pList->getActiveApp()->getAppName().c_str(), width()*0.8); }
CommandState AnimalBrain :: Process() { ActivateIfInactive(); CommandState subCommandState = ProcessSubCommands(); // if the animal is not currently running a subcommand then determine what the next command is: if((subCommandState == completed || subCommandState == failed)) { AddSubCommand(new CommandWander(owner)); } return state; }
CommandState CommandWander :: Process() { // If this is the first time processing, then activate: ActivateIfInactive(); CommandState subCommandState = ProcessSubCommands(); // if the animal is not currently running a subcommand then determine what the next command is: if((subCommandState == completed || subCommandState == failed)) { int choice = rand() % 2; if(choice == 0) { AddSubCommand(new CommandMoveToRandomPosition(owner, 10)); } if(choice == 1) { AddSubCommand(new CommandIdle(owner, 3000)); } } return state; }
CommandState CommandPickUpItem :: Process() { ActivateIfInactive(); ProcessSubCommands(); if(owner->GetFeetPosition().getDistanceFrom(item->GetPosition()) > 1.0f && !IsCurrentCommand(COMMAND_PATH_TO_POSITION)) { AddSubCommand(new CommandPathToPosition(owner, item->GetPosition() + vector3df(0,0.1f,0))); // Vector is to deal with items partially submerged in ground } else { owner->AddToInventory(item->GetItem(), item->GetItemAmount()); InstanceMgr->DestroyItemInstance(item); state = completed; } return state; }