using Godot;

namespace BITKit;

/// <summary>
/// 虚拟相机接口定义
/// </summary>
public interface IVirtualCamera:IActivable
{
    /// <summary>
    /// 相机的FOV
    /// </summary>
    int FOV { get; }
    /// <summary>
    /// 相机是否已启用
    /// </summary>
    bool IsEnabled { get; }
    /// <summary>
    /// 相机坐标
    /// </summary>
    Vector3 Position { get; }
    /// <summary>
    /// 相机旋转
    /// </summary>
    Quaternion Rotation { get; }
}
/// <summary>
/// 基于Node3D的包括基础功能的虚拟相机
/// </summary>
public partial class VirtualCamera : Node3D, IVirtualCamera
{
    [Export] private int fov;
    [Export] private bool isEnabled;
    public int FOV => fov;

    public bool IsEnabled => isEnabled;

    Vector3 IVirtualCamera.Position => GlobalPosition;
    Quaternion IVirtualCamera.Rotation => Quaternion.FromEuler(GlobalRotation);

    public void SetActive(bool active)
    {
        isEnabled = active;
    }

    public override void _Ready()
    {
        CameraService.Register(this);
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            CameraService.UnRegister(this);
        }
    }
}