fix rebase

This commit is contained in:
scott-c 2020-08-07 00:41:43 +08:00
parent bf025df204
commit a0107d5cda
13 changed files with 66 additions and 35 deletions

View File

@ -25,12 +25,12 @@ use common::{
Notification, PlayerInfo, PlayerListUpdate, RegisterError, RequestStateError, ServerInfo,
ServerMsg, MAX_BYTES_CHAT_MSG,
},
outcome::Outcome,
recipe::RecipeBook,
state::State,
sync::{Uid, UidAllocator, WorldSyncExt},
terrain::{block::Block, TerrainChunk, TerrainChunkSize},
vol::RectVolSize,
outcome::Outcome,
};
use futures_executor::block_on;
use futures_timer::Delay;
@ -1231,9 +1231,9 @@ impl Client {
self.view_distance = Some(vd);
frontend_events.push(Event::SetViewDistance(vd));
},
ServerMsg::Outcomes(outcomes) => frontend_events.extend(outcomes
.into_iter()
.map(Event::Outcome)),
ServerMsg::Outcomes(outcomes) => {
frontend_events.extend(outcomes.into_iter().map(Event::Outcome))
},
}
}
}

View File

@ -2,10 +2,11 @@ use crate::comp;
use serde::{Deserialize, Serialize};
use vek::*;
/// An outcome represents the final result of an instantaneous event. It implies that said event has
/// already occurred. It is not a request for that event to occur, nor is it something that may be
/// cancelled or otherwise altered. Its primary purpose is to act as something for frontends (both
/// server and client) to listen to in order to receive feedback about events in the world.
/// An outcome represents the final result of an instantaneous event. It implies
/// that said event has already occurred. It is not a request for that event to
/// occur, nor is it something that may be cancelled or otherwise altered. Its
/// primary purpose is to act as something for frontends (both server and
/// client) to listen to in order to receive feedback about events in the world.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum Outcome {
Explosion {
@ -19,7 +20,6 @@ pub enum Outcome {
},
}
impl Outcome {
pub fn get_pos(&self) -> Option<Vec3<f32>> {
match self {

View File

@ -4,8 +4,8 @@ use common::{
self, Agent, Alignment, Body, Gravity, Item, ItemDrop, LightEmitter, Loadout, Pos,
Projectile, Scale, Stats, Vel, WaypointArea,
},
util::Dir,
outcome::Outcome,
util::Dir,
};
use specs::{Builder, Entity as EcsEntity, WorldExt};
use vek::{Rgb, Vec3};
@ -93,7 +93,10 @@ pub fn handle_shoot(
let vel = *dir * 100.0;
// Add an outcome
state.ecs().write_resource::<Vec<Outcome>>().push(Outcome::ProjectileShot { pos, body, vel });
state
.ecs()
.write_resource::<Vec<Outcome>>()
.push(Outcome::ProjectileShot { pos, body, vel });
// TODO: Player height
pos.z += 1.2;

View File

@ -7,14 +7,14 @@ use crate::{
Tick,
};
use common::{
comp::{ForceUpdate, Inventory, InventoryUpdate, Last, Ori, Pos, Vel, Player},
comp::{ForceUpdate, Inventory, InventoryUpdate, Last, Ori, Player, Pos, Vel},
msg::ServerMsg,
outcome::Outcome,
region::{Event as RegionEvent, RegionMap},
state::TimeOfDay,
sync::{CompSyncPackage, Uid},
vol::RectVolSize,
terrain::TerrainChunkSize,
vol::RectVolSize,
};
use specs::{
Entities, Entity as EcsEntity, Join, Read, ReadExpect, ReadStorage, System, Write, WriteStorage,
@ -326,8 +326,12 @@ impl<'a> System<'a> for Sys {
// Sync outcomes
for (client, player, pos) in (&mut clients, &players, positions.maybe()).join() {
let is_near = |o_pos: Vec3<f32>| pos
.zip_with(player.view_distance, |pos, vd| pos.0.xy().distance_squared(o_pos.xy()) < (vd as f32 * TerrainChunkSize::RECT_SIZE.x as f32).powf(2.0));
let is_near = |o_pos: Vec3<f32>| {
pos.zip_with(player.view_distance, |pos, vd| {
pos.0.xy().distance_squared(o_pos.xy())
< (vd as f32 * TerrainChunkSize::RECT_SIZE.x as f32).powf(2.0)
})
};
let outcomes = outcomes
.iter()

View File

@ -171,8 +171,11 @@ impl SfxChannel {
pub fn update(&mut self, listener: &Listener) {
const FALLOFF: f32 = 0.13;
self.sink.set_emitter_position(((self.pos - listener.pos) * FALLOFF).into_array());
self.sink.set_left_ear_position(listener.ear_left_rpos.into_array());
self.sink.set_right_ear_position(listener.ear_right_rpos.into_array());
self.sink
.set_emitter_position(((self.pos - listener.pos) * FALLOFF).into_array());
self.sink
.set_left_ear_position(listener.ear_left_rpos.into_array());
self.sink
.set_right_ear_position(listener.ear_right_rpos.into_array());
}
}

View File

@ -41,7 +41,13 @@ pub struct CombatEventMapper {
}
impl EventMapper for CombatEventMapper {
fn maintain(&mut self, state: &State, player_entity: specs::Entity, camera: &Camera, triggers: &SfxTriggers) {
fn maintain(
&mut self,
state: &State,
player_entity: specs::Entity,
camera: &Camera,
triggers: &SfxTriggers,
) {
let ecs = state.ecs();
let sfx_event_bus = ecs.read_resource::<EventBus<SfxEventItem>>();
@ -56,9 +62,7 @@ impl EventMapper for CombatEventMapper {
ecs.read_storage::<CharacterState>().maybe(),
)
.join()
.filter(|(_, e_pos, ..)| {
(e_pos.0.distance_squared(cam_pos)) < SFX_DIST_LIMIT_SQR
})
.filter(|(_, e_pos, ..)| (e_pos.0.distance_squared(cam_pos)) < SFX_DIST_LIMIT_SQR)
{
if let Some(character) = character {
let state = self.event_history.entry(entity).or_default();

View File

@ -8,11 +8,17 @@ use combat::CombatEventMapper;
use movement::MovementEventMapper;
use progression::ProgressionEventMapper;
use crate::scene::Camera;
use super::SfxTriggers;
use crate::scene::Camera;
trait EventMapper {
fn maintain(&mut self, state: &State, player_entity: specs::Entity, camera: &Camera, triggers: &SfxTriggers);
fn maintain(
&mut self,
state: &State,
player_entity: specs::Entity,
camera: &Camera,
triggers: &SfxTriggers,
);
}
pub struct SfxEventMapper {

View File

@ -38,7 +38,13 @@ pub struct MovementEventMapper {
}
impl EventMapper for MovementEventMapper {
fn maintain(&mut self, state: &State, player_entity: specs::Entity, camera: &Camera, triggers: &SfxTriggers) {
fn maintain(
&mut self,
state: &State,
player_entity: specs::Entity,
camera: &Camera,
triggers: &SfxTriggers,
) {
let ecs = state.ecs();
let sfx_event_bus = ecs.read_resource::<EventBus<SfxEventItem>>();
@ -55,9 +61,7 @@ impl EventMapper for MovementEventMapper {
ecs.read_storage::<CharacterState>().maybe(),
)
.join()
.filter(|(_, e_pos, ..)| {
(e_pos.0.distance_squared(cam_pos)) < SFX_DIST_LIMIT_SQR
})
.filter(|(_, e_pos, ..)| (e_pos.0.distance_squared(cam_pos)) < SFX_DIST_LIMIT_SQR)
{
if let Some(character) = character {
let state = self.event_history.entry(entity).or_default();

View File

@ -26,7 +26,13 @@ pub struct ProgressionEventMapper {
impl EventMapper for ProgressionEventMapper {
#[allow(clippy::op_ref)] // TODO: Pending review in #587
fn maintain(&mut self, state: &State, player_entity: specs::Entity, _camera: &Camera, triggers: &SfxTriggers) {
fn maintain(
&mut self,
state: &State,
player_entity: specs::Entity,
_camera: &Camera,
triggers: &SfxTriggers,
) {
let ecs = state.ecs();
let next_state = ecs.read_storage::<Stats>().get(player_entity).map_or(

View File

@ -88,8 +88,8 @@ use crate::{audio::AudioFrontend, scene::Camera};
use common::{
assets,
comp::{
item::{Consumable, ItemKind, ToolCategory},
CharacterAbilityType, InventoryUpdateEvent, Ori, Pos,
item::{ItemKind, ToolCategory},
CharacterAbilityType, InventoryUpdateEvent,
},
event::EventBus,
outcome::Outcome,
@ -281,7 +281,7 @@ impl SfxMgr {
Some((*power / 2.5).min(1.5)),
);
},
Outcome::ProjectileShot { pos, body, .. } => {
Outcome::ProjectileShot { pos, .. } => {
audio.play_sfx(
// TODO: from sfx triggers config
"voxygen.audio.sfx.glider_open",

View File

@ -208,7 +208,7 @@ impl Scene {
timeout: 0.5,
fadeout: |timeout| timeout * 2.0,
}),
_ => {},
Outcome::ProjectileShot { .. } => {},
}
}

View File

@ -76,7 +76,7 @@ impl ParticleMgr {
});
}
},
_ => {},
Outcome::ProjectileShot { .. } => {},
}
}

View File

@ -1035,7 +1035,8 @@ impl PlayState for SessionState {
// Process outcomes from client
for outcome in outcomes {
self.scene.handle_outcome(&outcome, &scene_data, &mut global_state.audio);
self.scene
.handle_outcome(&outcome, &scene_data, &mut global_state.audio);
}
}
}