Support for Nested combat messages and JSPatch Notify from files #2

Merged
xeon merged 10 commits from nested-msgs into master 2024-09-14 09:05:18 +00:00
6 changed files with 22 additions and 8 deletions
Showing only changes of commit c042bd18cf - Show all commits

View file

@ -5,6 +5,7 @@ mod owner_player;
mod player_entity_marker;
mod position;
mod visibility;
mod weapon;
pub use attribute::Attribute;
pub use entity_config::EntityConfig;
@ -13,3 +14,4 @@ pub use owner_player::OwnerPlayer;
pub use player_entity_marker::PlayerEntityMarker;
pub use position::Position;
pub use visibility::Visibility;
pub use weapon::Weapon;

View file

@ -30,6 +30,7 @@ impl_component_container! {
Attribute;
PlayerEntityMarker;
Movement;
Weapon;
}
pub trait Component {

View file

@ -43,7 +43,7 @@ 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));
self.role_list.push(Role::new(1505, Some(21050036)));
}
self.formation_list.clear();
@ -217,8 +217,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),
1 => Role::new(Role::MAIN_CHARACTER_MALE_ID),
0 => Role::new(Role::MAIN_CHARACTER_FEMALE_ID, None),
1 => Role::new(Role::MAIN_CHARACTER_MALE_ID, None),
_ => unreachable!(),
};

View file

@ -1,12 +1,11 @@
use std::collections::HashMap;
use common::time_util;
pub use formation::RoleFormation;
use shorekeeper_data::role_info_data;
use shorekeeper_protocol::{ArrayIntInt, RoleData, RoleInfo};
mod formation;
pub use formation::RoleFormation;
pub struct Role {
pub role_id: i32,
pub name: String,
@ -17,14 +16,19 @@ pub struct Role {
pub star: i32,
pub favor: i32,
pub create_time: u32,
pub equip_weapon: i32,
}
impl Role {
pub const MAIN_CHARACTER_MALE_ID: i32 = 1501;
pub const MAIN_CHARACTER_FEMALE_ID: i32 = 1502;
pub fn new(role_id: i32) -> Self {
pub fn new(role_id: i32, weapon_id: Option<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,
@ -36,6 +40,7 @@ impl Role {
star: 0,
favor: 0,
create_time: time_util::unix_timestamp() as u32,
equip_weapon,
}
}
@ -69,6 +74,7 @@ impl Role {
star: data.star,
favor: data.favor,
create_time: data.create_time,
equip_weapon: data.equip_weapon,
}
}
@ -83,6 +89,7 @@ impl Role {
star: self.star,
favor: self.favor,
create_time: self.create_time,
equip_weapon: self.equip_weapon,
..Default::default()
}
}

View file

@ -8,14 +8,13 @@ use crate::{
logic::{
components::{
Attribute, EntityConfig, Movement, OwnerPlayer, PlayerEntityMarker, Position,
Visibility,
Visibility, Weapon
},
ecs::{component::ComponentContainer, world::World},
player::Player,
},
query_with,
};
use super::entity_serializer;
pub fn add_player_entities(world: &mut World, player: &Player) {
@ -44,6 +43,10 @@ pub fn add_player_entities(world: &mut World, player: &Player) {
.unwrap(),
)))
.with(ComponentContainer::Movement(Movement::default()))
.with(ComponentContainer::Weapon(Weapon {
weapon_id: role.equip_weapon,
weapon_breach_level: 0, // TODO: store this too
}))
.build();
tracing::debug!(

View file

@ -43,6 +43,7 @@ message RoleData {
repeated int32 models = 12;
repeated RoleSkillNodeData skill_node_state = 13;
int32 resonant_chain_group_index = 14;
int32 equip_weapon = 15;
}
message RoleFormationData {