use std::rc::Rc;

use data::math_def::Vector3;
use proto::{AbilitySyncStateInfo, MpLevelEntityInfo};

use crate::{entity::Entity, player::Player};

#[derive(Default)]
pub struct MPLevelEntity {
    pos: Vector3,
    rot: Vector3,
    id: u32,
    authority_peer_id: u32,
}

impl MPLevelEntity {
    pub fn set_authority_peer_id(&mut self, id: u32) {
        self.authority_peer_id = id;
    }

    pub fn to_client(&self, entity_info: &mut MpLevelEntityInfo) {
        entity_info.ability_info = Some(AbilitySyncStateInfo::default());
        entity_info.authority_peer_id = self.authority_peer_id;
        entity_info.entity_id = self.id;
    }
}

impl Entity for MPLevelEntity {
    fn get_entity_type(&self) -> proto::ProtEntityType {
        proto::ProtEntityType::ProtEntityMpLevel
    }

    fn get_group_id(&self) -> u32 {
        0
    }

    fn entity_id(&self) -> u32 {
        self.id
    }

    fn set_entity_id(&mut self, id: u32) {
        self.id = id;
    }

    fn position(&self) -> &data::math_def::Vector3 {
        &self.pos
    }

    fn rotation(&self) -> &data::math_def::Vector3 {
        &self.rot
    }

    fn set_position(&mut self, pos: data::math_def::Vector3) {
        self.pos = pos;
    }

    fn set_rotation(&mut self, rot: data::math_def::Vector3) {
        self.rot = rot;
    }

    fn get_owner_player(&self) -> Option<Rc<Player>> {
        None
    }
}
