game design and client work
This commit is contained in:
parent
ec5c27c260
commit
ad3ccf2c26
242
Cargo.lock
generated
242
Cargo.lock
generated
|
@ -10,6 +10,7 @@ dependencies = [
|
|||
"bevy-discord-presence",
|
||||
"bevy_egui",
|
||||
"bevy_framepace",
|
||||
"bevy_rapier3d",
|
||||
"bevy_rhai",
|
||||
"bevy_screen_diags",
|
||||
"discord-presence",
|
||||
|
@ -809,6 +810,19 @@ dependencies = [
|
|||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_rapier3d"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28b4b8b9331b8dd730ea00acd211f927ea44ae85d40587f255d4095e0532cef8"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bitflags",
|
||||
"log",
|
||||
"nalgebra",
|
||||
"rapier3d",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_reflect"
|
||||
version = "0.7.0"
|
||||
|
@ -1536,6 +1550,20 @@ dependencies = [
|
|||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-queue",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.4"
|
||||
|
@ -1546,6 +1574,41 @@ dependencies = [
|
|||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.8"
|
||||
|
@ -1700,6 +1763,12 @@ dependencies = [
|
|||
"nohash-hasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.18.0"
|
||||
|
@ -2223,7 +2292,7 @@ dependencies = [
|
|||
"byteorder",
|
||||
"color_quant",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-rational 0.3.2",
|
||||
"num-traits",
|
||||
"png",
|
||||
"scoped_threadpool",
|
||||
|
@ -2435,6 +2504,12 @@ version = "0.1.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db"
|
||||
|
||||
[[package]]
|
||||
name = "libspace"
|
||||
version = "0.1.0"
|
||||
|
@ -2534,6 +2609,15 @@ version = "0.1.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84"
|
||||
dependencies = [
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
|
@ -2725,6 +2809,34 @@ dependencies = [
|
|||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18a89248335f688e4bd994e6d030fd7e185eb41769b8c435395075425e100ac6"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"glam",
|
||||
"matrixmultiply",
|
||||
"nalgebra-macros",
|
||||
"num-complex",
|
||||
"num-rational 0.4.0",
|
||||
"num-traits",
|
||||
"simba",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra-macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "named_pipe"
|
||||
version = "0.4.1"
|
||||
|
@ -2903,6 +3015,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.3.3"
|
||||
|
@ -2946,6 +3067,17 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
|
@ -2953,6 +3085,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"libm 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3072,6 +3205,12 @@ version = "1.10.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||
|
||||
[[package]]
|
||||
name = "optional"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "978aa494585d3ca4ad74929863093e87cac9790d81fe7aba2b3dc2890643a0fc"
|
||||
|
||||
[[package]]
|
||||
name = "owned_ttf_parser"
|
||||
version = "0.15.0"
|
||||
|
@ -3135,6 +3274,27 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parry3d"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89cd07f0e1e9e207662f430a4e758c357fdf89450a548ef1ce59113822fd5fa7"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
"downcast-rs",
|
||||
"either",
|
||||
"nalgebra",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"rustc-hash",
|
||||
"simba",
|
||||
"slab",
|
||||
"smallvec",
|
||||
"spade",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.7"
|
||||
|
@ -3278,6 +3438,28 @@ version = "0.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6"
|
||||
|
||||
[[package]]
|
||||
name = "rapier3d"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "652dc538f3b0b0c1ba75aa3f4bdcac8d5132630bce22efd54a7240bdac33108d"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"arrayvec",
|
||||
"bit-vec",
|
||||
"bitflags",
|
||||
"crossbeam",
|
||||
"downcast-rs",
|
||||
"instant",
|
||||
"nalgebra",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"parry3d",
|
||||
"rustc-hash",
|
||||
"simba",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.4.3"
|
||||
|
@ -3287,6 +3469,12 @@ dependencies = [
|
|||
"cty",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rawpointer"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
||||
|
||||
[[package]]
|
||||
name = "rectangle-pack"
|
||||
version = "0.4.2"
|
||||
|
@ -3360,6 +3548,12 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "robust"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5864e7ef1a6b7bcf1d6ca3f655e65e724ed3b52546a0d0a663c991522f552ea"
|
||||
|
||||
[[package]]
|
||||
name = "rodio"
|
||||
version = "0.15.0"
|
||||
|
@ -3422,6 +3616,15 @@ version = "1.0.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
|
||||
|
||||
[[package]]
|
||||
name = "safe_arch"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
|
@ -3566,6 +3769,19 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simba"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13a2609e876d4f77f6ab7ff5254fc39b4f1927ba8e6db3d18be7c32534d3725e"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"num-complex",
|
||||
"num-traits",
|
||||
"paste",
|
||||
"wide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.6"
|
||||
|
@ -3611,6 +3827,18 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spade"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "333b8c21ebd9a45c5e955f3d7a1f0c4a2214847dd7e8e1abb69f34ec9b88882d"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"optional",
|
||||
"robust",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin_sleep"
|
||||
version = "1.1.1"
|
||||
|
@ -3707,7 +3935,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "7b0dc6d20ce137f302edf90f9cd3d278866fd7fb139efca6f246161222ad6d87"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libm",
|
||||
"libm 0.1.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4241,6 +4469,16 @@ dependencies = [
|
|||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wide"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3aba2d1dac31ac7cae82847ac5b8be822aee8f99a4e100f279605016b185c5f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"safe_arch",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "0.5.1"
|
||||
|
|
|
@ -5,6 +5,12 @@ edition = "2021"
|
|||
resolver = "2"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
[profile.dev.package.bevy_rapier3d]
|
||||
opt-level = 3
|
||||
|
||||
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.7.0", features = ["dynamic"] }
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
|
@ -19,4 +25,5 @@ bevy_egui = "0.14"
|
|||
egui= "*"
|
||||
discord-presence = "0.5.0"
|
||||
|
||||
bevy_rapier3d = { version = "*", features = [ "simd-stable", "debug-render" ] }
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
counter.count += 105;
|
||||
counter.count += 15;
|
||||
print("Hi");
|
|
@ -5,14 +5,28 @@ pub mod discord;
|
|||
pub mod species;
|
||||
pub mod ui;
|
||||
|
||||
// use crate::{computer::ComputerPlugin, discord::DiscordPlugin};
|
||||
use crate::ui::{diagnosis::diag_ui, UIPlugin};
|
||||
|
||||
use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
|
||||
use bevy::prelude::*;
|
||||
use bevy::winit::WinitSettings;
|
||||
|
||||
use bevy_egui::EguiPlugin;
|
||||
use bevy_framepace::FramepacePlugin;
|
||||
use bevy_rapier3d::{
|
||||
na::vector,
|
||||
plugin::{NoUserData, RapierPhysicsPlugin},
|
||||
prelude::{Collider, GenericJointBuilder, RapierDebugRenderPlugin, Restitution, RigidBody, *},
|
||||
rapier::{
|
||||
math::Point,
|
||||
prelude::{
|
||||
ColliderBuilder, ColliderSet, ImpulseJointSet, JointAxesMask, JointAxis,
|
||||
MultibodyJointSet, RigidBodyBuilder, RigidBodySet,
|
||||
},
|
||||
},
|
||||
};
|
||||
use libspace::user::generate_user_id;
|
||||
use ui::UIInfo;
|
||||
|
||||
use crate::ui::{
|
||||
client_settings::{client_settings, Settings},
|
||||
|
@ -26,33 +40,82 @@ fn main() {
|
|||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.insert_resource(WinitSettings::game())
|
||||
.insert_resource(Settings::default())
|
||||
.add_plugin(FramepacePlugin::default().without_warnings())
|
||||
.add_plugin(UIPlugin)
|
||||
// .add_plugin(ComputerPlugin) // Pending: Jordans acceptance
|
||||
// .add_plugin(DiscordPlugin) // FIXME: Preformance increase, halts game while updating
|
||||
.add_plugin(EguiPlugin)
|
||||
.add_system(client_settings)
|
||||
.add_system(settings_handler)
|
||||
.add_system(wiki_ui)
|
||||
.add_system(stats_ui)
|
||||
// .add_startup_system(setup)
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
|
||||
.add_plugin(RapierDebugRenderPlugin::default())
|
||||
.add_startup_system(setup_graphics)
|
||||
.add_startup_system(setup_physics)
|
||||
.add_system(print_ball_altitude)
|
||||
.add_system(cursor_grab_system)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct EnableText;
|
||||
|
||||
fn settings_handler(
|
||||
mut plugin: ResMut<FramepacePlugin>,
|
||||
fn cursor_grab_system(
|
||||
mut windows: ResMut<Windows>,
|
||||
|
||||
settings: Res<Settings>,
|
||||
btn: Res<Input<MouseButton>>,
|
||||
key: Res<Input<KeyCode>>,
|
||||
mut ui_info: ResMut<UIInfo>,
|
||||
) {
|
||||
let window = windows.primary_mut();
|
||||
let window = windows.get_primary_mut().unwrap();
|
||||
let cursor_state = window.cursor_locked();
|
||||
let visibility_state = window.cursor_visible();
|
||||
|
||||
plugin.framerate_limit = bevy_framepace::FramerateLimit::Manual(settings.target_fps);
|
||||
use bevy::window::WindowMode::{BorderlessFullscreen, Windowed};
|
||||
match settings.fullscreen {
|
||||
true => window.set_mode(BorderlessFullscreen),
|
||||
false => window.set_mode(Windowed),
|
||||
if key.just_pressed(KeyCode::Escape) {
|
||||
window.set_cursor_lock_mode(!cursor_state);
|
||||
window.set_cursor_visibility(!visibility_state);
|
||||
ui_info.mouse_grabbed = !ui_info.mouse_grabbed;
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_graphics(mut commands: Commands) {
|
||||
// Add a camera so we can see the debug-render.
|
||||
commands.spawn_bundle(PerspectiveCameraBundle {
|
||||
transform: Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
fn setup_physics(mut commands: Commands) {
|
||||
/* Create the ground. */
|
||||
commands
|
||||
.spawn()
|
||||
.insert(Collider::cuboid(100.0, 0.1, 100.0))
|
||||
.insert(Transform::from_xyz(0.0, -2.0, 0.0));
|
||||
|
||||
/* Create the bouncing ball. */
|
||||
commands
|
||||
.spawn()
|
||||
.insert(RigidBody::Dynamic)
|
||||
.insert(Collider::ball(0.5))
|
||||
.insert(Restitution::coefficient(0.7))
|
||||
.insert(Transform::from_xyz(0.0, 4.0, 0.0));
|
||||
|
||||
commands
|
||||
.spawn()
|
||||
.insert(RigidBody::Dynamic)
|
||||
.insert(Collider::cuboid(1.0, 2.0, 1.0))
|
||||
.insert(Restitution::coefficient(0.7))
|
||||
.insert(Transform::from_xyz(0.0, 4.0, 0.0));
|
||||
|
||||
let joint = FixedJointBuilder::new().local_anchor1(Vec3::new(0.0, 0.0, -2.0));
|
||||
|
||||
/*
|
||||
commands
|
||||
.spawn()
|
||||
.insert(RigidBody::Dynamic)
|
||||
.insert(ImpulseJoint::new(abc, joint));
|
||||
*/
|
||||
}
|
||||
|
||||
fn print_ball_altitude(positions: Query<&Transform, With<RigidBody>>) {
|
||||
for transform in positions.iter() {
|
||||
// println!("Ball altitude: {}", transform.translation.y);
|
||||
}
|
||||
}
|
||||
|
||||
fn create_player() {}
|
||||
|
|
30
client/src/ui/diagnosis.rs
Normal file
30
client/src/ui/diagnosis.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
pub const FPS: DiagnosticId = DiagnosticId::from_u128(288146834822086093791974408528866909483);
|
||||
|
||||
use bevy::{
|
||||
diagnostic::{DiagnosticId, Diagnostics},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy_egui::EguiContext;
|
||||
|
||||
use super::UIInfo;
|
||||
|
||||
pub fn diag_ui(
|
||||
mut egui_context: ResMut<EguiContext>,
|
||||
ui_info: Res<UIInfo>,
|
||||
|
||||
diagnostics: Res<Diagnostics>,
|
||||
) {
|
||||
let mut fps_count = 0;
|
||||
|
||||
match diagnostics.get_measurement(FPS) {
|
||||
Some(fps) => {
|
||||
fps_count = fps.value as u32;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
egui::Window::new("Diagnosis").show(egui_context.ctx_mut(), |ui| {
|
||||
ui.label(format!("FPS: {fps_count}"));
|
||||
ui.label(format!("Cursor captured: {}", ui_info.mouse_grabbed))
|
||||
});
|
||||
}
|
|
@ -1,3 +1,55 @@
|
|||
use bevy::{
|
||||
prelude::{Plugin, Res, ResMut},
|
||||
window::Windows,
|
||||
};
|
||||
use bevy_egui::EguiPlugin;
|
||||
use bevy_framepace::FramepacePlugin;
|
||||
|
||||
use self::{client_settings::Settings, diagnosis::diag_ui, stats::stats_ui, wiki::wiki_ui};
|
||||
use crate::client_settings;
|
||||
pub mod client_settings;
|
||||
pub mod diagnosis;
|
||||
pub mod stats;
|
||||
pub mod wiki;
|
||||
|
||||
pub struct UIInfo {
|
||||
pub mouse_grabbed: bool,
|
||||
}
|
||||
impl Default for UIInfo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
mouse_grabbed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UIPlugin;
|
||||
|
||||
impl Plugin for UIPlugin {
|
||||
fn build(&self, app: &mut bevy::prelude::App) {
|
||||
app.insert_resource(Settings::default())
|
||||
.insert_resource(UIInfo::default())
|
||||
.add_plugin(EguiPlugin)
|
||||
.add_system(client_settings)
|
||||
.add_system(settings_handler)
|
||||
.add_system(wiki_ui)
|
||||
.add_system(stats_ui)
|
||||
.add_system(diag_ui);
|
||||
}
|
||||
}
|
||||
|
||||
fn settings_handler(
|
||||
mut plugin: ResMut<FramepacePlugin>,
|
||||
mut windows: ResMut<Windows>,
|
||||
|
||||
settings: Res<Settings>,
|
||||
) {
|
||||
let window = windows.primary_mut();
|
||||
|
||||
plugin.framerate_limit = bevy_framepace::FramerateLimit::Manual(settings.target_fps);
|
||||
use bevy::window::WindowMode::{BorderlessFullscreen, Windowed};
|
||||
match settings.fullscreen {
|
||||
true => window.set_mode(BorderlessFullscreen),
|
||||
false => window.set_mode(Windowed),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct DateTime {
|
|||
impl DateTime {
|
||||
pub fn format(&self) -> String {
|
||||
format!(
|
||||
"{:02}/{:02}/{:02}-{:02}:{:02}:{:02}",
|
||||
"{:04}/{:02}/{:02}-{:02}:{:02}:{:02}",
|
||||
self.year, self.month, self.day, self.hour, self.minute, self.second
|
||||
)
|
||||
}
|
||||
|
|
|
@ -6,3 +6,5 @@ pub mod protocol;
|
|||
pub mod ship;
|
||||
pub mod user;
|
||||
pub mod wiki;
|
||||
|
||||
pub const PORT: u16 = 22222;
|
||||
|
|
4
libspace/src/solarbodies.rs
Normal file
4
libspace/src/solarbodies.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
pub struct SolarBody {
|
||||
pub name: String,
|
||||
pub size: usize,
|
||||
}
|
|
@ -3,7 +3,7 @@ use bevy::{app::ScheduleRunnerSettings, prelude::*, utils::Duration};
|
|||
use libspace::datetime::DateTime;
|
||||
|
||||
// TODO: Workout a proper TPS for the server.
|
||||
pub const TICKS_PER_SECOND: u32 = 20;
|
||||
pub const TICKS_PER_SECOND: u32 = 1;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
|
|
Loading…
Reference in a new issue