public static IEnumerable <Vector3> PredictMyRoute(Unit target, int time, Vector3 targetPosition) { var maxDistance = time / 1000.0f * target.MovementSpeed + target.HullRadius; bool completed; var path = Pathfinding.CalculateStaticLongPath( target.NetworkPosition, targetPosition, target.MovementSpeed * time * 4, true, out completed).ToList(); return(!completed ? new List <Vector3> { targetPosition } : path); }
public static Vector3 PredictPosition(Unit target, int time, PredictionType type = PredictionType.GridNav) { var maxDistance = (time / 1000.0f) * target.MovementSpeed; var inFront = Ensage.Common.Prediction.InFront(target, maxDistance); if (time <= 500) { return(inFront); } bool completed; var path = Pathfinding.CalculateStaticLongPath( target.NetworkPosition, inFront * 1.5f, target.MovementSpeed * time * 4, true, out completed).ToList(); if (!completed) { return(inFront); } var distance = 0.0f; var lastNode = Vector3.Zero; for (var i = 0; i < path.Count; ++i) { var len = i == 0 ? (path[i] - target.NetworkPosition).Length() : (path[i] - path[i - 1]).Length(); lastNode = path[i]; if (maxDistance < len + distance) { break; } distance += len; } var dir = lastNode.Normalized(); dir *= maxDistance - distance; return(lastNode + dir); }