~starkingdoms/starkingdoms

3fda3e4fdab15e5a633d1fc24dece34e16ba0743 — core 5 months ago 4296e75
chore(fmt): format
M crates/unified/src/client/incoming_particles.rs => crates/unified/src/client/incoming_particles.rs +27 -7
@@ 1,15 1,23 @@
use crate::ecs::Particles;
use bevy::prelude::*;
use bevy_enoki::{ParticleEffectHandle, ParticleSpawner};
use bevy_enoki::prelude::ParticleSpawnerState;
use crate::ecs::Particles;
use bevy_enoki::{ParticleEffectHandle, ParticleSpawner};

pub fn replicated_particles_plugin(app: &mut App) {
    app.add_systems(PreUpdate, (replicate_new_particles, replicate_updated_particles));
    app.add_systems(
        PreUpdate,
        (replicate_new_particles, replicate_updated_particles),
    );
}

fn replicate_new_particles(q: Query<(Entity, &Particles), Added<Particles>>, assets: Res<AssetServer>, mut commands: Commands) {
fn replicate_new_particles(
    q: Query<(Entity, &Particles), Added<Particles>>,
    assets: Res<AssetServer>,
    mut commands: Commands,
) {
    for (entity, p) in q.iter() {
        commands.entity(entity)
        commands
            .entity(entity)
            .insert(ParticleSpawner::default())
            .insert(ParticleEffectHandle(assets.load(&p.effect)))
            .insert(ParticleSpawnerState {


@@ 19,9 27,21 @@ fn replicate_new_particles(q: Query<(Entity, &Particles), Added<Particles>>, ass
        info!("replicate_new_particles {:?}", p);
    }
}
fn replicate_updated_particles(mut q: Query<(Entity, &mut ParticleEffectHandle, &mut ParticleSpawnerState, &Particles), Changed<Particles>>, assets: Res<AssetServer>, mut commands: Commands ) {
fn replicate_updated_particles(
    mut q: Query<
        (
            Entity,
            &mut ParticleEffectHandle,
            &mut ParticleSpawnerState,
            &Particles,
        ),
        Changed<Particles>,
    >,
    assets: Res<AssetServer>,
    mut commands: Commands,
) {
    for (_entity, mut handle, mut state, p) in q.iter_mut() {
        *handle = ParticleEffectHandle(assets.load(&p.effect));
        state.active = p.active;
    }
}
\ No newline at end of file
}

M crates/unified/src/client/mod.rs => crates/unified/src/client/mod.rs +2 -2
@@ 1,12 1,13 @@
mod colors;
mod incoming_particles;
mod incoming_parts;
mod incoming_planets;
mod key_input;
mod net;
mod starfield;
mod ui;
mod incoming_particles;

use crate::client::incoming_particles::replicated_particles_plugin;
use crate::client::incoming_parts::incoming_parts_plugin;
use crate::client::incoming_planets::incoming_planets_plugin;
use crate::client::key_input::key_input_plugin;


@@ 18,7 19,6 @@ use bevy::core_pipeline::fxaa::Fxaa;
use bevy::prelude::*;
use bevy::window::PrimaryWindow;
use bevy_replicon::shared::server_entity_map::ServerEntityMap;
use crate::client::incoming_particles::replicated_particles_plugin;

pub struct ClientPlugin {
    pub server: String,

M crates/unified/src/ecs.rs => crates/unified/src/ecs.rs +2 -2
@@ 65,5 65,5 @@ pub struct PlayerThrust {
#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Particles {
    pub effect: String,
    pub active: bool
}
\ No newline at end of file
    pub active: bool,
}

M crates/unified/src/lib.rs => crates/unified/src/lib.rs +1 -1
@@ 23,4 23,4 @@ pub mod ecs;
pub mod server;
#[cfg(all(not(target_arch = "wasm32"), feature = "native"))]
pub mod server_plugins;
pub mod shared_plugins;
\ No newline at end of file
pub mod shared_plugins;

M crates/unified/src/server/player.rs => crates/unified/src/server/player.rs +22 -4
@@ 83,7 83,12 @@ fn handle_new_players(
                        effect: "particles/ship_thruster.particle.ron".to_string(),
                        active: true
                    },
                    Transform::from_xyz(-wc.part.default_width / 2.0 + 5.0, -wc.part.default_height / 2.0, 0.0).with_rotation(Quat::from_rotation_z(180.0f32.to_radians())),
                    Transform::from_xyz(
                        -wc.part.default_width / 2.0 + 5.0,
                        -wc.part.default_height / 2.0,
                        0.0
                    )
                    .with_rotation(Quat::from_rotation_z(180.0f32.to_radians())),
                    Replicated
                ),
                // bottom right


@@ 92,7 97,12 @@ fn handle_new_players(
                        effect: "particles/ship_thruster.particle.ron".to_string(),
                        active: true
                    },
                    Transform::from_xyz(wc.part.default_width / 2.0 - 5.0, -wc.part.default_height / 2.0, 0.0).with_rotation(Quat::from_rotation_z(180.0f32.to_radians())),
                    Transform::from_xyz(
                        wc.part.default_width / 2.0 - 5.0,
                        -wc.part.default_height / 2.0,
                        0.0
                    )
                    .with_rotation(Quat::from_rotation_z(180.0f32.to_radians())),
                    Replicated
                ),
                // top left


@@ 101,7 111,11 @@ fn handle_new_players(
                        effect: "particles/ship_thruster.particle.ron".to_string(),
                        active: true
                    },
                    Transform::from_xyz(-wc.part.default_width / 2.0 + 5.0, wc.part.default_height / 2.0, 0.0),
                    Transform::from_xyz(
                        -wc.part.default_width / 2.0 + 5.0,
                        wc.part.default_height / 2.0,
                        0.0
                    ),
                    Replicated
                ),
                // top right


@@ 110,7 124,11 @@ fn handle_new_players(
                        effect: "particles/ship_thruster.particle.ron".to_string(),
                        active: true
                    },
                    Transform::from_xyz(wc.part.default_width / 2.0 - 5.0, wc.part.default_height / 2.0, 0.0),
                    Transform::from_xyz(
                        wc.part.default_width / 2.0 - 5.0,
                        wc.part.default_height / 2.0,
                        0.0
                    ),
                    Replicated
                ),
            ]);