rename settings.rs to var.rs, planning to add more than settings to it

This commit is contained in:
yuni 2024-04-14 14:55:00 +02:00
parent a670778fb0
commit 86cd3b049e
9 changed files with 34 additions and 34 deletions

View file

@ -2,7 +2,7 @@ use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*;
use bevy::scene::SceneInstance;
use bevy::math::DVec3;
use crate::{actor, audio, camera, chat, commands, effects, hud, nature, settings, world};
use crate::{actor, audio, camera, chat, commands, effects, hud, nature, var, world};
pub const ENGINE_SPEED_FACTOR: f32 = 30.0;
const MAX_TRANSMISSION_DISTANCE: f32 = 60.0;
@ -234,7 +234,7 @@ pub fn update_physics_lifeforms(
pub fn handle_input(
mut commands: Commands,
keyboard_input: Res<ButtonInput<KeyCode>>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
q_talker: Query<(&chat::Talker, &Transform), (Without<actor::Player>, Without<Camera>)>,
player: Query<Entity, With<actor::Player>>,
q_camera: Query<&Transform, With<Camera>>,
@ -424,7 +424,7 @@ fn handle_player_death(
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_effect: EventWriter<effects::SpawnEffectEvent>,
mut log: ResMut<hud::Log>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
) {
for death in er_playerdies.read() {
if settings.god_mode {
@ -472,7 +472,7 @@ fn handle_player_death(
fn handle_damage(
mut ew_playerdies: EventWriter<PlayerDiesEvent>,
mut q_hp: Query<(&mut HitPoints, Option<&Player>), Changed<HitPoints>>,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
) {
for (mut hp, player_maybe) in &mut q_hp {
if player_maybe.is_some() {

View file

@ -1,6 +1,6 @@
use bevy::prelude::*;
use bevy::audio::{PlaybackMode, Volume};
use crate::settings;
use crate::var;
const ASSET_CLICK: &str = "sounds/click-button-140881-crop.ogg";
const ASSET_SWITCH: &str = "sounds/typosonic-typing-192811-crop.ogg";
@ -59,7 +59,7 @@ pub enum Sfx {
pub fn setup(
mut commands: Commands,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
asset_server: Res<AssetServer>,
) {
commands.spawn((
@ -132,7 +132,7 @@ pub fn toggle_bgm(
keyboard_input: Res<ButtonInput<KeyCode>>,
mut evwriter_toggle: EventWriter<ToggleMusicEvent>,
mut evwriter_sfx: EventWriter<PlaySfxEvent>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
) {
if keyboard_input.just_pressed(KeyCode::KeyT) {
settings.mute_music ^= true;
@ -148,7 +148,7 @@ pub fn toggle_bgm(
pub fn play_sfx(
mut commands: Commands,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut events_sfx: EventReader<PlaySfxEvent>,
sound_click: Res<SoundClick>,
sound_switch: Res<SoundSwitch>,
@ -200,7 +200,7 @@ pub fn str2sfx(sfx_label: &str) -> Sfx {
pub fn update_music(
mut events: EventReader<ToggleMusicEvent>,
bgm_controller: Query<&AudioSink, With<ComponentBGM>>,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
) {
if !events.is_empty() {
events.clear();

View file

@ -8,7 +8,7 @@ use bevy::transform::TransformSystem;
use bevy::math::{DVec3, DQuat};
use bevy_xpbd_3d::prelude::*;
use std::f32::consts::PI;
use crate::{actor, audio, hud, settings};
use crate::{actor, audio, hud, var};
pub struct CameraPlugin;
@ -68,7 +68,7 @@ pub fn setup_camera(
}
pub fn sync_camera_to_player(
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut q_camera: Query<&mut Transform, (With<Camera>, Without<actor::PlayerCamera>)>,
q_playercam: Query<(&actor::Actor, &Transform), (With<actor::PlayerCamera>, Without<Camera>)>,
) {
@ -93,7 +93,7 @@ pub fn sync_camera_to_player(
pub fn update_fov(
q_player: Query<&actor::ExperiencesGForce, With<actor::Player>>,
mouse_input: Res<ButtonInput<MouseButton>>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
mut q_camera: Query<&mut Projection, With<Camera>>,
) {
if let (Ok(gforce), Ok(mut projection)) = (q_player.get_single(), q_camera.get_single_mut())
@ -116,7 +116,7 @@ pub fn update_fov(
pub fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
) {
if keyboard_input.just_pressed(settings.key_camera) {
@ -129,7 +129,7 @@ pub fn handle_input(
}
fn manage_player_actor(
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut q_playercam: Query<&mut Visibility, With<actor::PlayerCamera>>,
mut q_hiddenplayer: Query<(&mut Visibility, &mut Position, &mut Rotation, &mut LinearVelocity, &mut AngularVelocity), (With<actor::Player>, Without<actor::PlayerCamera>)>,
q_ride: Query<(&Transform, &Position, &Rotation, &LinearVelocity, &AngularVelocity), (With<actor::PlayerDrivesThis>, Without<actor::Player>)>,
@ -161,7 +161,7 @@ fn manage_player_actor(
#[allow(clippy::too_many_arguments)]
pub fn apply_input_to_player(
time: Res<Time>,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
windows: Query<&Window, With<PrimaryWindow>>,
mut mouse_events: EventReader<MouseMotion>,
key_input: Res<ButtonInput<KeyCode>>,

View file

@ -1,4 +1,4 @@
use crate::{actor, audio, hud, settings, world, effects};
use crate::{actor, audio, effects, hud, var, world};
use bevy::prelude::*;
use bevy::math::DVec3;
use bevy_xpbd_3d::prelude::*;
@ -30,9 +30,9 @@ pub const TOKEN_GOTO_EXIT: &str = "EXIT";
pub const DEFAULT_SOUND: &str = "chat";
pub const MAX_BRANCH_DEPTH: usize = 64;
pub const CHOICE_TIMER: f64 = 40.0 * settings::DEFAULT_CHAT_SPEED as f64;
pub const CHOICE_TIMER: f64 = 40.0 * var::DEFAULT_CHAT_SPEED as f64;
pub const LETTERS_PER_SECOND: f32 = 17.0;
pub const TALKER_SPEED_FACTOR: f32 = settings::DEFAULT_CHAT_SPEED / LETTERS_PER_SECOND;
pub const TALKER_SPEED_FACTOR: f32 = var::DEFAULT_CHAT_SPEED / LETTERS_PER_SECOND;
pub const CHAT_SPEED_MIN_LEN: f32 = 40.0;
pub const NON_CHOICE_TOKENS: &[&str] = &[
@ -599,7 +599,7 @@ pub fn handle_chat_events(
q_choices: Query<Entity, With<Choice>>,
mut q_chats: Query<(Entity, &mut Chat)>,
time: Res<Time>,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
) {
for event in er_chatevent.read() {
let now = time.elapsed_seconds_f64();
@ -660,7 +660,7 @@ pub fn handle_chat_events(
fn handle_reply_keys(
keyboard_input: Res<ButtonInput<KeyCode>>,
settings: ResMut<settings::Settings>,
settings: ResMut<var::Settings>,
q_choices: Query<&Choice>,
mut q_chats: Query<&mut Chat>,
//mut evwriter_sendmsg: EventWriter<SendMessageEvent>,

View file

@ -1,5 +1,5 @@
use bevy::prelude::*;
use crate::{camera, settings};
use crate::{camera, var};
pub struct EffectsPlugin;
@ -40,7 +40,7 @@ pub struct SpawnEffectEvent {
}
pub fn setup(
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut ew_effect: EventWriter<SpawnEffectEvent>,
) {
if !settings.dev_mode {

View file

@ -1,4 +1,4 @@
use crate::{actor, audio, camera, chat, nature, settings, world};
use crate::{actor, audio, camera, chat, nature, var, world};
use bevy::prelude::*;
use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin};
use bevy::transform::TransformSystem;
@ -151,7 +151,7 @@ impl Log {
fn setup(
mut commands: Commands,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
asset_server: Res<AssetServer>,
mut log: ResMut<Log>,
mut ambient_light: ResMut<AmbientLight>,
@ -414,7 +414,7 @@ fn update_hud(
q_choices: Query<&chat::Choice>,
mut query_chat: Query<&mut Text, (With<ChatText>, Without<GaugesText>)>,
query_all_actors: Query<&actor::Actor>,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
) {
// TODO only when hud is actually on
@ -563,7 +563,7 @@ fn update_hud(
fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
mouse_input: Res<ButtonInput<MouseButton>>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
mut q_hud: Query<(&mut Visibility, Option<&OnlyHideWhenTogglingHud>), With<ToggleableHudElement>>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_togglemusic: EventWriter<audio::ToggleMusicEvent>,
@ -607,7 +607,7 @@ fn handle_input(
fn handle_target_event(
mut commands: Commands,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut er_target: EventReader<TargetEvent>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
q_target: Query<Entity, With<IsTargeted>>,
@ -631,7 +631,7 @@ fn handle_target_event(
}
fn update_target_selectagon(
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut q_selectagon: Query<(&mut Transform, &mut Visibility), (With<Selectagon>, Without<IsTargeted>, Without<Camera>)>,
q_target: Query<&Transform, (With<IsTargeted>, Without<Camera>, Without<Selectagon>)>,
q_camera: Query<&Transform, (With<Camera>, Without<IsTargeted>, Without<Selectagon>)>,
@ -671,7 +671,7 @@ fn update_target_selectagon(
fn update_ar_overlays (
q_owners: Query<(Entity, &Transform, &Visibility), (With<AugmentedRealityOverlayBroadcaster>, Without<AugmentedRealityOverlay>)>,
mut q_overlays: Query<(&mut Transform, &mut Visibility, &mut AugmentedRealityOverlay)>,
settings: ResMut<settings::Settings>,
settings: ResMut<var::Settings>,
mut state: ResMut<AugmentedRealityState>,
) {
let (need_activate, need_clean, need_update);

View file

@ -5,8 +5,8 @@ mod chat;
mod commands;
mod effects;
mod hud;
mod settings;
mod stars;
mod var;
mod world;
#[allow(dead_code)]
@ -47,7 +47,7 @@ impl Plugin for OutFlyPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup);
app.add_systems(Update, handle_input);
app.insert_resource(settings::Settings::default());
app.insert_resource(var::Settings::default());
app.add_plugins((
DefaultPlugins,//.set(ImagePlugin::default_nearest()),
FrameTimeDiagnosticsPlugin,
@ -77,7 +77,7 @@ fn setup(
fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
settings: Res<settings::Settings>,
settings: Res<var::Settings>,
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
mut windows: Query<&mut Window, With<PrimaryWindow>>,
) {

View file

@ -1,4 +1,4 @@
use crate::{actor, audio, hud, nature, settings, stars};
use crate::{actor, audio, hud, nature, stars, var};
use bevy::prelude::*;
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
use bevy::math::{DVec3, I64Vec3};
@ -385,7 +385,7 @@ fn handle_cheats(
mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
mut q_life: Query<(&mut actor::LifeForm, &mut actor::ExperiencesGForce), With<actor::Player>>,
mut ew_playerdies: EventWriter<actor::PlayerDiesEvent>,
mut settings: ResMut<settings::Settings>,
mut settings: ResMut<var::Settings>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
) {
if q_player.is_empty() || q_life.is_empty() {