#ifndef PINGPONG_PADDLE_H
#define PINGPONG_PADDLE_H

#include <godot_cpp/classes/character_body2d.hpp>

namespace godot {

// ═══════════════════════════════════════════════════════
// 视觉常量 — 以后替换为 Sprite2D 时删除本段
// (颜色值定义在 pingpong_paddle.cpp 中)
// ═══════════════════════════════════════════════════════
static constexpr float PADDLE_WIDTH = 18.0f;
static constexpr float PADDLE_HEIGHT = 100.0f;
static constexpr float PADDLE_CORNER_RADIUS = 6.0f;

// AI 参数
static constexpr float AI_SPEED_FACTOR = 0.85f;
static constexpr float AI_REACTION_DELAY_MIN = 3.0f;
static constexpr float AI_REACTION_DELAY_MAX = 10.0f;
static constexpr float AI_TRACKING_NOISE = 30.0f;

class PingPongPaddle : public CharacterBody2D {
    GDCLASS(PingPongPaddle, CharacterBody2D)

private:
    float speed = 350.0f;
    bool is_player = true;
    NodePath ball_path;
    float half_height = PADDLE_HEIGHT / 2.0f + 10.0f;

    // AI 内部状态
    float ai_reaction_counter = 0.0f;
    float ai_target_y = 0.0f;

protected:
    static void _bind_methods();

public:
    PingPongPaddle();
    ~PingPongPaddle();

    void _physics_process(double delta) override;
    void _draw() override;

    // 属性 getter/setter
    void set_speed(float p_speed);
    float get_speed() const;

    void set_is_player(bool p_is_player);
    bool get_is_player() const;

    void set_ball_path(const NodePath &p_path);
    NodePath get_ball_path() const;
};

}

#endif // PINGPONG_PADDLE_H
