diff --git a/common/net/src/synced_components.rs b/common/net/src/synced_components.rs index 0db52a0dcb..9f3482c304 100644 --- a/common/net/src/synced_components.rs +++ b/common/net/src/synced_components.rs @@ -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; } diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index 4fad5479f9..6f4c59bfdd 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -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 diff --git a/common/src/states/behavior.rs b/common/src/states/behavior.rs index 12875e95f3..0c7e21207d 100644 --- a/common/src/states/behavior.rs +++ b/common/src/states/behavior.rs @@ -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, diff --git a/common/systems/src/character_behavior.rs b/common/systems/src/character_behavior.rs index cfd9e6cc1e..96a01739a5 100644 --- a/common/systems/src/character_behavior.rs +++ b/common/systems/src/character_behavior.rs @@ -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);