WIP thruster particles
This commit is contained in:
parent
dcb6e6e5a9
commit
b01823c641
BIN
assets/textures/exhaust.png
Normal file
BIN
assets/textures/exhaust.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
33
src/game.rs
33
src/game.rs
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use bevy::color::palettes::css;
|
use bevy::color::palettes::css;
|
||||||
use bevy::pbr::ExtendedMaterial;
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::scene::SceneInstance;
|
use bevy::scene::SceneInstance;
|
||||||
use bevy::window::{PrimaryWindow, Window, WindowMode};
|
use bevy::window::{PrimaryWindow, Window, WindowMode};
|
||||||
|
@ -471,22 +470,30 @@ fn update_id2v(mut id2v: ResMut<Id2V>, q_id: Query<(&LinearVelocity, &actor::Ide
|
||||||
fn debug(
|
fn debug(
|
||||||
settings: Res<var::Settings>,
|
settings: Res<var::Settings>,
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut commands: Commands,
|
// mut commands: Commands,
|
||||||
mut extended_materials: ResMut<
|
// mut extended_materials: ResMut<
|
||||||
Assets<ExtendedMaterial<StandardMaterial, load::AsteroidSurface>>,
|
// Assets<bevy::pbr::ExtendedMaterial<StandardMaterial, load::AsteroidSurface>>,
|
||||||
>,
|
// >,
|
||||||
mut achievement_tracker: ResMut<var::AchievementTracker>,
|
mut achievement_tracker: ResMut<var::AchievementTracker>,
|
||||||
vars: Res<var::GameVars>,
|
vars: Res<var::GameVars>,
|
||||||
materials: Query<(Entity, Option<&Name>, &Handle<Mesh>)>,
|
q_playercam: Query<(&Position, &LinearVelocity), With<actor::PlayerCamera>>,
|
||||||
|
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
|
||||||
|
// materials: Query<(Entity, Option<&Name>, &Handle<Mesh>)>,
|
||||||
) {
|
) {
|
||||||
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyP) {
|
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyP) {
|
||||||
for (entity, _name, mesh) in &materials {
|
let (pos, v) = q_playercam.get_single().unwrap();
|
||||||
dbg!(mesh);
|
ew_effect.send(visual::SpawnEffectEvent {
|
||||||
let mut entity = commands.entity(entity);
|
duration: 0.0,
|
||||||
entity.remove::<Handle<StandardMaterial>>();
|
class: visual::Effects::ThrusterParticle(pos.clone(), v.clone()),
|
||||||
let material = extended_materials.add(load::AsteroidSurface::material());
|
});
|
||||||
entity.insert(material);
|
|
||||||
}
|
// for (entity, _name, mesh) in &materials {
|
||||||
|
// dbg!(mesh);
|
||||||
|
// let mut entity = commands.entity(entity);
|
||||||
|
// entity.remove::<Handle<StandardMaterial>>();
|
||||||
|
// let material = extended_materials.add(load::AsteroidSurface::material());
|
||||||
|
// entity.insert(material);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyN) {
|
if settings.dev_mode && keyboard_input.just_pressed(KeyCode::KeyN) {
|
||||||
achievement_tracker.achieve_all();
|
achievement_tracker.achieve_all();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy_xpbd_3d::prelude::*;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub struct VisualPlugin;
|
pub struct VisualPlugin;
|
||||||
|
@ -37,6 +38,7 @@ impl Plugin for VisualPlugin {
|
||||||
pub enum Effects {
|
pub enum Effects {
|
||||||
FadeIn(Color),
|
FadeIn(Color),
|
||||||
FadeOut(Color),
|
FadeOut(Color),
|
||||||
|
ThrusterParticle(Position, LinearVelocity),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blackout disabled for now
|
// Blackout disabled for now
|
||||||
|
@ -109,6 +111,9 @@ pub fn setup(
|
||||||
pub fn spawn_effects(
|
pub fn spawn_effects(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut er_effect: EventReader<SpawnEffectEvent>,
|
mut er_effect: EventReader<SpawnEffectEvent>,
|
||||||
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
asset_server: Res<AssetServer>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
) {
|
) {
|
||||||
let now = time.elapsed_seconds_f64();
|
let now = time.elapsed_seconds_f64();
|
||||||
|
@ -144,6 +149,27 @@ pub fn spawn_effects(
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Effects::ThrusterParticle(pos, v) => {
|
||||||
|
let texture = asset_server.load("textures/exhaust.png");
|
||||||
|
commands.spawn((
|
||||||
|
RigidBody::Kinematic,
|
||||||
|
bevy::pbr::NotShadowCaster,
|
||||||
|
pos,
|
||||||
|
v,
|
||||||
|
world::DespawnOnPlayerDeath,
|
||||||
|
actor::WantsToLookAt(cmd::ID_SPECIAL_PLAYERCAM.into()),
|
||||||
|
PbrBundle {
|
||||||
|
mesh: meshes.add(Mesh::from(Rectangle::new(1.0, 1.0))),
|
||||||
|
material: materials.add(StandardMaterial {
|
||||||
|
base_color_texture: Some(texture),
|
||||||
|
perceptual_roughness: 1.0,
|
||||||
|
alpha_mode: AlphaMode::Blend,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue