importonly class EnteredPathWithDoors extends Event
{
}

importonly class FinishedPathWithDoors extends Event
{
}

import enum worldNavigationRequestStatus
{
	OK,
	InvalidStartingPosition,
	InvalidEndPosition,
	OtherError,
}

import enum NavGenAgentSize
{
	Human,
}

importonly class NavigationObstacle extends IScriptable
{
}

importonly class NavigationFindWallResult extends IScriptable
{
	import var hitPosition : Vector4;
	import var isHit : Bool;
	import var status : worldNavigationRequestStatus;
}

importonly struct NavigationFindPointResult
{
	import var status : worldNavigationRequestStatus;
	import var point : Vector4;
}

importonly class NavigationCostModCircle extends IScriptable
{
	import var pos : Vector4;
	import var range : Float;
	import var cost : Float;
}

importonly class NavigationPath extends IScriptable
{
	import var path : array< Vector4 >;

	public import function CalculateLength() : Float;
}

import class NavigationSystem extends IScriptable
{
	public import const function CalculatePathOnlyHumanNavmesh( startPoint : Vector4, endPoint : Vector4, agentSize : NavGenAgentSize, findPointTolerance : Float, optional costModCircle : NavigationCostModCircle ) : NavigationPath;
	public import function FindWallInLineOnlyHumanNavmesh( startPoint : Vector4, endPoint : Vector4, agentSize : NavGenAgentSize, findPointTolerance : Float ) : NavigationFindWallResult;
	public import const function FindPointInSphereOnlyHumanNavmesh( center : Vector4, radius : Float, agentSize : NavGenAgentSize, heightDetail : Bool ) : NavigationFindPointResult;
	public import const function FindPursuitPoint( playerPos : Vector4, pos : Vector4, dir : Vector4, radius : Float, navVisCheck : Bool, agentSize : NavGenAgentSize, out destination : Vector4, out isDestinationFallback : Bool ) : Bool;
	public import const function FindPursuitPointRange( playerPos : Vector4, pos : Vector4, dir : Vector4, radiusMin : Float, radiusMax : Float, navVisCheck : Bool, agentSize : NavGenAgentSize, out destination : Vector4, out isDestinationFallback : Bool ) : Bool;
	public import const function FindPursuitPointsRange( playerPos : Vector4, pos : Vector4, dir : Vector4, radiusMin : Float, radiusMax : Float, count : Int32, navVisCheck : Bool, agentSize : NavGenAgentSize, out results : array< Vector4 >, out fallbackResults : array< Vector4 > ) : Bool;
	public import const function FindNavmeshPointAwayFromReferencePoint( pos : Vector4, refPos : Vector4, distance : Float, agentSize : NavGenAgentSize, out destination : Vector4, optional distanceTolerance : Float, optional angleTolerance : Float ) : Bool;
	public import const function IsNavmeshStreamedInLocation( origin : Vector4, findPointTolerance : Float, optional allowedMask : Uint16, optional blockedMask : Uint16 ) : Bool;
	public import function AddObstacle( position : Vector4, radius : Float, height : Float, agentSize : NavGenAgentSize ) : NavigationObstacle;
	public import function RemoveObstacle( obstacle : NavigationObstacle );

	public const function GetNearestNavmeshPointBelowOnlyHumanNavmesh( origin : Vector4, querySphereRadius : Float, numberOfSpheres : Int32 ) : Vector4
	{
		var i : Int32;
		var pointResults : NavigationFindPointResult;
		var point : Vector4;
		for( i = 0; i < numberOfSpheres; i += 1 )
		{
			pointResults = FindPointInSphereOnlyHumanNavmesh( origin, querySphereRadius, NavGenAgentSize.Human, false );
			if( pointResults.status != worldNavigationRequestStatus.OK )
			{
				origin.Z -= querySphereRadius;
				continue;
			}
			else
			{
				point = pointResults.point;
				break;
			}
		}
		return point;
	}

	public const function IsOnGround( const target : GameObject, optional queryLength : Float ) : Bool
	{
		var startingPoint : Vector4;
		var geometryDescription : GeometryDescriptionQuery;
		var staticQueryFilter : QueryFilter;
		var geometryDescriptionResult : GeometryDescriptionResult;
		if( queryLength == 0.0 )
		{
			queryLength = 0.2;
		}
		startingPoint = target.GetWorldPosition() + ( target.GetWorldUp() * 0.1 );
		QueryFilter.AddGroup( staticQueryFilter, 'Static' );
		geometryDescription = new GeometryDescriptionQuery;
		geometryDescription.refPosition = startingPoint;
		geometryDescription.refDirection = Vector4( 0.0, 0.0, -1.0, 0.0 );
		geometryDescription.filter = staticQueryFilter;
		geometryDescription.primitiveDimension = Vector4( 0.1, 0.1, queryLength, 0.0 );
		geometryDescriptionResult = GameInstance.GetSpatialQueriesSystem( target.GetGame() ).GetGeometryDescriptionSystem().QueryExtents( geometryDescription );
		return geometryDescriptionResult.queryStatus == worldgeometryDescriptionQueryStatus.OK;
	}

}

