set prop default state

This commit is contained in:
amizing25 2024-04-10 00:49:17 +07:00
parent a56d3e768f
commit 46ae86cacf
2 changed files with 22 additions and 17 deletions

View File

@ -1,6 +1,5 @@
use lazy_static::lazy_static; use lazy_static::lazy_static;
use prost::Message; use prost::Message;
use rand::Rng;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use crate::{ use crate::{
@ -275,26 +274,21 @@ async fn load_scene(
}), }),
}; };
let mut entities = 0; let mut entity_id = 10;
// LOAD PROPS // LOAD PROPS
for prop in level.props { for prop in level.props {
if entities >= 500 { entity_id += 1;
continue;
}
entities += 1;
let mut rng = rand::thread_rng();
let prop_state = if prop.anchor_id.unwrap_or_default() > 0 { let prop_state = if prop.anchor_id.unwrap_or_default() > 0 {
8 8
} else { } else {
prop.prop_state_list.first().unwrap().clone() as u32 prop.state as u32
}; };
let info = SceneEntityInfo { let info = SceneEntityInfo {
inst_id: prop.id as u32, inst_id: prop.id as u32,
group_id: prop.group_id, group_id: prop.group_id,
entity_id: rng.gen(), entity_id,
motion: Some(MotionInfo { motion: Some(MotionInfo {
// pos // pos
aomilajjmii: Some(Vector { aomilajjmii: Some(Vector {
@ -336,17 +330,12 @@ async fn load_scene(
// LOAD MONSTERS // LOAD MONSTERS
for monster in level.monsters { for monster in level.monsters {
if entities >= 500 { entity_id += 1;
continue;
}
entities += 1;
let mut rng = rand::thread_rng();
let info = SceneEntityInfo { let info = SceneEntityInfo {
inst_id: monster.id as u32, inst_id: monster.id as u32,
group_id: monster.group_id, group_id: monster.group_id,
entity_id: rng.gen(), entity_id,
motion: Some(MotionInfo { motion: Some(MotionInfo {
// pos // pos
aomilajjmii: Some(Vector { aomilajjmii: Some(Vector {

View File

@ -63,10 +63,20 @@ pub struct LevelProp {
#[serde(rename = "MappingInfoID")] #[serde(rename = "MappingInfoID")]
pub mapping_info_id: Option<u32>, pub mapping_info_id: Option<u32>,
#[serde(default)]
#[serde(rename = "State")]
pub state: PropState,
#[serde(default)] #[serde(default)]
pub prop_state_list: Vec<PropState>, pub prop_state_list: Vec<PropState>,
#[serde(default)] #[serde(default)]
pub group_id: u32, pub group_id: u32,
#[serde(rename = "IsDelete")]
#[serde(default)]
pub is_delete: bool,
#[serde(rename = "IsClientOnly")]
#[serde(default)]
pub client_only: bool,
} }
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
@ -250,6 +260,12 @@ pub enum PropState {
CustomState09 = 109, CustomState09 = 109,
} }
impl Default for PropState {
fn default() -> Self {
PropState::Closed
}
}
pub type IntMap<T> = HashMap<u32, T>; pub type IntMap<T> = HashMap<u32, T>;
pub type StringMap<T> = HashMap<String, T>; pub type StringMap<T> = HashMap<String, T>;