Exemplo n.º 1
0
bool Arbiter::setSlotBehaviors(Basic::PairStream* const x)
{
   bool ok = true;

   // First, make sure they are all behaviors
   {
      Basic::List::Item* item = x->getFirstItem();
      while (item != nullptr && ok) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         item = item->getNext();
         Behavior* b = dynamic_cast<Behavior*>( pair->object() );
         if (b == nullptr) {
            // Item is NOT a behavior
            std::cerr << "setSlotBehaviors: slot: " << *pair->slot() << " is NOT of a Behavior type!" << std::endl;
            ok = false;
         }
      }
   }

   // next, add behaviors to our list
   if (ok) {
      Basic::List::Item* item = x->getFirstItem();
      while (item != nullptr) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         item = item->getNext();
         Behavior* b = static_cast<Behavior*>(pair->object());
         addBehavior(b);
      }
   }

   return ok;
}
Exemplo n.º 2
0
// copy constructor
MObject3d::MObject3d(const MObject3d & object):
	m_parent(NULL),
	m_position(object.m_position),
	m_scale(object.m_scale),
	m_rotation(object.m_rotation),
	m_matrix(object.m_matrix),
	m_isVisible(object.m_isVisible),
	m_isActive(object.m_isActive),
	m_needToUpdate(object.m_needToUpdate)
{
	if(object.m_parent)
		linkTo(object.m_parent);

	unsigned int i;
	unsigned int bSize = object.m_behaviors.size();
	for(i=0; i<bSize; i++)
		addBehavior(object.m_behaviors[i]->getCopy(this));
}
Exemplo n.º 3
0
ProtoMotivator::ProtoMotivator()
{
	//Configure behaviors
	addBehavior(new BForward());
	behaviors[B_FORWARD]->init();

	addBehavior(new BRight());
	behaviors[B_RIGHT]->init();

	addBehavior(new BLeft());
	behaviors[B_LEFT]->init();

	addBehavior(new BStop());
	behaviors[B_STOP]->init();

	addBehavior(new BBackward());
	behaviors[B_BACKWARD]->init();

	addBehavior(new BScanForward());
	behaviors[B_SCANFORWARD]->init();

	addBehavior(new BScanFull());
	behaviors[B_SCANFULL]->init();

	addBehavior(new BScanDirectForward());
	behaviors[B_SCANDIRECTFORWARD]->init();

	addBehavior(new BReadCompass());
	behaviors[B_READCOMPASS]->init();

	//configure behavior conflicts
	behaviors[B_FORWARD]->addConflict(behaviors[B_RIGHT]);
	behaviors[B_FORWARD]->addConflict(behaviors[B_LEFT]);
	behaviors[B_FORWARD]->addConflict(behaviors[B_STOP]);
	behaviors[B_FORWARD]->addConflict(behaviors[B_BACKWARD]);

	behaviors[B_RIGHT]->addConflict(behaviors[B_FORWARD]);
	behaviors[B_RIGHT]->addConflict(behaviors[B_LEFT]);
	behaviors[B_RIGHT]->addConflict(behaviors[B_STOP]);
	behaviors[B_RIGHT]->addConflict(behaviors[B_BACKWARD]);

	behaviors[B_LEFT]->addConflict(behaviors[B_FORWARD]);
	behaviors[B_LEFT]->addConflict(behaviors[B_RIGHT]);
	behaviors[B_LEFT]->addConflict(behaviors[B_STOP]);
	behaviors[B_LEFT]->addConflict(behaviors[B_BACKWARD]);

	behaviors[B_STOP]->addConflict(behaviors[B_FORWARD]);
	behaviors[B_STOP]->addConflict(behaviors[B_RIGHT]);
	behaviors[B_STOP]->addConflict(behaviors[B_LEFT]);
	behaviors[B_STOP]->addConflict(behaviors[B_BACKWARD]);

	behaviors[B_BACKWARD]->addConflict(behaviors[B_FORWARD]);
	behaviors[B_BACKWARD]->addConflict(behaviors[B_RIGHT]);
	behaviors[B_BACKWARD]->addConflict(behaviors[B_LEFT]);
	behaviors[B_BACKWARD]->addConflict(behaviors[B_STOP]);

	behaviors[B_SCANFORWARD]->addConflict(behaviors[B_SCANFULL]);
	behaviors[B_SCANFORWARD]->addConflict(behaviors[B_SCANDIRECTFORWARD]);

	behaviors[B_SCANFULL]->addConflict(behaviors[B_SCANFORWARD]);
	behaviors[B_SCANFULL]->addConflict(behaviors[B_SCANDIRECTFORWARD]);
	
	behaviors[B_SCANDIRECTFORWARD]->addConflict(behaviors[B_SCANFORWARD]);
	behaviors[B_SCANDIRECTFORWARD]->addConflict(behaviors[B_SCANFULL]);
}