Implement explore tools and some logic adjustments
This commit is contained in:
parent
73060a426d
commit
d93c61cc92
18 changed files with 492 additions and 30 deletions
246
assets/logic/json/ExploreTools.json
Normal file
246
assets/logic/json/ExploreTools.json
Normal file
|
@ -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
|
||||
}
|
||||
]
|
|
@ -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,
|
||||
}))
|
||||
})),
|
||||
})
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
23
game-server/src/logic/components/vision_skill.rs
Normal file
23
game-server/src/logic/components/vision_skill.rs
Normal file
|
@ -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()
|
||||
}],
|
||||
})),
|
||||
})
|
||||
}
|
||||
}
|
|
@ -30,7 +30,8 @@ impl_component_container! {
|
|||
Attribute;
|
||||
PlayerEntityMarker;
|
||||
Movement;
|
||||
Weapon;
|
||||
Equip;
|
||||
VisionSkill;
|
||||
}
|
||||
|
||||
pub trait Component {
|
||||
|
|
11
game-server/src/logic/handler/misc.rs
Normal file
11
game-server/src/logic/handler/misc.rs
Normal file
|
@ -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());
|
||||
}
|
|
@ -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! {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
32
game-server/src/logic/handler/skill.rs
Normal file
32
game-server/src/logic/handler/skill.rs
Normal file
|
@ -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;
|
||||
}
|
76
game-server/src/logic/player/explore_tools.rs
Normal file
76
game-server/src/logic/player/explore_tools.rs
Normal file
|
@ -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<i32>,
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Arc<Session>>,
|
||||
// Persistent
|
||||
pub basic_info: PlayerBasicInfo,
|
||||
pub role_list: Vec<Role>,
|
||||
pub formation_list: Vec<RoleFormation>,
|
||||
pub location: PlayerLocation,
|
||||
pub func: PlayerFunc,
|
||||
pub explore_tools: ExploreTools,
|
||||
// Runtime
|
||||
pub world: Rc<RefCell<World>>,
|
||||
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!(),
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<i32>) -> 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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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!(
|
||||
|
|
17
shorekeeper-data/src/explore_tools.rs
Normal file
17
shorekeeper-data/src/explore_tools.rs
Normal file
|
@ -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<i32, i32>,
|
||||
}
|
|
@ -47,4 +47,5 @@ json_data! {
|
|||
BaseProperty;
|
||||
InstanceDungeon;
|
||||
FunctionCondition;
|
||||
ExploreTools;
|
||||
}
|
||||
|
|
|
@ -67,9 +67,16 @@ message PlayerFuncData {
|
|||
map<int32, int32> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue