private static bool GoThroughWall(Vector2 pos1, Vector2 pos2)
{
if (Wall == null)
{
return false;
}
var wallWidth = 300 + 50 * Convert.ToInt32(Wall.Name.Substring(Wall.Name.Length - 6, 1));
var wallDirection = (Wall.Position.To2D() - wallCastedPos).Normalized().Perpendicular();
var wallStart = Wall.Position.To2D() + wallWidth / 2f * wallDirection;
var wallEnd = wallStart - wallWidth * wallDirection;
var wallPolygon = new Geometry.Polygon.Rectangle(wallStart, wallEnd, 75);
var intersections = new List<Vector2>();
for (var i = 0; i < wallPolygon.Points.Count; i++)
{
var inter =
wallPolygon.Points[i].Intersection(
wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0],
pos1,
pos2);
if (inter.Intersects)
{
intersections.Add(inter.Point);
}
}
return intersections.Any();
}