removed hannabi

This commit is contained in:
Nixon 2022-08-24 13:52:14 +08:00
parent 05ef42d8c3
commit f0e5f2f360
7 changed files with 17 additions and 112 deletions

29
Cargo.lock generated
View file

@ -469,23 +469,6 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "bevy_hanabi"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "371c5bd9edcf42721cd4e769354c221f3c4090e7a1dba0eb0bd6ca29e7828142"
dependencies = [
"anyhow",
"bevy",
"bitflags",
"bytemuck",
"copyless",
"rand",
"rand_pcg",
"ron",
"serde",
]
[[package]] [[package]]
name = "bevy_hierarchy" name = "bevy_hierarchy"
version = "0.8.0" version = "0.8.0"
@ -915,11 +898,12 @@ version = "0.1.0"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy-inspector-egui", "bevy-inspector-egui",
"bevy_hanabi",
"bevy_rapier2d", "bevy_rapier2d",
"cpal 0.14.0", "cpal 0.14.0",
"crossbeam-channel", "crossbeam-channel",
"hexodsp", "hexodsp",
"rand",
"rand_distr",
"ticktock", "ticktock",
] ]
@ -3131,12 +3115,13 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rand_pcg" name = "rand_distr"
version = "0.3.1" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31"
dependencies = [ dependencies = [
"rand_core", "num-traits",
"rand",
] ]
[[package]] [[package]]

View file

@ -7,13 +7,15 @@ edition = "2021"
[dependencies] [dependencies]
bevy = "0.8.0" bevy = "0.8.0"
bevy_hanabi = "0.3.1" # bevy_hanabi = "0.3.1"
bevy-inspector-egui = "0.12.1" bevy-inspector-egui = "0.12.1"
bevy_rapier2d = "0.16.2" bevy_rapier2d = "0.16.2"
cpal = "0.14.0" cpal = "0.14.0"
crossbeam-channel = "0.5.6" crossbeam-channel = "0.5.6"
hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP" } hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP" }
ticktock = "0.8.0" ticktock = "0.8.0"
rand = "0.8.5"
rand_distr = "0.4.3"
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 3 opt-level = 3

View file

@ -10,7 +10,6 @@ use bevy::{
prelude::{shape::Quad, *}, prelude::{shape::Quad, *},
sprite::Mesh2dHandle, sprite::Mesh2dHandle,
}; };
use bevy_hanabi::*;
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
use std::collections::BTreeSet; use std::collections::BTreeSet;
@ -101,7 +100,6 @@ fn setup(
pub fn spawn_character( pub fn spawn_character(
commands: &mut Commands, commands: &mut Commands,
character_meshes: &Res<CharacterMeshes>, character_meshes: &Res<CharacterMeshes>,
effects: &mut ResMut<Assets<EffectAsset>>,
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
selected_character_id: &mut Mut<SelectedCharacterId>, selected_character_id: &mut Mut<SelectedCharacterId>,
character_id_list: &mut Mut<CharacterIdList>, character_id_list: &mut Mut<CharacterIdList>,
@ -118,22 +116,6 @@ pub fn spawn_character(
); );
character_id_list.0.insert(character_id); character_id_list.0.insert(character_id);
let mut gradient = Gradient::new();
gradient.add_key(
0.0,
(Vec4::from(color) + Vec4::new(0.1, 0.1, 0.1, 0.0))
.clamp(Vec4::new(0., 0., 0., 0.), Vec4::new(1., 1., 1., 0.)),
);
gradient.add_key(
0.2,
(Vec4::from(color) + Vec4::new(0.1, 0.1, 0.1, 0.0))
.clamp(Vec4::new(0., 0., 0., 0.), Vec4::new(1., 1., 1., 1.)),
);
gradient.add_key(
1.0,
(Vec4::from(color) + Vec4::new(0.1, 0.1, 0.1, 0.0))
.clamp(Vec4::new(0., 0., 0., 0.), Vec4::new(1., 1., 1., 0.)),
);
commands commands
.spawn_bundle(ColorMesh2dBundle { .spawn_bundle(ColorMesh2dBundle {
mesh: character_meshes.square.clone(), mesh: character_meshes.square.clone(),
@ -156,35 +138,7 @@ pub fn spawn_character(
angular_damping: 0.5, angular_damping: 0.5,
}) })
.insert(ExternalImpulse::default()) .insert(ExternalImpulse::default())
.insert(ActiveEvents::COLLISION_EVENTS) .insert(ActiveEvents::COLLISION_EVENTS);
.with_children(|c| {
c.spawn_bundle(ParticleEffectBundle {
effect: ParticleEffect::new(
effects.add(
EffectAsset {
name: "Particles".into(),
capacity: 4096,
spawner: Spawner::rate(30.0.into())
.with_active(selected_character_id.0.is_none()),
..Default::default()
}
.init(PositionCircleModifier {
radius: 30.0,
speed: 20.0.into(),
dimension: ShapeDimension::Surface,
..Default::default()
})
.init(ParticleLifetimeModifier { lifetime: 0.8 })
.render(SizeOverLifetimeModifier {
gradient: Gradient::constant(Vec2::splat(4.0)),
})
.render(ColorOverLifetimeModifier { gradient }),
),
),
transform: Transform::from_xyz(0., 0., 0.1),
..Default::default()
});
});
// If no character is selected, then select this one // If no character is selected, then select this one
if selected_character_id.0.is_none() { if selected_character_id.0.is_none() {
@ -199,7 +153,6 @@ fn collision_event_system(
mut commands: Commands, mut commands: Commands,
character_meshes: Res<CharacterMeshes>, character_meshes: Res<CharacterMeshes>,
mut materials: ResMut<Assets<ColorMaterial>>, mut materials: ResMut<Assets<ColorMaterial>>,
mut effects: ResMut<Assets<EffectAsset>>,
mut collision_events: EventReader<CollisionEvent>, mut collision_events: EventReader<CollisionEvent>,
character_query: Query<(&CharacterId, &CharacterColor, &Transform)>, character_query: Query<(&CharacterId, &CharacterColor, &Transform)>,
mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>, mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>,
@ -235,7 +188,6 @@ fn collision_event_system(
spawn_character( spawn_character(
&mut commands, &mut commands,
&character_meshes, &character_meshes,
&mut effects,
&mut materials, &mut materials,
&mut selected_character_id, &mut selected_character_id,
&mut character_id_list, &mut character_id_list,
@ -251,27 +203,14 @@ fn collision_event_system(
fn keyboard_input_system( fn keyboard_input_system(
keyboard_input: Res<Input<KeyCode>>, keyboard_input: Res<Input<KeyCode>>,
mut characters: Query<(&CharacterId, &mut Velocity, &CharacterColor, &Children)>, mut characters: Query<(&CharacterId, &mut Velocity, &CharacterColor)>,
mut level_query: Query<(&mut SelectedCharacterId, &CharacterIdList)>, mut level_query: Query<(&mut SelectedCharacterId, &CharacterIdList)>,
mut effect: Query<&mut ParticleEffect>,
mut app_state: ResMut<State<AppState>>, mut app_state: ResMut<State<AppState>>,
audio: Res<crossbeam_channel::Sender<AudioMsg>>, audio: Res<crossbeam_channel::Sender<AudioMsg>>,
) { ) {
if let Ok((mut selected_character_id, character_id_list)) = level_query.get_single_mut() { if let Ok((mut selected_character_id, character_id_list)) = level_query.get_single_mut() {
if keyboard_input.just_pressed(KeyCode::Tab) { if keyboard_input.just_pressed(KeyCode::Tab) {
let selected = if let Some(selected_character_id) = &mut selected_character_id.0 { let selected = if let Some(selected_character_id) = &mut selected_character_id.0 {
if let Some((_character_id, _velocity, _color, children)) = characters
.iter_mut()
.find(|(character_id, _velocity, _color, _children)| {
*character_id == selected_character_id
}) {
effect
.get_mut(children[0])
.unwrap()
.maybe_spawner()
.unwrap()
.set_active(false);
}
*selected_character_id = *character_id_list *selected_character_id = *character_id_list
.0 .0
@ -284,16 +223,10 @@ fn keyboard_input_system(
CharacterId(0) CharacterId(0)
}; };
if let Some((_character_id, _velocity, color, children)) = characters if let Some((_character_id, _velocity, color)) = characters
.iter_mut() .iter_mut()
.find(|(character_id, _velocity, _color, _children)| **character_id == selected) .find(|(character_id, _velocity, _color)| **character_id == selected)
{ {
effect
.get_mut(children[0])
.unwrap()
.maybe_spawner()
.unwrap()
.set_active(true);
audio audio
.send(AudioMsg::Color([color.0.r(), color.0.g(), color.0.b()])) .send(AudioMsg::Color([color.0.r(), color.0.g(), color.0.b()]))
.ok(); .ok();
@ -306,9 +239,9 @@ fn keyboard_input_system(
keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A); keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A);
if let Some(selected_character_id) = &selected_character_id.0 { if let Some(selected_character_id) = &selected_character_id.0 {
if let Some((_character_id, mut velocity, _color, _children)) = characters if let Some((_character_id, mut velocity, _color)) = characters
.iter_mut() .iter_mut()
.find(|(character_id, _velocity, _color, _children)| { .find(|(character_id, _velocity, _color)| {
*character_id == selected_character_id *character_id == selected_character_id
}) { }) {
velocity.linvel.x = 200. * (right_pressed as i8 - left_pressed as i8) as f32; velocity.linvel.x = 200. * (right_pressed as i8 - left_pressed as i8) as f32;

View file

@ -7,7 +7,6 @@ mod level1;
use crate::game::*; use crate::game::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_hanabi::*;
use std::collections::BTreeSet; use std::collections::BTreeSet;
pub fn setup_level( pub fn setup_level(
@ -37,7 +36,6 @@ pub fn despawn_level(mut commands: Commands, level_query: Query<Entity, With<Lev
pub fn post_setup_level( pub fn post_setup_level(
mut commands: Commands, mut commands: Commands,
character_meshes: Res<CharacterMeshes>, character_meshes: Res<CharacterMeshes>,
mut effects: ResMut<Assets<EffectAsset>>,
mut materials: ResMut<Assets<ColorMaterial>>, mut materials: ResMut<Assets<ColorMaterial>>,
current_level: Res<CurrentLevel>, current_level: Res<CurrentLevel>,
mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>, mut level_query: Query<(&mut SelectedCharacterId, &mut CharacterIdList)>,
@ -54,7 +52,6 @@ pub fn post_setup_level(
0 => level0::setup( 0 => level0::setup(
&mut commands, &mut commands,
&character_meshes, &character_meshes,
&mut effects,
&mut materials, &mut materials,
&mut selected_character_id, &mut selected_character_id,
&mut character_id_list, &mut character_id_list,
@ -63,7 +60,6 @@ pub fn post_setup_level(
1 => level1::setup( 1 => level1::setup(
&mut commands, &mut commands,
&character_meshes, &character_meshes,
&mut effects,
&mut materials, &mut materials,
&mut selected_character_id, &mut selected_character_id,
&mut character_id_list, &mut character_id_list,

View file

@ -1,13 +1,11 @@
use crate::game::*; use crate::game::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_hanabi::*;
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
pub fn setup( pub fn setup(
commands: &mut Commands, commands: &mut Commands,
character_meshes: &Res<CharacterMeshes>, character_meshes: &Res<CharacterMeshes>,
effects: &mut ResMut<Assets<EffectAsset>>,
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
selected_character_id: &mut Mut<SelectedCharacterId>, selected_character_id: &mut Mut<SelectedCharacterId>,
character_id_list: &mut Mut<CharacterIdList>, character_id_list: &mut Mut<CharacterIdList>,
@ -21,7 +19,6 @@ pub fn setup(
spawn_character( spawn_character(
commands, commands,
character_meshes, character_meshes,
effects,
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
@ -32,7 +29,6 @@ pub fn setup(
spawn_character( spawn_character(
commands, commands,
character_meshes, character_meshes,
effects,
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
@ -43,7 +39,6 @@ pub fn setup(
spawn_character( spawn_character(
commands, commands,
character_meshes, character_meshes,
effects,
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,

View file

@ -1,13 +1,11 @@
use crate::game::*; use crate::game::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_hanabi::*;
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
pub fn setup( pub fn setup(
commands: &mut Commands, commands: &mut Commands,
character_meshes: &Res<CharacterMeshes>, character_meshes: &Res<CharacterMeshes>,
effects: &mut ResMut<Assets<EffectAsset>>,
materials: &mut ResMut<Assets<ColorMaterial>>, materials: &mut ResMut<Assets<ColorMaterial>>,
selected_character_id: &mut Mut<SelectedCharacterId>, selected_character_id: &mut Mut<SelectedCharacterId>,
character_id_list: &mut Mut<CharacterIdList>, character_id_list: &mut Mut<CharacterIdList>,
@ -27,7 +25,6 @@ pub fn setup(
spawn_character( spawn_character(
commands, commands,
character_meshes, character_meshes,
effects,
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
@ -38,7 +35,6 @@ pub fn setup(
spawn_character( spawn_character(
commands, commands,
character_meshes, character_meshes,
effects,
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,
@ -49,7 +45,6 @@ pub fn setup(
spawn_character( spawn_character(
commands, commands,
character_meshes, character_meshes,
effects,
materials, materials,
selected_character_id, selected_character_id,
character_id_list, character_id_list,

View file

@ -9,7 +9,6 @@ use bevy::{
prelude::*, prelude::*,
render::settings::{WgpuFeatures, WgpuSettings}, render::settings::{WgpuFeatures, WgpuSettings},
}; };
use bevy_hanabi::*;
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
@ -33,11 +32,11 @@ fn main() {
.insert_resource(audio_event_sender) .insert_resource(audio_event_sender)
.add_state(AppState::Menu) .add_state(AppState::Menu)
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(HanabiPlugin)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(64.0)) .add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(64.0))
.add_plugin(RapierDebugRenderPlugin::default()) .add_plugin(RapierDebugRenderPlugin::default())
.add_plugin(menu::MenuPlugin) .add_plugin(menu::MenuPlugin)
.add_plugin(game::GamePlugin) .add_plugin(game::GamePlugin)
.add_plugin(particle_effect::ParticleEffectPlugin)
.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new()) .add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
.add_startup_system(setup) .add_startup_system(setup)
.run(); .run();