Skip to content

Commit cb68731

Browse files
committed
formatting
1 parent b533c4f commit cb68731

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

crates/bevy_mod_scripting_core/src/asset.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ pub struct ScriptAssetSettings {
124124
impl ScriptAssetSettings {
125125
/// Selects the language for a given asset path
126126
pub fn select_script_language(&self, path: &AssetPath) -> Language {
127-
let extension = path.path().extension().and_then(|ext| ext.to_str()).unwrap_or_default();
127+
let extension = path
128+
.path()
129+
.extension()
130+
.and_then(|ext| ext.to_str())
131+
.unwrap_or_default();
128132
self.extension_to_language_map
129133
.get(extension)
130134
.cloned()
131-
.unwrap_or_default()
135+
.unwrap_or_default()
132136
}
133137
}
134138

@@ -156,7 +160,6 @@ pub struct AssetPathToScriptIdMapper {
156160
pub map: fn(&AssetPath) -> ScriptId,
157161
}
158162

159-
160163
/// A cache of asset id's to their script id's. Necessary since when we drop an asset we won't have the ability to get the path from the asset.
161164
#[derive(Default, Debug, Resource)]
162165
pub struct ScriptMetadataStore {

crates/bevy_mod_scripting_core/src/lib.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
use crate::event::ScriptErrorEvent;
66
use asset::{
7-
configure_asset_systems, configure_asset_systems_for_plugin,
8-
Language, ScriptAsset, ScriptAssetLoader, ScriptAssetSettings,
7+
configure_asset_systems, configure_asset_systems_for_plugin, Language, ScriptAsset,
8+
ScriptAssetLoader, ScriptAssetSettings,
99
};
1010
use bevy::prelude::*;
1111
use bindings::{
@@ -97,7 +97,6 @@ pub struct ScriptingPlugin<P: IntoScriptPluginParams> {
9797
pub context_initializers: Vec<ContextInitializer<P>>,
9898
/// initializers for the contexts run every time before handling events
9999
pub context_pre_handling_initializers: Vec<ContextPreHandlingInitializer<P>>,
100-
101100
}
102101

103102
impl<P: IntoScriptPluginParams> Default for ScriptingPlugin<P> {
@@ -138,7 +137,10 @@ impl<P: IntoScriptPluginParams> Plugin for ScriptingPlugin<P> {
138137
once_per_app_init(app);
139138

140139
if !self.additional_supported_extensions.is_empty() {
141-
app.add_supported_script_extensions(self.additional_supported_extensions, self.language.clone());
140+
app.add_supported_script_extensions(
141+
self.additional_supported_extensions,
142+
self.language.clone(),
143+
);
142144
}
143145

144146
register_types(app);
@@ -202,7 +204,7 @@ pub trait ConfigureScriptPlugin {
202204
fn enable_context_sharing(self) -> Self;
203205

204206
/// Set the set of extensions to be added for the plugin's language.
205-
///
207+
///
206208
/// This is useful for adding extensions that are not supported by default by BMS.
207209
fn set_additional_supported_extensions(self, extensions: &'static [&'static str]) -> Self;
208210
}
@@ -238,8 +240,6 @@ impl<P: IntoScriptPluginParams + AsMut<ScriptingPlugin<P>>> ConfigureScriptPlugi
238240
self.as_mut().additional_supported_extensions = extensions;
239241
self
240242
}
241-
242-
243243
}
244244

245245
fn once_per_app_finalize(app: &mut App) {
@@ -395,13 +395,21 @@ impl ManageStaticScripts for App {
395395
/// Any changes to the asset settings after that will not be reflected in the asset loader.
396396
pub trait ConfigureScriptAssetSettings {
397397
/// Adds a supported extension to the asset settings
398-
///
398+
///
399399
/// This is only valid to call in the plugin building phase, as the asset loader will be created in the `finalize` phase.
400-
fn add_supported_script_extensions(&mut self, extensions: &[&'static str], language: Language) -> &mut Self;
400+
fn add_supported_script_extensions(
401+
&mut self,
402+
extensions: &[&'static str],
403+
language: Language,
404+
) -> &mut Self;
401405
}
402406

403407
impl ConfigureScriptAssetSettings for App {
404-
fn add_supported_script_extensions(&mut self, extensions: &[&'static str], language: Language) -> &mut Self {
408+
fn add_supported_script_extensions(
409+
&mut self,
410+
extensions: &[&'static str],
411+
language: Language,
412+
) -> &mut Self {
405413
let mut asset_settings = self
406414
.world_mut()
407415
.get_resource_or_init::<ScriptAssetSettings>();
@@ -414,7 +422,9 @@ impl ConfigureScriptAssetSettings for App {
414422

415423
asset_settings.supported_extensions = new_arr_static;
416424
for extension in extensions {
417-
asset_settings.extension_to_language_map.insert(*extension, language.clone());
425+
asset_settings
426+
.extension_to_language_map
427+
.insert(*extension, language.clone());
418428
}
419429

420430
self

crates/languages/bevy_mod_scripting_lua/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ impl Default for LuaScriptingPlugin {
137137
}
138138
}
139139

140-
141140
impl Plugin for LuaScriptingPlugin {
142141
fn build(&self, app: &mut bevy::prelude::App) {
143142
self.scripting_plugin.build(app);

0 commit comments

Comments
 (0)