Former-commit-id: 047a4ffcad326721eaff6f77eb9c8b57cfa0b2b4
This commit is contained in:
Pfauenauge 2019-05-01 23:47:09 +02:00
parent a3cb1c26d7
commit 5362ac7289
5 changed files with 1916 additions and 88 deletions

View File

@ -7,8 +7,7 @@ edition = "2018"
[dependencies]
sphynx = { git = "https://gitlab.com/veloren/sphynx.git", features = ["serde1"] }
specs = { version = "0.14", features = ["serde"] }
shred = { version = "0.7", features = ["nightly"] }
specs = { version = "0.14", features = ["serde", "nightly"] }
vek = { version = "0.9", features = ["serde"] }
dot_vox = "4.0"
threadpool = "1.7"
@ -19,3 +18,4 @@ serde_derive = "1.0"
bincode = "1.0"
log = "0.4"
rand = "0.5"
rayon = "1.0"

View File

@ -7,14 +7,15 @@ use crate::{
sys,
terrain::{TerrainChunk, TerrainMap},
};
use shred::{Fetch, FetchMut};
use rayon::{ThreadPool, ThreadPoolBuilder};
use specs::{
saveload::{MarkedBuilder, MarkerAllocator},
shred::{Fetch, FetchMut},
storage::{MaskedStorage as EcsMaskedStorage, Storage as EcsStorage},
Builder, Component, DispatcherBuilder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder,
};
use sphynx;
use std::{collections::HashSet, time::Duration};
use std::{collections::HashSet, sync::Arc, time::Duration};
use vek::*;
/// How much faster should an in-game day be compared to a real day?
@ -57,6 +58,8 @@ impl Changes {
/// things like entity components, terrain data, and global state like weather, time of day, etc.
pub struct State {
ecs: sphynx::World<EcsPacket>,
// Avoid lifetime annotation by storing a thread pool instead of the whole dispatcher
thread_pool: Arc<ThreadPool>,
changes: Changes,
}
@ -65,6 +68,7 @@ impl State {
pub fn new() -> Self {
Self {
ecs: sphynx::World::new(specs::World::new(), Self::setup_sphynx_world),
thread_pool: Arc::new(ThreadPoolBuilder::new().build().unwrap()),
changes: Changes::default(),
}
}
@ -77,6 +81,7 @@ impl State {
Self::setup_sphynx_world,
state_package,
),
thread_pool: Arc::new(ThreadPoolBuilder::new().build().unwrap()),
changes: Changes::default(),
}
}
@ -197,7 +202,7 @@ impl State {
self.ecs.write_resource::<DeltaTime>().0 = dt.as_secs_f64();
// Create and run dispatcher for ecs systems
let mut dispatch_builder = DispatcherBuilder::new();
let mut dispatch_builder = DispatcherBuilder::new().with_pool(self.thread_pool.clone());
sys::add_local_systems(&mut dispatch_builder);
// This dispatches all the systems in parallel
dispatch_builder.build().dispatch(&self.ecs.res);

View File

@ -102,8 +102,6 @@ widget_ids! {
settings_title,
settings_r,
settings_l,
settings_scrollbar,
controls_text,
//Contents
button_help,
button_help2,
@ -550,12 +548,12 @@ impl Hud {
ids,
chat,
settings_tab: SettingsTab::Interface,
show_help: false,
show_debug: true,
show_help: true,
show_debug: false,
bag_open: false,
menu_open: false,
map_open: false,
mmap_open: false,
mmap_open: true,
show_ui: true,
inventorytest_button: false,
inventory_space: 0,
@ -1008,10 +1006,10 @@ impl Hud {
// X-button
if Button::image(self.imgs.close_button)
.w_h(28.0, 28.0)
.w_h(4.0 * 4.0, 4.0 * 4.0)
.hover_image(self.imgs.close_button_hover)
.press_image(self.imgs.close_button_press)
.top_right_with_margins_on(self.ids.bag_contents, 0.0, 0.0)
.top_right_with_margins_on(self.ids.bag_contents, 4.5, 4.5)
.set(self.ids.bag_close, ui_widgets)
.was_clicked()
{
@ -1081,10 +1079,6 @@ impl Hud {
.scroll_kids()
.scroll_kids_vertically()
.set(self.ids.settings_content, ui_widgets);
Scrollbar::y_axis(self.ids.settings_content)
.thickness(5.0)
.rgba(0.33, 0.33, 0.33, 1.0)
.set(self.ids.settings_scrollbar, ui_widgets);
// X-Button
if Button::image(self.imgs.close_button)
.w_h(28.0, 28.0)
@ -1243,75 +1237,7 @@ impl Hud {
{
self.settings_tab = SettingsTab::Controls;
}
if let SettingsTab::Controls = self.settings_tab {
Text::new(
"Free Cursor: TAB \n\
Toggle Help Window: F1 \n\
Toggle Interface: F2 \n\
Toggle FPS and Debug Info: F3 \n\
\n\
\n\
Move Forward: W \n\
Move Left : A \n\
Move Right: S \n\
Move Backwards: D \n\
\n\
Jump: Space \n\
\n\
Dodge: ?? \n\
\n\
Auto Walk: ?? \n\
\n\
Sheathe/Draw Weapons: Y \n\
\n\
Put on/Remove Helmet: ?? [Has a Cast time of 0,5s] \n\
\n\
\n\
Basic Attack: L-Click \n\
Secondary Attack/Block/Aim: R-Click \n\
\n\
\n\
Skillbar Slot 1: 1 \n\
Skillbar Slot 2: 2 \n\
Skillbar Slot 3: 3 \n\
Skillbar Slot 4: 4 \n\
Skillbar Slot 5: 5 \n\
Skillbar Slot 6: 6 \n\
Skillbar Slot 7: 7 \n\
Skillbar Slot 8: 8 \n\
Skillbar Slot 9: 9 \n\
Skillbar Slot 10: 0 \n\
\n\
\n\
Pause Menu: ESC \n\
Settings: N \n\
Social: O \n\
Map: M \n\
Spellbook: P \n\
Character: C \n\
Questlog L \n\
Bag: B \n\
\n\
\n\
\n\
Activate Chat & Input/Send Message: Enter \n\
Scroll Chat: Mousewheel on Chat-Window \n\
\n\
\n\
Chat commands: \n\
\n\
/alias [Name] - Change your Chat Name \n\
/tp [Name] - Teleports you to another player
")
.color(TEXT_COLOR)
.top_left_with_margins_on(self.ids.settings_content, 5.0, 5.0)
.font_id(self.font_opensans)
.font_size(18)
.set(self.ids.controls_text, ui_widgets);
}
// 4 Video////////////////////////////////
if Button::image(if let SettingsTab::Video = self.settings_tab {
self.imgs.settings_button_pressed
@ -1741,9 +1667,7 @@ impl Hud {
.set(self.ids.menu_button_2, ui_widgets)
.was_clicked()
{
self.menu_open = false;
self.settings_tab = SettingsTab::Controls;
self.open_windows = Windows::Settings;
//self.menu_open = false;
};
// Servers
if Button::image(self.imgs.button_dark)

File diff suppressed because it is too large Load Diff

View File

@ -116,7 +116,7 @@ impl FigureCache {
match head {
Head::DefaultHead => "head.vox",
},
Vec3::new(-7.5, -8.0, 0.0),
Vec3::new(-5.5, -7.0, -6.0),
)
}