class FilterTargetsByDistanceFromRoot extends EffectObjectSingleFilter_Scripted
{
	private editable var m_rootOffset_Z : Float;
	default m_rootOffset_Z = 1.0f;
	private editable var m_tollerance : Float;
	default m_tollerance = 0.5f;

	public export function Process( ctx : EffectScriptContext, filterCtx : EffectSingleFilterScriptContext ) : Bool
	{
		var target : Entity;
		var source : Entity;
		var effectRange : Float;
		var targetPos : Vector4;
		var sourcePos : Vector4;
		var distance : Float;
		target = EffectSingleFilterScriptContext.GetEntity( filterCtx );
		source = EffectScriptContext.GetSource( ctx );
		if( ( target == NULL ) || ( source == NULL ) )
		{
			return true;
		}
		targetPos = target.GetWorldPosition();
		targetPos.Z += m_rootOffset_Z;
		EffectData.GetFloat( EffectScriptContext.GetSharedData( ctx ), GetAllBlackboardDefs().EffectSharedData.radius, effectRange );
		effectRange += m_tollerance;
		EffectData.GetVector( EffectScriptContext.GetSharedData( ctx ), GetAllBlackboardDefs().EffectSharedData.position, sourcePos );
		distance = Vector4.Distance( sourcePos, targetPos );
		if( distance <= effectRange )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

