public float GetClosestPointAtAngleInRange(Vector2 target) { PhysicalObject parent = ((PhysicalObject)(this.Parent)); if (parent != null) { float worldDirection = Vector2Utils.Vector2Angle(target - this.WorldPosition()); float targetAngleRelativeToParent = worldDirection - parent.WorldDirection() - this.DirectionRelativeToParent; return(MathUtils.ClosestInRange(Vector2Utils.MinimizeMagnitude(targetAngleRelativeToParent), this.Range, -this.Range)); } else { return(0); } }