diff --git a/Cargo.toml b/Cargo.toml index 1b43403..cb06553 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,29 +7,30 @@ edition = "2021" anyhow = "1.0.4" arrayvec = "0.7" async-trait = "0.1" -bevy = { version = "0.10", default-features = false, features = ["dds", "tga", "bevy_asset", "bevy_core_pipeline", "bevy_winit", "bevy_render", "bevy_pbr"] } -bevy_egui = "0.20.2" -bevy-inspector-egui = "0.18" -bevy_polyline = "0.6.0" -bevy_rapier3d = "0.21" -bitflags = "1.2" +bevy = { version = "0.11.2", default-features = false, features = ["dds", "tga", "bevy_asset", "bevy_core_pipeline", "bevy_winit", "bevy_render", "bevy_pbr"] } +bevy_egui = "0.21" +bevy-inspector-egui = "0.19" +bevy_polyline = "0.7" +bevy_rapier3d = "0.22" +bitflags = "2.3" bytemuck = { version = "1.7.0", features = ["derive"] } chrono = "0.4" clap = "3.2" cpal = "0.15" crossbeam-channel = "0.5" directories = "5.0" -dolly = "0.4.1" -egui = "0.21" -egui_extras = "0.21" +dolly = "0.4.2" +egui = "0.22" +egui_extras = "0.22" enum-map = { version = "2.0", features = ["serde"] } +glam = "0.24.1" hound = "3.4" image = { version = "0.24", default-features = false, features = ["dds", "ico", "tga"] } lazy_static = "1.4.0" lewton = "0.10" log = "0.4.14" md5 = "0.7.0" -num-derive = "0.3" +num-derive = "0.4" num-traits = "0.2" oddio = "0.6" pelite = "0.10.0" @@ -40,34 +41,35 @@ tokio = { version = "1.17", features = ["rt", "net", "sync", "macros", "io-util" toml = "0.7.2" quick-xml = { version = "0.26.0", features = ["serialize"] } regex = "1" -rose-data = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } -rose-data-irose = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } -rose-file-readers = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } -rose-game-common = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } -rose-game-irose = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } -rose-network-common = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } -rose-network-irose = { git = "https://github.com/exjam/rose-offline", rev = "4605e4584647ca40594af4e3108fe8fd69c23c45" } +rose-data = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } +rose-data-irose = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } +rose-file-readers = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } +rose-game-common = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } +rose-game-irose = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } +rose-network-common = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } +rose-network-irose = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" } [patch.crates-io] -bevy = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_egui = { git = "https://github.com/exjam/bevy_egui", rev = "36988d9f5197c3a1f57ab56e89f8261269174fef" } -egui = { git = "https://github.com/exjam/egui", rev = "3ff66738341330d40e206269ce3540379b9ce1f5" } +bevy = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_egui = { git = "https://github.com/exjam/bevy_egui", rev = "cc94933c647ed4e6cba48a559f70cc69cb2f1708" } +dolly = { git = "https://github.com/exjam/dolly", rev = "007862856f95c2b75b1e18ade4f4e35cfe6829a5" } +egui = { git = "https://github.com/exjam/egui", rev = "cc52964889bf41d3268a553836515f7e17fc6e48" } oddio = { git = "https://github.com/exjam/oddio", rev = "3c20292903fe629d7eab08c1790db70b9fddac96" } pelite = { git = "https://github.com/exjam/pelite", rev = "750b4aea126b1248b46e52cf2b9ad288d01e698c" } winit = { git = "https://github.com/exjam/winit", rev = "5c5519c5c192e1eb6eda5f3420d467131d3273bb" } # Thanks bevy-inspector-egui -bevy_app = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_asset = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_core = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_ecs = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_hierarchy = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_log = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_math = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_reflect = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_utils = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_core_pipeline = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_pbr = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } -bevy_render = { git = "https://github.com/exjam/bevy", rev = "4a309dafa9c912d36ecbcbd29253b9876b67c7e1" } +bevy_app = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_asset = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_core = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_ecs = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_hierarchy = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_log = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_math = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_reflect = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_utils = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_core_pipeline = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_pbr = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } +bevy_render = { git = "https://github.com/exjam/bevy", rev = "04945fbacb297d3720049b7c89e3cb8eb19049c2" } [profile.dev.package."*"] opt-level = 3 diff --git a/src/animation/animation_state.rs b/src/animation/animation_state.rs index a7fc153..fb6c720 100644 --- a/src/animation/animation_state.rs +++ b/src/animation/animation_state.rs @@ -1,5 +1,5 @@ use bevy::{ - prelude::{Component, Entity, Handle}, + prelude::{Component, Entity, Event, Handle}, reflect::Reflect, time::Time, }; @@ -8,6 +8,7 @@ use rose_data::AnimationEventFlags; use crate::animation::ZmoAsset; +#[derive(Event)] pub struct AnimationFrameEvent { pub entity: Entity, pub flags: AnimationEventFlags, diff --git a/src/animation/mod.rs b/src/animation/mod.rs index 2409123..85a4239 100644 --- a/src/animation/mod.rs +++ b/src/animation/mod.rs @@ -1,5 +1,7 @@ use bevy::{ - prelude::{AddAsset, App, CoreSet, IntoSystemConfigs, IntoSystemSetConfig, Plugin, SystemSet}, + prelude::{ + AddAsset, App, IntoSystemConfigs, IntoSystemSetConfig, Plugin, PostUpdate, SystemSet, + }, transform::TransformSystem, }; @@ -49,11 +51,11 @@ impl Plugin for RoseAnimationPlugin { .register_type::(); app.configure_set( - RoseAnimationSystem - .in_base_set(CoreSet::PostUpdate) - .before(TransformSystem::TransformPropagate), + PostUpdate, + RoseAnimationSystem.before(TransformSystem::TransformPropagate), ) .add_systems( + PostUpdate, ( camera_animation_system, mesh_animation_system, diff --git a/src/animation/zmo_asset_loader.rs b/src/animation/zmo_asset_loader.rs index ba14266..3b46f6a 100644 --- a/src/animation/zmo_asset_loader.rs +++ b/src/animation/zmo_asset_loader.rs @@ -4,7 +4,7 @@ use bevy::{ asset::{AssetLoader, BoxedFuture, LoadContext, LoadedAsset}, math::{Quat, Vec3}, prelude::{Handle, Image}, - reflect::{FromReflect, Reflect, TypeUuid}, + reflect::{Reflect, TypeUuid}, render::render_resource::{Extent3d, TextureDimension, TextureFormat}, }; use rose_file_readers::{RoseFile, ZmoChannel, ZmoFile}; @@ -15,14 +15,14 @@ pub struct ZmoAssetLoader; #[derive(Default)] pub struct ZmoTextureAssetLoader; -#[derive(Reflect, FromReflect, Clone, Default)] +#[derive(Reflect, Clone, Default)] pub struct ZmoAssetBone { pub translation: Vec, pub rotation: Vec, pub scale: Vec, } -#[derive(Reflect, FromReflect, Clone, Default)] +#[derive(Reflect, Clone, Default)] pub struct ZmoAssetAnimationTexture { pub texture: Handle, pub alphas: Vec, @@ -32,7 +32,7 @@ pub struct ZmoAssetAnimationTexture { pub has_uv1_channel: bool, } -#[derive(Reflect, FromReflect, TypeUuid)] +#[derive(Reflect, TypeUuid)] #[uuid = "120cb5ff-e72d-4730-9756-648d0001fdfa"] pub struct ZmoAsset { pub num_frames: usize, diff --git a/src/audio/audio_source.rs b/src/audio/audio_source.rs index de9cea3..44beb55 100644 --- a/src/audio/audio_source.rs +++ b/src/audio/audio_source.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bevy::reflect::TypeUuid; +use bevy::reflect::{TypePath, TypeUuid}; pub trait StreamingAudioSource { fn channel_count(&self) -> u32; @@ -15,7 +15,7 @@ pub struct AudioSourceDecoded { pub sample_rate: u32, } -#[derive(Clone, TypeUuid)] +#[derive(Clone, TypeUuid, TypePath)] #[uuid = "f40c2d6a-d2ad-42cc-8f86-0147d3ddd68c"] pub struct AudioSource { pub bytes: Arc<[u8]>, diff --git a/src/audio/mod.rs b/src/audio/mod.rs index 94c3b41..d98b882 100644 --- a/src/audio/mod.rs +++ b/src/audio/mod.rs @@ -1,6 +1,4 @@ -use bevy::prelude::{ - AddAsset, App, Component, CoreSet, IntoSystemConfig, IntoSystemConfigs, Plugin, Resource, -}; +use bevy::prelude::{AddAsset, App, Component, IntoSystemConfigs, Last, Plugin, Resource}; mod audio_source; mod global_sound; @@ -98,13 +96,13 @@ impl Plugin for OddioPlugin { .init_asset_loader::() .init_asset_loader::() .add_systems( + Last, ( spatial_sound_gain_changed_system.before(spatial_sound_system), spatial_sound_system, global_sound_gain_changed_system.before(global_sound_system), global_sound_system, - ) - .in_base_set(CoreSet::Last), + ), ); } } diff --git a/src/components/character_model_blink_timer.rs b/src/components/character_model_blink_timer.rs index 95975b9..9521ae4 100644 --- a/src/components/character_model_blink_timer.rs +++ b/src/components/character_model_blink_timer.rs @@ -1,12 +1,9 @@ use std::ops::Range; -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; use rand::Rng; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct CharacterBlinkTimer { pub timer: f32, pub is_open: bool, diff --git a/src/components/client_entity.rs b/src/components/client_entity.rs index 8dec5a2..8c8fa7c 100644 --- a/src/components/client_entity.rs +++ b/src/components/client_entity.rs @@ -1,11 +1,8 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; pub use rose_game_common::messages::ClientEntityId; -#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect)] pub enum ClientEntityType { Character, Monster, @@ -13,7 +10,7 @@ pub enum ClientEntityType { ItemDrop, } -#[derive(Copy, Clone, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Component, Reflect)] pub struct ClientEntity { pub id: ClientEntityId, pub entity_type: ClientEntityType, diff --git a/src/components/client_entity_name.rs b/src/components/client_entity_name.rs index da6ddc3..de2c859 100644 --- a/src/components/client_entity_name.rs +++ b/src/components/client_entity_name.rs @@ -1,9 +1,9 @@ use bevy::{ prelude::{Component, Deref, DerefMut}, - reflect::{FromReflect, Reflect}, + reflect::Reflect, }; -#[derive(Component, Deref, DerefMut, Reflect, FromReflect)] +#[derive(Component, Deref, DerefMut, Reflect)] pub struct ClientEntityName { pub name: String, } diff --git a/src/components/command.rs b/src/components/command.rs index 7348c17..bc2f00f 100644 --- a/src/components/command.rs +++ b/src/components/command.rs @@ -1,45 +1,45 @@ use bevy::{ math::{Vec2, Vec3}, prelude::{Component, Entity}, - reflect::{FromReflect, Reflect}, + reflect::Reflect, }; use rose_data::{MotionId, SkillId}; use std::ops::{Deref, DerefMut}; use rose_game_common::components::MoveMode; -#[derive(Clone, Debug, PartialEq, Reflect, FromReflect)] +#[derive(Clone, Debug, PartialEq, Reflect)] pub struct CommandMove { pub destination: Vec3, pub target: Option, pub move_mode: Option, } -#[derive(Clone, Debug, PartialEq, Eq, Reflect, FromReflect)] +#[derive(Clone, Debug, PartialEq, Eq, Reflect)] pub struct CommandAttack { pub target: Entity, } -#[derive(Clone, Debug, PartialEq, Eq, Reflect, FromReflect)] +#[derive(Clone, Debug, PartialEq, Eq, Reflect)] pub struct CommandEmote { pub motion_id: MotionId, pub is_stop: bool, } -#[derive(Clone, Debug, PartialEq, Eq, Reflect, FromReflect)] +#[derive(Clone, Debug, PartialEq, Eq, Reflect)] pub enum CommandSit { Sitting, Sit, Standing, } -#[derive(Copy, Clone, Debug, PartialEq, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Reflect)] pub enum CommandCastSkillTarget { Entity(Entity), Position(Vec2), } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect)] pub enum CommandCastSkillState { Starting, Casting, @@ -47,7 +47,7 @@ pub enum CommandCastSkillState { Action, } -#[derive(Clone, Debug, PartialEq, Reflect, FromReflect)] +#[derive(Clone, Debug, PartialEq, Reflect)] pub struct CommandCastSkill { pub skill_id: SkillId, pub skill_target: Option, @@ -58,7 +58,7 @@ pub struct CommandCastSkill { pub ready_action: bool, } -#[derive(Component, Clone, Debug, PartialEq, Reflect, FromReflect)] +#[derive(Component, Clone, Debug, PartialEq, Reflect)] pub enum Command { Stop, Move(CommandMove), @@ -213,7 +213,7 @@ impl Command { } } -#[derive(Component, Debug, Default, Reflect, FromReflect)] +#[derive(Component, Debug, Default, Reflect)] pub struct NextCommand(Option); impl NextCommand { diff --git a/src/components/dead.rs b/src/components/dead.rs index 1257113..9c59c0d 100644 --- a/src/components/dead.rs +++ b/src/components/dead.rs @@ -1,7 +1,4 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct Dead; diff --git a/src/components/dummy_bone_offset.rs b/src/components/dummy_bone_offset.rs index c5ce343..528082a 100644 --- a/src/components/dummy_bone_offset.rs +++ b/src/components/dummy_bone_offset.rs @@ -1,9 +1,6 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct DummyBoneOffset { pub index: usize, } diff --git a/src/components/effect.rs b/src/components/effect.rs index 0448e01..5cb6bdb 100644 --- a/src/components/effect.rs +++ b/src/components/effect.rs @@ -1,9 +1,6 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct Effect { pub manual_despawn: bool, } @@ -14,8 +11,8 @@ impl Effect { } } -#[derive(Component, Default, Reflect, FromReflect)] +#[derive(Component, Default, Reflect)] pub struct EffectMesh {} -#[derive(Component, Default, Reflect, FromReflect)] +#[derive(Component, Default, Reflect)] pub struct EffectParticle {} diff --git a/src/components/event_object.rs b/src/components/event_object.rs index 69662be..3809e6e 100644 --- a/src/components/event_object.rs +++ b/src/components/event_object.rs @@ -1,9 +1,6 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct EventObject { pub quest_trigger_name: String, pub script_function_name: String, diff --git a/src/components/facing_direction.rs b/src/components/facing_direction.rs index 9fa3ebc..c18c99a 100644 --- a/src/components/facing_direction.rs +++ b/src/components/facing_direction.rs @@ -1,9 +1,9 @@ use bevy::{ prelude::{Component, Vec3}, - reflect::{FromReflect, Reflect}, + reflect::Reflect, }; -#[derive(Component, Default, Reflect, FromReflect)] +#[derive(Component, Default, Reflect)] pub struct FacingDirection { pub desired: f32, pub actual: f32, diff --git a/src/components/model_height.rs b/src/components/model_height.rs index 0aa45bd..0a1f7cd 100644 --- a/src/components/model_height.rs +++ b/src/components/model_height.rs @@ -1,9 +1,6 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct ModelHeight { pub height: f32, } diff --git a/src/components/night_time_effect.rs b/src/components/night_time_effect.rs index 74e8d30..d763ddb 100644 --- a/src/components/night_time_effect.rs +++ b/src/components/night_time_effect.rs @@ -1,7 +1,4 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct NightTimeEffect; diff --git a/src/components/passive_recovery_time.rs b/src/components/passive_recovery_time.rs index 8825d5f..f47d6a1 100644 --- a/src/components/passive_recovery_time.rs +++ b/src/components/passive_recovery_time.rs @@ -1,11 +1,8 @@ use std::time::Duration; -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Default, Reflect, FromReflect)] +#[derive(Component, Default, Reflect)] pub struct PassiveRecoveryTime { pub time: Duration, } diff --git a/src/components/personal_store.rs b/src/components/personal_store.rs index f5db098..9e34e91 100644 --- a/src/components/personal_store.rs +++ b/src/components/personal_store.rs @@ -1,9 +1,9 @@ use bevy::{ prelude::{Component, Entity}, - reflect::{FromReflect, Reflect}, + reflect::Reflect, }; -#[derive(Clone, Component, Reflect, FromReflect)] +#[derive(Clone, Component, Reflect)] pub struct PersonalStore { pub title: String, pub skin: usize, @@ -15,7 +15,7 @@ impl PersonalStore { } } -#[derive(Clone, Component, Reflect, FromReflect)] +#[derive(Clone, Component, Reflect)] pub struct PersonalStoreModel { pub skin: usize, pub model: Entity, diff --git a/src/components/player_character.rs b/src/components/player_character.rs index a1b3b0a..7095b19 100644 --- a/src/components/player_character.rs +++ b/src/components/player_character.rs @@ -1,7 +1,4 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct PlayerCharacter; diff --git a/src/components/position.rs b/src/components/position.rs index 734978f..c89a043 100644 --- a/src/components/position.rs +++ b/src/components/position.rs @@ -1,9 +1,9 @@ use bevy::{ prelude::{Component, Deref, DerefMut, Vec3}, - reflect::{FromReflect, Reflect}, + reflect::Reflect, }; -#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, FromReflect)] +#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect)] pub struct Position { pub position: Vec3, } diff --git a/src/components/sound_category.rs b/src/components/sound_category.rs index 60c7875..5dbdf0f 100644 --- a/src/components/sound_category.rs +++ b/src/components/sound_category.rs @@ -1,10 +1,7 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; use enum_map::Enum; -#[derive(Component, Enum, Copy, Clone, Debug, Reflect, FromReflect)] +#[derive(Component, Enum, Copy, Clone, Debug, Reflect)] pub enum SoundCategory { BackgroundMusic, PlayerFootstep, diff --git a/src/components/warp_object.rs b/src/components/warp_object.rs index c3428f6..f0eb751 100644 --- a/src/components/warp_object.rs +++ b/src/components/warp_object.rs @@ -1,11 +1,8 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; use rose_data::WarpGateId; -#[derive(Component, Reflect, FromReflect)] +#[derive(Component, Reflect)] pub struct WarpObject { pub warp_id: WarpGateId, pub last_collision: f64, diff --git a/src/components/zone_object.rs b/src/components/zone_object.rs index 5ce838b..b8781ac 100644 --- a/src/components/zone_object.rs +++ b/src/components/zone_object.rs @@ -1,11 +1,8 @@ -use bevy::{ - prelude::Component, - reflect::{FromReflect, Reflect}, -}; +use bevy::{prelude::Component, reflect::Reflect}; use rose_file_readers::ZscCollisionShape; -#[derive(Clone, Reflect, FromReflect)] +#[derive(Clone, Reflect)] pub enum ZoneObjectPartCollisionShape { None, Sphere, @@ -32,13 +29,13 @@ impl From<&Option> for ZoneObjectPartCollisionShape { } } -#[derive(Clone, Default, Reflect, FromReflect)] +#[derive(Clone, Default, Reflect)] pub struct ZoneObjectId { pub ifo_object_id: usize, pub zsc_object_id: usize, } -#[derive(Clone, Default, Reflect, FromReflect)] +#[derive(Clone, Default, Reflect)] pub struct ZoneObjectPart { pub ifo_object_id: usize, pub zsc_object_id: usize, @@ -51,20 +48,20 @@ pub struct ZoneObjectPart { pub collision_no_camera: bool, } -#[derive(Clone, Default, Reflect, FromReflect)] +#[derive(Clone, Default, Reflect)] pub struct ZoneObjectAnimatedObject { pub mesh_path: String, pub motion_path: String, pub texture_path: String, } -#[derive(Clone, Default, Reflect, FromReflect)] +#[derive(Clone, Default, Reflect)] pub struct ZoneObjectTerrain { pub block_x: u32, pub block_y: u32, } -#[derive(Clone, Component, Default, Reflect, FromReflect)] +#[derive(Clone, Component, Default, Reflect)] pub enum ZoneObject { AnimatedObject(ZoneObjectAnimatedObject), WarpObject(ZoneObjectId), diff --git a/src/events/bank_event.rs b/src/events/bank_event.rs index 21811d0..abd8cc1 100644 --- a/src/events/bank_event.rs +++ b/src/events/bank_event.rs @@ -1,5 +1,8 @@ +use bevy::prelude::Event; + use rose_game_common::messages::ClientEntityId; +#[derive(Event)] pub enum BankEvent { OpenBankFromClientEntity { client_entity_id: ClientEntityId }, Show, diff --git a/src/events/character_select_event.rs b/src/events/character_select_event.rs index a72c368..765fb49 100644 --- a/src/events/character_select_event.rs +++ b/src/events/character_select_event.rs @@ -1,3 +1,6 @@ +use bevy::prelude::Event; + +#[derive(Event)] pub enum CharacterSelectEvent { SelectCharacter(usize), PlaySelected, diff --git a/src/events/chatbox_event.rs b/src/events/chatbox_event.rs index 724b976..7c0ae2f 100644 --- a/src/events/chatbox_event.rs +++ b/src/events/chatbox_event.rs @@ -1,3 +1,6 @@ +use bevy::prelude::Event; + +#[derive(Event)] pub enum ChatboxEvent { Say(String, String), Shout(String, String), diff --git a/src/events/clan_dialog_event.rs b/src/events/clan_dialog_event.rs index a56fd1b..4236014 100644 --- a/src/events/clan_dialog_event.rs +++ b/src/events/clan_dialog_event.rs @@ -1,3 +1,6 @@ +use bevy::prelude::Event; + +#[derive(Event)] pub enum ClanDialogEvent { Open, } diff --git a/src/events/client_entity_event.rs b/src/events/client_entity_event.rs index a57f70d..b295c06 100644 --- a/src/events/client_entity_event.rs +++ b/src/events/client_entity_event.rs @@ -1,6 +1,6 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; -#[derive(Copy, Clone, Debug)] +#[derive(Event, Copy, Clone, Debug)] pub enum ClientEntityEvent { Die(Entity), LevelUp(Entity, Option), diff --git a/src/events/conversation_dialog_event.rs b/src/events/conversation_dialog_event.rs index 7f52176..c5ef881 100644 --- a/src/events/conversation_dialog_event.rs +++ b/src/events/conversation_dialog_event.rs @@ -1,7 +1,8 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; use rose_file_readers::VfsPathBuf; +#[derive(Event)] pub enum ConversationDialogEvent { OpenNpcDialog(Entity, VfsPathBuf), OpenEventDialog(VfsPathBuf), diff --git a/src/events/game_connection_event.rs b/src/events/game_connection_event.rs index e564614..0f6ee98 100644 --- a/src/events/game_connection_event.rs +++ b/src/events/game_connection_event.rs @@ -1,5 +1,8 @@ +use bevy::prelude::Event; + use rose_data::ZoneId; +#[derive(Event)] pub enum GameConnectionEvent { Connected(ZoneId), } diff --git a/src/events/hit_event.rs b/src/events/hit_event.rs index 4383804..ee363c1 100644 --- a/src/events/hit_event.rs +++ b/src/events/hit_event.rs @@ -1,7 +1,8 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; use rose_data::{EffectId, SkillId}; +#[derive(Event)] pub struct HitEvent { pub attacker: Entity, pub defender: Entity, diff --git a/src/events/login_event.rs b/src/events/login_event.rs index 9e98f99..2a6f6a7 100644 --- a/src/events/login_event.rs +++ b/src/events/login_event.rs @@ -1,3 +1,6 @@ +use bevy::prelude::Event; + +#[derive(Event)] pub enum LoginEvent { Login { username: String, password: String }, SelectServer { server_id: usize, channel_id: usize }, diff --git a/src/events/message_box_event.rs b/src/events/message_box_event.rs index c75f782..7c3f23e 100644 --- a/src/events/message_box_event.rs +++ b/src/events/message_box_event.rs @@ -1,5 +1,6 @@ -use bevy::prelude::Commands; +use bevy::prelude::{Commands, Event}; +#[derive(Event)] pub enum MessageBoxEvent { Show { message: String, diff --git a/src/events/move_destination_effect_event.rs b/src/events/move_destination_effect_event.rs index 5cafb0e..3e2a46f 100644 --- a/src/events/move_destination_effect_event.rs +++ b/src/events/move_destination_effect_event.rs @@ -1,5 +1,6 @@ -use bevy::prelude::Vec3; +use bevy::prelude::{Event, Vec3}; +#[derive(Event)] pub enum MoveDestinationEffectEvent { Show { position: Vec3 }, Hide, diff --git a/src/events/network_event.rs b/src/events/network_event.rs index de0d23c..0b6fa54 100644 --- a/src/events/network_event.rs +++ b/src/events/network_event.rs @@ -1,3 +1,6 @@ +use bevy::prelude::Event; + +#[derive(Event)] #[allow(clippy::enum_variant_names)] pub enum NetworkEvent { ConnectLogin { diff --git a/src/events/npc_store_event.rs b/src/events/npc_store_event.rs index 6c8dc98..c9a5d8a 100644 --- a/src/events/npc_store_event.rs +++ b/src/events/npc_store_event.rs @@ -1,5 +1,8 @@ +use bevy::prelude::Event; + use rose_game_common::messages::ClientEntityId; +#[derive(Event)] pub enum NpcStoreEvent { OpenClientEntityStore(ClientEntityId), RemoveFromBuyList(usize), diff --git a/src/events/number_input_dialog_event.rs b/src/events/number_input_dialog_event.rs index 3f4804d..feadf28 100644 --- a/src/events/number_input_dialog_event.rs +++ b/src/events/number_input_dialog_event.rs @@ -1,5 +1,6 @@ -use bevy::prelude::Commands; +use bevy::prelude::{Commands, Event}; +#[derive(Event)] pub enum NumberInputDialogEvent { Show { max_value: Option, diff --git a/src/events/party_event.rs b/src/events/party_event.rs index 72efe88..2167371 100644 --- a/src/events/party_event.rs +++ b/src/events/party_event.rs @@ -1,5 +1,6 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; +#[derive(Event)] pub enum PartyEvent { InvitedCreate(Entity), InvitedJoin(Entity), diff --git a/src/events/personal_store_event.rs b/src/events/personal_store_event.rs index d1a5258..3951cd0 100644 --- a/src/events/personal_store_event.rs +++ b/src/events/personal_store_event.rs @@ -1,8 +1,9 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; use rose_data::Item; use rose_game_common::components::Money; +#[derive(Event)] pub enum PersonalStoreEvent { OpenEntityStore(Entity), SetItemList { diff --git a/src/events/player_command_event.rs b/src/events/player_command_event.rs index e0fb835..ad7d50d 100644 --- a/src/events/player_command_event.rs +++ b/src/events/player_command_event.rs @@ -1,11 +1,11 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; use rose_data::{AmmoIndex, EquipmentIndex, VehiclePartIndex}; use rose_game_common::components::{HotbarSlot, ItemSlot, SkillSlot}; use crate::components::Position; -#[derive(Clone)] +#[derive(Event, Clone)] pub enum PlayerCommandEvent { UseSkill(SkillSlot), DropItem(ItemSlot), diff --git a/src/events/quest_trigger_event.rs b/src/events/quest_trigger_event.rs index 2307bca..939b0dc 100644 --- a/src/events/quest_trigger_event.rs +++ b/src/events/quest_trigger_event.rs @@ -1,5 +1,8 @@ +use bevy::prelude::Event; + use rose_data::QuestTriggerHash; +#[derive(Event)] pub enum QuestTriggerEvent { ApplyRewards(QuestTriggerHash), DoTrigger(QuestTriggerHash), diff --git a/src/events/spawn_effect_event.rs b/src/events/spawn_effect_event.rs index 5054a86..bf12ed9 100644 --- a/src/events/spawn_effect_event.rs +++ b/src/events/spawn_effect_event.rs @@ -1,4 +1,5 @@ -use bevy::prelude::{Entity, Transform}; +use bevy::prelude::{Entity, Event, Transform}; + use rose_data::EffectFileId; use rose_file_readers::VfsPathBuf; @@ -33,6 +34,7 @@ impl SpawnEffectData { } } +#[derive(Event)] pub enum SpawnEffectEvent { // Spawns an effect at the same location than Entity, but does not attach to entity AtEntity(Entity, SpawnEffectData), diff --git a/src/events/spawn_projectile_event.rs b/src/events/spawn_projectile_event.rs index eb04b6e..c17dc24 100644 --- a/src/events/spawn_projectile_event.rs +++ b/src/events/spawn_projectile_event.rs @@ -1,9 +1,10 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; use rose_data::{EffectBulletMoveType, EffectId, SkillId}; use crate::components::ProjectileTarget; +#[derive(Event)] pub struct SpawnProjectileEvent { pub effect_id: EffectId, diff --git a/src/events/system_func_event.rs b/src/events/system_func_event.rs index a95616c..a5f0a40 100644 --- a/src/events/system_func_event.rs +++ b/src/events/system_func_event.rs @@ -1,6 +1,8 @@ +use bevy::prelude::Event; + use crate::scripting::lua4::Lua4Value; -#[derive(Clone)] +#[derive(Event, Clone)] pub enum SystemFuncEvent { CallFunction(String, Vec), } diff --git a/src/events/use_item_event.rs b/src/events/use_item_event.rs index 7684f4a..027fd0e 100644 --- a/src/events/use_item_event.rs +++ b/src/events/use_item_event.rs @@ -1,7 +1,8 @@ -use bevy::prelude::Entity; +use bevy::prelude::{Entity, Event}; use rose_data::ItemReference; +#[derive(Event)] pub struct UseItemEvent { pub entity: Entity, pub item: ItemReference, diff --git a/src/events/world_connection_event.rs b/src/events/world_connection_event.rs index 8b8ee3e..9f8a3d8 100644 --- a/src/events/world_connection_event.rs +++ b/src/events/world_connection_event.rs @@ -1,5 +1,8 @@ +use bevy::prelude::Event; + use rose_game_common::{components::CharacterDeleteTime, messages::server::CreateCharacterError}; +#[derive(Event)] pub enum WorldConnectionEvent { CreateCharacterSuccess { character_slot: usize, diff --git a/src/events/zone_event.rs b/src/events/zone_event.rs index 21c528a..9c11f8d 100644 --- a/src/events/zone_event.rs +++ b/src/events/zone_event.rs @@ -1,5 +1,8 @@ +use bevy::prelude::Event; + use rose_data::ZoneId; +#[derive(Event)] pub struct LoadZoneEvent { pub id: ZoneId, pub despawn_other_zones: bool, @@ -14,6 +17,7 @@ impl LoadZoneEvent { } } +#[derive(Event)] pub enum ZoneEvent { Loaded(ZoneId), } diff --git a/src/exe_resource_loader.rs b/src/exe_resource_loader.rs index 9210792..8ca4874 100644 --- a/src/exe_resource_loader.rs +++ b/src/exe_resource_loader.rs @@ -1,6 +1,6 @@ use bevy::{ asset::{AssetLoader, LoadContext, LoadedAsset}, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, utils::BoxedFuture, window::{CursorIcon, CursorIconCustom}, }; @@ -8,7 +8,7 @@ use bevy::{ #[derive(Clone, Default)] pub struct ExeResourceLoader; -#[derive(Debug, TypeUuid, Clone)] +#[derive(Debug, TypeUuid, TypePath, Clone)] #[uuid = "dda4ba39-576d-4863-a8b4-ca73cedcfbcd"] pub struct ExeResourceCursor { pub cursor: CursorIcon, diff --git a/src/lib.rs b/src/lib.rs index b97b2f8..5954556 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,12 +7,13 @@ use bevy::{ ecs::event::Events, log::Level, prelude::{ - apply_system_buffers, in_state, AddAsset, App, AssetServer, Assets, Camera, Camera3dBundle, - Color, Commands, CoreSet, IntoSystemAppConfig, IntoSystemConfig, IntoSystemConfigs, - IntoSystemSetConfigs, Msaa, OnEnter, OnExit, OnUpdate, PluginGroup, Quat, Res, ResMut, - StartupSet, State, SystemSet, Transform, Vec3, + apply_deferred, in_state, AddAsset, App, AssetServer, Assets, Camera, Camera3dBundle, + Color, Commands, IntoSystemConfigs, IntoSystemSetConfigs, Msaa, OnEnter, OnExit, + PluginGroup, PostStartup, PostUpdate, PreUpdate, Quat, Res, ResMut, Startup, State, + SystemSet, Transform, Update, Vec3, }, render::{render_resource::WgpuFeatures, settings::WgpuSettings}, + transform::TransformSystem, window::{Window, WindowMode}, }; use bevy_egui::{egui, EguiContexts, EguiSet}; @@ -40,7 +41,6 @@ pub mod events; pub mod exe_resource_loader; pub mod model_loader; pub mod protocol; -pub mod ray_from_screenspace; pub mod render; pub mod resources; pub mod scripting; @@ -416,7 +416,6 @@ pub fn run_zone_viewer(config: &Config, zone_id: Option) { } #[derive(Debug, Clone, PartialEq, Eq, Hash, SystemSet)] -#[system_set(base)] enum GameStages { ZoneChange, ZoneChangeFlush, @@ -465,13 +464,14 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC .insert_resource(AssetServer::new(VfsAssetIo::new(virtual_filesystem))); // Initialise bevy engine - app.insert_resource(Msaa::default()) + app.insert_resource(Msaa::Off) .insert_resource(ClearColor(Color::rgb(0.70, 0.90, 1.0))) - .add_plugins( + .add_plugins(( bevy::prelude::DefaultPlugins .set(bevy::render::RenderPlugin { wgpu_settings: WgpuSettings { features: WgpuFeatures::TEXTURE_COMPRESSION_BC, + // backends: Some(Backends::DX12), ..Default::default() }, }) @@ -505,22 +505,27 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC .set(bevy::pbr::PbrPlugin { prepass_enabled: false, }), - ) - .add_plugin(bevy::diagnostic::EntityCountDiagnosticsPlugin::default()) - .add_plugin(bevy::diagnostic::FrameTimeDiagnosticsPlugin::default()); + bevy::diagnostic::EntityCountDiagnosticsPlugin, + bevy::diagnostic::FrameTimeDiagnosticsPlugin, + )); // Initialise 3rd party bevy plugins - app.add_plugin(bevy_polyline::PolylinePlugin) - .add_plugin(bevy_egui::EguiPlugin) - .add_plugin(bevy_rapier3d::prelude::RapierPhysicsPlugin::< - bevy_rapier3d::prelude::NoUserData, - >::default()) - .insert_resource(bevy_rapier3d::prelude::RapierConfiguration { - physics_pipeline_active: false, - query_pipeline_active: true, + app.insert_resource(bevy_rapier3d::prelude::RapierConfiguration { + physics_pipeline_active: false, + query_pipeline_active: true, + ..Default::default() + }); + app.add_plugins(( + bevy_polyline::PolylinePlugin, + bevy_egui::EguiPlugin, + bevy_rapier3d::prelude::RapierPhysicsPlugin::::default( + ), + bevy_rapier3d::prelude::RapierDebugRenderPlugin { + enabled: false, ..Default::default() - }) - .add_plugin(OddioPlugin); + }, + OddioPlugin, + )); // Initialise rose stuff app.init_asset_loader::() @@ -558,14 +563,16 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC SoundCategory::Ui => config.sound.volume.ui_sounds, }, }) - .add_plugin(RoseAnimationPlugin) - .add_plugin(RoseRenderPlugin) - .add_plugin(RoseScriptingPlugin) - .add_plugin(DebugInspectorPlugin); + .add_plugins(( + RoseAnimationPlugin, + RoseRenderPlugin, + RoseScriptingPlugin, + DebugInspectorPlugin, + )); // Setup state app.add_state::() - .insert_resource(State::(app_state)); + .insert_resource(State::new(app_state)); app.add_event::() .add_event::() @@ -594,98 +601,110 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC .add_event::() .add_event::(); - app.add_system(apply_system_buffers.in_base_set(GameStages::ZoneChangeFlush)); - - app.add_system(apply_system_buffers.in_base_set(GameStages::DebugRenderPreFlush)); - - app.add_systems((free_camera_system, orbit_camera_system).in_set(GameSystemSets::UpdateCamera)); - - app.add_system(auto_login_system) - .add_system(background_music_system) - .add_system(character_model_update_system) - .add_system(character_model_add_collider_system.after(character_model_update_system)) - .add_system(personal_store_model_system) - .add_system(personal_store_model_add_collider_system.after(personal_store_model_system)) - .add_system(npc_model_update_system) - .add_system(npc_model_add_collider_system.after(npc_model_update_system)) - .add_system(item_drop_model_system) - .add_system(item_drop_model_add_collider_system.after(item_drop_model_system)) - .add_system(particle_sequence_system) - .add_system(effect_system) - .add_system(animation_effect_system.before(spawn_effect_system)) - .add_system(animation_sound_system) - .add_system( - projectile_system - .after(animation_effect_system) - .before(spawn_effect_system), - ) - .add_system(visible_status_effects_system.before(spawn_effect_system)) - .add_system( - spawn_projectile_system - .after(animation_effect_system) - .before(spawn_effect_system), - ) - .add_system( - pending_damage_system - .after(animation_effect_system) - .after(projectile_system), - ) - .add_system( - pending_skill_effect_system - .after(animation_effect_system) - .after(projectile_system), - ) - .add_system( - hit_event_system - .after(animation_effect_system) - .after(pending_skill_effect_system) - .after(projectile_system) - .before(spawn_effect_system), - ) - .add_system( - damage_digit_render_system - .after(pending_damage_system) - .after(hit_event_system), - ) - .add_system( - name_tag_update_healthbar_system - .after(pending_damage_system) - .after(hit_event_system), - ) - .add_system(update_ui_resources) - .add_system(spawn_effect_system) - .add_system(move_destination_effect_system.after(game_mouse_input_system)) - .add_system(npc_idle_sound_system) - .add_system(name_tag_system) - .add_system(name_tag_visibility_system.after(game_mouse_input_system)) - .add_system(name_tag_update_color_system) - .add_system(world_time_system) - .add_system(system_func_event_system) - .add_system(load_dialog_sprites_system) - .add_system(zone_time_system.after(world_time_system)) - .add_system(directional_light_system); - - app.add_system( - ui_requested_cursor_apply_system - .in_base_set(CoreSet::PostUpdate) - .after(EguiSet::ProcessOutput), + app.add_systems( + PostUpdate, + (apply_deferred,).in_set(GameStages::ZoneChangeFlush), + ); + app.add_systems( + PostUpdate, + (apply_deferred,).in_set(GameStages::DebugRenderPreFlush), + ); + + app.add_systems( + Update, + (free_camera_system, orbit_camera_system).in_set(GameSystemSets::UpdateCamera), + ); + app.add_systems( + Update, + ( + ( + auto_login_system, + background_music_system, + character_model_update_system, + character_model_add_collider_system.after(character_model_update_system), + personal_store_model_system, + personal_store_model_add_collider_system.after(personal_store_model_system), + npc_model_update_system, + npc_model_add_collider_system.after(npc_model_update_system), + item_drop_model_system, + item_drop_model_add_collider_system.after(item_drop_model_system), + particle_sequence_system, + effect_system, + animation_effect_system.before(spawn_effect_system), + animation_sound_system, + ), + ( + projectile_system + .after(animation_effect_system) + .before(spawn_effect_system), + visible_status_effects_system.before(spawn_effect_system), + spawn_projectile_system + .after(animation_effect_system) + .before(spawn_effect_system), + pending_damage_system + .after(animation_effect_system) + .after(projectile_system), + pending_skill_effect_system + .after(animation_effect_system) + .after(projectile_system), + hit_event_system + .after(animation_effect_system) + .after(pending_skill_effect_system) + .after(projectile_system) + .before(spawn_effect_system), + damage_digit_render_system + .after(pending_damage_system) + .after(hit_event_system), + name_tag_update_healthbar_system + .after(pending_damage_system) + .after(hit_event_system), + ), + ( + update_ui_resources, + spawn_effect_system, + move_destination_effect_system.after(game_mouse_input_system), + npc_idle_sound_system, + name_tag_system, + name_tag_visibility_system.after(game_mouse_input_system), + name_tag_update_color_system, + world_time_system, + system_func_event_system, + load_dialog_sprites_system, + zone_time_system.after(world_time_system), + directional_light_system, + ), + ), + ); + + app.add_systems( + PostUpdate, + ui_requested_cursor_apply_system.after(EguiSet::ProcessOutput), ); - app.add_system(ui_item_drop_name_system.in_set(UiSystemSets::UiFirst)); + app.add_systems( + Update, + ui_item_drop_name_system.in_set(UiSystemSets::UiFirst), + ); app.add_systems( + Update, (ui_message_box_system, ui_number_input_dialog_system).in_set(UiSystemSets::UiLast), ); app.add_systems( + Update, ( ui_window_sound_system.before(ui_sound_event_system), ui_sound_event_system, ) .after(UiSystemSets::UiLast), ); - app.add_systems((ui_debug_menu_system,).in_set(UiSystemSets::UiDebugMenu)); + app.add_systems( + Update, + (ui_debug_menu_system,).in_set(UiSystemSets::UiDebugMenu), + ); app.add_systems( + Update, ( ui_debug_camera_info_system, ui_debug_client_entity_list_system, @@ -708,89 +727,103 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC // character_model_blink_system in PostUpdate to avoid any conflicts with model destruction // e.g. through the character select exit system. - app.add_system(character_model_blink_system.in_base_set(CoreSet::PostUpdate)); + app.add_systems(PostUpdate, character_model_blink_system); // vehicle_model_system in after ::Update but before ::PostUpdate to avoid any conflicts, // with model destruction but to also be before global transform is calculated. - app.add_system(vehicle_model_system.in_base_set(GameStages::AfterUpdate)); - app.add_system( - vehicle_sound_system - .in_base_set(GameStages::AfterUpdate) - .after(vehicle_model_system), + app.add_systems( + PostUpdate, + (vehicle_model_system, vehicle_sound_system) + .chain() + .in_set(GameStages::AfterUpdate), ); // Run zone change system just before physics sync which is after Update app.add_systems( + Update, ( zone_loader_system, game_zone_change_system.after(zone_loader_system), ) - .in_base_set(GameStages::ZoneChange), + .in_set(GameStages::ZoneChange), ); // Run debug render stage last after physics update so it has accurate data - app.add_startup_system(debug_render_polylines_setup_system); + app.add_systems(Startup, debug_render_polylines_setup_system); app.add_systems( + Update, ( debug_render_collider_system.before(debug_render_polylines_update_system), debug_render_skeleton_system.before(debug_render_polylines_update_system), debug_render_directional_light_system.before(debug_render_polylines_update_system), debug_render_polylines_update_system, ) - .in_base_set(GameStages::DebugRender), + .in_set(GameStages::DebugRender), ); // Zone Viewer - app.add_system(zone_viewer_enter_system.in_schedule(OnEnter(AppState::ZoneViewer))); + app.add_systems(OnEnter(AppState::ZoneViewer), zone_viewer_enter_system); // Model Viewer, we avoid deleting any entities during CoreStage::Update by using a custom // stage which runs after Update. We cannot run before Update because the on_enter system // below will have not run yet. - app.add_system(model_viewer_enter_system.in_schedule(OnEnter(AppState::ModelViewer))) - .add_system(model_viewer_exit_system.in_schedule(OnExit(AppState::ModelViewer))); - app.add_system( + app.add_systems(OnEnter(AppState::ModelViewer), model_viewer_enter_system); + app.add_systems(OnExit(AppState::ModelViewer), model_viewer_exit_system); + app.add_systems( + PostUpdate, model_viewer_system .run_if(in_state(AppState::ModelViewer)) - .in_base_set(GameStages::ZoneChange), + .in_set(GameStages::ZoneChange) + .before(EguiSet::ProcessOutput), // model_viewer_system renders UI so must be before egui ); // Game Login - app.add_system(login_state_enter_system.in_schedule(OnEnter(AppState::GameLogin))) - .add_system(login_state_exit_system.in_schedule(OnExit(AppState::GameLogin))); + app.add_systems(OnEnter(AppState::GameLogin), login_state_enter_system) + .add_systems(OnExit(AppState::GameLogin), login_state_exit_system); - app.add_systems((login_system, login_event_system).in_set(OnUpdate(AppState::GameLogin))); + app.add_systems( + Update, + (login_system, login_event_system).run_if(in_state(AppState::GameLogin)), + ); app.add_systems( + Update, (ui_login_system, ui_server_select_system) - .in_set(OnUpdate(AppState::GameLogin)) + .run_if(in_state(AppState::GameLogin)) .in_set(UiSystemSets::Ui) .after(login_system) .before(login_event_system), ); // Game Character Select - app.add_system( - character_select_enter_system.in_schedule(OnEnter(AppState::GameCharacterSelect)), + app.add_systems( + OnEnter(AppState::GameCharacterSelect), + character_select_enter_system, ) - .add_system(character_select_exit_system.in_schedule(OnExit(AppState::GameCharacterSelect))); + .add_systems( + OnExit(AppState::GameCharacterSelect), + character_select_exit_system, + ); app.add_systems( + Update, ( character_select_system, character_select_input_system, character_select_models_system, character_select_event_system, ) - .in_set(OnUpdate(AppState::GameCharacterSelect)), + .run_if(in_state(AppState::GameCharacterSelect)), ); app.add_systems( + Update, ( ui_character_create_system, ui_character_select_system, ui_character_select_name_tag_system, ) - .in_set(OnUpdate(AppState::GameCharacterSelect)) + .run_if(in_state(AppState::GameCharacterSelect)) .in_set(UiSystemSets::Ui) .after(character_select_system) .after(character_select_input_system) @@ -808,9 +841,10 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC .init_resource::() .init_resource::(); - app.add_system(game_state_enter_system.in_schedule(OnEnter(AppState::Game))); + app.add_systems(OnEnter(AppState::Game), game_state_enter_system); app.add_systems( + Update, ( ability_values_system, clan_system, @@ -831,58 +865,56 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC status_effect_system, passive_recovery_system, quest_trigger_system, + game_mouse_input_system.after(GameSystemSets::Ui), ) - .in_set(OnUpdate(AppState::Game)), - ) - .add_systems( - (game_mouse_input_system.after(GameSystemSets::Ui),).in_set(OnUpdate(AppState::Game)), + .run_if(in_state(AppState::Game)), ); app.add_systems( + Update, ( - ui_bank_system, - ui_chatbox_system, - ui_character_info_system, - ui_clan_system, - ui_create_clan_system, - ui_inventory_system, - ui_game_menu_system.after(ui_character_info_system), - ui_hotbar_system, - ui_minimap_system, - ui_npc_store_system, - ui_party_system, - ui_party_option_system, - ui_personal_store_system, - ui_player_info_system, - ui_quest_list_system, + ( + ui_bank_system, + ui_chatbox_system, + ui_character_info_system, + ui_clan_system, + ui_create_clan_system, + ui_inventory_system, + ui_game_menu_system.after(ui_character_info_system), + ui_hotbar_system, + ui_minimap_system, + ui_npc_store_system, + ui_party_system, + ui_party_option_system, + ui_personal_store_system, + ui_player_info_system, + ), + ( + ui_quest_list_system, + ui_respawn_system, + ui_selected_target_system, + ui_skill_list_system, + ui_skill_tree_system, + ui_settings_system, + ui_status_effects_system, + conversation_dialog_system, + ), ) - .in_set(OnUpdate(AppState::Game)) - .in_set(UiSystemSets::Ui), - ) - .add_systems( - ( - ui_respawn_system, - ui_selected_target_system, - ui_skill_list_system, - ui_skill_tree_system, - ui_settings_system, - ui_status_effects_system, - conversation_dialog_system, - ) - .in_set(OnUpdate(AppState::Game)) + .run_if(in_state(AppState::Game)) .in_set(UiSystemSets::Ui), ); if !systems_config.disable_player_command_system { app.add_systems( + Update, (player_command_system .after(cooldown_system) .after(game_mouse_input_system),) - .in_set(OnUpdate(AppState::Game)), + .run_if(in_state(AppState::Game)), ); } - app.add_system(ui_drag_and_drop_system.in_base_set(CoreSet::PostUpdate)); + app.add_systems(PostUpdate, ui_drag_and_drop_system); // Setup network let (network_thread_tx, network_thread_rx) = @@ -892,15 +924,15 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC // Run network systems before Update, so we can add/remove entities app.add_systems( + PreUpdate, ( login_connection_system, world_connection_system, game_connection_system, - ) - .in_base_set(CoreSet::PreUpdate), + ), ); - app.add_startup_system(load_common_game_data.in_base_set(StartupSet::PostStartup)); + app.add_systems(PostStartup, load_common_game_data); if let Some(app_builder) = systems_config.add_custom_systems.take() { app_builder(&mut app); @@ -908,7 +940,7 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC match config.game.network_version.as_str() { "irose" => { - app.add_system(network_thread_system.in_base_set(CoreSet::PostUpdate)); + app.add_systems(PostUpdate, network_thread_system); } "custom" => {} unknown => panic!("Unknown game network version {}", unknown), @@ -916,7 +948,7 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC match config.game.ui_version.as_str() { "irose" => { - app.add_startup_system(load_ui_resources); + app.add_systems(Startup, load_ui_resources); } "custom" => {} unknown => panic!("Unknown game ui version {}", unknown), @@ -924,33 +956,37 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC match config.game.data_version.as_str() { "irose" => { - app.add_startup_system(load_game_data_irose); + app.add_systems(Startup, load_game_data_irose); } "custom" => {} unknown => panic!("Unknown game data version {}", unknown), }; app.configure_sets( - (GameStages::AfterUpdate,) - .after(CoreSet::UpdateFlush) - .before(PhysicsSet::SyncBackend), + PostUpdate, + (GameStages::AfterUpdate,).before(PhysicsSet::SyncBackend), ); app.configure_sets( - (GameStages::ZoneChange, GameStages::ZoneChangeFlush) + PostUpdate, + ( + GameStages::ZoneChange, + GameStages::ZoneChangeFlush, + GameStages::AfterUpdate, + ) .chain() - .after(CoreSet::UpdateFlush) .before(PhysicsSet::SyncBackend), ); app.configure_sets( + PostUpdate, (GameStages::DebugRenderPreFlush, GameStages::DebugRender) .chain() - .after(PhysicsSet::Writeback) - .before(CoreSet::PostUpdate), + .after(TransformSystem::TransformPropagate), ); app.configure_sets( + Update, ( UiSystemSets::UiDebugMenu, UiSystemSets::UiFirst, @@ -962,7 +998,10 @@ fn run_client(config: &Config, app_state: AppState, mut systems_config: SystemsC .in_set(GameSystemSets::Ui), ); - app.configure_sets((GameSystemSets::UpdateCamera, GameSystemSets::Ui).chain()); + app.configure_sets( + Update, + (GameSystemSets::UpdateCamera, GameSystemSets::Ui).chain(), + ); app.run(); diff --git a/src/ray_from_screenspace.rs b/src/ray_from_screenspace.rs deleted file mode 100644 index cef8381..0000000 --- a/src/ray_from_screenspace.rs +++ /dev/null @@ -1,40 +0,0 @@ -use bevy::{ - math::{Mat4, Vec2, Vec3}, - prelude::{Camera, GlobalTransform}, - render::camera::Projection, - window::Window, -}; - -pub fn ray_from_screenspace( - cursor_pos_screen: Vec2, - window: &Window, - camera: &Camera, - camera_projection: &Projection, - camera_transform: &GlobalTransform, -) -> Option<(Vec3, Vec3)> { - let view = camera_transform.compute_matrix(); - let screen_size = Vec2::from([window.width(), window.height()]); - let projection = camera.projection_matrix(); - - // 2D Normalized device coordinate cursor position from (-1, -1) to (1, 1) - let cursor_ndc = (cursor_pos_screen / screen_size) * 2.0 - Vec2::from([1.0, 1.0]); - let ndc_to_world: Mat4 = view * projection.inverse(); - let world_to_ndc = projection * view; - let is_orthographic = projection.w_axis[3] == 1.0; - - // Compute the cursor position at the near plane. The bevy camera looks at -Z. - let camera_near = match camera_projection { - Projection::Perspective(perspective_projection) => perspective_projection.near, - Projection::Orthographic(orthographic_projection) => orthographic_projection.near, - }; - let ndc_near = world_to_ndc.transform_point3(-Vec3::Z * camera_near).z; - let cursor_pos_near = ndc_to_world.transform_point3(cursor_ndc.extend(ndc_near)); - - // Compute the ray's direction depending on the projection used. - let ray_direction = match is_orthographic { - true => view.transform_vector3(-Vec3::Z), // All screenspace rays are parallel in ortho - false => cursor_pos_near - camera_transform.translation(), // Direction from camera to cursor - }; - - Some((cursor_pos_near, ray_direction)) -} diff --git a/src/render/damage_digit_material.rs b/src/render/damage_digit_material.rs index 68ff0f9..33ba5ac 100644 --- a/src/render/damage_digit_material.rs +++ b/src/render/damage_digit_material.rs @@ -2,7 +2,7 @@ use bevy::{ app::{App, Plugin}, asset::{AddAsset, Handle}, ecs::system::{lifetimeless::SRes, SystemParamItem}, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, render::{ render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin}, renderer::RenderDevice, @@ -10,7 +10,7 @@ use bevy::{ }, }; -#[derive(Debug, Clone, TypeUuid)] +#[derive(Debug, Clone, TypeUuid, TypePath)] #[uuid = "83077909-bf71-4f14-9a86-16f65d611ce9"] pub struct DamageDigitMaterial { pub texture: Handle, @@ -20,7 +20,7 @@ pub struct DamageDigitMaterialPlugin; impl Plugin for DamageDigitMaterialPlugin { fn build(&self, app: &mut App) { - app.add_plugin(RenderAssetPlugin::::default()) + app.add_plugins(RenderAssetPlugin::::default()) .add_asset::(); } } diff --git a/src/render/damage_digit_pipeline.rs b/src/render/damage_digit_pipeline.rs index 40ea1a5..60ed101 100644 --- a/src/render/damage_digit_pipeline.rs +++ b/src/render/damage_digit_pipeline.rs @@ -23,7 +23,7 @@ use bevy::{ ComputedVisibility, ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, }, - Extract, ExtractSchedule, RenderApp, RenderSet, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, }; use bytemuck::Pod; @@ -47,16 +47,24 @@ impl Plugin for DamageDigitRenderPlugin { let render_app = app.sub_app_mut(RenderApp); render_app - .add_system(extract_damage_digits.in_schedule(ExtractSchedule)) - .add_system(prepare_damage_digits.in_set(RenderSet::Prepare)) - .add_system(queue_damage_digits.in_set(RenderSet::Queue)) - .init_resource::() + .add_systems(ExtractSchedule, extract_damage_digits) + .add_systems(Render, prepare_damage_digits.in_set(RenderSet::Prepare)) + .add_systems(Render, queue_damage_digits.in_set(RenderSet::Queue)) .init_resource::() .init_resource::() .init_resource::() .init_resource::>() .add_render_command::(); } + + fn finish(&self, app: &mut App) { + let render_app = match app.get_sub_app_mut(RenderApp) { + Ok(render_app) => render_app, + Err(_) => return, + }; + + render_app.init_resource::(); + } } #[derive(Resource)] @@ -68,7 +76,7 @@ struct DamageDigitPipeline { impl FromWorld for DamageDigitPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.get_resource::().unwrap(); + let render_device = world.resource::(); let view_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[BindGroupLayoutEntry { @@ -77,7 +85,7 @@ impl FromWorld for DamageDigitPipeline { ty: BindingType::Buffer { ty: BufferBindingType::Uniform, has_dynamic_offset: true, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(ViewUniform::min_size()), }, count: None, }], @@ -94,7 +102,7 @@ impl FromWorld for DamageDigitPipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec4::min_size()), }, count: None, }, @@ -105,7 +113,7 @@ impl FromWorld for DamageDigitPipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec2::min_size()), }, count: None, }, @@ -116,7 +124,7 @@ impl FromWorld for DamageDigitPipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec4::min_size()), }, count: None, }, @@ -156,6 +164,7 @@ impl FromWorld for DamageDigitPipeline { } bitflags::bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct DamageDigitPipelineKey: u32 { const NONE = 0; @@ -170,7 +179,7 @@ impl DamageDigitPipelineKey { pub fn from_msaa_samples(msaa_samples: u32) -> Self { let msaa_bits = ((msaa_samples - 1) & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS; - DamageDigitPipelineKey::from_bits(msaa_bits).unwrap() + DamageDigitPipelineKey::from_bits_retain(msaa_bits) } pub fn from_hdr(hdr: bool) -> Self { @@ -182,7 +191,7 @@ impl DamageDigitPipelineKey { } pub fn msaa_samples(&self) -> u32 { - ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) + 1 + ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) + 1 } } diff --git a/src/render/effect_mesh_material.rs b/src/render/effect_mesh_material.rs index 27420d5..a61792f 100644 --- a/src/render/effect_mesh_material.rs +++ b/src/render/effect_mesh_material.rs @@ -12,7 +12,7 @@ use bevy::{ MeshPipelineKey, SetMaterialBindGroup, SetMeshBindGroup, SetMeshViewBindGroup, }, prelude::{App, Component, FromWorld, HandleUntyped, Mesh, Plugin, With, World}, - reflect::{Reflect, TypeUuid}, + reflect::{Reflect, TypePath, TypeUuid}, render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, mesh::{GpuBufferInfo, MeshVertexBufferLayout}, @@ -51,10 +51,12 @@ impl Plugin for EffectMeshMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(ExtractComponentPlugin::::extract_visible()); + app.add_plugins( + ExtractComponentPlugin::::extract_visible(), + ); app.register_type::(); - app.add_plugin(MaterialPlugin::< + app.add_plugins(MaterialPlugin::< EffectMeshMaterial, DrawEffectMeshMaterial, DrawPrepass, @@ -67,6 +69,7 @@ impl Plugin for EffectMeshMaterialPlugin { } bitflags::bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct EffectMeshMaterialFlags: u32 { const ALPHA_MODE_OPAQUE = (1 << 0); @@ -76,6 +79,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct EffectMeshAnimationFlags: u32 { const ANIMATE_POSITION = (1 << 0); @@ -110,7 +114,7 @@ pub struct EffectMeshMaterialUniformData { pub alpha_cutoff: f32, } -#[derive(AsBindGroup, Debug, Clone, TypeUuid)] +#[derive(AsBindGroup, Debug, Clone, TypeUuid, TypePath)] #[uuid = "9ac3266d-1aa6-4f67-ade4-e3765fd0b1a1"] #[bind_group_data(EffectMeshMaterialKey)] #[uniform(0, EffectMeshMaterialUniformData)] @@ -342,6 +346,7 @@ impl RenderCommand

for DrawEffectMesh { if let Some(gpu_mesh) = meshes.into_inner().get(mesh_handle) { pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..)); + match &gpu_mesh.buffer_info { GpuBufferInfo::Indexed { buffer, @@ -351,8 +356,8 @@ impl RenderCommand

for DrawEffectMesh { pass.set_index_buffer(buffer.slice(..), 0, *index_format); pass.draw_indexed(0..*count, 0, 0..1); } - GpuBufferInfo::NonIndexed { vertex_count } => { - pass.draw(0..*vertex_count, 0..1); + GpuBufferInfo::NonIndexed => { + pass.draw(0..gpu_mesh.vertex_count, 0..1); } } RenderCommandResult::Success diff --git a/src/render/mod.rs b/src/render/mod.rs index 5bac2b0..a3dbb10 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -66,17 +66,19 @@ impl Plugin for RoseRenderPlugin { fn build(&self, app: &mut App) { let prepass_enabled = false; - app.add_plugin(ZoneLightingPlugin) - .add_plugin(TerrainMaterialPlugin { prepass_enabled }) - .add_plugin(EffectMeshMaterialPlugin { prepass_enabled }) - .add_plugin(ObjectMaterialPlugin { prepass_enabled }) - .add_plugin(WaterMaterialPlugin { prepass_enabled }) - .add_plugin(ParticleMaterialPlugin) - .add_plugin(ParticleRenderPlugin) - .add_plugin(DamageDigitMaterialPlugin) - .add_plugin(DamageDigitRenderPlugin) - .add_plugin(SkyMaterialPlugin { prepass_enabled }) - .add_plugin(TrailEffectRenderPlugin) - .add_plugin(WorldUiRenderPlugin); + app.add_plugins(( + ZoneLightingPlugin, + TerrainMaterialPlugin { prepass_enabled }, + EffectMeshMaterialPlugin { prepass_enabled }, + ObjectMaterialPlugin { prepass_enabled }, + WaterMaterialPlugin { prepass_enabled }, + ParticleMaterialPlugin, + ParticleRenderPlugin, + DamageDigitMaterialPlugin, + DamageDigitRenderPlugin, + SkyMaterialPlugin { prepass_enabled }, + TrailEffectRenderPlugin, + WorldUiRenderPlugin, + )); } } diff --git a/src/render/object_material.rs b/src/render/object_material.rs index 5fa778d..022e59d 100644 --- a/src/render/object_material.rs +++ b/src/render/object_material.rs @@ -16,7 +16,7 @@ use bevy::{ AddAsset, App, Component, FromWorld, HandleUntyped, Material, MaterialPlugin, Mesh, Plugin, Vec3, With, World, }, - reflect::{FromReflect, Reflect, TypeUuid}, + reflect::{Reflect, TypeUuid}, render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, mesh::{GpuBufferInfo, MeshVertexBufferLayout}, @@ -58,11 +58,11 @@ impl Plugin for ObjectMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(ExtractComponentPlugin::::extract_visible()); + app.add_plugins(ExtractComponentPlugin::::extract_visible()); app.register_type::(); - app.add_plugin(MaterialPlugin::< + app.add_plugins(MaterialPlugin::< ObjectMaterial, DrawObjectMaterial, DrawPrepass, @@ -128,9 +128,9 @@ impl RenderCommand

for DrawObjectMesh { pass.set_index_buffer(buffer.slice(..), 0, *index_format); pass.draw_indexed(start_index..end_index, 0, 0..1); } - GpuBufferInfo::NonIndexed { vertex_count } => { + GpuBufferInfo::NonIndexed => { let start_vertex = start_index_offset; - let end_vertex = *vertex_count - end_index_offset; + let end_vertex = gpu_mesh.vertex_count - end_index_offset; pass.draw(start_vertex..end_vertex, 0..1); } } @@ -152,6 +152,7 @@ type DrawObjectMaterial = ( // NOTE: These must match the bit flags in shaders/object_material.wgsl! bitflags::bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct ObjectMaterialFlags: u32 { const ALPHA_MODE_OPAQUE = (1 << 0); @@ -213,7 +214,7 @@ impl From<&ObjectMaterial> for ObjectMaterialUniformData { } } -#[derive(Copy, Clone, Debug, Default, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, Reflect)] pub enum ObjectMaterialBlend { #[default] Normal, @@ -229,7 +230,7 @@ impl From for ObjectMaterialBlend { } } -#[derive(Copy, Clone, Debug, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Reflect)] pub enum ObjectMaterialGlow { Simple(Vec3), Light(Vec3), @@ -260,7 +261,7 @@ impl From for ObjectMaterialGlow { } } -#[derive(Debug, Clone, TypeUuid, Reflect, FromReflect, AsBindGroup)] +#[derive(Debug, Clone, TypeUuid, Reflect, AsBindGroup)] #[uniform(0, ObjectMaterialUniformData)] #[bind_group_data(ObjectMaterialKey)] #[uuid = "62a496fa-33e8-41a8-9a44-237d70214227"] @@ -383,12 +384,12 @@ impl Material for ObjectMaterial { descriptor .vertex .shader_defs - .push(ShaderDefVal::Bool("HAS_OBJECT_LIGHTMAP".into(), true)); + .push(ShaderDefVal::Bool("VERTEX_UVS_LIGHTMAP".into(), true)); if let Some(fragment) = descriptor.fragment.as_mut() { fragment .shader_defs - .push(ShaderDefVal::Bool("HAS_OBJECT_LIGHTMAP".into(), true)); + .push(ShaderDefVal::Bool("VERTEX_UVS_LIGHTMAP".into(), true)); } vertex_attributes.push(MESH_ATTRIBUTE_UV_1.at_shader_location(3)); @@ -401,17 +402,6 @@ impl Material for ObjectMaterial { if layout.contains(Mesh::ATTRIBUTE_JOINT_INDEX) && layout.contains(Mesh::ATTRIBUTE_JOINT_WEIGHT) { - descriptor - .vertex - .shader_defs - .push(ShaderDefVal::Bool("SKINNED".into(), true)); - - if let Some(fragment) = descriptor.fragment.as_mut() { - fragment - .shader_defs - .push(ShaderDefVal::Bool("SKINNED".into(), true)); - } - vertex_attributes.push(Mesh::ATTRIBUTE_JOINT_INDEX.at_shader_location(4)); vertex_attributes.push(Mesh::ATTRIBUTE_JOINT_WEIGHT.at_shader_location(5)); } diff --git a/src/render/particle_material.rs b/src/render/particle_material.rs index dfcab9c..3308f2a 100644 --- a/src/render/particle_material.rs +++ b/src/render/particle_material.rs @@ -2,7 +2,7 @@ use bevy::{ app::{App, Plugin}, asset::{AddAsset, Handle}, ecs::system::{lifetimeless::SRes, SystemParamItem}, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, render::{ render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin}, renderer::RenderDevice, @@ -10,7 +10,7 @@ use bevy::{ }, }; -#[derive(Debug, Clone, TypeUuid)] +#[derive(Debug, Clone, TypeUuid, TypePath)] #[uuid = "0078f73d-8715-427e-aa65-dc8e1f485d3d"] pub struct ParticleMaterial { pub texture: Handle, @@ -20,7 +20,7 @@ pub struct ParticleMaterialPlugin; impl Plugin for ParticleMaterialPlugin { fn build(&self, app: &mut App) { - app.add_plugin(RenderAssetPlugin::::default()) + app.add_plugins(RenderAssetPlugin::::default()) .add_asset::(); } } diff --git a/src/render/particle_pipeline.rs b/src/render/particle_pipeline.rs index cae9823..1a09f2a 100644 --- a/src/render/particle_pipeline.rs +++ b/src/render/particle_pipeline.rs @@ -24,7 +24,7 @@ use bevy::{ ComputedVisibility, ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, VisibilitySystems, }, - Extract, ExtractSchedule, RenderApp, RenderSet, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, }; use bytemuck::Pod; @@ -50,20 +50,31 @@ impl Plugin for ParticleRenderPlugin { Shader::from_wgsl ); - app.add_system(compute_particles_aabb.in_set(VisibilitySystems::CalculateBounds)); + app.add_systems( + PostUpdate, + compute_particles_aabb.in_set(VisibilitySystems::CalculateBounds), + ); let render_app = app.sub_app_mut(RenderApp); render_app - .add_system(extract_particles.in_schedule(ExtractSchedule)) - .add_system(prepare_particles.in_set(RenderSet::Prepare)) - .add_system(queue_particles.in_set(RenderSet::Queue)) - .init_resource::() + .add_systems(ExtractSchedule, extract_particles) + .add_systems(Render, prepare_particles.in_set(RenderSet::Prepare)) + .add_systems(Render, queue_particles.in_set(RenderSet::Queue)) .init_resource::() .init_resource::() .init_resource::() .init_resource::>() .add_render_command::(); } + + fn finish(&self, app: &mut App) { + let render_app = match app.get_sub_app_mut(RenderApp) { + Ok(render_app) => render_app, + Err(_) => return, + }; + + render_app.init_resource::(); + } } #[derive(Resource)] @@ -76,7 +87,7 @@ struct ParticlePipeline { impl FromWorld for ParticlePipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.get_resource::().unwrap(); + let render_device = world.resource::(); let view_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[BindGroupLayoutEntry { @@ -85,7 +96,7 @@ impl FromWorld for ParticlePipeline { ty: BindingType::Buffer { ty: BufferBindingType::Uniform, has_dynamic_offset: true, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(ViewUniform::min_size()), }, count: None, }], @@ -102,7 +113,7 @@ impl FromWorld for ParticlePipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec4::min_size()), }, count: None, }, @@ -113,7 +124,7 @@ impl FromWorld for ParticlePipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec2::min_size()), }, count: None, }, @@ -124,7 +135,7 @@ impl FromWorld for ParticlePipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec4::min_size()), }, count: None, }, @@ -135,7 +146,7 @@ impl FromWorld for ParticlePipeline { ty: BindingType::Buffer { ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(Vec4::min_size()), }, count: None, }, @@ -182,6 +193,7 @@ impl FromWorld for ParticlePipeline { } bitflags::bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] #[repr(transparent)] pub struct ParticlePipelineKey: u32 { const NONE = 0; @@ -237,7 +249,7 @@ impl ParticlePipelineKey { pub fn from_msaa_samples(msaa_samples: u32) -> Self { let msaa_bits = ((msaa_samples - 1) & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS; - ParticlePipelineKey::from_bits(msaa_bits).unwrap() + ParticlePipelineKey::from_bits_retain(msaa_bits) } pub fn from_hdr(hdr: bool) -> Self { @@ -252,39 +264,39 @@ impl ParticlePipelineKey { let blend_bits = (blend_op as u32) << Self::BLEND_OP_SHIFT_BITS | (src_blend_factor as u32) << Self::SRC_BLEND_FACTOR_SHIFT_BITS | (dst_blend_factor as u32) << Self::DST_BLEND_FACTOR_SHIFT_BITS; - ParticlePipelineKey::from_bits(blend_bits).unwrap() + ParticlePipelineKey::from_bits_retain(blend_bits) } pub fn from_billboard(billboard_type: ParticleRenderBillboardType) -> Self { let billboard_bits = (billboard_type as u32) << Self::BILLBOARD_SHIFT_BITS; - ParticlePipelineKey::from_bits(billboard_bits).unwrap() + ParticlePipelineKey::from_bits_retain(billboard_bits) } pub fn billboard_type(&self) -> ParticleRenderBillboardType { FromPrimitive::from_u32( - (self.bits >> Self::BILLBOARD_SHIFT_BITS) & Self::BILLBOARD_MASK_BITS, + (self.bits() >> Self::BILLBOARD_SHIFT_BITS) & Self::BILLBOARD_MASK_BITS, ) .unwrap() } pub fn blend_op(&self) -> BlendOperation { - decode_blend_op((self.bits >> Self::BLEND_OP_SHIFT_BITS) & Self::BLEND_OP_MASK_BITS) + decode_blend_op((self.bits() >> Self::BLEND_OP_SHIFT_BITS) & Self::BLEND_OP_MASK_BITS) } pub fn src_blend_factor(&self) -> BlendFactor { decode_blend_factor( - (self.bits >> Self::SRC_BLEND_FACTOR_SHIFT_BITS) & Self::BLEND_FACTOR_MASK_BITS, + (self.bits() >> Self::SRC_BLEND_FACTOR_SHIFT_BITS) & Self::BLEND_FACTOR_MASK_BITS, ) } pub fn dst_blend_factor(&self) -> BlendFactor { decode_blend_factor( - (self.bits >> Self::DST_BLEND_FACTOR_SHIFT_BITS) & Self::BLEND_FACTOR_MASK_BITS, + (self.bits() >> Self::DST_BLEND_FACTOR_SHIFT_BITS) & Self::BLEND_FACTOR_MASK_BITS, ) } pub fn msaa_samples(&self) -> u32 { - ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) + 1 + ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) + 1 } } diff --git a/src/render/shaders/damage_digit.wgsl b/src/render/shaders/damage_digit.wgsl index e2e6426..670eba2 100644 --- a/src/render/shaders/damage_digit.wgsl +++ b/src/render/shaders/damage_digit.wgsl @@ -1,4 +1,4 @@ -#import bevy_render::view +#import bevy_render::view View @group(0) @binding(0) var view: View; diff --git a/src/render/shaders/effect_mesh_material.wgsl b/src/render/shaders/effect_mesh_material.wgsl index a1b4e80..4c31d69 100644 --- a/src/render/shaders/effect_mesh_material.wgsl +++ b/src/render/shaders/effect_mesh_material.wgsl @@ -1,6 +1,7 @@ -#import bevy_pbr::mesh_types -#import bevy_pbr::mesh_view_bindings -#import rose_client::zone_lighting +#import bevy_pbr::mesh_bindings mesh +#import bevy_pbr::mesh_view_bindings view +#import bevy_pbr::mesh_functions mesh_normal_local_to_world +#import rose_client::zone_lighting apply_zone_lighting struct EffectMeshMaterialData { flags: u32, @@ -37,11 +38,6 @@ struct AnimationState { var animation_state: AnimationState; #endif -@group(2) @binding(0) -var mesh: Mesh; - -#import bevy_pbr::mesh_functions - struct Vertex { @location(0) position: vec3, @location(1) uv: vec2, diff --git a/src/render/shaders/object_material.wgsl b/src/render/shaders/object_material.wgsl index 8f0c861..c0b2e0f 100644 --- a/src/render/shaders/object_material.wgsl +++ b/src/render/shaders/object_material.wgsl @@ -1,18 +1,12 @@ -#import bevy_pbr::mesh_types -#import bevy_pbr::mesh_view_bindings -#import rose_client::zone_lighting - -@group(2) @binding(0) -var mesh: Mesh; - -#import bevy_pbr::utils -#import bevy_pbr::mesh_functions -#import bevy_pbr::shadows +#import bevy_pbr::mesh_types Mesh, SkinnedMesh +#import bevy_pbr::mesh_view_bindings view +#import bevy_pbr::mesh_bindings mesh +#import bevy_pbr::mesh_functions mesh_position_local_to_world, mesh_normal_local_to_world, mesh_position_world_to_clip +#import bevy_pbr::shadows fetch_directional_shadow +#import rose_client::zone_lighting apply_zone_lighting #ifdef SKINNED -@group(2) @binding(1) -var joint_matrices: SkinnedMesh; -#import bevy_pbr::skinning +#import bevy_pbr::skinning skin_normals, skin_model #endif @group(1) @binding(0) @@ -31,27 +25,39 @@ var specular_texture: texture_2d; var specular_sampler: sampler; struct Vertex { +#ifdef VERTEX_POSITIONS @location(0) position: vec3, +#endif + +#ifdef VERTEX_NORMALS @location(1) normal: vec3, +#endif + +#ifdef VERTEX_UVS @location(2) uv: vec2, +#endif -#ifdef HAS_OBJECT_LIGHTMAP +#ifdef VERTEX_UVS_LIGHTMAP @location(3) lightmap_uv: vec2, #endif #ifdef SKINNED - @location(4) joint_indexes: vec4, + @location(4) joint_indices: vec4, @location(5) joint_weights: vec4, #endif }; struct VertexOutput { @builtin(position) clip_position: vec4, + @location(0) world_position: vec4, @location(1) world_normal: vec3, + +#ifdef VERTEX_UVS @location(2) uv: vec2, +#endif -#ifdef HAS_OBJECT_LIGHTMAP +#ifdef VERTEX_UVS_LIGHTMAP @location(3) lightmap_uv: vec2, #endif }; @@ -59,22 +65,34 @@ struct VertexOutput { @vertex fn vertex(vertex: Vertex) -> VertexOutput { var out: VertexOutput; - out.uv = vertex.uv; -#ifdef HAS_OBJECT_LIGHTMAP - out.lightmap_uv = vertex.lightmap_uv; +#ifdef SKINNED + var model = skin_model(vertex.joint_indices, vertex.joint_weights); +#else + var model = mesh.model; #endif +#ifdef VERTEX_NORMALS #ifdef SKINNED - let skinned_model = skin_model(vertex.joint_indexes, vertex.joint_weights); - out.world_position = mesh_position_local_to_world(skinned_model, vec4(vertex.position, 1.0)); - out.world_normal = skin_normals(skinned_model, vertex.normal); + out.world_normal = skin_normals(model, vertex.normal); #else - out.world_position = mesh_position_local_to_world(mesh.model, vec4(vertex.position, 1.0)); out.world_normal = mesh_normal_local_to_world(vertex.normal); -#endif // ifdef SKINNED +#endif +#endif + +#ifdef VERTEX_POSITIONS + out.world_position = mesh_position_local_to_world(model, vec4(vertex.position, 1.0)); + out.clip_position = mesh_position_world_to_clip(out.world_position); +#endif + +#ifdef VERTEX_UVS + out.uv = vertex.uv; +#endif + +#ifdef VERTEX_UVS_LIGHTMAP + out.lightmap_uv = vertex.lightmap_uv; +#endif - out.clip_position = view.view_proj * out.world_position; return out; } @@ -96,13 +114,18 @@ struct FragmentInput { @builtin(position) frag_coord: vec4, @location(0) world_position: vec4, @location(1) world_normal: vec3, + +#ifdef VERTEX_UVS @location(2) uv: vec2, -#ifdef HAS_OBJECT_LIGHTMAP +#endif + +#ifdef VERTEX_UVS_LIGHTMAP @location(3) lightmap_uv: vec2, #endif }; #ifdef DEPTH_PREPASS + @fragment fn fragment(in: FragmentInput) { var output_color: vec4 = textureSample(base_texture, base_sampler, in.uv); @@ -112,7 +135,9 @@ fn fragment(in: FragmentInput) { } } } + #else // ifdef DEPTH_PREPASS + @fragment fn fragment(in: FragmentInput) -> @location(0) vec4 { var output_color: vec4 = textureSample(base_texture, base_sampler, in.uv); @@ -123,8 +148,7 @@ fn fragment(in: FragmentInput) -> @location(0) vec4 { view.inverse_view[3].z ), in.world_position); - -#ifdef HAS_OBJECT_LIGHTMAP +#ifdef VERTEX_UVS_LIGHTMAP let shadow = fetch_directional_shadow(0u, in.world_position, in.world_normal, view_z); output_color = vec4(output_color.xyz * (shadow * 0.2 + 0.8), output_color.w); @@ -157,4 +181,5 @@ fn fragment(in: FragmentInput) -> @location(0) vec4 { return apply_zone_lighting(in.world_position, in.world_normal, output_color, view_z); } + #endif // else ifdef DEPTH_PREPASS diff --git a/src/render/shaders/particle.wgsl b/src/render/shaders/particle.wgsl index e7ecd5b..20a3fe1 100644 --- a/src/render/shaders/particle.wgsl +++ b/src/render/shaders/particle.wgsl @@ -1,4 +1,4 @@ -#import bevy_render::view +#import bevy_render::view View @group(0) @binding(0) var view: View; diff --git a/src/render/shaders/sky_material.wgsl b/src/render/shaders/sky_material.wgsl index 7a9835f..e943080 100644 --- a/src/render/shaders/sky_material.wgsl +++ b/src/render/shaders/sky_material.wgsl @@ -1,8 +1,5 @@ -#import bevy_pbr::mesh_types -#import bevy_pbr::mesh_view_bindings - -@group(2) @binding(0) -var mesh: Mesh; +#import bevy_pbr::mesh_bindings mesh +#import bevy_pbr::mesh_view_bindings view struct Vertex { @location(0) position: vec3, diff --git a/src/render/shaders/terrain_material.wgsl b/src/render/shaders/terrain_material.wgsl index f0477ab..572e94b 100644 --- a/src/render/shaders/terrain_material.wgsl +++ b/src/render/shaders/terrain_material.wgsl @@ -1,13 +1,8 @@ -#import bevy_pbr::mesh_types -#import bevy_pbr::mesh_view_bindings -#import rose_client::zone_lighting - -@group(2) @binding(0) -var mesh: Mesh; - -#import bevy_pbr::utils -#import bevy_pbr::mesh_functions -#import bevy_pbr::shadows +#import bevy_pbr::mesh_bindings mesh +#import bevy_pbr::mesh_view_bindings view +#import bevy_pbr::mesh_functions mesh_position_local_to_world, mesh_normal_local_to_world, mesh_position_local_to_clip +#import bevy_pbr::shadows fetch_directional_shadow +#import rose_client::zone_lighting apply_zone_lighting struct Vertex { @location(0) position: vec3, @@ -28,13 +23,10 @@ struct VertexOutput { @vertex fn vertex(vertex: Vertex) -> VertexOutput { - let world_position = mesh_position_local_to_world(mesh.model, vec4(vertex.position, 1.0)); - let world_normal = mesh_normal_local_to_world(vertex.normal); - var out: VertexOutput; - out.clip_position = view.view_proj * world_position; - out.world_position = world_position; - out.world_normal = world_normal; + out.clip_position = mesh_position_local_to_clip(mesh.model, vec4(vertex.position, 1.0)); + out.world_position = mesh_position_local_to_world(mesh.model, vec4(vertex.position, 1.0)); + out.world_normal = mesh_normal_local_to_world(vertex.normal); out.uv0 = vertex.uv0; out.uv1 = vertex.uv1; out.tile_info = vertex.tile_info; diff --git a/src/render/shaders/trail_effect.wgsl b/src/render/shaders/trail_effect.wgsl index e84b090..3a3d2f7 100644 --- a/src/render/shaders/trail_effect.wgsl +++ b/src/render/shaders/trail_effect.wgsl @@ -1,4 +1,4 @@ -#import bevy_render::view +#import bevy_render::view View @group(0) @binding(0) var view: View; diff --git a/src/render/shaders/water_material.wgsl b/src/render/shaders/water_material.wgsl index 3e07287..fbdecb5 100644 --- a/src/render/shaders/water_material.wgsl +++ b/src/render/shaders/water_material.wgsl @@ -1,11 +1,7 @@ -#import bevy_pbr::mesh_types -#import bevy_pbr::mesh_view_bindings -#import rose_client::zone_lighting - -@group(2) @binding(0) -var mesh: Mesh; - -#import bevy_pbr::mesh_functions +#import bevy_pbr::mesh_bindings mesh +#import bevy_pbr::mesh_view_bindings view +#import bevy_pbr::mesh_functions mesh_position_local_to_world, mesh_normal_local_to_world +#import rose_client::zone_lighting apply_zone_lighting struct Vertex { @location(0) position: vec3, diff --git a/src/render/shaders/world_ui.wgsl b/src/render/shaders/world_ui.wgsl index 513130a..0497480 100644 --- a/src/render/shaders/world_ui.wgsl +++ b/src/render/shaders/world_ui.wgsl @@ -1,5 +1,5 @@ -#import bevy_render::view -#import rose_client::zone_lighting +#import bevy_render::view View +#import rose_client::zone_lighting apply_zone_lighting_fog @group(0) @binding(0) var view: View; diff --git a/src/render/sky_material.rs b/src/render/sky_material.rs index 0061e17..14af44d 100644 --- a/src/render/sky_material.rs +++ b/src/render/sky_material.rs @@ -9,7 +9,7 @@ use bevy::{ SetMeshViewBindGroup, }, prelude::{App, HandleUntyped, Image, Material, MaterialPlugin, Mesh, Plugin}, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, render::{ extract_resource::ExtractResourcePlugin, mesh::MeshVertexBufferLayout, @@ -43,18 +43,17 @@ impl Plugin for SkyMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(ExtractResourcePlugin::::default()); - - app.add_plugin( + app.add_plugins(( + ExtractResourcePlugin::::default(), MaterialPlugin::> { prepass_enabled: self.prepass_enabled, ..Default::default() }, - ); + )); } } -#[derive(Debug, Clone, TypeUuid, AsBindGroup)] +#[derive(Debug, Clone, TypeUuid, TypePath, AsBindGroup)] #[uuid = "971a6c96-4516-4ea0-aeb6-349633e7934e"] pub struct SkyMaterial { #[texture(0)] diff --git a/src/render/terrain_material.rs b/src/render/terrain_material.rs index 466851b..531fbb5 100644 --- a/src/render/terrain_material.rs +++ b/src/render/terrain_material.rs @@ -9,7 +9,7 @@ use bevy::{ prelude::{ AlphaMode, App, FromWorld, HandleUntyped, Material, MaterialPlugin, Mesh, Plugin, World, }, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, render::{ mesh::{MeshVertexAttribute, MeshVertexBufferLayout}, prelude::Shader, @@ -55,7 +55,7 @@ impl Plugin for TerrainMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(MaterialPlugin::< + app.add_plugins(MaterialPlugin::< TerrainMaterial, DrawTerrainMaterial, DrawPrepass, @@ -82,7 +82,7 @@ impl FromWorld for TerrainMaterialPipelineData { } } -#[derive(Debug, Clone, TypeUuid)] +#[derive(Debug, Clone, TypeUuid, TypePath)] #[uuid = "403e3628-46d2-4d2a-b74c-ce84be2b1ba2"] pub struct TerrainMaterial { pub textures: Vec>, @@ -167,7 +167,7 @@ impl AsBindGroup for TerrainMaterial { } } - let mut textures = vec![&*fallback_image.texture_view; TERRAIN_MATERIAL_MAX_TEXTURES]; + let mut textures = vec![&*fallback_image.d2.texture_view; TERRAIN_MATERIAL_MAX_TEXTURES]; for (id, image) in images.into_iter().enumerate() { textures[id] = &*image.texture_view; } diff --git a/src/render/trail_effect.rs b/src/render/trail_effect.rs index 68f4058..2cd0e9f 100644 --- a/src/render/trail_effect.rs +++ b/src/render/trail_effect.rs @@ -26,7 +26,7 @@ use bevy::{ ComputedVisibility, ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, }, - Extract, ExtractSchedule, RenderApp, RenderSet, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, time::Time, }; @@ -49,22 +49,29 @@ impl Plugin for TrailEffectRenderPlugin { Shader::from_wgsl ); - app.add_systems( - (initialise_trail_effects, update_trail_effects).in_base_set(CoreSet::PostUpdate), - ); + app.add_systems(Update, (initialise_trail_effects,)); + app.add_systems(PostUpdate, (update_trail_effects,)); let render_app = app.sub_app_mut(RenderApp); render_app - .add_system(extract_trail_effects.in_schedule(ExtractSchedule)) - .add_system(prepare_trail_effects.in_set(RenderSet::Prepare)) - .add_system(queue_trail_effects.in_set(RenderSet::Queue)) - .init_resource::() + .add_systems(ExtractSchedule, extract_trail_effects) + .add_systems(Render, prepare_trail_effects.in_set(RenderSet::Prepare)) + .add_systems(Render, queue_trail_effects.in_set(RenderSet::Queue)) .init_resource::() .init_resource::() .init_resource::() .init_resource::>() .add_render_command::(); } + + fn finish(&self, app: &mut App) { + let render_app = match app.get_sub_app_mut(RenderApp) { + Ok(render_app) => render_app, + Err(_) => return, + }; + + render_app.init_resource::(); + } } #[derive(Component)] @@ -298,7 +305,7 @@ struct TrailEffectPipeline { impl FromWorld for TrailEffectPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.get_resource::().unwrap(); + let render_device = world.resource::(); let view_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[BindGroupLayoutEntry { @@ -307,7 +314,7 @@ impl FromWorld for TrailEffectPipeline { ty: BindingType::Buffer { ty: BufferBindingType::Uniform, has_dynamic_offset: true, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(ViewUniform::min_size()), }, count: None, }], diff --git a/src/render/water_material.rs b/src/render/water_material.rs index d85a17c..f508b72 100644 --- a/src/render/water_material.rs +++ b/src/render/water_material.rs @@ -11,10 +11,10 @@ use bevy::{ SetMeshViewBindGroup, }, prelude::{ - AlphaMode, App, Commands, FromWorld, HandleUntyped, Image, IntoSystemAppConfig, Material, - MaterialPlugin, Mesh, Plugin, Res, Resource, Time, World, + AlphaMode, App, Commands, FromWorld, HandleUntyped, Image, Material, MaterialPlugin, Mesh, + Plugin, Res, Resource, Time, World, }, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, render::{ mesh::MeshVertexBufferLayout, prelude::Shader, @@ -57,7 +57,7 @@ impl Plugin for WaterMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(MaterialPlugin::< + app.add_plugins(MaterialPlugin::< WaterMaterial, DrawWaterMaterial, DrawPrepass, @@ -67,7 +67,7 @@ impl Plugin for WaterMaterialPlugin { }); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { - render_app.add_system(extract_water_push_constant_data.in_schedule(ExtractSchedule)); + render_app.add_systems(ExtractSchedule, extract_water_push_constant_data); } } } @@ -108,7 +108,7 @@ impl FromWorld for WaterMaterialPipelineData { } } -#[derive(Debug, Clone, TypeUuid)] +#[derive(Debug, Clone, TypeUuid, TypePath)] #[uuid = "e9e46dcc-94db-4b31-819f-d5ecffc732f0"] pub struct WaterMaterial { pub textures: Vec>, @@ -208,7 +208,7 @@ impl AsBindGroup for WaterMaterial { } } - let mut textures = vec![&*fallback_image.texture_view; WATER_MATERIAL_NUM_TEXTURES]; + let mut textures = vec![&*fallback_image.d2.texture_view; WATER_MATERIAL_NUM_TEXTURES]; for (id, image) in images.into_iter().enumerate() { textures[id] = &*image.texture_view; } diff --git a/src/render/world_ui.rs b/src/render/world_ui.rs index c9f9eda..44338cd 100644 --- a/src/render/world_ui.rs +++ b/src/render/world_ui.rs @@ -13,8 +13,8 @@ use bevy::{ pbr::MeshPipelineKey, prelude::{ App, Assets, Color, Commands, Component, ComputedVisibility, FromWorld, GlobalTransform, - HandleUntyped, IntoSystemAppConfig, IntoSystemConfig, Msaa, Plugin, Query, Res, ResMut, - Resource, Vec2, Vec3, World, + HandleUntyped, IntoSystemConfigs, Msaa, Plugin, Query, Res, ResMut, Resource, Vec2, Vec3, + World, }, reflect::TypeUuid, render::{ @@ -27,19 +27,19 @@ use bevy::{ render_resource::{ BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, - BlendComponent, BlendFactor, BlendOperation, BlendState, BufferBindingType, BufferSize, + BlendComponent, BlendFactor, BlendOperation, BlendState, BufferBindingType, BufferUsages, BufferVec, ColorTargetState, ColorWrites, CompareFunction, DepthBiasState, DepthStencilState, FragmentState, FrontFace, MultisampleState, PipelineCache, PolygonMode, PrimitiveState, PrimitiveTopology, - RenderPipelineDescriptor, SamplerBindingType, ShaderStages, SpecializedRenderPipeline, - SpecializedRenderPipelines, StencilFaceState, StencilState, TextureFormat, - TextureSampleType, TextureViewDimension, VertexAttribute, VertexBufferLayout, - VertexFormat, VertexState, VertexStepMode, + RenderPipelineDescriptor, SamplerBindingType, ShaderStages, ShaderType, + SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState, + TextureFormat, TextureSampleType, TextureViewDimension, VertexAttribute, + VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, }, renderer::{RenderDevice, RenderQueue}, texture::{BevyDefault, Image}, view::{ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms}, - Extract, ExtractSchedule, RenderApp, RenderSet, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, utils::HashMap, }; @@ -68,12 +68,20 @@ impl Plugin for WorldUiRenderPlugin { .init_resource::() .init_resource::() .add_render_command::() - .init_resource::() .init_resource::>() - .add_system(extract_world_ui_rects.in_schedule(ExtractSchedule)) - .add_system(queue_world_ui_meshes.in_set(RenderSet::Queue)); + .add_systems(ExtractSchedule, extract_world_ui_rects) + .add_systems(Render, (queue_world_ui_meshes,).in_set(RenderSet::Queue)); } } + + fn finish(&self, app: &mut App) { + let render_app = match app.get_sub_app_mut(RenderApp) { + Ok(render_app) => render_app, + Err(_) => return, + }; + + render_app.init_resource::(); + } } #[derive(Component, Clone)] @@ -288,7 +296,7 @@ impl FromWorld for WorldUiPipeline { ty: BindingType::Buffer { ty: BufferBindingType::Uniform, has_dynamic_offset: true, - min_binding_size: BufferSize::new(std::mem::size_of::() as u64), + min_binding_size: Some(ViewUniform::min_size()), }, count: None, }], diff --git a/src/render/zone_lighting.rs b/src/render/zone_lighting.rs index 027c1ad..f1d3db6 100644 --- a/src/render/zone_lighting.rs +++ b/src/render/zone_lighting.rs @@ -8,10 +8,10 @@ use bevy::{ pbr::CascadeShadowConfig, prelude::{ AmbientLight, App, Color, Commands, DirectionalLight, DirectionalLightBundle, EulerRot, - FromWorld, HandleUntyped, IntoSystemAppConfig, IntoSystemConfig, Plugin, Quat, - ReflectResource, Res, ResMut, Resource, Shader, Transform, World, + FromWorld, HandleUntyped, IntoSystemConfigs, Plugin, Quat, ReflectResource, Res, ResMut, + Resource, Shader, Startup, Transform, World, }, - reflect::{FromReflect, Reflect, TypeUuid}, + reflect::{Reflect, TypeUuid}, render::{ render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, render_resource::{ @@ -21,7 +21,7 @@ use bevy::{ ShaderType, }, renderer::{RenderDevice, RenderQueue}, - Extract, ExtractSchedule, RenderApp, RenderSet, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, }; @@ -54,12 +54,19 @@ impl Plugin for ZoneLightingPlugin { if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app - .init_resource::() - .add_system(extract_uniform_data.in_schedule(ExtractSchedule)) - .add_system(prepare_uniform_data.in_set(RenderSet::Prepare)); + .add_systems(ExtractSchedule, extract_uniform_data) + .add_systems(Render, (prepare_uniform_data,).in_set(RenderSet::Prepare)); } - app.add_startup_system(spawn_lights); + app.add_systems(Startup, spawn_lights); + } + + fn finish(&self, app: &mut App) { + let render_app = match app.get_sub_app_mut(RenderApp) { + Ok(render_app) => render_app, + Err(_) => return, + }; + render_app.init_resource::(); } } @@ -85,7 +92,7 @@ fn spawn_lights(mut commands: Commands) { }); } -#[derive(Resource, Reflect, FromReflect)] +#[derive(Resource, Reflect)] #[reflect(Resource)] pub struct ZoneLighting { pub map_ambient_color: Vec3, diff --git a/src/systems/auto_login_system.rs b/src/systems/auto_login_system.rs index 9a21ccb..23eaa2a 100644 --- a/src/systems/auto_login_system.rs +++ b/src/systems/auto_login_system.rs @@ -29,7 +29,7 @@ pub fn auto_login_system( match *auto_login_state { AutoLoginState::Login => { - if matches!(app_state.0, AppState::GameLogin) { + if matches!(app_state.get(), AppState::GameLogin) { if let (Some(username), Some(password)) = ( &server_configuration.preset_username, &server_configuration.preset_password, @@ -77,12 +77,12 @@ pub fn auto_login_system( } } - if matches!(app_state.0, AppState::GameCharacterSelect) { + if matches!(app_state.get(), AppState::GameCharacterSelect) { *auto_login_state = AutoLoginState::WaitCharacterList; } } AutoLoginState::WaitCharacterList => { - if matches!(app_state.0, AppState::GameCharacterSelect) { + if matches!(app_state.get(), AppState::GameCharacterSelect) { if let Some(preset_character_name) = server_configuration.preset_character_name.as_ref() { diff --git a/src/systems/character_select_system.rs b/src/systems/character_select_system.rs index 84aedf8..49d4064 100644 --- a/src/systems/character_select_system.rs +++ b/src/systems/character_select_system.rs @@ -7,7 +7,7 @@ use bevy::{ DespawnRecursiveExt, Entity, EventReader, EventWriter, GlobalTransform, Handle, Local, MouseButton, NextState, Query, Res, ResMut, Resource, Visibility, With, }, - render::{camera::Projection, mesh::skinning::SkinnedMesh}, + render::mesh::skinning::SkinnedMesh, window::{CursorGrabMode, PrimaryWindow, Window}, }; use bevy_egui::{egui, EguiContexts}; @@ -23,7 +23,6 @@ use crate::{ COLLISION_GROUP_PLAYER, }, events::{CharacterSelectEvent, GameConnectionEvent, LoadZoneEvent, WorldConnectionEvent}, - ray_from_screenspace::ray_from_screenspace, resources::{ AppState, CharacterList, CharacterSelectState, GameData, ServerConfiguration, WorldConnection, @@ -386,7 +385,7 @@ pub fn character_select_input_system( mouse_button_input: Res>, rapier_context: Res, mut last_selected_time: Local>, - query_camera: Query<(&Camera, &Projection, &GlobalTransform), With>, + query_camera: Query<(&Camera, &GlobalTransform), With>, query_collider_parent: Query<&ColliderParent>, query_select_character: Query<&CharacterSelectCharacter>, query_window: Query<&Window, With>, @@ -415,17 +414,11 @@ pub fn character_select_input_system( }; if mouse_button_input.just_pressed(MouseButton::Left) { - for (camera, camera_projection, camera_transform) in query_camera.iter() { - if let Some((ray_origin, ray_direction)) = ray_from_screenspace( - cursor_position, - window, - camera, - camera_projection, - camera_transform, - ) { + for (camera, camera_transform) in query_camera.iter() { + if let Some(ray) = camera.viewport_to_world(camera_transform, cursor_position) { if let Some((collider_entity, _)) = rapier_context.cast_ray( - ray_origin, - ray_direction, + ray.origin, + ray.direction, 10000000.0, false, QueryFilter::new().groups(CollisionGroups::new( diff --git a/src/systems/debug_inspector_system.rs b/src/systems/debug_inspector_system.rs index 7f8632f..a43e987 100644 --- a/src/systems/debug_inspector_system.rs +++ b/src/systems/debug_inspector_system.rs @@ -1,7 +1,8 @@ use bevy::{ input::Input, - prelude::{App, Camera, Camera3d, GlobalTransform, KeyCode, Plugin, Query, Res, ResMut, With}, - render::camera::Projection, + prelude::{ + App, Camera, Camera3d, GlobalTransform, KeyCode, Plugin, Query, Res, ResMut, Update, With, + }, window::{PrimaryWindow, Window}, }; use bevy_egui::EguiContexts; @@ -11,7 +12,6 @@ use rose_game_common::{components::*, messages::ClientEntityId}; use crate::{ components::*, - ray_from_screenspace::ray_from_screenspace, render::{ObjectMaterialBlend, ObjectMaterialGlow}, resources::DebugInspector, }; @@ -21,7 +21,7 @@ pub struct DebugInspectorPlugin; impl Plugin for DebugInspectorPlugin { fn build(&self, app: &mut App) { app.insert_resource(DebugInspector::default()) - .add_system(debug_inspector_picking_system); + .add_systems(Update, debug_inspector_picking_system); app.register_type::() .register_type::() @@ -89,7 +89,7 @@ impl Plugin for DebugInspectorPlugin { .register_type::() .register_type::(); - app.add_plugin(bevy_inspector_egui::DefaultInspectorConfigPlugin); + app.add_plugins(bevy_inspector_egui::DefaultInspectorConfigPlugin); } } @@ -100,7 +100,7 @@ fn debug_inspector_picking_system( key_code_input: Res>, rapier_context: Res, query_window: Query<&Window, With>, - query_camera: Query<(&Camera, &Projection, &GlobalTransform), With>, + query_camera: Query<(&Camera, &GlobalTransform), With>, ) { if !debug_inspector_state.enable_picking { // Picking disabled @@ -119,17 +119,11 @@ fn debug_inspector_picking_system( let cursor_position = cursor_position.unwrap(); if key_code_input.just_pressed(KeyCode::P) { - for (camera, camera_projection, camera_transform) in query_camera.iter() { - if let Some((ray_origin, ray_direction)) = ray_from_screenspace( - cursor_position, - window, - camera, - camera_projection, - camera_transform, - ) { + for (camera, camera_transform) in query_camera.iter() { + if let Some(ray) = camera.viewport_to_world(camera_transform, cursor_position) { if let Some((collider_entity, _distance)) = rapier_context.cast_ray( - ray_origin, - ray_direction, + ray.origin, + ray.direction, 10000000.0, false, QueryFilter::new().groups(CollisionGroups::new( diff --git a/src/systems/debug_render_directional_light_system.rs b/src/systems/debug_render_directional_light_system.rs index 44560b8..9fc32b2 100644 --- a/src/systems/debug_render_directional_light_system.rs +++ b/src/systems/debug_render_directional_light_system.rs @@ -1,11 +1,11 @@ use bevy::{ prelude::{DirectionalLight, Local, Query, Res, ResMut, Vec3, With}, - render::primitives::{CascadesFrusta, Frustum, Plane}, + render::primitives::{CascadesFrusta, Frustum, HalfSpace}, }; use crate::resources::{DebugRenderConfig, DebugRenderDirectionalLightData}; -fn calculate_frustum_corner(plane1: &Plane, plane2: &Plane, plane3: &Plane) -> Vec3 { +fn calculate_frustum_corner(plane1: &HalfSpace, plane2: &HalfSpace, plane3: &HalfSpace) -> Vec3 { let denominator = plane1.normal().dot(plane2.normal().cross(plane3.normal())); if denominator.abs() > 0.0 { let mut nominator = -plane1.d() * plane2.normal().cross(plane3.normal()); @@ -26,9 +26,9 @@ fn calculate_frustum_corners(frustum: &Frustum) -> [Vec3; 8] { for j in 2..4 { for k in 4..6 { corners[index] = calculate_frustum_corner( - &frustum.planes[i], - &frustum.planes[j], - &frustum.planes[k], + &frustum.half_spaces[i], + &frustum.half_spaces[j], + &frustum.half_spaces[k], ); index += 1; } diff --git a/src/systems/free_camera_system.rs b/src/systems/free_camera_system.rs index cdfa40d..4d30eb2 100644 --- a/src/systems/free_camera_system.rs +++ b/src/systems/free_camera_system.rs @@ -109,7 +109,7 @@ pub fn free_camera_system( KeyCode::D => move_vec.x += 1.0, // Right KeyCode::Q => translate_vec.y -= 1.0, // Down KeyCode::E => translate_vec.y += 1.0, // Up - KeyCode::LShift => speed_boost_multiplier = 4.0, + KeyCode::ShiftLeft => speed_boost_multiplier = 4.0, _ => {} } } diff --git a/src/systems/game_connection_system.rs b/src/systems/game_connection_system.rs index c5b5848..3853bc2 100644 --- a/src/systems/game_connection_system.rs +++ b/src/systems/game_connection_system.rs @@ -262,7 +262,7 @@ pub fn game_connection_system( client_entity_list.player_entity_id = Some(entity_id); // Transition to in game state if we are not already - if !matches!(app_state_current.0, AppState::Game) { + if !matches!(app_state_current.get(), AppState::Game) { app_state_next.set(AppState::Game); } } @@ -772,14 +772,14 @@ pub fn game_connection_system( match item_slot { ItemSlot::Equipment(index) => { if let Some(mut equipment) = world.entity_mut(entity).get_mut::() { - if let Some(mut equipment_item) = equipment.get_equipment_item_mut(index) { + if let Some(equipment_item) = equipment.get_equipment_item_mut(index) { equipment_item.life = life; } } }, ItemSlot::Vehicle(index) => { if let Some(mut equipment) = world.entity_mut(entity).get_mut::() { - if let Some(mut equipment_item) = equipment.get_vehicle_item_mut(index) { + if let Some(equipment_item) = equipment.get_vehicle_item_mut(index) { equipment_item.life = life; } } diff --git a/src/systems/game_mouse_input_system.rs b/src/systems/game_mouse_input_system.rs index ee2bd63..fb1b322 100644 --- a/src/systems/game_mouse_input_system.rs +++ b/src/systems/game_mouse_input_system.rs @@ -6,7 +6,6 @@ use bevy::{ Camera, Camera3d, Entity, EventWriter, GlobalTransform, MouseButton, Query, Res, ResMut, With, }, - render::camera::Projection, window::{CursorGrabMode, PrimaryWindow, Window}, }; use bevy_egui::EguiContexts; @@ -20,7 +19,6 @@ use crate::{ COLLISION_FILTER_CLICKABLE, COLLISION_GROUP_PHYSICS_TOY, COLLISION_GROUP_PLAYER, }, events::{MoveDestinationEffectEvent, PlayerCommandEvent}, - ray_from_screenspace::ray_from_screenspace, resources::{SelectedTarget, UiCursorType, UiRequestedCursor}, }; @@ -34,7 +32,7 @@ pub struct PlayerQuery<'w> { pub fn game_mouse_input_system( mouse_button_input: Res>, query_window: Query<&Window, With>, - query_camera: Query<(&Camera, &Projection, &GlobalTransform), With>, + query_camera: Query<(&Camera, &GlobalTransform), With>, rapier_context: Res, mut egui_ctx: EguiContexts, query_collider_parent: Query<&ColliderParent>, @@ -77,20 +75,14 @@ pub fn game_mouse_input_system( } else { return; }; - let Ok((camera, camera_projection, camera_transform)) = query_camera.get_single() else { + let Ok((camera, camera_transform)) = query_camera.get_single() else { return; }; - if let Some((ray_origin, ray_direction)) = ray_from_screenspace( - cursor_position, - window, - camera, - camera_projection, - camera_transform, - ) { + if let Some(ray) = camera.viewport_to_world(camera_transform, cursor_position) { if let Some((collider_entity, distance)) = rapier_context.cast_ray( - ray_origin, - ray_direction, + ray.origin, + ray.direction, 10000000.0, false, QueryFilter::new().groups(CollisionGroups::new( @@ -98,7 +90,7 @@ pub fn game_mouse_input_system( !COLLISION_GROUP_PLAYER & !COLLISION_GROUP_PHYSICS_TOY, )), ) { - let hit_position = ray_origin + ray_direction * distance; + let hit_position = ray.get_point(distance); let hit_entity = query_collider_parent .get(collider_entity) .map_or(collider_entity, |collider_parent| collider_parent.entity); diff --git a/src/systems/pending_damage_system.rs b/src/systems/pending_damage_system.rs index 16f8f63..685bfa3 100644 --- a/src/systems/pending_damage_system.rs +++ b/src/systems/pending_damage_system.rs @@ -57,7 +57,7 @@ pub fn pending_damage_system( for mut target in query_target.iter_mut() { let mut i = 0; while i < target.pending_damage_list.len() { - let mut pending_damage = &mut target.pending_damage_list[i]; + let pending_damage = &mut target.pending_damage_list[i]; pending_damage.age += delta_time; if pending_damage.is_immediate diff --git a/src/systems/world_connection_system.rs b/src/systems/world_connection_system.rs index 426e77b..c97b097 100644 --- a/src/systems/world_connection_system.rs +++ b/src/systems/world_connection_system.rs @@ -45,7 +45,7 @@ pub fn world_connection_system( Ok(ServerMessage::CharacterList { character_list: characters, }) => { - if !matches!(app_state_current.0, AppState::GameCharacterSelect) { + if !matches!(app_state_current.get(), AppState::GameCharacterSelect) { app_state_next.set(AppState::GameCharacterSelect); } diff --git a/src/ui/ui_debug_client_entity_list_system.rs b/src/ui/ui_debug_client_entity_list_system.rs index 808475c..46d2ff7 100644 --- a/src/ui/ui_debug_client_entity_list_system.rs +++ b/src/ui/ui_debug_client_entity_list_system.rs @@ -113,7 +113,7 @@ pub fn ui_debug_client_entity_list_system( egui::ScrollArea::vertical() .auto_shrink([false, false]) - .always_show_scroll(true) + .scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible) .show(ui, |ui| { egui::Grid::new("client_entity_list_grid") .num_columns(4) diff --git a/src/ui/ui_debug_diagnostics_system.rs b/src/ui/ui_debug_diagnostics_system.rs index 0ee9d70..01ff545 100644 --- a/src/ui/ui_debug_diagnostics_system.rs +++ b/src/ui/ui_debug_diagnostics_system.rs @@ -1,5 +1,5 @@ use bevy::{ - diagnostic::Diagnostics, + diagnostic::DiagnosticsStore, prelude::{Res, ResMut}, }; use bevy_egui::{egui, EguiContexts}; @@ -9,7 +9,7 @@ use crate::ui::UiStateDebugWindows; pub fn ui_debug_diagnostics_system( mut egui_context: EguiContexts, ui_state_debug_windows: ResMut, - diagnostics: Res, + diagnostics: Res, ) { if !ui_state_debug_windows.debug_ui_open { return; diff --git a/src/ui/ui_debug_item_list_system.rs b/src/ui/ui_debug_item_list_system.rs index c908d98..8df0320 100644 --- a/src/ui/ui_debug_item_list_system.rs +++ b/src/ui/ui_debug_item_list_system.rs @@ -74,7 +74,7 @@ pub fn ui_debug_item_list_system( } ui.end_row(); - if matches!(app_state.0, AppState::Game) { + if matches!(app_state.get(), AppState::Game) { ui.label("Spawn Quantity:"); ui.add( egui::DragValue::new(&mut ui_state_debug_item_list.spawn_quantity) @@ -313,7 +313,7 @@ pub fn ui_debug_item_list_system( }); row.col(|ui| { - if matches!(app_state.0, AppState::ModelViewer) + if matches!(app_state.get(), AppState::ModelViewer) && ui.button("Equip").clicked() { if let Some(equipment_index) = equipment_index { @@ -326,7 +326,7 @@ pub fn ui_debug_item_list_system( ItemType::Gem ) { for mut equipment in query_set.p0().iter_mut() { - if let Some(mut weapon) = equipment.equipped_items + if let Some(weapon) = equipment.equipped_items [EquipmentIndex::Weapon] .as_mut() { @@ -334,8 +334,8 @@ pub fn ui_debug_item_list_system( weapon.gem = 0; } - if let Some(mut sub_weapon) = equipment - .equipped_items[EquipmentIndex::SubWeapon] + if let Some(sub_weapon) = equipment.equipped_items + [EquipmentIndex::SubWeapon] .as_mut() { sub_weapon.has_socket = false; @@ -400,7 +400,7 @@ pub fn ui_debug_item_list_system( ui.label(item_data.name); }); - row.col(|ui| match app_state.0 { + row.col(|ui| match app_state.get() { AppState::Game => { if ui.button("Spawn").clicked() { if let Some(game_connection) = game_connection.as_ref() @@ -467,7 +467,7 @@ pub fn ui_debug_item_list_system( ) && ui.button("Equip").clicked() { for mut equipment in query_set.p0().iter_mut() { - if let Some(mut weapon) = equipment.equipped_items + if let Some(weapon) = equipment.equipped_items [EquipmentIndex::Weapon] .as_mut() { @@ -475,8 +475,8 @@ pub fn ui_debug_item_list_system( weapon.gem = item_reference.item_number as u16; } - if let Some(mut sub_weapon) = equipment - .equipped_items[EquipmentIndex::SubWeapon] + if let Some(sub_weapon) = equipment.equipped_items + [EquipmentIndex::SubWeapon] .as_mut() { sub_weapon.has_socket = true; diff --git a/src/ui/ui_debug_npc_list_system.rs b/src/ui/ui_debug_npc_list_system.rs index 0be7e15..1ff44b8 100644 --- a/src/ui/ui_debug_npc_list_system.rs +++ b/src/ui/ui_debug_npc_list_system.rs @@ -73,7 +73,7 @@ pub fn ui_debug_npc_list_system( } ui.end_row(); - if matches!(app_state.0, AppState::Game) { + if matches!(app_state.get(), AppState::Game) { ui.label("Spawn Count:"); ui.add( egui::DragValue::new(&mut ui_state_debug_npc_list.spawn_count) @@ -187,7 +187,7 @@ pub fn ui_debug_npc_list_system( ui.label(format!("{}", npc_data.level)); }); - row.col(|ui| match app_state.0 { + row.col(|ui| match app_state.get() { AppState::Game => { if ui .add_enabled( diff --git a/src/ui/ui_debug_physics.rs b/src/ui/ui_debug_physics.rs index 1ca7426..077a966 100644 --- a/src/ui/ui_debug_physics.rs +++ b/src/ui/ui_debug_physics.rs @@ -7,7 +7,6 @@ use bevy::{ shape, Assets, Camera, Camera3d, Color, Commands, ComputedVisibility, GlobalTransform, Handle, KeyCode, Local, Mesh, Query, Res, ResMut, Time, Transform, Visibility, With, }, - render::camera::Projection, window::{PrimaryWindow, Window}, }; use bevy_egui::{egui, EguiContexts}; @@ -21,7 +20,6 @@ use rose_game_common::components::Npc; use crate::{ components::{ColliderEntity, COLLISION_FILTER_CLICKABLE, COLLISION_GROUP_PHYSICS_TOY}, - ray_from_screenspace::ray_from_screenspace, ui::UiStateDebugWindows, }; @@ -104,7 +102,7 @@ pub fn ui_debug_physics_system( rapier_context: Res, time: Res