mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Persistence of auxiliary abilities.
This commit is contained in:
parent
d86692c4fe
commit
4c3771a1a0
@ -62,12 +62,11 @@ impl Default for ActiveAbilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveAbilities {
|
impl ActiveAbilities {
|
||||||
pub fn new(_inv: Option<&Inventory>, _skill_set: Option<&SkillSet>) -> Self {
|
pub fn new(auxiliary_sets: HashMap<AuxiliaryKey, [AuxiliaryAbility; MAX_ABILITIES]>) -> Self {
|
||||||
// Maybe hook into loading saved variants when they exist here?
|
ActiveAbilities {
|
||||||
// let mut pool = Self::default();
|
auxiliary_sets,
|
||||||
// pool.auto_update(inv, skill_set);
|
..Self::default()
|
||||||
// pool
|
}
|
||||||
Self::default()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn change_ability(
|
pub fn change_ability(
|
||||||
|
@ -115,6 +115,7 @@ pub enum ServerEvent {
|
|||||||
comp::Inventory,
|
comp::Inventory,
|
||||||
Option<comp::Waypoint>,
|
Option<comp::Waypoint>,
|
||||||
Vec<(comp::Pet, comp::Body, comp::Stats)>,
|
Vec<(comp::Pet, comp::Body, comp::Stats)>,
|
||||||
|
comp::ActiveAbilities,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
ExitIngame {
|
ExitIngame {
|
||||||
|
@ -69,7 +69,15 @@ pub fn create_character(
|
|||||||
entity,
|
entity,
|
||||||
player_uuid,
|
player_uuid,
|
||||||
character_alias,
|
character_alias,
|
||||||
(body, stats, skill_set, inventory, waypoint, Vec::new()),
|
(
|
||||||
|
body,
|
||||||
|
stats,
|
||||||
|
skill_set,
|
||||||
|
inventory,
|
||||||
|
waypoint,
|
||||||
|
Vec::new(),
|
||||||
|
Default::default(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ pub fn handle_loaded_character_data(
|
|||||||
comp::Inventory,
|
comp::Inventory,
|
||||||
Option<comp::Waypoint>,
|
Option<comp::Waypoint>,
|
||||||
Vec<(comp::Pet, comp::Body, comp::Stats)>,
|
Vec<(comp::Pet, comp::Body, comp::Stats)>,
|
||||||
|
comp::ActiveAbilities,
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
server
|
server
|
||||||
|
@ -202,6 +202,7 @@ fn persist_entity(state: &mut State, entity: EcsEntity) -> EcsEntity {
|
|||||||
Some(presence),
|
Some(presence),
|
||||||
Some(skill_set),
|
Some(skill_set),
|
||||||
Some(inventory),
|
Some(inventory),
|
||||||
|
Some(active_abilities),
|
||||||
Some(player_uid),
|
Some(player_uid),
|
||||||
Some(player_info),
|
Some(player_info),
|
||||||
mut character_updater,
|
mut character_updater,
|
||||||
@ -210,6 +211,9 @@ fn persist_entity(state: &mut State, entity: EcsEntity) -> EcsEntity {
|
|||||||
state.read_storage::<Presence>().get(entity),
|
state.read_storage::<Presence>().get(entity),
|
||||||
state.read_storage::<comp::SkillSet>().get(entity),
|
state.read_storage::<comp::SkillSet>().get(entity),
|
||||||
state.read_storage::<comp::Inventory>().get(entity),
|
state.read_storage::<comp::Inventory>().get(entity),
|
||||||
|
state
|
||||||
|
.read_storage::<comp::ability::ActiveAbilities>()
|
||||||
|
.get(entity),
|
||||||
state.read_storage::<Uid>().get(entity),
|
state.read_storage::<Uid>().get(entity),
|
||||||
state.read_storage::<comp::Player>().get(entity),
|
state.read_storage::<comp::Player>().get(entity),
|
||||||
state.ecs().fetch_mut::<CharacterUpdater>(),
|
state.ecs().fetch_mut::<CharacterUpdater>(),
|
||||||
@ -251,7 +255,13 @@ fn persist_entity(state: &mut State, entity: EcsEntity) -> EcsEntity {
|
|||||||
|
|
||||||
character_updater.add_pending_logout_update(
|
character_updater.add_pending_logout_update(
|
||||||
char_id,
|
char_id,
|
||||||
(skill_set.clone(), inventory.clone(), pets, waypoint),
|
(
|
||||||
|
skill_set.clone(),
|
||||||
|
inventory.clone(),
|
||||||
|
pets,
|
||||||
|
waypoint,
|
||||||
|
active_abilities.clone(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
PresenceKind::Spectator => { /* Do nothing, spectators do not need persisting */ },
|
PresenceKind::Spectator => { /* Do nothing, spectators do not need persisting */ },
|
||||||
|
12
server/src/migrations/V46__ability_sets.sql
Normal file
12
server/src/migrations/V46__ability_sets.sql
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
-- Creates new ability_set table
|
||||||
|
CREATE TABLE "ability_set" (
|
||||||
|
"entity_id" INT NOT NULL,
|
||||||
|
"ability_sets" TEXT NOT NULL,
|
||||||
|
PRIMARY KEY("entity_id"),
|
||||||
|
FOREIGN KEY("entity_id") REFERENCES "character"("character_id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Inserts starting ability sets for everyone
|
||||||
|
INSERT INTO ability_set
|
||||||
|
SELECT c.character_id, 'Empty'
|
||||||
|
FROM character c
|
@ -8,10 +8,10 @@ extern crate rusqlite;
|
|||||||
|
|
||||||
use super::{error::PersistenceError, models::*};
|
use super::{error::PersistenceError, models::*};
|
||||||
use crate::{
|
use crate::{
|
||||||
comp,
|
comp::{self, Inventory},
|
||||||
comp::Inventory,
|
|
||||||
persistence::{
|
persistence::{
|
||||||
character::conversions::{
|
character::conversions::{
|
||||||
|
convert_active_abilities_from_database, convert_active_abilities_to_database,
|
||||||
convert_body_from_database, convert_body_to_database_json,
|
convert_body_from_database, convert_body_to_database_json,
|
||||||
convert_character_from_database, convert_inventory_from_database_items,
|
convert_character_from_database, convert_inventory_from_database_items,
|
||||||
convert_items_to_database_items, convert_loadout_from_database_items,
|
convert_items_to_database_items, convert_loadout_from_database_items,
|
||||||
@ -234,6 +234,20 @@ pub fn load_character_data(
|
|||||||
})
|
})
|
||||||
.collect::<Vec<(comp::Pet, comp::Body, comp::Stats)>>();
|
.collect::<Vec<(comp::Pet, comp::Body, comp::Stats)>>();
|
||||||
|
|
||||||
|
let mut stmt = connection.prepare_cached(
|
||||||
|
"
|
||||||
|
SELECT ability_sets
|
||||||
|
FROM ability_set
|
||||||
|
WHERE entity_id = ?1",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let ability_set_data = stmt.query_row(&[char_id], |row| {
|
||||||
|
Ok(AbilitySets {
|
||||||
|
entity_id: char_id,
|
||||||
|
ability_sets: row.get(0)?,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
convert_body_from_database(&body_data.variant, &body_data.body_data)?,
|
convert_body_from_database(&body_data.variant, &body_data.body_data)?,
|
||||||
convert_stats_from_database(character_data.alias),
|
convert_stats_from_database(character_data.alias),
|
||||||
@ -246,6 +260,7 @@ pub fn load_character_data(
|
|||||||
)?,
|
)?,
|
||||||
char_waypoint,
|
char_waypoint,
|
||||||
pets,
|
pets,
|
||||||
|
convert_active_abilities_from_database(&ability_set_data),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,14 +342,14 @@ pub fn create_character(
|
|||||||
uuid: &str,
|
uuid: &str,
|
||||||
character_alias: &str,
|
character_alias: &str,
|
||||||
persisted_components: PersistedComponents,
|
persisted_components: PersistedComponents,
|
||||||
transactionn: &mut Transaction,
|
transaction: &mut Transaction,
|
||||||
) -> CharacterCreationResult {
|
) -> CharacterCreationResult {
|
||||||
check_character_limit(uuid, transactionn)?;
|
check_character_limit(uuid, transaction)?;
|
||||||
|
|
||||||
let (body, _stats, skill_set, inventory, waypoint, _) = persisted_components;
|
let (body, _stats, skill_set, inventory, waypoint, _, active_abilities) = persisted_components;
|
||||||
|
|
||||||
// Fetch new entity IDs for character, inventory and loadout
|
// Fetch new entity IDs for character, inventory and loadout
|
||||||
let mut new_entity_ids = get_new_entity_ids(transactionn, |next_id| next_id + 3)?;
|
let mut new_entity_ids = get_new_entity_ids(transaction, |next_id| next_id + 3)?;
|
||||||
|
|
||||||
// Create pseudo-container items for character
|
// Create pseudo-container items for character
|
||||||
let character_id = new_entity_ids.next().unwrap();
|
let character_id = new_entity_ids.next().unwrap();
|
||||||
@ -365,7 +380,7 @@ pub fn create_character(
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut stmt = transactionn.prepare_cached(
|
let mut stmt = transaction.prepare_cached(
|
||||||
"
|
"
|
||||||
INSERT INTO item (item_id,
|
INSERT INTO item (item_id,
|
||||||
parent_container_item_id,
|
parent_container_item_id,
|
||||||
@ -386,7 +401,7 @@ pub fn create_character(
|
|||||||
}
|
}
|
||||||
drop(stmt);
|
drop(stmt);
|
||||||
|
|
||||||
let mut stmt = transactionn.prepare_cached(
|
let mut stmt = transaction.prepare_cached(
|
||||||
"
|
"
|
||||||
INSERT INTO body (body_id,
|
INSERT INTO body (body_id,
|
||||||
variant,
|
variant,
|
||||||
@ -402,7 +417,7 @@ pub fn create_character(
|
|||||||
])?;
|
])?;
|
||||||
drop(stmt);
|
drop(stmt);
|
||||||
|
|
||||||
let mut stmt = transactionn.prepare_cached(
|
let mut stmt = transaction.prepare_cached(
|
||||||
"
|
"
|
||||||
INSERT INTO character (character_id,
|
INSERT INTO character (character_id,
|
||||||
player_uuid,
|
player_uuid,
|
||||||
@ -421,7 +436,7 @@ pub fn create_character(
|
|||||||
|
|
||||||
let db_skill_groups = convert_skill_groups_to_database(character_id, skill_set.skill_groups());
|
let db_skill_groups = convert_skill_groups_to_database(character_id, skill_set.skill_groups());
|
||||||
|
|
||||||
let mut stmt = transactionn.prepare_cached(
|
let mut stmt = transaction.prepare_cached(
|
||||||
"
|
"
|
||||||
INSERT INTO skill_group (entity_id,
|
INSERT INTO skill_group (entity_id,
|
||||||
skill_group_kind,
|
skill_group_kind,
|
||||||
@ -444,10 +459,25 @@ pub fn create_character(
|
|||||||
}
|
}
|
||||||
drop(stmt);
|
drop(stmt);
|
||||||
|
|
||||||
|
let ability_sets = convert_active_abilities_to_database(character_id, &active_abilities);
|
||||||
|
|
||||||
|
let mut stmt = transaction.prepare_cached(
|
||||||
|
"
|
||||||
|
INSERT INTO skill_group (entity_id,
|
||||||
|
ability_sets)
|
||||||
|
VALUES (?1, ?2)",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
stmt.execute(&[
|
||||||
|
&character_id as &dyn ToSql,
|
||||||
|
&ability_sets.ability_sets as &dyn ToSql,
|
||||||
|
])?;
|
||||||
|
drop(stmt);
|
||||||
|
|
||||||
// Insert default inventory and loadout item records
|
// Insert default inventory and loadout item records
|
||||||
let mut inserts = Vec::new();
|
let mut inserts = Vec::new();
|
||||||
|
|
||||||
get_new_entity_ids(transactionn, |mut next_id| {
|
get_new_entity_ids(transaction, |mut next_id| {
|
||||||
let inserts_ = convert_items_to_database_items(
|
let inserts_ = convert_items_to_database_items(
|
||||||
loadout_container_id,
|
loadout_container_id,
|
||||||
&inventory,
|
&inventory,
|
||||||
@ -458,7 +488,7 @@ pub fn create_character(
|
|||||||
next_id
|
next_id
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let mut stmt = transactionn.prepare_cached(
|
let mut stmt = transaction.prepare_cached(
|
||||||
"
|
"
|
||||||
INSERT INTO item (item_id,
|
INSERT INTO item (item_id,
|
||||||
parent_container_item_id,
|
parent_container_item_id,
|
||||||
@ -479,7 +509,7 @@ pub fn create_character(
|
|||||||
}
|
}
|
||||||
drop(stmt);
|
drop(stmt);
|
||||||
|
|
||||||
load_character_list(uuid, transactionn).map(|list| (character_id, list))
|
load_character_list(uuid, transaction).map(|list| (character_id, list))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn edit_character(
|
pub fn edit_character(
|
||||||
@ -579,6 +609,17 @@ pub fn delete_character(
|
|||||||
delete_pets(transaction, char_id, Rc::new(pet_ids))?;
|
delete_pets(transaction, char_id, Rc::new(pet_ids))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete ability sets
|
||||||
|
let mut stmt = transaction.prepare_cached(
|
||||||
|
"
|
||||||
|
DELETE
|
||||||
|
FROM ability_set
|
||||||
|
WHERE entity_id = ?1",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
stmt.execute(&[&char_id])?;
|
||||||
|
drop(stmt);
|
||||||
|
|
||||||
// Delete character
|
// Delete character
|
||||||
let mut stmt = transaction.prepare_cached(
|
let mut stmt = transaction.prepare_cached(
|
||||||
"
|
"
|
||||||
@ -892,6 +933,7 @@ pub fn update(
|
|||||||
inventory: comp::Inventory,
|
inventory: comp::Inventory,
|
||||||
pets: Vec<PetPersistenceData>,
|
pets: Vec<PetPersistenceData>,
|
||||||
char_waypoint: Option<comp::Waypoint>,
|
char_waypoint: Option<comp::Waypoint>,
|
||||||
|
active_abilities: comp::ability::ActiveAbilities,
|
||||||
transaction: &mut Transaction,
|
transaction: &mut Transaction,
|
||||||
) -> Result<(), PersistenceError> {
|
) -> Result<(), PersistenceError> {
|
||||||
// Run pet persistence
|
// Run pet persistence
|
||||||
@ -1035,5 +1077,27 @@ pub fn update(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ability_sets = convert_active_abilities_to_database(char_id, &active_abilities);
|
||||||
|
|
||||||
|
let mut stmt = transaction.prepare_cached(
|
||||||
|
"
|
||||||
|
UPDATE ability_set
|
||||||
|
SET ability_sets = ?1
|
||||||
|
WHERE entity_id = ?2
|
||||||
|
",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let ability_sets_count = stmt.execute(&[
|
||||||
|
&ability_sets.ability_sets as &dyn ToSql,
|
||||||
|
&char_id as &dyn ToSql,
|
||||||
|
])?;
|
||||||
|
|
||||||
|
if ability_sets_count != 1 {
|
||||||
|
return Err(PersistenceError::OtherError(format!(
|
||||||
|
"Error updating ability_set table for char_id {}",
|
||||||
|
char_id
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::persistence::{
|
use crate::persistence::{
|
||||||
character::EntityId,
|
character::EntityId,
|
||||||
models::{Character, Item, SkillGroup},
|
models::{AbilitySets, Character, Item, SkillGroup},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::persistence::{
|
use crate::persistence::{
|
||||||
@ -602,3 +602,29 @@ pub fn convert_skill_groups_to_database<'a, I: Iterator<Item = &'a skillset::Ski
|
|||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn convert_active_abilities_to_database(
|
||||||
|
entity_id: CharacterId,
|
||||||
|
active_abilities: &ability::ActiveAbilities,
|
||||||
|
) -> AbilitySets {
|
||||||
|
let ability_sets = active_abilities
|
||||||
|
.auxiliary_sets
|
||||||
|
.iter()
|
||||||
|
.filter_map(|set| serde_json::to_string(&set).ok())
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
AbilitySets {
|
||||||
|
entity_id,
|
||||||
|
ability_sets: serde_json::to_string(&ability_sets).unwrap_or_default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn convert_active_abilities_from_database(
|
||||||
|
ability_sets: &AbilitySets,
|
||||||
|
) -> ability::ActiveAbilities {
|
||||||
|
let ability_sets = core::iter::once(ability_sets)
|
||||||
|
.flat_map(|sets| serde_json::from_str::<Vec<String>>(&sets.ability_sets))
|
||||||
|
.flatten()
|
||||||
|
.filter_map(|set| serde_json::from_str::<(ability::AuxiliaryKey, [ability::AuxiliaryAbility; ability::MAX_ABILITIES])>(&set).ok())
|
||||||
|
.collect::<HashMap<ability::AuxiliaryKey, [ability::AuxiliaryAbility; ability::MAX_ABILITIES]>>();
|
||||||
|
ability::ActiveAbilities::new(ability_sets)
|
||||||
|
}
|
||||||
|
@ -24,6 +24,7 @@ pub type CharacterUpdateData = (
|
|||||||
comp::Inventory,
|
comp::Inventory,
|
||||||
Vec<PetPersistenceData>,
|
Vec<PetPersistenceData>,
|
||||||
Option<comp::Waypoint>,
|
Option<comp::Waypoint>,
|
||||||
|
comp::ability::ActiveAbilities,
|
||||||
);
|
);
|
||||||
|
|
||||||
pub type PetPersistenceData = (comp::Pet, comp::Body, comp::Stats);
|
pub type PetPersistenceData = (comp::Pet, comp::Body, comp::Stats);
|
||||||
@ -330,11 +331,13 @@ impl CharacterUpdater {
|
|||||||
&'a comp::Inventory,
|
&'a comp::Inventory,
|
||||||
Vec<PetPersistenceData>,
|
Vec<PetPersistenceData>,
|
||||||
Option<&'a comp::Waypoint>,
|
Option<&'a comp::Waypoint>,
|
||||||
|
&'a comp::ability::ActiveAbilities,
|
||||||
),
|
),
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
let updates = updates
|
let updates = updates
|
||||||
.map(|(character_id, skill_set, inventory, pets, waypoint)| {
|
.map(
|
||||||
|
|(character_id, skill_set, inventory, pets, waypoint, active_abilities)| {
|
||||||
(
|
(
|
||||||
character_id,
|
character_id,
|
||||||
(
|
(
|
||||||
@ -342,9 +345,11 @@ impl CharacterUpdater {
|
|||||||
inventory.clone(),
|
inventory.clone(),
|
||||||
pets,
|
pets,
|
||||||
waypoint.cloned(),
|
waypoint.cloned(),
|
||||||
|
active_abilities.clone(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
.chain(self.pending_logout_updates.drain())
|
.chain(self.pending_logout_updates.drain())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -382,18 +387,19 @@ fn execute_batch_update(
|
|||||||
let mut transaction = connection.connection.transaction()?;
|
let mut transaction = connection.connection.transaction()?;
|
||||||
transaction.set_drop_behavior(DropBehavior::Rollback);
|
transaction.set_drop_behavior(DropBehavior::Rollback);
|
||||||
trace!("Transaction started for character batch update");
|
trace!("Transaction started for character batch update");
|
||||||
updates
|
updates.into_iter().try_for_each(
|
||||||
.into_iter()
|
|(character_id, (stats, inventory, pets, waypoint, active_abilities))| {
|
||||||
.try_for_each(|(character_id, (stats, inventory, pets, waypoint))| {
|
|
||||||
super::character::update(
|
super::character::update(
|
||||||
character_id,
|
character_id,
|
||||||
stats,
|
stats,
|
||||||
inventory,
|
inventory,
|
||||||
pets,
|
pets,
|
||||||
waypoint,
|
waypoint,
|
||||||
|
active_abilities,
|
||||||
&mut transaction,
|
&mut transaction,
|
||||||
)
|
)
|
||||||
})?;
|
},
|
||||||
|
)?;
|
||||||
transaction.commit()?;
|
transaction.commit()?;
|
||||||
|
|
||||||
trace!("Commit for character batch update completed");
|
trace!("Commit for character batch update completed");
|
||||||
|
@ -29,6 +29,7 @@ pub type PersistedComponents = (
|
|||||||
comp::Inventory,
|
comp::Inventory,
|
||||||
Option<comp::Waypoint>,
|
Option<comp::Waypoint>,
|
||||||
Vec<PetPersistenceData>,
|
Vec<PetPersistenceData>,
|
||||||
|
comp::ActiveAbilities,
|
||||||
);
|
);
|
||||||
|
|
||||||
pub type EditableComponents = (comp::Body,);
|
pub type EditableComponents = (comp::Body,);
|
||||||
|
@ -35,3 +35,8 @@ pub struct Pet {
|
|||||||
pub body_variant: String,
|
pub body_variant: String,
|
||||||
pub body_data: String,
|
pub body_data: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct AbilitySets {
|
||||||
|
pub entity_id: i64,
|
||||||
|
pub ability_sets: String,
|
||||||
|
}
|
||||||
|
@ -238,10 +238,8 @@ impl StateExt for State {
|
|||||||
.unwrap_or(0),
|
.unwrap_or(0),
|
||||||
))
|
))
|
||||||
.with(stats)
|
.with(stats)
|
||||||
.with(comp::ActiveAbilities::new(
|
// TODO: Figure out way to have this start with sane defaults
|
||||||
Some(&inventory),
|
.with(comp::ActiveAbilities::default())
|
||||||
Some(&skill_set),
|
|
||||||
))
|
|
||||||
.with(skill_set)
|
.with(skill_set)
|
||||||
.maybe_with(health)
|
.maybe_with(health)
|
||||||
.with(poise)
|
.with(poise)
|
||||||
@ -500,7 +498,7 @@ impl StateExt for State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents) {
|
fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents) {
|
||||||
let (body, stats, skill_set, inventory, waypoint, pets) = components;
|
let (body, stats, skill_set, inventory, waypoint, pets, active_abilities) = components;
|
||||||
|
|
||||||
if let Some(player_uid) = self.read_component_copied::<Uid>(entity) {
|
if let Some(player_uid) = self.read_component_copied::<Uid>(entity) {
|
||||||
// Notify clients of a player list update
|
// Notify clients of a player list update
|
||||||
@ -530,10 +528,7 @@ impl StateExt for State {
|
|||||||
self.write_component_ignore_entity_dead(entity, comp::Energy::new(body, energy_level));
|
self.write_component_ignore_entity_dead(entity, comp::Energy::new(body, energy_level));
|
||||||
self.write_component_ignore_entity_dead(entity, comp::Poise::new(body));
|
self.write_component_ignore_entity_dead(entity, comp::Poise::new(body));
|
||||||
self.write_component_ignore_entity_dead(entity, stats);
|
self.write_component_ignore_entity_dead(entity, stats);
|
||||||
self.write_component_ignore_entity_dead(
|
self.write_component_ignore_entity_dead(entity, active_abilities);
|
||||||
entity,
|
|
||||||
comp::ActiveAbilities::new(Some(&inventory), Some(&skill_set)),
|
|
||||||
);
|
|
||||||
self.write_component_ignore_entity_dead(entity, skill_set);
|
self.write_component_ignore_entity_dead(entity, skill_set);
|
||||||
self.write_component_ignore_entity_dead(entity, inventory);
|
self.write_component_ignore_entity_dead(entity, inventory);
|
||||||
self.write_component_ignore_entity_dead(
|
self.write_component_ignore_entity_dead(
|
||||||
|
@ -2,7 +2,7 @@ use crate::{persistence::character_updater, presence::Presence, sys::SysSchedule
|
|||||||
use common::{
|
use common::{
|
||||||
comp::{
|
comp::{
|
||||||
pet::{is_tameable, Pet},
|
pet::{is_tameable, Pet},
|
||||||
Alignment, Body, Inventory, SkillSet, Stats, Waypoint,
|
ActiveAbilities, Alignment, Body, Inventory, SkillSet, Stats, Waypoint,
|
||||||
},
|
},
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
};
|
};
|
||||||
@ -25,6 +25,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
ReadStorage<'a, Waypoint>,
|
ReadStorage<'a, Waypoint>,
|
||||||
ReadStorage<'a, Pet>,
|
ReadStorage<'a, Pet>,
|
||||||
ReadStorage<'a, Stats>,
|
ReadStorage<'a, Stats>,
|
||||||
|
ReadStorage<'a, ActiveAbilities>,
|
||||||
WriteExpect<'a, character_updater::CharacterUpdater>,
|
WriteExpect<'a, character_updater::CharacterUpdater>,
|
||||||
Write<'a, SysScheduler<Self>>,
|
Write<'a, SysScheduler<Self>>,
|
||||||
);
|
);
|
||||||
@ -45,6 +46,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
player_waypoints,
|
player_waypoints,
|
||||||
pets,
|
pets,
|
||||||
stats,
|
stats,
|
||||||
|
active_abilities,
|
||||||
mut updater,
|
mut updater,
|
||||||
mut scheduler,
|
mut scheduler,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
@ -57,11 +59,18 @@ impl<'a> System<'a> for Sys {
|
|||||||
&player_inventories,
|
&player_inventories,
|
||||||
&uids,
|
&uids,
|
||||||
player_waypoints.maybe(),
|
player_waypoints.maybe(),
|
||||||
|
&active_abilities,
|
||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
.filter_map(
|
.filter_map(
|
||||||
|(presence, skill_set, inventory, player_uid, waypoint)| match presence.kind
|
|(
|
||||||
{
|
presence,
|
||||||
|
skill_set,
|
||||||
|
inventory,
|
||||||
|
player_uid,
|
||||||
|
waypoint,
|
||||||
|
active_abilities,
|
||||||
|
)| match presence.kind {
|
||||||
PresenceKind::Character(id) => {
|
PresenceKind::Character(id) => {
|
||||||
let pets = (&alignments, &bodies, &stats, &pets)
|
let pets = (&alignments, &bodies, &stats, &pets)
|
||||||
.join()
|
.join()
|
||||||
@ -78,7 +87,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Some((id, skill_set, inventory, pets, waypoint))
|
Some((id, skill_set, inventory, pets, waypoint, active_abilities))
|
||||||
},
|
},
|
||||||
PresenceKind::Spectator => None,
|
PresenceKind::Spectator => None,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user