Sync SkillSet from all entities for now since it is needed for some things in voxygen, fix character_behavior system always triggering energy and density modification flags

This commit is contained in:
Imbris 2022-01-17 01:38:44 -05:00
parent 7f7dc5ff8a
commit 5494bd31f2
4 changed files with 20 additions and 12 deletions

View File

@ -50,11 +50,14 @@ macro_rules! synced_components {
// ServerGeneral::InventoryUpdate so we could use that instead
// or remove the part where it clones the inventory.
inventory: Inventory,
// TODO: this is used in combat rating calculation in voxygen but we can probably
// remove it from that and then see if it's used for anything else and try to move
// to only being synced for the client's entity.
skill_set: SkillSet,
// Synced to the client only for its own entity
combo: Combo,
skill_set: SkillSet,
active_abilities: ActiveAbilities,
can_build: CanBuild,
}
@ -193,16 +196,16 @@ impl NetSync for Inventory {
const SYNC_FROM: SyncFrom = SyncFrom::AllEntities;
}
impl NetSync for SkillSet {
const SYNC_FROM: SyncFrom = SyncFrom::AllEntities;
}
// SyncFrom::ClientEntity
impl NetSync for Combo {
const SYNC_FROM: SyncFrom = SyncFrom::ClientEntity;
}
impl NetSync for SkillSet {
const SYNC_FROM: SyncFrom = SyncFrom::ClientEntity;
}
impl NetSync for ActiveAbilities {
const SYNC_FROM: SyncFrom = SyncFrom::ClientEntity;
}

View File

@ -4,7 +4,7 @@ use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage;
use std::ops::Mul;
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
/// Energy is represented by u32s within the module, but treated as a float by
/// the rest of the game.
// As a general rule, all input and output values to public functions should be

View File

@ -139,7 +139,7 @@ pub struct JoinStruct<'a> {
pub vel: &'a mut Vel,
pub ori: &'a mut Ori,
pub mass: &'a Mass,
pub density: &'a mut Density,
pub density: FlaggedAccessMut<'a, &'a mut Density, Density>,
pub energy: FlaggedAccessMut<'a, &'a mut Energy, Energy>,
pub inventory: Option<&'a Inventory>,
pub controller: &'a mut Controller,
@ -171,7 +171,7 @@ impl<'a> JoinData<'a> {
vel: j.vel,
ori: j.ori,
mass: j.mass,
density: j.density,
density: &j.density,
energy: &j.energy,
inventory: j.inventory,
controller: j.controller,

View File

@ -105,7 +105,7 @@ impl<'a> System<'a> for Sys {
vel,
ori,
mass,
mut density,
density,
energy,
inventory,
controller,
@ -180,7 +180,7 @@ impl<'a> System<'a> for Sys {
vel,
ori,
mass,
density: &mut density,
density,
energy,
inventory,
controller,
@ -241,12 +241,17 @@ impl Sys {
// TODO: if checking equality is expensive use optional field in StateUpdate
if *join.char_state != state_update.character {
*join.char_state = state_update.character
}
if *join.density != state_update.density {
*join.density = state_update.density
}
if *join.energy != state_update.energy {
*join.energy = state_update.energy;
};
*join.pos = state_update.pos;
*join.vel = state_update.vel;
*join.ori = state_update.ori;
*join.density = state_update.density;
*join.energy = state_update.energy;
join.controller
.queued_inputs
.append(&mut state_update.queued_inputs);