From 87781530dead7478c827ea974b6c8ae4ac0b9c23 Mon Sep 17 00:00:00 2001 From: Nobody Date: Tue, 5 Apr 2022 22:32:04 +0500 Subject: [PATCH] Now load info about scenes from config --- src/jsonmanager/json_manager.rs | 7 +++++++ src/jsonmanager/mod.rs | 1 + src/jsonmanager/scene.rs | 20 ++++++++++++++++++++ src/server/game_world.rs | 4 +++- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/jsonmanager/scene.rs diff --git a/src/jsonmanager/json_manager.rs b/src/jsonmanager/json_manager.rs index dc16953..a5fe6db 100644 --- a/src/jsonmanager/json_manager.rs +++ b/src/jsonmanager/json_manager.rs @@ -10,6 +10,7 @@ use rand::{seq::IteratorRandom, thread_rng}; use crate::jsonmanager::gather::Gather; use crate::jsonmanager::material::Material; use crate::jsonmanager::reliquary::{Reliquary, ReliquaryAffix, ReliquaryMainProp}; +use crate::jsonmanager::scene::Scene; use crate::jsonmanager::shop_goods::ShopGoods; use crate::jsonmanager::shop_rotate::ShopRotate; use crate::jsonmanager::teleport_point::TeleportPoint; @@ -57,6 +58,8 @@ pub struct JsonManager { pub materials: HashMap, pub teleport_points: HashMap>, + + pub scenes: HashMap, } impl std::fmt::Debug for JsonManager { // TODO: fucking hack! @@ -89,6 +92,8 @@ impl JsonManager { let teleport_points: Vec = reader.read_json_list_3rdparty("TeleportPoints"); + let scenes: Vec = reader.read_json_list_game("Scene"); + return JsonManager { reader: reader, avatar_skill_depot: asd.into_iter().map(|a| (a.id, a)).collect(), @@ -115,6 +120,8 @@ impl JsonManager { teleport_points: group_nonconsec_by(teleport_points, |tp| tp.scene_id).into_iter() .map(|(scene_id, tp_list)| (scene_id, tp_list.into_iter().map(|tp| (tp.point_id, tp)).collect())) .collect(), + + scenes: scenes.into_iter().map(|s| (s.id, s)).collect(), }; } diff --git a/src/jsonmanager/mod.rs b/src/jsonmanager/mod.rs index 0a03f33..64ed55d 100644 --- a/src/jsonmanager/mod.rs +++ b/src/jsonmanager/mod.rs @@ -14,6 +14,7 @@ mod weapon; mod reliquary; mod material; mod teleport_point; +mod scene; pub use entity_curve::{CurveInfo,EntityCurve}; pub use shop_goods::ShopGoods; \ No newline at end of file diff --git a/src/jsonmanager/scene.rs b/src/jsonmanager/scene.rs new file mode 100644 index 0000000..90a5ebb --- /dev/null +++ b/src/jsonmanager/scene.rs @@ -0,0 +1,20 @@ +use serde::{Serialize, Deserialize}; + +#[derive(Deserialize, Clone)] +#[serde(rename_all="PascalCase")] +pub struct Scene { + pub id: u32, + pub r#type: String, // TODO: that's an enum! + pub script_data: String, + pub override_default_profile: String, + pub level_entity_config: String, + #[serde(default)] + pub max_specified_avatar_num: u32, + pub specified_avatar_list: Vec, + pub comment: String, + + #[serde(default)] + pub ignore_nav_mesh: bool, + + pub safe_point: Option, +} \ No newline at end of file diff --git a/src/server/game_world.rs b/src/server/game_world.rs index 0f65679..7453928 100644 --- a/src/server/game_world.rs +++ b/src/server/game_world.rs @@ -172,8 +172,10 @@ impl GameWorld { scene_time: 9000, }); + let level_config = &self.jm.scenes[¤t_scene_info.scene_id].level_entity_config; + build_and_send!(self, user_id, metadata, SceneDataNotify { - level_config_name_list: vec!["Level_BigWorld".to_string()], // TODO + level_config_name_list: vec![level_config.to_string()], // TODO: maybe there's more? }); build_and_send!(self, user_id, metadata, HostPlayerNotify {