void ColorScanAction::execute() { connect(_manager, SIGNAL(sensorStateChanged(Comm::SensorType, int, int)), this, SLOT(testColor(Comm::SensorType, int, int))); connect(_finder, SIGNAL(objectiveReached()), this, SLOT(destinationReached())); connect(_finder, SIGNAL(objectiveCanceled()), this, SLOT(destinationReached())); connect(_startAction, SIGNAL(finished(bool)), this, SLOT(startActionFinished(bool))); connect(_endAction, SIGNAL(finished(bool)), this, SLOT(endActionFinished(bool))); connect(_leftOpponentColorAction, SIGNAL(finished(bool)), this, SLOT(leftArmActionFinished(bool))); connect(_leftOurColorAction, SIGNAL(finished(bool)), this, SLOT(leftArmActionFinished(bool))); connect(_rightOpponentColorAction, SIGNAL(finished(bool)), this, SLOT(rightArmActionFinished(bool))); connect(_rightOurColorAction, SIGNAL(finished(bool)), this, SLOT(rightArmActionFinished(bool))); if (_startAction) executeSubAction(_startAction); else startActionFinished(true); }
void NPCCharacter::_behaviorMove(const Ogre::Vector3& target) { //Check for duplicate move calls and update lua function call with that info //std::cout << target << std::endl; if(_destination.squaredDistance(target) >= 5) { updateDestination(target,false); _destination = target; } if(destinationReached()) { _isBhvFinished = true; } else { _isBhvFinished = false; } //point the character in the direction it's traveling Ogre::Vector3 vel = getVelocity(); float speed = vel.length(); vel.y = 0; vel.normalise(); if(speed > .2f) { Ogre::Vector3 src = _node->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z; src.y = 0; //moving sufficiently fast, change to moving animation and point character Utility::rotateToTarget(_node,vel,true); //change animation if needed. if(_animHandler.getSource() != nullptr) { Ogre::AnimationState* target = _animHandler.getTarget(); //this relies on the properties of the '&&' construct used by C++(if the first is false, //then the if-statement is false. It DOESN'T check both fields. if((target == nullptr && _animHandler.getSource()->getAnimationName() != "Walk") || (target != nullptr && target->getAnimationName() != "Walk")) { _animHandler.blend("Walk",AnimationBlender::BlendWhileAnimating,.2f,true); } } } //also have to reset the head, since I'm manually controlling it. Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton(); Ogre::Bone* headBone = skel->getBone("Bip01_Head"); //not sure how to do this. }
void ColorScanAction::end() { disconnect(_manager, SIGNAL(sensorStateChanged(Comm::SensorType, int, int)), this, SLOT(testColor(Comm::SensorType, int, int))); disconnect(_finder, SIGNAL(objectiveReached()), this, SLOT(destinationReached())); disconnect(_finder, SIGNAL(objectiveCanceled()), this, SLOT(destinationReached())); }