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

View File

@ -63,10 +63,20 @@ pub struct LevelProp {
#[serde(rename = "MappingInfoID")]
pub mapping_info_id: Option<u32>,
#[serde(default)]
#[serde(rename = "State")]
pub state: PropState,
#[serde(default)]
pub prop_state_list: Vec<PropState>,
#[serde(default)]
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)]
@ -250,6 +260,12 @@ pub enum PropState {
CustomState09 = 109,
}
impl Default for PropState {
fn default() -> Self {
PropState::Closed
}
}
pub type IntMap<T> = HashMap<u32, T>;
pub type StringMap<T> = HashMap<String, T>;