2025-05-07 20:23:22 -04:00
|
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
|
|
|
#[sea_orm(table_name = "garages")]
|
|
|
|
|
pub struct Model {
|
|
|
|
|
#[sea_orm(primary_key)]
|
2025-06-06 19:03:08 -04:00
|
|
|
pub id: i32,
|
|
|
|
|
pub user_id: i32,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub creation_time: i64, // seconds since unix epoch
|
2025-06-06 19:03:08 -04:00
|
|
|
pub slot: i32,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub name: String,
|
2025-06-06 19:03:08 -04:00
|
|
|
pub crf_id: Option<i32>,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub was_rated: bool,
|
|
|
|
|
pub movement_categories: String, // csv?
|
|
|
|
|
pub uuid: i64,
|
2025-06-06 19:03:08 -04:00
|
|
|
pub thumbnail_version: i32,
|
|
|
|
|
pub total_robot_cpu: i32,
|
|
|
|
|
pub total_cosmetic_cpu: i32,
|
|
|
|
|
pub total_robot_ranking: i32,
|
|
|
|
|
pub bay_cpu: i32,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub tutorial_robot: bool,
|
2025-06-06 19:03:08 -04:00
|
|
|
pub starter_robot_index: Option<i32>,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub control_type: ControlType,
|
2025-05-26 21:30:28 -04:00
|
|
|
// control options
|
2025-05-07 20:23:22 -04:00
|
|
|
pub vertical_strafing: bool,
|
|
|
|
|
pub sideways_driving: bool,
|
|
|
|
|
pub tracks_turn_on_spot: bool,
|
2025-05-26 21:30:28 -04:00
|
|
|
// end control options
|
2025-06-06 19:03:08 -04:00
|
|
|
pub mastery_level: i32,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub bay_skin_id: String,
|
2025-05-26 21:30:28 -04:00
|
|
|
pub death_animation_id: String,
|
|
|
|
|
pub spawn_animation_id: String,
|
2025-05-07 20:23:22 -04:00
|
|
|
pub weapon_order: String, // csv?
|
|
|
|
|
pub robot_data: Vec<u8>,
|
|
|
|
|
pub colour_data: Vec<u8>,
|
|
|
|
|
pub selected: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Model {
|
|
|
|
|
pub fn cube_count(&self) -> u32 {
|
|
|
|
|
if self.robot_data.len() >= 4 {
|
|
|
|
|
u32::from_le_bytes([self.robot_data[0], self.robot_data[1], self.robot_data[2], self.robot_data[3]])
|
|
|
|
|
} else {
|
|
|
|
|
0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
|
|
|
pub enum Relation {
|
|
|
|
|
#[sea_orm(
|
|
|
|
|
belongs_to = "super::user::Entity",
|
|
|
|
|
from = "Column::UserId",
|
|
|
|
|
to = "super::user::Column::Id"
|
|
|
|
|
)]
|
|
|
|
|
User,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Related<super::user::Entity> for Entity {
|
|
|
|
|
fn to() -> RelationDef {
|
|
|
|
|
Relation::User.def()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
|
|
|
|
2025-06-06 19:03:08 -04:00
|
|
|
#[repr(i32)]
|
2025-05-07 20:23:22 -04:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
|
2025-06-06 19:03:08 -04:00
|
|
|
#[sea_orm(rs_type = "i32", db_type = "Integer")]
|
2025-05-07 20:23:22 -04:00
|
|
|
pub enum ControlType {
|
|
|
|
|
Camera = 0,
|
|
|
|
|
Keyboard = 1,
|
|
|
|
|
Count = 2,
|
|
|
|
|
}
|