mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Switched to using ForceUpdate to forcefully update the client position after a blink
This commit is contained in:
parent
ade466a12b
commit
f117a57083
@ -3,7 +3,7 @@ ComboMelee(
|
||||
(
|
||||
stage: 1,
|
||||
base_damage: 90,
|
||||
base_poise_damage: 20,
|
||||
base_poise_damage: 15,
|
||||
damage_increase: 10,
|
||||
poise_damage_increase: 0,
|
||||
knockback: 8.0,
|
||||
|
@ -1644,15 +1644,6 @@ impl Client {
|
||||
impulse,
|
||||
});
|
||||
},
|
||||
ServerGeneral::PositionUpdate(pos) => {
|
||||
self.state
|
||||
.ecs()
|
||||
.read_resource::<EventBus<LocalEvent>>()
|
||||
.emit_now(LocalEvent::PositionUpdate {
|
||||
entity: self.entity(),
|
||||
pos,
|
||||
});
|
||||
},
|
||||
ServerGeneral::UpdatePendingTrade(id, trade, pricing) => {
|
||||
tracing::trace!("UpdatePendingTrade {:?} {:?}", id, trade);
|
||||
self.pending_trade = Some((id, trade, pricing));
|
||||
|
@ -104,7 +104,6 @@ pub enum ServerGeneral {
|
||||
SetViewDistance(u32),
|
||||
Outcomes(Vec<Outcome>),
|
||||
Knockback(Vec3<f32>),
|
||||
PositionUpdate(comp::Pos),
|
||||
// Ingame related AND terrain stream
|
||||
TerrainChunkUpdate {
|
||||
key: Vec2<i32>,
|
||||
@ -236,7 +235,6 @@ impl ServerMsg {
|
||||
| ServerGeneral::SetViewDistance(_)
|
||||
| ServerGeneral::Outcomes(_)
|
||||
| ServerGeneral::Knockback(_)
|
||||
| ServerGeneral::PositionUpdate(_)
|
||||
| ServerGeneral::UpdatePendingTrade(_, _, _)
|
||||
| ServerGeneral::FinishedTrade(_)
|
||||
| ServerGeneral::SiteEconomy(_) => {
|
||||
|
@ -154,7 +154,8 @@ impl Component for PhysicsState {
|
||||
type Storage = IdvStorage<Self>;
|
||||
}
|
||||
|
||||
// ForceUpdate
|
||||
/// Used to forcefully update the position, velocity, and orientation of the
|
||||
/// client
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ForceUpdate;
|
||||
|
||||
|
@ -29,8 +29,6 @@ pub enum LocalEvent {
|
||||
},
|
||||
/// Applies `vel` velocity to `entity`
|
||||
Boost { entity: EcsEntity, vel: Vec3<f32> },
|
||||
/// Updates the position of the entity
|
||||
PositionUpdate { entity: EcsEntity, pos: Pos },
|
||||
/// Creates an outcome
|
||||
CreateOutcome(Outcome),
|
||||
}
|
||||
|
@ -490,7 +490,6 @@ impl State {
|
||||
let events = self.ecs.read_resource::<EventBus<LocalEvent>>().recv_all();
|
||||
for event in events {
|
||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||
let mut positions = self.ecs.write_storage::<comp::Pos>();
|
||||
let physics = self.ecs.read_storage::<comp::PhysicsState>();
|
||||
match event {
|
||||
LocalEvent::Jump(entity, impulse) => {
|
||||
@ -511,11 +510,6 @@ impl State {
|
||||
vel.0 += extra_vel;
|
||||
}
|
||||
},
|
||||
LocalEvent::PositionUpdate { entity, pos } => {
|
||||
if let Some(position) = positions.get_mut(entity) {
|
||||
*position = pos;
|
||||
}
|
||||
},
|
||||
LocalEvent::CreateOutcome(outcome) => {
|
||||
self.ecs.write_resource::<Vec<Outcome>>().push(outcome);
|
||||
},
|
||||
|
@ -110,7 +110,6 @@ impl Client {
|
||||
| ServerGeneral::SiteEconomy(_)
|
||||
| ServerGeneral::Outcomes(_)
|
||||
| ServerGeneral::Knockback(_)
|
||||
| ServerGeneral::PositionUpdate(_)
|
||||
| ServerGeneral::UpdatePendingTrade(_, _, _)
|
||||
| ServerGeneral::FinishedTrade(_) => {
|
||||
self.in_game_stream.lock().unwrap().send(g)
|
||||
@ -181,7 +180,6 @@ impl Client {
|
||||
| ServerGeneral::SetViewDistance(_)
|
||||
| ServerGeneral::Outcomes(_)
|
||||
| ServerGeneral::Knockback(_)
|
||||
| ServerGeneral::PositionUpdate(_)
|
||||
| ServerGeneral::SiteEconomy(_)
|
||||
| ServerGeneral::UpdatePendingTrade(_, _, _)
|
||||
| ServerGeneral::FinishedTrade(_) => {
|
||||
|
@ -952,11 +952,8 @@ pub fn handle_combo_change(server: &Server, entity: EcsEntity, change: i32) {
|
||||
pub fn handle_teleport_to(server: &Server, entity: EcsEntity, target: Uid, max_range: Option<f32>) {
|
||||
let ecs = &server.state.ecs();
|
||||
let mut positions = ecs.write_storage::<Pos>();
|
||||
let clients = ecs.read_storage::<Client>();
|
||||
|
||||
let target_pos = server
|
||||
.state
|
||||
.ecs()
|
||||
let target_pos = ecs
|
||||
.entity_from_uid(target.into())
|
||||
.and_then(|e| positions.get(e))
|
||||
.copied();
|
||||
@ -964,9 +961,15 @@ pub fn handle_teleport_to(server: &Server, entity: EcsEntity, target: Uid, max_r
|
||||
if let (Some(pos), Some(target_pos)) = (positions.get_mut(entity), target_pos) {
|
||||
if max_range.map_or(true, |r| pos.0.distance_squared(target_pos.0) < r.powi(2)) {
|
||||
*pos = target_pos;
|
||||
if let Some(client) = clients.get(entity) {
|
||||
client.send_fallible(ServerGeneral::PositionUpdate(target_pos));
|
||||
}
|
||||
ecs.write_storage()
|
||||
.insert(entity, comp::ForceUpdate)
|
||||
.err()
|
||||
.map(|e| {
|
||||
error!(
|
||||
?e,
|
||||
"Error inserting ForceUpdate component when teleporting client"
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user