private Vector2 GetArrowScreenBorderPosition(GraphicsContext graphicsContext, Vector2 entityPosition) { Vector2 direction = entityPosition - CCamera2D.Active.Position; Ray2D ray = new Ray2D(graphicsContext.ScreenSize / 2f, Vector2.Normalize(direction)); // ray from screen center to the direction of the drop if (!Check.IsValid(ray)) { return -Vector2.One * 10000; // invalid number } RectangleF screenArea = new RectangleF(graphicsContext.ScreenArea).Inflate(-16); Vector2 hitPosition; if (ray.Intersects(screenArea.GetSideSegment(Direction2D.Left), out hitPosition) || ray.Intersects(screenArea.GetSideSegment(Direction2D.Right), out hitPosition) || ray.Intersects(screenArea.GetSideSegment(Direction2D.Up), out hitPosition) || ray.Intersects(screenArea.GetSideSegment(Direction2D.Down), out hitPosition)) { return hitPosition; } throw new InvalidOperationException(""); }