use godot::{classes::SpriteFrames, prelude::*};

#[derive(GodotConvert, Export, Var, Default, Clone, PartialEq, Eq, Debug, Hash)]
#[godot(via=GString)]
pub enum HazardType {
    #[default]
    None,
    GymBro,
    LoosePlate,
    PhoneDistraction,
    Manager,
}

#[derive(GodotClass)]
#[class(base=Resource)]
pub struct HazardDef {
    #[export]
    pub hazard_type: HazardType,
    #[export]
    pub display_name: GString,
    #[export]
    pub animations: Option<Gd<SpriteFrames>>,
    #[export]
    pub idle_anim_name: GString,
    #[export]
    pub walk_anim_name: GString,
    #[export]
    pub time_to_fail: f32,
    #[export]
    pub spawn_weight: f32,
    #[export]
    pub min_focus_to_spawn: f32,
    #[export]
    pub clicks_to_resolve: i32,

    base: Base<Resource>,
}

#[godot_api]
impl IResource for HazardDef {
    fn init(base: Base<Resource>) -> Self {
        Self {
            hazard_type: HazardType::None,
            display_name: "Unnamed Hazard".into(),
            animations: None,
            idle_anim_name: "idle".into(),
            walk_anim_name: "walk".into(),
            time_to_fail: 5.0,
            spawn_weight: 1.0,
            min_focus_to_spawn: 0.0,
            clicks_to_resolve: 1,
            base,
        }
    }
}
