From d93c61cc921b592722081e2eea2b143005df10e3 Mon Sep 17 00:00:00 2001 From: xeon Date: Mon, 16 Sep 2024 03:09:26 +0300 Subject: [PATCH] Implement explore tools and some logic adjustments --- assets/logic/json/ExploreTools.json | 246 ++++++++++++++++++ .../logic/components/{weapon.rs => equip.rs} | 10 +- game-server/src/logic/components/mod.rs | 6 +- .../src/logic/components/vision_skill.rs | 23 ++ game-server/src/logic/ecs/component.rs | 3 +- game-server/src/logic/handler/misc.rs | 11 + game-server/src/logic/handler/mod.rs | 11 + game-server/src/logic/handler/scene.rs | 3 +- game-server/src/logic/handler/skill.rs | 32 +++ game-server/src/logic/player/explore_tools.rs | 76 ++++++ game-server/src/logic/player/mod.rs | 36 ++- game-server/src/logic/player/player_func.rs | 4 + game-server/src/logic/role/mod.rs | 8 +- game-server/src/logic/thread_mgr.rs | 17 +- game-server/src/logic/utils/world_util.rs | 11 +- shorekeeper-data/src/explore_tools.rs | 17 ++ shorekeeper-data/src/lib.rs | 1 + shorekeeper-protocol/proto/data.proto | 7 + 18 files changed, 492 insertions(+), 30 deletions(-) create mode 100644 assets/logic/json/ExploreTools.json rename game-server/src/logic/components/{weapon.rs => equip.rs} (89%) create mode 100644 game-server/src/logic/components/vision_skill.rs create mode 100644 game-server/src/logic/handler/misc.rs create mode 100644 game-server/src/logic/handler/skill.rs create mode 100644 game-server/src/logic/player/explore_tools.rs create mode 100644 shorekeeper-data/src/explore_tools.rs diff --git a/assets/logic/json/ExploreTools.json b/assets/logic/json/ExploreTools.json new file mode 100644 index 0000000..12b5a8e --- /dev/null +++ b/assets/logic/json/ExploreTools.json @@ -0,0 +1,246 @@ +[ +{ + "PhantomSkillId": 1004, + "Name": "ExploreTools_1004_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1004_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT3.SP_IconT3", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT3.SP_IconT3", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT3.SP_IconT3", + "SortId": 3, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1001, + "Name": "ExploreTools_1001_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1001_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT6.SP_IconT6", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT6.SP_IconT6", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT6.SP_IconT6", + "SortId": 1, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1003, + "Name": "ExploreTools_1003_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1003_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT1.SP_IconT1", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT1.SP_IconT1", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT1.SP_IconT1", + "SortId": 4, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1005, + "Name": "ExploreTools_1005_Name", + "SkillType": 2, + "CurrentSkillInfo": "ExploreTools_1005_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT2.SP_IconT2", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT2.SP_IconT2", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT2.SP_IconT2", + "SortId": 5, + "AutoFill": false, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1006, + "Name": "ExploreTools_1006_Name", + "SkillType": 2, + "CurrentSkillInfo": "ExploreTools_1006_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT5.SP_IconT5", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT5.SP_IconT5", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT5.SP_IconT5", + "SortId": 6, + "AutoFill": false, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1007, + "Name": "ExploreTools_1007_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1007_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT29.SP_IconT29", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT29.SP_IconT29", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT29.SP_IconT29", + "SortId": 7, + "AutoFill": false, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1009, + "Name": "ExploreTools_1009_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1009_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "SortId": 9, + "AutoFill": false, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": true, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 3001, + "Name": "ExploreTools_1009_Name", + "SkillType": 3, + "CurrentSkillInfo": "ExploreTools_1009_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "SortId": 10, + "AutoFill": false, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 3002, + "Name": "ExploreTools_1009_Name", + "SkillType": 3, + "CurrentSkillInfo": "ExploreTools_1009_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT9.SP_IconT9", + "BattleViewIcon": "/Game/Aki/UI/UIResources/UiSkillswitching/Atlas/SP_SkillswitchingItemNone.SP_SkillswitchingItemNone", + "SortId": 10, + "AutoFill": false, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1010, + "Name": "ExploreTools_1010_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1010_CurrentSkillInfo", + "HelpId": 30, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT30.SP_IconT30", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT30.SP_IconT30", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT30.SP_IconT30", + "SortId": 11, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": { + "10808": 1 + }, + "Authorization": {}, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1011, + "Name": "ExploreTools_1011_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1011_CurrentSkillInfo", + "HelpId": 28, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT32.SP_IconT32", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT32.SP_IconT32", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT32.SP_IconT32", + "SortId": 12, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": { + "10807": 1 + }, + "Authorization": { + "1": 10805, + "900": 10805 + }, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1012, + "Name": "ExploreTools_1012_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1012_CurrentSkillInfo", + "HelpId": 29, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT31.SP_IconT31", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT31.SP_IconT31", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT31.SP_IconT31", + "SortId": 13, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": { + "1": 10806, + "900": 10806 + }, + "SummonConfigId": 0 +}, +{ + "PhantomSkillId": 1013, + "Name": "ExploreTools_1013_Name", + "SkillType": 1, + "CurrentSkillInfo": "ExploreTools_1013_CurrentSkillInfo", + "HelpId": 0, + "Icon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT34.SP_IconT34", + "BackGround": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT34.SP_IconT34", + "BattleViewIcon": "/Game/Aki/UI/UIResources/Common/Atlas/SkillIcon/SkillIconNor/SP_IconT34.SP_IconT34", + "SortId": 14, + "AutoFill": true, + "ShowUnlock": false, + "SkillGroupId": 1, + "IsUseInPhantomTeam": false, + "Cost": {}, + "Authorization": {}, + "SummonConfigId": 24000022 +} +] diff --git a/game-server/src/logic/components/weapon.rs b/game-server/src/logic/components/equip.rs similarity index 89% rename from game-server/src/logic/components/weapon.rs rename to game-server/src/logic/components/equip.rs index a2e6031..d996b33 100644 --- a/game-server/src/logic/components/weapon.rs +++ b/game-server/src/logic/components/equip.rs @@ -1,19 +1,19 @@ -use shorekeeper_protocol::{EntityComponentPb, EquipComponentPb}; -use shorekeeper_protocol::entity_component_pb::ComponentPb; use crate::logic::ecs::component::Component; +use shorekeeper_protocol::entity_component_pb::ComponentPb; +use shorekeeper_protocol::{EntityComponentPb, EquipComponentPb}; -pub struct Weapon { +pub struct Equip { pub weapon_id: i32, pub weapon_breach_level: i32, } -impl Component for Weapon { +impl Component for Equip { fn set_pb_data(&self, pb: &mut shorekeeper_protocol::EntityPb) { pb.component_pbs.push(EntityComponentPb { component_pb: Some(ComponentPb::EquipComponent(EquipComponentPb { weapon_id: self.weapon_id, weapon_breach_level: self.weapon_breach_level, - })) + })), }) } } diff --git a/game-server/src/logic/components/mod.rs b/game-server/src/logic/components/mod.rs index d090d34..910823c 100644 --- a/game-server/src/logic/components/mod.rs +++ b/game-server/src/logic/components/mod.rs @@ -1,17 +1,19 @@ mod attribute; mod entity_config; +mod equip; mod movement; mod owner_player; mod player_entity_marker; mod position; mod visibility; -mod weapon; +mod vision_skill; pub use attribute::Attribute; pub use entity_config::EntityConfig; +pub use equip::Equip; pub use movement::Movement; pub use owner_player::OwnerPlayer; pub use player_entity_marker::PlayerEntityMarker; pub use position::Position; pub use visibility::Visibility; -pub use weapon::Weapon; +pub use vision_skill::VisionSkill; diff --git a/game-server/src/logic/components/vision_skill.rs b/game-server/src/logic/components/vision_skill.rs new file mode 100644 index 0000000..baa6b77 --- /dev/null +++ b/game-server/src/logic/components/vision_skill.rs @@ -0,0 +1,23 @@ +use shorekeeper_protocol::{ + entity_component_pb::ComponentPb, EntityComponentPb, VisionSkillComponentPb, + VisionSkillInformation, +}; + +use crate::logic::ecs::component::Component; + +pub struct VisionSkill { + pub skill_id: i32, +} + +impl Component for VisionSkill { + fn set_pb_data(&self, pb: &mut shorekeeper_protocol::EntityPb) { + pb.component_pbs.push(EntityComponentPb { + component_pb: Some(ComponentPb::VisionSkillComponent(VisionSkillComponentPb { + vision_skill_infos: vec![VisionSkillInformation { + skill_id: self.skill_id, + ..Default::default() + }], + })), + }) + } +} diff --git a/game-server/src/logic/ecs/component.rs b/game-server/src/logic/ecs/component.rs index a50c162..40491dc 100644 --- a/game-server/src/logic/ecs/component.rs +++ b/game-server/src/logic/ecs/component.rs @@ -30,7 +30,8 @@ impl_component_container! { Attribute; PlayerEntityMarker; Movement; - Weapon; + Equip; + VisionSkill; } pub trait Component { diff --git a/game-server/src/logic/handler/misc.rs b/game-server/src/logic/handler/misc.rs new file mode 100644 index 0000000..aec22b1 --- /dev/null +++ b/game-server/src/logic/handler/misc.rs @@ -0,0 +1,11 @@ +use shorekeeper_protocol::{IYa, InputSettingRequest, InputSettingResponse}; + +use crate::logic::player::Player; + +pub fn on_input_setting_request( + _: &Player, + _: InputSettingRequest, + response: &mut InputSettingResponse, +) { + response.i_ya = Some(IYa::default()); +} diff --git a/game-server/src/logic/handler/mod.rs b/game-server/src/logic/handler/mod.rs index 72ae68a..6c6e83a 100644 --- a/game-server/src/logic/handler/mod.rs +++ b/game-server/src/logic/handler/mod.rs @@ -1,5 +1,9 @@ +mod misc; mod scene; +mod skill; +pub use misc::*; pub use scene::*; +pub use skill::*; use shorekeeper_protocol::message::Message; @@ -59,10 +63,17 @@ macro_rules! handle_push { } handle_request! { + // Scene UpdateSceneDate; EntityActive; EntityOnLanded; CombatSendPack, combat_message; + + // Skill + VisionExploreSkillSet; + + // Misc + InputSetting; } handle_push! { diff --git a/game-server/src/logic/handler/scene.rs b/game-server/src/logic/handler/scene.rs index 827ae17..d7891aa 100644 --- a/game-server/src/logic/handler/scene.rs +++ b/game-server/src/logic/handler/scene.rs @@ -1,8 +1,8 @@ +use shorekeeper_protocol::combat_message::{CombatSendPackRequest, CombatSendPackResponse}; use shorekeeper_protocol::{ EntityActiveRequest, EntityActiveResponse, EntityOnLandedRequest, EntityOnLandedResponse, ErrorCode, MovePackagePush, UpdateSceneDateRequest, UpdateSceneDateResponse, }; -use shorekeeper_protocol::combat_message::{CombatSendPackRequest, CombatSendPackResponse}; use crate::{logic::ecs::component::ComponentContainer, logic::player::Player, query_components}; @@ -43,6 +43,7 @@ pub fn on_entity_active_request( response.pos = Some(position.0.get_position_protobuf()); response.rot = Some(position.0.get_rotation_protobuf()); } + response.component_pbs = Vec::new(); // not implemented response.error_code = ErrorCode::Success.into(); } diff --git a/game-server/src/logic/handler/skill.rs b/game-server/src/logic/handler/skill.rs new file mode 100644 index 0000000..a7c0689 --- /dev/null +++ b/game-server/src/logic/handler/skill.rs @@ -0,0 +1,32 @@ +use crate::logic::ecs::component::ComponentContainer; +use shorekeeper_protocol::{ + VisionExploreSkillSetRequest, VisionExploreSkillSetResponse, VisionSkillChangeNotify, + VisionSkillInformation, +}; + +use crate::{logic::player::Player, query_with}; + +pub fn on_vision_explore_skill_set_request( + player: &mut Player, + request: VisionExploreSkillSetRequest, + response: &mut VisionExploreSkillSetResponse, +) { + player.explore_tools.active_explore_skill = request.skill_id; + + let world = player.world.borrow(); + for (entity, owner, mut vision_skill) in query_with!(world, OwnerPlayer, VisionSkill) { + if owner.0 == player.basic_info.id { + vision_skill.skill_id = request.skill_id; + player.notify(VisionSkillChangeNotify { + entity_id: entity.into(), + vision_skill_infos: vec![VisionSkillInformation { + skill_id: request.skill_id, + ..Default::default() + }], + ..Default::default() + }) + } + } + + response.skill_id = request.skill_id; +} diff --git a/game-server/src/logic/player/explore_tools.rs b/game-server/src/logic/player/explore_tools.rs new file mode 100644 index 0000000..0b69013 --- /dev/null +++ b/game-server/src/logic/player/explore_tools.rs @@ -0,0 +1,76 @@ +use std::collections::HashSet; + +use shorekeeper_data::explore_tools_data; +use shorekeeper_protocol::{ + ExploreSkillRoulette, ExploreSkillRouletteUpdateNotify, ExploreToolAllNotify, + PlayerExploreToolsData, +}; + +type Roulette = [i32; 8]; + +pub struct ExploreTools { + pub unlocked_explore_skills: HashSet, + pub active_explore_skill: i32, + pub roulette: Roulette, +} + +impl ExploreTools { + pub fn build_save_data(&self) -> PlayerExploreToolsData { + PlayerExploreToolsData { + unlocked_skill_list: self.unlocked_explore_skills.iter().cloned().collect(), + active_skill_id: self.active_explore_skill, + roulette: self.roulette.iter().cloned().collect(), + } + } + + pub fn load_from_save(data: PlayerExploreToolsData) -> Self { + Self { + unlocked_explore_skills: data.unlocked_skill_list.into_iter().collect(), + active_explore_skill: data.active_skill_id, + roulette: data + .roulette + .try_into() + .unwrap_or_else(|_| Self::default_roulette()), + } + } + + pub fn build_explore_tool_all_notify(&self) -> ExploreToolAllNotify { + ExploreToolAllNotify { + skill_list: self.unlocked_explore_skills.iter().cloned().collect(), + explore_skill: self.active_explore_skill, + ..Default::default() + } + } + + pub fn build_roulette_update_notify(&self) -> ExploreSkillRouletteUpdateNotify { + ExploreSkillRouletteUpdateNotify { + roulette_info: vec![ExploreSkillRoulette { + skill_ids: self.roulette.iter().cloned().collect(), + extra_item_id: 0, + }], + } + } + + fn default_roulette() -> Roulette { + let mut roulette = [0i32; 8]; + explore_tools_data::iter() + .take(3) + .enumerate() + .for_each(|(i, e)| roulette[i] = e.phantom_skill_id); + + roulette + } +} + +impl Default for ExploreTools { + fn default() -> Self { + Self { + unlocked_explore_skills: explore_tools_data::iter() + .filter(|e| e.authorization.is_empty()) + .map(|e| e.phantom_skill_id) + .collect(), + active_explore_skill: 1001, + roulette: Self::default_roulette(), + } + } +} diff --git a/game-server/src/logic/player/mod.rs b/game-server/src/logic/player/mod.rs index 671b173..56dd969 100644 --- a/game-server/src/logic/player/mod.rs +++ b/game-server/src/logic/player/mod.rs @@ -2,11 +2,12 @@ use std::{cell::RefCell, collections::HashSet, rc::Rc, sync::Arc}; use basic_info::PlayerBasicInfo; use common::time_util; +use explore_tools::ExploreTools; use location::PlayerLocation; use player_func::PlayerFunc; use shorekeeper_protocol::{ - message::Message, PbGetRoleListNotify, PlayerBasicData, PlayerRoleData, PlayerSaveData, - ProtocolUnit, + message::Message, ItemPkgOpenNotify, PbGetRoleListNotify, PlayerBasicData, PlayerRoleData, + PlayerSaveData, ProtocolUnit, }; use crate::session::Session; @@ -17,6 +18,7 @@ use super::{ }; mod basic_info; +mod explore_tools; mod in_world_player; mod location; mod player_func; @@ -25,11 +27,14 @@ pub use in_world_player::InWorldPlayer; pub struct Player { session: Option>, + // Persistent pub basic_info: PlayerBasicInfo, pub role_list: Vec, pub formation_list: Vec, pub location: PlayerLocation, pub func: PlayerFunc, + pub explore_tools: ExploreTools, + // Runtime pub world: Rc>, pub last_save_time: u64, } @@ -43,7 +48,9 @@ impl Player { // we need shorekeeper // TODO: remove this part after implementing team switch if !self.role_list.iter().any(|r| r.role_id == 1505) { - self.role_list.push(Role::new(1505, Some(21050036))); + let mut shorekeeper = Role::new(1505); + shorekeeper.equip_weapon = 21050036; + self.role_list.push(shorekeeper); } self.formation_list.clear(); @@ -56,12 +63,19 @@ impl Player { // End shorekeeper hardcode part self.ensure_current_formation(); + self.ensure_basic_unlock_func(); } pub fn notify_general_data(&self) { self.notify(self.basic_info.build_notify()); self.notify(self.func.build_func_open_notify()); self.notify(self.build_role_list_notify()); + self.notify(self.explore_tools.build_explore_tool_all_notify()); + self.notify(self.explore_tools.build_roulette_update_notify()); + + self.notify(ItemPkgOpenNotify { + open_pkg: (0..8).collect(), + }); } fn on_first_enter(&mut self) { @@ -82,6 +96,13 @@ impl Player { self.location = PlayerLocation::default(); } + // Ensure basic functionality is unlocked + // Should be handled by quest progression, + // but as of right now, just unlock what we need + fn ensure_basic_unlock_func(&mut self) { + self.func.unlock(10026); // explore tools + } + fn ensure_current_formation(&mut self) { if self.formation_list.is_empty() { let role = &self.role_list[0]; @@ -162,6 +183,10 @@ impl Player { .func_data .map(PlayerFunc::load_from_save) .unwrap_or_default(), + explore_tools: save_data + .explore_tools_data + .map(ExploreTools::load_from_save) + .unwrap_or_default(), world: Rc::new(RefCell::new(World::new())), last_save_time: time_util::unix_timestamp(), } @@ -180,6 +205,7 @@ impl Player { }), location_data: Some(self.location.build_save_data()), func_data: Some(self.func.build_save_data()), + explore_tools_data: Some(self.explore_tools.build_save_data()), } } @@ -216,8 +242,8 @@ impl Player { fn create_main_character_role(name: String, sex: i32) -> Role { let mut role = match sex { - 0 => Role::new(Role::MAIN_CHARACTER_FEMALE_ID, None), - 1 => Role::new(Role::MAIN_CHARACTER_MALE_ID, None), + 0 => Role::new(Role::MAIN_CHARACTER_FEMALE_ID), + 1 => Role::new(Role::MAIN_CHARACTER_MALE_ID), _ => unreachable!(), }; diff --git a/game-server/src/logic/player/player_func.rs b/game-server/src/logic/player/player_func.rs index 27a0f24..4ffbf91 100644 --- a/game-server/src/logic/player/player_func.rs +++ b/game-server/src/logic/player/player_func.rs @@ -8,6 +8,10 @@ pub struct PlayerFunc { } impl PlayerFunc { + pub fn unlock(&mut self, id: i32) { + self.func_map.insert(id, 2); + } + pub fn load_from_save(data: PlayerFuncData) -> Self { PlayerFunc { func_map: data.func_map, diff --git a/game-server/src/logic/role/mod.rs b/game-server/src/logic/role/mod.rs index e3a76a0..6cf2069 100644 --- a/game-server/src/logic/role/mod.rs +++ b/game-server/src/logic/role/mod.rs @@ -23,12 +23,8 @@ impl Role { pub const MAIN_CHARACTER_MALE_ID: i32 = 1501; pub const MAIN_CHARACTER_FEMALE_ID: i32 = 1502; - pub fn new(role_id: i32, weapon_id: Option) -> Self { + pub fn new(role_id: i32) -> Self { let data = role_info_data::iter().find(|d| d.id == role_id).unwrap(); - let equip_weapon = match weapon_id { - None => data.init_weapon_item_id, - Some(x) => x, - }; Self { role_id, @@ -40,7 +36,7 @@ impl Role { star: 0, favor: 0, create_time: time_util::unix_timestamp() as u32, - equip_weapon, + equip_weapon: data.init_weapon_item_id, } } diff --git a/game-server/src/logic/thread_mgr.rs b/game-server/src/logic/thread_mgr.rs index 776c89e..b1c8c87 100644 --- a/game-server/src/logic/thread_mgr.rs +++ b/game-server/src/logic/thread_mgr.rs @@ -11,9 +11,11 @@ use std::{ }; use common::time_util; -use shorekeeper_protocol::{message::Message, JoinSceneNotify, TransitionOptionPb, - AfterJoinSceneNotify, EnterGameResponse, JsPatchNotify}; -use shorekeeper_protocol::{PlayerSaveData}; +use shorekeeper_protocol::PlayerSaveData; +use shorekeeper_protocol::{ + message::Message, AfterJoinSceneNotify, EnterGameResponse, JoinSceneNotify, JsPatchNotify, + TransitionOptionPb, +}; use crate::{ player_save_task::{self, PlayerSaveReason}, @@ -149,6 +151,7 @@ fn handle_logic_input(state: &mut LogicState, input: LogicInput) { player.init(); player.set_session(session); + player.respond(EnterGameResponse::default(), enter_rpc_id); player.notify_general_data(); player @@ -168,6 +171,10 @@ fn handle_logic_input(state: &mut LogicState, input: LogicInput) { scene_info: Some(scene_info), transition_option: Some(TransitionOptionPb::default()), }); + + player.notify(AfterJoinSceneNotify::default()); + + // TODO: maybe move somewhere else? player.notify(JsPatchNotify { content: WATER_MASK.to_string(), }); @@ -177,11 +184,9 @@ fn handle_logic_input(state: &mut LogicState, input: LogicInput) { .replace("{SELECTED_COLOR}", "50FC71"), }); player.notify(JsPatchNotify { - content: CENSORSHIP_FIX.to_string() + content: CENSORSHIP_FIX.to_string(), }); - player.respond(EnterGameResponse::default(), enter_rpc_id); - player.notify(AfterJoinSceneNotify::default()); drop(player); state diff --git a/game-server/src/logic/utils/world_util.rs b/game-server/src/logic/utils/world_util.rs index 5099a17..0f1cc0e 100644 --- a/game-server/src/logic/utils/world_util.rs +++ b/game-server/src/logic/utils/world_util.rs @@ -4,18 +4,18 @@ use shorekeeper_protocol::{ ScenePlayerInformation, SceneTimeInfo, }; +use super::entity_serializer; use crate::{ logic::{ components::{ - Attribute, EntityConfig, Movement, OwnerPlayer, PlayerEntityMarker, Position, - Visibility, Weapon + Attribute, EntityConfig, Equip, Movement, OwnerPlayer, PlayerEntityMarker, Position, + Visibility, VisionSkill, }, ecs::{component::ComponentContainer, world::World}, player::Player, }, query_with, }; -use super::entity_serializer; pub fn add_player_entities(world: &mut World, player: &Player) { let cur_role_id = player.get_cur_role_id(); @@ -43,10 +43,13 @@ pub fn add_player_entities(world: &mut World, player: &Player) { .unwrap(), ))) .with(ComponentContainer::Movement(Movement::default())) - .with(ComponentContainer::Weapon(Weapon { + .with(ComponentContainer::Equip(Equip { weapon_id: role.equip_weapon, weapon_breach_level: 0, // TODO: store this too })) + .with(ComponentContainer::VisionSkill(VisionSkill { + skill_id: player.explore_tools.active_explore_skill, + })) .build(); tracing::debug!( diff --git a/shorekeeper-data/src/explore_tools.rs b/shorekeeper-data/src/explore_tools.rs new file mode 100644 index 0000000..69c777b --- /dev/null +++ b/shorekeeper-data/src/explore_tools.rs @@ -0,0 +1,17 @@ +use std::collections::HashMap; + +use serde::Deserialize; + +#[derive(Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct ExploreToolsData { + pub phantom_skill_id: i32, + pub skill_type: i32, + pub sort_id: i32, + pub auto_fill: bool, + pub show_unlock: bool, + pub skill_group_id: i32, + pub is_use_in_phantom_team: bool, + pub summon_config_id: i32, + pub authorization: HashMap, +} diff --git a/shorekeeper-data/src/lib.rs b/shorekeeper-data/src/lib.rs index c3be6e0..73593ae 100644 --- a/shorekeeper-data/src/lib.rs +++ b/shorekeeper-data/src/lib.rs @@ -47,4 +47,5 @@ json_data! { BaseProperty; InstanceDungeon; FunctionCondition; + ExploreTools; } diff --git a/shorekeeper-protocol/proto/data.proto b/shorekeeper-protocol/proto/data.proto index 87e4d68..f11cd85 100644 --- a/shorekeeper-protocol/proto/data.proto +++ b/shorekeeper-protocol/proto/data.proto @@ -67,9 +67,16 @@ message PlayerFuncData { map func_map = 1; } +message PlayerExploreToolsData { + repeated int32 unlocked_skill_list = 1; + int32 active_skill_id = 2; + repeated int32 roulette = 3; +} + message PlayerSaveData { PlayerBasicData basic_data = 1; PlayerRoleData role_data = 2; PlayerLocationData location_data = 3; PlayerFuncData func_data = 4; + PlayerExploreToolsData explore_tools_data = 5; }