use codegridfx::Module;
use num_traits::zero;
use rusterix::Map;
use theframework::prelude::*;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Character {
pub id: Uuid,
pub name: String,
pub map: Map,
#[serde(default)]
pub module: Module,
pub source: String,
#[serde(default)]
pub source_debug: String,
#[serde(default)]
pub data: String,
#[serde(default)]
pub preview_rigging: String,
pub position: Vec3<f32>,
#[serde(default = "default_orientation")]
pub orientation: Vec2<f32>,
pub character_id: Uuid,
}
impl Default for Character {
fn default() -> Self {
Self::new()
}
}
impl Character {
pub fn new() -> Self {
Self {
id: Uuid::new_v4(),
name: "NewCharacter".to_string(),
module: Module::as_type(codegridfx::ModuleType::CharacterTemplate),
map: Map::default(),
source: String::new(),
source_debug: String::new(),
data: String::new(),
preview_rigging: String::new(),
position: zero(),
orientation: default_orientation(),
character_id: Uuid::new_v4(),
}
}
}
fn default_orientation() -> Vec2<f32> {
Vec2::new(1.0, 0.0)
}