Merge branch 'bevy14'

This commit is contained in:
yuni 2024-07-09 04:00:47 +02:00
commit d262796db0
33 changed files with 782 additions and 503 deletions

1145
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ repository = "https://codeberg.org/outfly/outfly"
categories = ["game", "aerospace", "simulation"]
keywords = ["game", "space", "3d"]
license = "GPL-3.0-only"
rust-version = "1.76.0"
rust-version = "1.79.0"
[dependencies]
# For parsing the game definition file, src/data/defs.txt
@ -36,27 +36,18 @@ toml_edit = { version = "0.22", features = ["serde"] }
[dependencies.bevy]
# The bevy game engine, the basis for this game
# We temporarily use a fork with a custom bug fix, see https://codeberg.org/outfly/bevy
version = "0.13.2"
git = "https://codeberg.org/outfly/bevy.git"
rev = "e4dc13639106aa86826f6243d58f3209e1e94b1b"
version = "0.14"
default-features = false
features = ["animation", "bevy_asset", "bevy_audio", "bevy_scene", "bevy_winit", "bevy_core_pipeline", "bevy_pbr", "bevy_gltf", "bevy_render", "bevy_text", "bevy_ui", "jpeg", "multi-threaded", "png", "tonemapping_luts", "vorbis"]
features = ["animation", "bevy_asset", "bevy_audio", "bevy_scene", "bevy_winit", "bevy_core_pipeline", "bevy_pbr", "bevy_gltf", "bevy_render", "bevy_text", "bevy_ui", "jpeg", "multi_threaded", "png", "tonemapping_luts", "vorbis"]
[dependencies.bevy_embedded_assets]
# For embedding assets into the binary, creating a self-sufficient executable
# We temporarily use a fork with a custom bug fix, see https://codeberg.org/outfly/bevy
version = "0.10.2"
git = "https://codeberg.org/outfly/bevy_embedded_assets.git"
rev = "2696fcc0319e8660c50d4601e7d4e530cf0bb981"
version = "0.11"
optional = true
[dependencies.bevy_xpbd_3d]
# For physics and collision handling
# We temporarily use a fork with a custom bug fix, see https://codeberg.org/outfly/bevy
version = "0.4.2"
git = "https://codeberg.org/outfly/bevy_xpbd.git"
rev = "b6a03d6ec41e409d56f6b876f654a14d0b33afa7"
version = "0.5"
default-features = false
features = ["3d", "f64", "parry-f64", "parallel", "async-collider"]
@ -70,7 +61,7 @@ blend = "0.8.0"
[features]
default = ["x11", "embed_assets"]
dev_mode = []
dev = ["dev_mode", "bevy/dynamic_linking", "bevy/file_watcher"]
dev = ["dev_mode", "bevy/file_watcher"] #, "bevy/dynamic_linking"
release_linux = ["x11", "wayland", "embed_assets"]
release_windows = ["embed_assets"]
wasm = ["bevy/webgl2"]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -12,6 +12,7 @@
// and manages the flow of conversations.
use crate::prelude::*;
use bevy::color::palettes::css;
use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*;
use serde::Deserialize;
@ -926,14 +927,14 @@ pub fn handle_chat_scripts(
}
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp));
ew_effect.send(visual::SpawnEffectEvent {
class: visual::Effects::FadeIn(Color::CYAN),
class: visual::Effects::FadeIn(css::AQUA.into()),
duration: 1.0,
});
}
}
"cryofadeout" => {
ew_effect.send(visual::SpawnEffectEvent {
class: visual::Effects::FadeOut(Color::CYAN),
class: visual::Effects::FadeOut(css::AQUA.into()),
duration: 5.1,
});
}

View file

@ -609,8 +609,8 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
}
["light", color_hex, brightness] => {
if let Ok(brightness_float) = brightness.parse::<f32>() {
if let Ok(color) = Color::hex(color_hex) {
state.light_color = Some(color);
if let Ok(color) = Srgba::hex(color_hex) {
state.light_color = Some(Color::Srgba(color));
state.light_brightness = brightness_float;
} else {
error!("Can't parse hexadecimal color code: {line}");
@ -925,7 +925,7 @@ fn spawn_entities(
if state.is_sun {
let (r, g, b) = nature::star_color_index_to_rgb(0.656);
actor.insert(materials.add(StandardMaterial {
base_color: Color::rgb(r, g, b) * 13.0,
base_color: Color::srgb(r * 13.0, g * 13.0, b * 13.0),
unlit: true,
..default()
}));

View file

@ -11,6 +11,7 @@
// This module handles player input, and coordinates interplay between other modules
use crate::prelude::*;
use bevy::color::palettes::css;
use bevy::pbr::ExtendedMaterial;
use bevy::prelude::*;
use bevy::scene::SceneInstance;
@ -304,21 +305,21 @@ fn handle_player_death(
actor::DamageType::Trauma => {
settings.death_cause = "Trauma".to_string();
ew_effect.send(visual::SpawnEffectEvent {
class: visual::Effects::FadeIn(Color::MAROON),
class: visual::Effects::FadeIn(css::MAROON.into()),
duration: 1.0,
});
}
actor::DamageType::GForce => {
settings.death_cause = "Trauma from excessive g forces".to_string();
ew_effect.send(visual::SpawnEffectEvent {
class: visual::Effects::FadeIn(Color::MAROON),
class: visual::Effects::FadeIn(css::MAROON.into()),
duration: 1.0,
});
}
_ => {
settings.death_cause = "Unknown".to_string();
ew_effect.send(visual::SpawnEffectEvent {
class: visual::Effects::FadeIn(Color::MAROON),
class: visual::Effects::FadeIn(css::MAROON.into()),
duration: 1.0,
});
}

View file

@ -970,7 +970,7 @@ fn update_hud(
LogLevel::Info => settings.hud_color_console_system,
_ => settings.hud_color_console,
};
chat.sections[row].style.color.set_a(opacity);
chat.sections[row].style.color.set_alpha(opacity);
row += 1;
}
@ -1134,7 +1134,7 @@ fn update_target_selectagon(
}
selectagon_trans.translation = target_trans.translation;
selectagon_trans.scale = target_trans.scale;
selectagon_trans.look_at(camera_trans.translation, camera_trans.up().into());
selectagon_trans.look_at(camera_trans.translation, camera_trans.up());
// Enlarge Selectagon to a minimum angular diameter
let (angular_diameter, _, _) =
@ -1221,7 +1221,7 @@ fn update_poi_overlays(
if angular_diameter < min_angular_diameter {
trans.scale *= min_angular_diameter / angular_diameter;
}
trans.look_at(camera_trans.translation, camera_trans.up().into());
trans.look_at(camera_trans.translation, camera_trans.up());
}
}
}

View file

@ -121,7 +121,7 @@ impl AsteroidSurface {
pub fn material() -> ExtendedMaterial<StandardMaterial, AsteroidSurface> {
ExtendedMaterial {
base: StandardMaterial {
base_color: Color::rgb(0.29, 0.255, 0.208),
base_color: Color::srgb(0.29, 0.255, 0.208),
perceptual_roughness: 1.0,
opaque_render_method: OpaqueRendererMethod::Auto,
..default()

View file

@ -186,7 +186,7 @@ pub fn setup(
MenuElement,
NodeBundle {
style: style_fullscreen(),
background_color: Color::rgba(0.0, 0.0, 0.0, 0.8).into(),
background_color: Color::srgba(0.0, 0.0, 0.0, 0.8).into(),
visibility: Visibility::Hidden,
..default()
},
@ -517,7 +517,7 @@ pub fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
mut settings: ResMut<Settings>,
mut menustate: ResMut<MenuState>,
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
mut app_exit_events: ResMut<Events<AppExit>>,
mut ew_game: EventWriter<game::GameEvent>,
mut ew_playerdies: EventWriter<game::PlayerDiesEvent>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
@ -601,7 +601,7 @@ pub fn handle_input(
ew_playerdies.send(game::PlayerDiesEvent(actor::DamageType::Depressurization));
}
MenuAction::Quit => {
app_exit_events.send(bevy::app::AppExit);
app_exit_events.send(AppExit::Success);
}
};
}

View file

@ -204,24 +204,24 @@ impl Default for Settings {
font_size_achievement_header: 32.0,
font_size_keybindings: 20.0,
font_size_version: 20.0,
hud_color: Color::hex(COLOR_PRIMARY).unwrap(),
hud_color_fps: Color::hex("#181818").unwrap(),
hud_color_console: Color::hex(COLOR_PRIMARY).unwrap(),
hud_color_console_achievement: Color::hex(COLOR_SUCCESS).unwrap(),
hud_color_console_warn: Color::hex(COLOR_WARNING).unwrap(),
hud_color_console_system: Color::hex(COLOR_SECONDARY).unwrap(),
hud_color_alert: Color::hex(COLOR_SECONDARY).unwrap(),
hud_color_subtitles: Color::hex(COLOR_SECONDARY).unwrap(),
hud_color_choices: Color::hex(COLOR_BODY).unwrap(),
hud_color_speedometer: Color::hex(COLOR_PRIMARY).unwrap(),
hud_color_deathpoem: Color::hex("#CC2200").unwrap(),
hud_color_achievement: Color::hex(COLOR_DIM).unwrap(),
hud_color_achievement_accomplished: Color::hex(COLOR_SUCCESS).unwrap(),
hud_color_achievement_header: Color::hex(COLOR_PRIMARY).unwrap(),
hud_color_death: Color::hex(COLOR_SECONDARY).unwrap(),
hud_color_death_achievements: Color::hex(COLOR_SECONDARY).unwrap(),
hud_color_keybindings: Color::hex(COLOR_DIM).unwrap(),
hud_color_version: Color::hex(COLOR_PRIMARY).unwrap(),
hud_color: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_fps: Srgba::hex("#181818").unwrap().into(),
hud_color_console: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_console_achievement: Srgba::hex(COLOR_SUCCESS).unwrap().into(),
hud_color_console_warn: Srgba::hex(COLOR_WARNING).unwrap().into(),
hud_color_console_system: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_alert: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_subtitles: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_choices: Srgba::hex(COLOR_BODY).unwrap().into(),
hud_color_speedometer: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_deathpoem: Srgba::hex("#CC2200").unwrap().into(),
hud_color_achievement: Srgba::hex(COLOR_DIM).unwrap().into(),
hud_color_achievement_accomplished: Srgba::hex(COLOR_SUCCESS).unwrap().into(),
hud_color_achievement_header: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_death: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_death_achievements: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_keybindings: Srgba::hex(COLOR_DIM).unwrap().into(),
hud_color_version: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 },
ar_avatar: 0,
flashlight_active: false,

View file

@ -12,6 +12,7 @@
use crate::prelude::*;
use bevy::prelude::*;
use std::time::Duration;
pub struct VisualPlugin;
@ -57,13 +58,36 @@ pub struct SpawnEffectEvent {
pub duration: f64,
}
pub fn setup(settings: Res<var::Settings>, mut ew_effect: EventWriter<SpawnEffectEvent>) {
#[derive(Resource)]
pub struct SuitAnimation {
index: AnimationNodeIndex,
graph: Handle<AnimationGraph>
}
pub fn setup(
settings: Res<var::Settings>,
asset_server: Res<AssetServer>,
mut commands: Commands,
mut ew_effect: EventWriter<SpawnEffectEvent>,
mut graphs: ResMut<Assets<AnimationGraph>>,
) {
if !settings.dev_mode {
ew_effect.send(SpawnEffectEvent {
class: Effects::FadeIn(Color::BLACK),
duration: 4.0,
});
}
let mut graph = AnimationGraph::new();
let index = graph.add_clip(
asset_server.load(GltfAssetLabel::Animation(0).from_asset("models/suit_v2/suit_v2.glb")),
1.0,
graph.root,
);
let graph = graphs.add(graph);
commands.insert_resource(SuitAnimation { index, graph });
// Blackout disabled for now
// commands.spawn((
// BlackOutOverlay,
@ -115,7 +139,7 @@ pub fn spawn_effects(
FadeOut,
NodeBundle {
style: style_fullscreen(),
background_color: color.with_a(0.0).into(),
background_color: color.with_alpha(0.0).into(),
..default()
},
));
@ -136,7 +160,7 @@ pub fn update_fadein(
continue;
}
let alpha = (1.3 - 1.3 * (now - effect.start_time) / effect.duration).clamp(0.0, 1.0);
bgcolor.0.set_a(alpha as f32);
bgcolor.0.set_alpha(alpha as f32);
}
}
@ -152,17 +176,22 @@ pub fn update_fadeout(
continue;
}
let alpha = ((now - effect.start_time) / effect.duration).clamp(0.0, 1.0);
bgcolor.0.set_a(alpha as f32);
bgcolor.0.set_alpha(alpha as f32);
}
}
fn play_animations(
mut players: Query<&mut AnimationPlayer, Added<AnimationPlayer>>,
asset_server: Res<AssetServer>,
mut commands: Commands,
mut players: Query<(Entity, &mut AnimationPlayer), Added<AnimationPlayer>>,
suit_animation: Res<SuitAnimation>,
) {
for mut player in &mut players {
let animation = asset_server.load("models/suit_v2/suit_v2.glb#Animation0");
player.play(animation.clone()).repeat();
for (entity, mut player) in &mut players {
let mut transitions = AnimationTransitions::new();
transitions
.play(&mut player, suit_animation.index, Duration::ZERO)
.repeat();
commands.entity(entity).insert(suit_animation.graph.clone()).insert(transitions);
//player.play(suit_ani_node_index.0).repeat();
}
}
@ -175,6 +204,6 @@ fn play_animations(
// let threshold = 0.3;
// let factor = 1.0 / (1.0 - threshold);
// let alpha = (factor * (gforce.blackout - threshold)).clamp(0.0, 1.0);
// bgcolor.0.set_a(alpha as f32);
// bgcolor.0.set_alpha(alpha as f32);
// }
//}

View file

@ -115,7 +115,7 @@ pub fn setup(
//(radius as f64 * nature::SOL_RADIUS).powf(0.02) as f32 *
let star_color_handle = materials.add(StandardMaterial {
base_color: Color::rgb(scale_color(r), scale_color(g), scale_color(b)),
base_color: Color::srgb(scale_color(r), scale_color(g), scale_color(b)),
unlit: true,
..default()
});