virtual bool Execute(Agent *_Agent)
	{
		float dist2 = 0;
		if(_Agent->Attack)
		{
			Agent *TargetEnemy = nullptr;
			for ( auto EnemyCurrent : _Agent->Enemies)
			{
				TargetEnemy = EnemyCurrent;
				float Len = 0, tLen;

				tLen = glm::length(_Agent->GetPos()) - glm::length(EnemyCurrent->GetPos());
				if(tLen < 0){tLen *= -1;}
				if(tLen > Len){Len = tLen;TargetEnemy = EnemyCurrent;}
			}
			if(TargetEnemy != nullptr)
				dist2 = glm::distance2(_Agent->GetPos(), TargetEnemy->GetPos());
		}
		else
		{
			dist2 = glm::distance2(_Agent->GetPos(), _Agent->GetTarget());
		}

		if (dist2 < Range2)
			return true;
		return false;
	}
void StalkerModule::QueueLineOfSightRay(Agent& stalker, IAIObject* target, StalkerInstance& instance)
{
	PhysSkipList skipList;
	stalker.GetPhysicalSkipEntities(skipList);
	if (IAIActor* aiActor = target->CastToIAIActor())
		aiActor->GetPhysicalSkipEntities(skipList);

	instance.rayID = g_pGame->GetRayCaster().Queue(
		RayCastRequest::HighPriority,
		RayCastRequest(target->GetPos(), stalker.GetPos() - target->GetPos(),
		ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid,
		((geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask)),
		&skipList[0], skipList.size()),
		functor(*this, &StalkerModule::LineOfSightRayComplete));
}
// ===========================================================================
// Process possible collision between an agent and the hazard.
//
//	In:		The agent.
//	Out:	The collision result (NULL is invalid!)
//
void HazardDataSphere::CheckCollision(Agent& agent, HazardCollisionResult* result) const
{
	assert(result != NULL);
	result->Reset();

	if (Distance::Point_PointSq(agent.GetPos(), m_Context.m_CenterPos) > 
		m_RadiusSq)
	{
		return;
	}		

	result->m_CollisionFlag = true;
	result->m_HazardOriginPos = m_Context.m_CenterPos;
	return;
}
	virtual bool  Execute(Agent *_Agent)
	{
		glm::vec3 Pos, Dir(0);
		if(_Agent->Attack)
		{
			if(_Agent->Path.size() > 0)
			{
				_Agent->SetTarget(_Agent->Move(1.0f));
			}
			else
			{
				Agent *TargetEnemy = nullptr;
				Pos = _Agent->GetPos();
				for ( auto EnemyCurrent : _Agent->Enemies)
				{
					float Len = 0, tLen;

					tLen = glm::length(Pos) - glm::length(EnemyCurrent->GetPos());
					if(tLen < 0){tLen *= -1;}
					if(tLen > Len){Len = tLen;TargetEnemy = EnemyCurrent;}
				}


				if(TargetEnemy != nullptr)
				{
					_Agent->Path = Path->Path(Pos,TargetEnemy->GetPos());
					Dir = _Agent->Move(1.0);
				}
			}
			if(glm::length(_Agent->GetPos()) - glm::length(_Agent->Path[0]->Position)<1.0f)
			{
				_Agent->Path.erase(_Agent->Path.begin());
			}


		}
		else
		{
			if(_Agent->Path.size() > 0)
			{
				_Agent->SetTarget(_Agent->Move(1.0f));
				if(glm::length(_Agent->GetPos()) - glm::length(_Agent->Path[0]->Position)<1.0f)
				{
					_Agent->Path.erase(_Agent->Path.begin());
				}
			}
			else
			{
				Flag *TargetFlag = nullptr;
				for (auto Flag : _Agent->Flags)
				{
					float Len = 0, tLen;

					tLen = glm::length(Pos) - glm::length(Flag->GetPos());
					if(tLen < 0){tLen *= -1;}
					if(tLen > Len){Len = tLen;TargetFlag = Flag;}
				}
				if(TargetFlag != nullptr)
				{
					_Agent->Path = Path->Path(Pos,TargetFlag->Position);
				}
			}
			_Agent->Velocity +=Dir * Speed * Utility::getDeltaTime();

			return true;
		}
	}