import java.awt.Point;
import java.awt.geom.Point2D;

public class EnhancedAimAssist {
    private Point playerPosition;
    private Point targetPosition;
    private double bulletSpeed;

    public EnhancedAimAssist(Point playerPosition, Point targetPosition, double bulletSpeed) {
        this.playerPosition = playerPosition;
        this.targetPosition = targetPosition;
        this.bulletSpeed = bulletSpeed;
    }

    public double calculateAngle() {
        double dx = targetPosition.x - playerPosition.x;
        double dy = targetPosition.y - playerPosition.y;
        double distance = Point2D.distance(playerPosition.x, playerPosition.y, targetPosition.x, targetPosition.y);
        double timeToTarget = distance / bulletSpeed;

        // 考虑目标的移动，预测目标位置
        double predictedTargetX = targetPosition.x + (targetPosition.x - playerPosition.x) * timeToTarget;
        double predictedTargetY = targetPosition.y + (targetPosition.y - playerPosition.y) * timeToTarget;

        double predicteddx = predictedTargetX - playerPosition.x;
        double predicteddy = predictedTargetY - playerPosition.y;
        return Math.atan2(predicteddy, predicteddx);
    }

    public static void main(String[] args) {
        // 示例用法
        Point playerPosition = new Point(0, 0);
        Point targetPosition = new Point(100, 100);
        double bulletSpeed = 5.0;

        EnhancedAimAssist aimAssist = new EnhancedAimAssist(playerPosition, targetPosition, bulletSpeed);
        double angle = aimAssist.calculateAngle();

        System.out.println("The calculated angle for enhanced aim assist is: " + Math.toDegrees(angle) + " degrees");
    }
}