M crates/unified/src/client/mod.rs => crates/unified/src/client/mod.rs +0 -3
@@ 13,15 13,12 @@ use crate::ecs::{CursorWorldCoordinates, MainCamera, Player};
use bevy::core_pipeline::fxaa::Fxaa;
use bevy::prelude::*;
use bevy::window::PrimaryWindow;
-use bevy_replicon::prelude::RepliconChannels;
use bevy_replicon::shared::server_entity_map::ServerEntityMap;
-use web_time::SystemTime;
pub struct ClientPlugin {
pub server: String
}
impl Plugin for ClientPlugin {
- #[allow(clippy::clone_on_copy)]
fn build(&self, app: &mut App) {
let server = self.server.clone();
app.insert_resource(CursorWorldCoordinates(None))
M crates/unified/src/client/net.rs => crates/unified/src/client/net.rs +1 -2
@@ 1,7 1,6 @@
use aeronet::io::{Session, SessionEndpoint};
use aeronet::io::connection::Disconnected;
use aeronet_replicon::client::AeronetRepliconClient;
-use aeronet_transport::TransportConfig;
use bevy::prelude::*;
pub fn on_connecting(trigger: Trigger<OnAdd, SessionEndpoint>, names: Query<&Name>, mut commands: Commands) {
@@ 11,7 10,7 @@ pub fn on_connecting(trigger: Trigger<OnAdd, SessionEndpoint>, names: Query<&Nam
commands.entity(entity).insert(AeronetRepliconClient);
}
-pub fn on_connected(trigger: Trigger<OnAdd, Session>, names: Query<&Name>, mut commands: Commands) {
+pub fn on_connected(trigger: Trigger<OnAdd, Session>, names: Query<&Name>) {
let entity = trigger.target();
let name = names.get(entity).unwrap();
info!("{name} is connected");
M crates/unified/src/ecs.rs => crates/unified/src/ecs.rs +1 -0
@@ 54,6 54,7 @@ pub struct Player {
}
#[derive(Component, Default, Serialize, Deserialize, Debug)]
+#[allow(clippy::struct_excessive_bools, reason = "It's not a state machine")]
pub struct PlayerThrust {
pub up: bool,
pub down: bool,
M crates/unified/src/lib.rs => crates/unified/src/lib.rs +10 -0
@@ 1,3 1,13 @@
+#![warn(clippy::pedantic)] // Be annoying, and disable specific irritating lints if needed
+#![deny(clippy::allow_attributes_without_reason, clippy::assertions_on_result_states)]
+#![warn(clippy::if_then_some_else_none)]
+
+
+#![allow(clippy::type_complexity, reason = "Bevy makes this a nightmare")]
+#![allow(clippy::needless_pass_by_value, reason = "Bevy makes this a nightmare")]
+#![allow(clippy::cast_precision_loss, reason = "We cast ints to floats a lot")]
+#![allow(clippy::missing_panics_doc, reason = "Gamedev! We panic a lot")]
+
//! Primary entrypoint for the lib... mostly useful for wasm
#[cfg(target_arch = "wasm32")]
pub mod wasm_entrypoint;
M crates/unified/src/server/gravity.rs => crates/unified/src/server/gravity.rs +1 -2
@@ 15,7 15,6 @@ fn update_gravity(
&Transform,
&ReadMassProperties,
&mut ExternalForce,
- &mut ExternalImpulse,
),
With<Part>,
>,
@@ 26,7 25,7 @@ fn update_gravity(
return;
};
- for (part_transform, part_mass, mut forces, impulses) in &mut part_query {
+ for (part_transform, part_mass, mut forces) in &mut part_query {
let part_mass = part_mass.mass;
let part_translation = part_transform.translation;
M crates/unified/src/server/mod.rs => crates/unified/src/server/mod.rs +0 -1
@@ 9,7 9,6 @@ use aeronet::io::server::Server;
use aeronet::io::Session;
use aeronet_replicon::server::AeronetRepliconServer;
use aeronet_websocket::server::WebSocketServer;
-use bevy::asset::AssetContainer;
use bevy::prelude::*;
use bevy_replicon::prelude::Replicated;
use crate::server::gravity::newtonian_gravity_plugin;
M crates/unified/src/server/player.rs => crates/unified/src/server/player.rs +6 -7
@@ 7,7 7,7 @@ use bevy::prelude::*;
use bevy_rapier2d::prelude::{
AdditionalMassProperties, Collider, ExternalForce, ExternalImpulse, MassProperties,
};
-use bevy_replicon::prelude::{ConnectedClient, FromClient, Replicated};
+use bevy_replicon::prelude::{FromClient, Replicated};
use crate::server::{ConnectedGameEntity, ConnectedNetworkEntity};
pub fn player_management_plugin(app: &mut App) {
@@ 81,11 81,10 @@ fn handle_new_players(
fn player_thrust(
mut players: Query<(&Transform, &mut ExternalForce, &mut PlayerThrust)>,
- mut clients: Query<&ConnectedNetworkEntity>,
+ clients: Query<&ConnectedNetworkEntity>,
mut thrust_event: EventReader<FromClient<ThrustEvent>>,
world_config: Res<WorldConfigResource>,
) {
- use ThrustEvent::*;
for FromClient { client_entity, event } in thrust_event.read() {
let ConnectedNetworkEntity { game_entity } = clients.get(*client_entity).unwrap();
@@ 93,10 92,10 @@ fn player_thrust(
continue;
};
match *event {
- Up(on) => thrust.up = on,
- Down(on) => thrust.down = on,
- Left(on) => thrust.left = on,
- Right(on) => thrust.right = on,
+ ThrustEvent::Up(on) => thrust.up = on,
+ ThrustEvent::Down(on) => thrust.down = on,
+ ThrustEvent::Left(on) => thrust.left = on,
+ ThrustEvent::Right(on) => thrust.right = on,
}
}
for (transform, mut force, thrust) in &mut players {
M crates/unified/src/server/world_config.rs => crates/unified/src/server/world_config.rs +0 -1
@@ 19,7 19,6 @@ fn start_loading_planets(assets: Res<AssetServer>, mut planets: ResMut<WorldConf
}
pub fn update_planets(
- commands: Commands,
mut ev_config: EventReader<AssetEvent<GlobalWorldConfig>>,
assets: ResMut<Assets<GlobalWorldConfig>>,
mut resource: ResMut<WorldConfigResource>,
M crates/xtask/src/main.rs => crates/xtask/src/main.rs +10 -0
@@ 250,6 250,16 @@ fn main() {
exec("wasm-bindgen", format!("--target web --typescript --out-dir {} {}", unified.join("web/").display(), wasm_file.display()).as_str());
println!("{} {} {}", "-->".dimmed(), "✓ done".green(), format!("{}ms", start.elapsed().as_millis()).dimmed());
},
+ "unified:web:release" => {
+ let start = Instant::now();
+ let target = workspace_dir().join("target/");
+ let unified = workspace_dir().join("crates/unified/");
+ exec("cargo", "build --package starkingdoms --lib --target wasm32-unknown-unknown -F wasm --no-default-features --profile wasm-release");
+ let wasm_file = target.join("wasm32-unknown-unknown/wasm-release/starkingdoms.wasm");
+ exec("wasm-bindgen", format!("--target web --typescript --out-dir {} {}", unified.join("web/").display(), wasm_file.display()).as_str());
+ exec("wasm-opt", format!("-Oz -d {} -o {}", unified.join("web/starkingdoms_bg.wasm").display(), unified.join("web/starkingdoms_bg.wasm").display()).as_str());
+ println!("{} {} {}", "-->".dimmed(), "✓ done".green(), format!("{}ms", start.elapsed().as_millis()).dimmed());
+ },
_ => panic!("unsupported command"),
}
}