From cf1a6b1806bd905339b121bbf6a34fe2e361ebf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Mon, 30 Aug 2021 09:24:32 +0200 Subject: [PATCH] switch to SharedLink and unset context --- Cargo.lock | 12 ++++++++++++ voxygen/Cargo.toml | 3 +++ voxygen/src/session/mod.rs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index aabfea4d2f..3461ea8e4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3184,6 +3184,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" +[[package]] +name = "mumble-link" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a92ff7d87d3ca752fda7a1ccfcde284ea3de84fc8b8a0c43bf434652226bd95" +dependencies = [ + "kernel32-sys", + "libc", + "winapi 0.2.8", +] + [[package]] name = "naga" version = "0.4.0" @@ -6200,6 +6211,7 @@ dependencies = [ "itertools 0.10.1", "keyboard-keynames", "lazy_static", + "mumble-link", "naga 0.6.0", "native-dialog", "num 0.4.0", diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index bcad860fc2..04f78d71fa 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -84,6 +84,9 @@ vek = {version = "=0.14.1", features = ["serde"]} # Controller gilrs = {version = "0.8.0", features = ["serde-serialize"]} +# Mumble +mumble-link = "0.1.0" + # Singleplayer server = { package = "veloren-server", path = "../server", optional = true, default-features = false, features = ["worldgen"] } diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 57dda45d51..224755203c 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -2,6 +2,7 @@ pub mod settings_change; use std::{cell::RefCell, collections::HashSet, rc::Rc, result::Result, sync::Arc, time::Duration}; +use mumble_link::SharedLink; use ordered_float::OrderedFloat; use specs::{Join, WorldExt}; use tracing::{error, info, warn}; @@ -77,6 +78,7 @@ pub struct SessionState { target_entity: Option, selected_entity: Option<(specs::Entity, std::time::Instant)>, interactable: Option, + mumble_link: SharedLink, hitboxes: HashMap, } @@ -95,12 +97,22 @@ impl SessionState { scene .camera_mut() .set_fov_deg(global_state.settings.graphics.fov); + let mut mumble_link = SharedLink::new("veloren", "veloren-voxygen"); { let mut client = client.borrow_mut(); client.request_player_physics(global_state.settings.gameplay.player_physics_behavior); client.request_lossy_terrain_compression( global_state.settings.graphics.lossy_terrain_compression, ); + if let Some(uid) = client.uid() { + let identiy = if let Some(info) = client.player_list().get(&uid) { + format!("{}-{}", info.player_alias, uid.to_string()) + } else { + format!("unknown-{}", uid.to_string()) + }; + mumble_link.set_identity(&identiy); + // TODO: evaluate context + } } let hud = Hud::new(global_state, &client.borrow()); let walk_forward_dir = scene.camera().forward_xy(); @@ -124,6 +136,7 @@ impl SessionState { target_entity: None, selected_entity: None, interactable: None, + mumble_link, hitboxes: HashMap::new(), } } @@ -146,6 +159,24 @@ impl SessionState { let mut client = self.client.borrow_mut(); self.scene .maintain_debug_hitboxes(&client, &global_state.settings, &mut self.hitboxes); + + // Update mumble positional audio + let pos = client.position().unwrap_or_default(); + let ori = client + .state() + .read_storage::() + .get(client.entity()) + .map_or_else(comp::Ori::default, |o| *o); + let front = ori.look_dir().to_vec(); + let top = ori.up().to_vec(); + // converting from veloren z = height axis, to mumble y = height axis + let player_pos = mumble_link::Position { + position: [pos.x, pos.z, pos.y], + front: [front.x, front.z, front.y], + top: [top.x, top.z, top.y], + }; + self.mumble_link.update(player_pos, player_pos); + for event in client.tick(self.inputs.clone(), dt, crate::ecs::sys::add_local_systems)? { match event { client::Event::Chat(m) => {