Example #1
0
 virtual bool Compare(const Imp& imp) const
 {
    ConstCastVisitor_T<ElementTypeT> castVisitor;
    imp.Accept(castVisitor);
    return castVisitor.m_pElement &&
           m_Element == *castVisitor.m_pElement;
 }
 NetgenOutStream(ostream * aout, Imp imp ) :
   out(aout),
   printheader(1)
 { 
   if ( netgen::printmessage_importance >= imp.GetImp() )
     print = true;
   else
     print = false;
 }
Example #3
0
void Imp::renegotiate()
{
	Vector2f* impPosition = this->getPosition();
	Vector2f* tilePosition = this->job->destination->getPosition();

	int x = tilePosition->x - impPosition->x;
	int y = tilePosition->y - impPosition->y;
	int distance = x * x + y * y;

	if (distance > 25000)
	{
		int length = this->workers->size();
		
		Imp* imp = nullptr;

		for (int i = 0; i < length; i++)
		{
			Imp* current = (*this->workers)[i];
			
			if (current->isIdle() && !current->hasMaxGold())
			{
				int currentDistance;

				impPosition = current->getPosition();

				x = tilePosition->x - impPosition->x;
				y = tilePosition->y - impPosition->y;

				currentDistance = x * x + y * y;

				if (currentDistance < distance)
				{
					imp = current;
					distance = currentDistance;
				}
			}
		}

		if (imp != nullptr)
		{
			imp->setJob(this->job);
			this->status = Status::IDLE;
		}
	}
}
Example #4
0
 bool Compare(const Imp& imp) const
 {
    CastVisitor<const ElementTypeT> castVisitor;
    imp.Accept(castVisitor);
    return castVisitor.element && m_Element == *castVisitor.element;
 }