10 - A cone of vision
cast(originX, originY, directionX, directionY, maxDistance, options)
Fired once per angle across the cone, it gives the shape the guard can actually see: the polygon its endpoints trace, closed back on the guard itself.
lineOfSight(startX, startY, endX, endY, options)
Answers whether anything stands between two points. Being seen is two separate questions, and a guard that asks only the first one sees through walls.
- Is the corner inside the angle, and within range? That is arithmetic, not a cast.
- Is the line to it clear? That is the cast.
The rectangle is tested at its four corners and its center. One point is enough to be spotted, which is why the cone turns red while most of the box is still hidden.