mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix invisible chars
Former-commit-id: cbb93e0511100b9b66f9ea22451c99a69b50b19c
This commit is contained in:
parent
cda253c3cf
commit
64b00f41f4
@ -17,8 +17,8 @@ pub struct AnimationInfo {
|
||||
pub changed: bool,
|
||||
}
|
||||
|
||||
impl AnimationInfo {
|
||||
pub fn new() -> Self {
|
||||
impl Default for AnimationInfo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
animation: Animation::Idle,
|
||||
time: 0.0,
|
||||
|
@ -127,7 +127,7 @@ impl<'a> System<'a> for Sys {
|
||||
let last = animation_infos
|
||||
.get_mut(entity)
|
||||
.cloned()
|
||||
.unwrap_or(AnimationInfo::new());
|
||||
.unwrap_or(AnimationInfo::default());
|
||||
let changed = last.animation != animation;
|
||||
|
||||
animation_infos.insert(
|
||||
@ -149,6 +149,7 @@ impl<'a> System<'a> for Sys {
|
||||
{
|
||||
// Check if it is a hit
|
||||
if entity != b
|
||||
&& !stat_b.is_dead()
|
||||
&& pos.0.distance_squared(pos_b.0) < 50.0
|
||||
&& dir.0.angle_between(pos_b.0 - pos.0).to_degrees() < 70.0
|
||||
{
|
||||
|
@ -139,6 +139,7 @@ impl Server {
|
||||
.with(comp::Control::default())
|
||||
.with(comp::phys::Vel(Vec3::zero()))
|
||||
.with(comp::phys::Dir(Vec3::unit_y()))
|
||||
.with(comp::AnimationInfo::default())
|
||||
.with(comp::Actor::Character { name, body })
|
||||
.with(comp::Stats::default())
|
||||
}
|
||||
@ -155,7 +156,7 @@ impl Server {
|
||||
state.write_component(entity, comp::Actor::Character { name, body });
|
||||
state.write_component(entity, comp::Stats::default());
|
||||
state.write_component(entity, comp::Control::default());
|
||||
state.write_component(entity, comp::AnimationInfo::new());
|
||||
state.write_component(entity, comp::AnimationInfo::default());
|
||||
state.write_component(entity, comp::phys::Pos(spawn_point));
|
||||
state.write_component(entity, comp::phys::Vel(Vec3::zero()));
|
||||
state.write_component(entity, comp::phys::Dir(Vec3::unit_y()));
|
||||
@ -569,18 +570,35 @@ impl Server {
|
||||
// Save player metadata (for example the username).
|
||||
state.write_component(entity, player);
|
||||
|
||||
// Sync logical information other players have authority over, not the server.
|
||||
for (other_entity, &uid, &animation_info) in (
|
||||
// Sync physics
|
||||
for (entity, &uid, &pos, &vel, &dir) in (
|
||||
&state.ecs().entities(),
|
||||
&state.ecs().read_storage::<common::state::Uid>(),
|
||||
&state.ecs().read_storage::<Uid>(),
|
||||
&state.ecs().read_storage::<comp::phys::Pos>(),
|
||||
&state.ecs().read_storage::<comp::phys::Vel>(),
|
||||
&state.ecs().read_storage::<comp::phys::Dir>(),
|
||||
)
|
||||
.join()
|
||||
{
|
||||
client.notify(ServerMsg::EntityPhysics {
|
||||
entity: uid.into(),
|
||||
pos,
|
||||
vel,
|
||||
dir,
|
||||
});
|
||||
}
|
||||
|
||||
// Sync animations
|
||||
for (entity, &uid, &animation_info) in (
|
||||
&state.ecs().entities(),
|
||||
&state.ecs().read_storage::<Uid>(),
|
||||
&state.ecs().read_storage::<comp::AnimationInfo>(),
|
||||
)
|
||||
.join()
|
||||
{
|
||||
// Animation
|
||||
client.notify(ServerMsg::EntityAnimation {
|
||||
entity: uid.into(),
|
||||
animation_info: animation_info,
|
||||
animation_info: animation_info.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -594,7 +612,7 @@ impl Server {
|
||||
self.clients
|
||||
.notify_registered(ServerMsg::EcsSync(self.state.ecs_mut().next_sync_package()));
|
||||
|
||||
// Sync 'physical' state.
|
||||
// Sync physics
|
||||
for (entity, &uid, &pos, &vel, &dir, force_update) in (
|
||||
&self.state.ecs().entities(),
|
||||
&self.state.ecs().read_storage::<Uid>(),
|
||||
@ -616,27 +634,32 @@ impl Server {
|
||||
};
|
||||
|
||||
match force_update {
|
||||
Some(_) => self.clients.notify_ingame(msg),
|
||||
None => self.clients.notify_ingame_except(entity, msg),
|
||||
Some(_) => self.clients.notify_registered(msg),
|
||||
None => self.clients.notify_registered_except(entity, msg),
|
||||
}
|
||||
}
|
||||
|
||||
// Sync animation.
|
||||
for (entity, &uid, &animation_info) in (
|
||||
// Sync animations
|
||||
for (entity, &uid, &animation_info, force_update) in (
|
||||
&self.state.ecs().entities(),
|
||||
&self.state.ecs().read_storage::<Uid>(),
|
||||
&self.state.ecs().read_storage::<comp::AnimationInfo>(),
|
||||
self.state
|
||||
.ecs()
|
||||
.read_storage::<comp::phys::ForceUpdate>()
|
||||
.maybe(),
|
||||
)
|
||||
.join()
|
||||
{
|
||||
if animation_info.changed {
|
||||
self.clients.notify_ingame_except(
|
||||
entity,
|
||||
ServerMsg::EntityAnimation {
|
||||
entity: uid.into(),
|
||||
animation_info: animation_info.clone(),
|
||||
},
|
||||
);
|
||||
if animation_info.changed || force_update.is_some() {
|
||||
let msg = ServerMsg::EntityAnimation {
|
||||
entity: uid.into(),
|
||||
animation_info: animation_info.clone(),
|
||||
};
|
||||
match force_update {
|
||||
Some(_) => self.clients.notify_registered(msg),
|
||||
None => self.clients.notify_registered_except(entity, msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,15 +335,10 @@ impl Hud {
|
||||
.resolution(100.0)
|
||||
.set(id, ui_widgets);
|
||||
}
|
||||
for (pos, hp) in (&entities, &pos, &stats)
|
||||
|
||||
for (entity, pos, stats) in (&entities, &pos, &stats)
|
||||
.join()
|
||||
.filter_map(|(entity, pos, stats)| {
|
||||
if entity != me {
|
||||
Some((pos.0, stats.hp))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.filter(|(entity, _, stats)| *entity != me && !stats.is_dead())
|
||||
{
|
||||
let back_id = health_back_id_walker.next(
|
||||
&mut self.ids.health_bar_backs,
|
||||
@ -356,17 +351,20 @@ impl Hud {
|
||||
// Healh Bar
|
||||
Rectangle::fill_with([120.0, 8.0], Color::Rgba(0.3, 0.3, 0.3, 0.5))
|
||||
.x_y(0.0, -25.0)
|
||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 3.0))
|
||||
.position_ingame(pos.0 + Vec3::new(0.0, 0.0, 3.0))
|
||||
.resolution(100.0)
|
||||
.set(back_id, ui_widgets);
|
||||
|
||||
// Filling
|
||||
Rectangle::fill_with(
|
||||
[120.0 * (hp.current as f64 / hp.maximum as f64), 8.0],
|
||||
[
|
||||
120.0 * (stats.hp.current as f64 / stats.hp.maximum as f64),
|
||||
8.0,
|
||||
],
|
||||
HP_COLOR,
|
||||
)
|
||||
.x_y(0.0, -25.0)
|
||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 3.0))
|
||||
.position_ingame(pos.0 + Vec3::new(0.0, 0.0, 3.0))
|
||||
.resolution(100.0)
|
||||
.set(bar_id, ui_widgets);
|
||||
}
|
||||
|
@ -461,15 +461,15 @@ impl FigureMgr {
|
||||
let tick = client.get_tick();
|
||||
let ecs = client.state().ecs();
|
||||
|
||||
for (entity, actor, stats) in (
|
||||
for (entity, actor, stat) in (
|
||||
&ecs.entities(),
|
||||
&ecs.read_storage::<comp::Actor>(),
|
||||
&ecs.read_storage::<comp::Stats>(), // Just to make sure the entity is alive
|
||||
)
|
||||
.join()
|
||||
{
|
||||
if stats.is_dead() {
|
||||
return;
|
||||
if stat.is_dead() {
|
||||
//return;
|
||||
}
|
||||
|
||||
match actor {
|
||||
@ -487,6 +487,8 @@ impl FigureMgr {
|
||||
let model = self.model_cache.get_or_create_model(renderer, *body, tick);
|
||||
|
||||
renderer.render_figure(model, globals, locals, bone_consts);
|
||||
} else {
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,10 +156,6 @@ impl PlayState for SessionState {
|
||||
// Maintain global state
|
||||
global_state.maintain();
|
||||
|
||||
// Maintain the scene.
|
||||
self.scene
|
||||
.maintain(global_state.window.renderer_mut(), &self.client.borrow());
|
||||
|
||||
// extract HUD events ensuring the client borrow gets dropped
|
||||
let hud_events = self.hud.maintain(
|
||||
&self.client.borrow(),
|
||||
@ -201,7 +197,10 @@ impl PlayState for SessionState {
|
||||
}
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
// Maintain the scene.
|
||||
self.scene
|
||||
.maintain(global_state.window.renderer_mut(), &self.client.borrow());
|
||||
|
||||
// Render the session.
|
||||
self.render(global_state.window.renderer_mut());
|
||||
|
Loading…
Reference in New Issue
Block a user