public static bool IsPointInMobVisionCone( Mob mob, Point3d point) { MobType mobType = mob.MobType; Vector2d mobToPoint = (point - mob.Position).ToVector2d(); Vector2d facingVector = MathConstants.GetUnitVectorForAngle(mob.Angle); float cosHalfAngle = (float)Math.Cos(mob.MobType.VisionCone.GetHalfAngle()); float cosAngleToProp = facingVector.Dot(mobToPoint); float pointDistanceSquared = Point2d.DistanceSquared(point, mob.Position); float minVisionCircleDistanceSquared = WorldConstants.ROOM_TILE_SIZE * WorldConstants.ROOM_TILE_SIZE; float minVisionConeDistanceSquared = (float)(mobType.VisionCone.distance * mobType.VisionCone.distance); bool isInVisionCone = (pointDistanceSquared <= minVisionCircleDistanceSquared) || ((cosAngleToProp > cosHalfAngle) && (pointDistanceSquared <= minVisionConeDistanceSquared)); return(isInVisionCone); }