JaneDoe-ZS/nap_gameserver/src/logic/role/role_model.rs
2024-07-20 15:59:36 +03:00

34 lines
803 B
Rust

use data::tables;
use proto::RoleModelBin;
use crate::logic::role::Avatar;
pub struct RoleModel {
pub avatar_list: Vec<Avatar>,
}
impl Default for RoleModel {
fn default() -> Self {
Self {
avatar_list: tables::avatar_base_template_tb::iter()
.map(|a| a.id)
.filter(|tmpl_id| *tmpl_id < 2000)
.map(|tmpl_id| Avatar::new(tmpl_id))
.collect(),
}
}
}
impl RoleModel {
pub fn from_bin(bin: RoleModelBin) -> Self {
Self {
avatar_list: bin.avatar_list.into_iter().map(Avatar::from_bin).collect(),
}
}
pub fn to_bin(&self) -> RoleModelBin {
RoleModelBin {
avatar_list: self.avatar_list.iter().map(Avatar::to_bin).collect(),
}
}
}