#include "CameraComponent.h"
#include "../Entitys/Object.h"

CameraComponent::CameraComponent(Object* owner) : Component(owner) {}

std::string CameraComponent::GetName() const {
    return "CameraComponent";
}

void CameraComponent::Save(YAML::Emitter& out) const {
    out << YAML::BeginMap;
    out << YAML::Key << "type" << YAML::Value << GetName();
    out << YAML::Key << "fov" << YAML::Value << fov;
    out << YAML::Key << "aspect" << YAML::Value << aspect;
    out << YAML::Key << "zoom" << YAML::Value << zoom;
    out << YAML::Key << "primary" << YAML::Value << primary;


    out << YAML::EndMap;
}

void CameraComponent::Load(const YAML::Node& node) {
    if (node["fov"]) fov = node["fov"].as<float>();
    if (node["aspect"]) aspect = node["aspect"].as<float>();
    if (node["zoom"]) zoom = node["zoom"].as<float>();
    if (node["primary"]) primary = node["primary"].as<bool>();


}
