diff --git a/crates/bindings/bevy_mod_scripting_bevy_state_bindings/src/lib.rs b/crates/bindings/bevy_mod_scripting_bevy_state_bindings/src/lib.rs index 326ccb68cd..782712c2f4 100644 --- a/crates/bindings/bevy_mod_scripting_bevy_state_bindings/src/lib.rs +++ b/crates/bindings/bevy_mod_scripting_bevy_state_bindings/src/lib.rs @@ -7,7 +7,11 @@ use bevy_app::{App, Plugin}; use bevy_ecs::world::World; use bevy_mod_scripting_bindings::{ InteropError, ReferencePart, ReflectReference, ScriptTypeRegistration, WorldExtensions, - function::{from::V, script_function::FunctionCallContext}, + function::{ + from::V, + generics::{A, TypeOf, ValueOf}, + script_function::FunctionCallContext, + }, }; use bevy_mod_scripting_derive::script_bindings; use bevy_reflect::{ @@ -50,10 +54,10 @@ impl World { /// The state type is passed as its registration, see `world.get_type_by_name`. fn get_state( ctxt: FunctionCallContext, - state_type: V, - ) -> Result, InteropError> { + state_type: TypeOf, A>, + ) -> Result>, InteropError> { let world = ctxt.world()?; - let state_type = state_type.into_inner(); + let state_type = state_type.into_inner().into_inner(); let state_path = format!( "bevy_state::state::resources::State<{}>", state_type.type_name() @@ -73,7 +77,7 @@ impl World { resource.type_registration().type_id(), ); reference.push_path(ReferencePart::IntegerAccess(0, false)); - Ok(Some(reference)) + Ok(Some(ValueOf::new(reference))) } /// Sets the state to change to in the next state transition, for the type of the given state value. diff --git a/crates/bindings/bevy_mod_scripting_bevy_time_bindings/src/time.rs b/crates/bindings/bevy_mod_scripting_bevy_time_bindings/src/time.rs index 6db624d23f..60bbc82583 100644 --- a/crates/bindings/bevy_mod_scripting_bevy_time_bindings/src/time.rs +++ b/crates/bindings/bevy_mod_scripting_bevy_time_bindings/src/time.rs @@ -8,6 +8,7 @@ use bevy_mod_scripting_bindings::{ InteropError, ReflectReference, function::{ from::{M, R, V}, + generics::ValueOf, script_function::FunctionCallContext, }, }; @@ -159,23 +160,23 @@ impl Time { )] impl World { /// The default clock: in Update it advances by the frame time, in FixedUpdate by the fixed timestep. - fn time(ctxt: FunctionCallContext) -> Result { - ReflectReference::new_resource_ref::>(ctxt.world()?) + fn time(ctxt: FunctionCallContext) -> Result>, InteropError> { + ReflectReference::new_resource_ref::>(ctxt.world()?).map(ValueOf::new) } /// The clock which can be paused and slowed down, it is the one games usually move objects with. - fn virtual_time(ctxt: FunctionCallContext) -> Result { - ReflectReference::new_resource_ref::>(ctxt.world()?) + fn virtual_time(ctxt: FunctionCallContext) -> Result>, InteropError> { + ReflectReference::new_resource_ref::>(ctxt.world()?).map(ValueOf::new) } /// The clock of the real world, which always advances at the system's pace. - fn real_time(ctxt: FunctionCallContext) -> Result { - ReflectReference::new_resource_ref::>(ctxt.world()?) + fn real_time(ctxt: FunctionCallContext) -> Result>, InteropError> { + ReflectReference::new_resource_ref::>(ctxt.world()?).map(ValueOf::new) } /// The clock of the fixed update step, which advances in steps of the fixed timestep. - fn fixed_time(ctxt: FunctionCallContext) -> Result { - ReflectReference::new_resource_ref::>(ctxt.world()?) + fn fixed_time(ctxt: FunctionCallContext) -> Result>, InteropError> { + ReflectReference::new_resource_ref::>(ctxt.world()?).map(ValueOf::new) } } diff --git a/crates/bindings/bevy_mod_scripting_bevy_window_bindings/src/window.rs b/crates/bindings/bevy_mod_scripting_bevy_window_bindings/src/window.rs index 81cac37647..518810e9fe 100644 --- a/crates/bindings/bevy_mod_scripting_bevy_window_bindings/src/window.rs +++ b/crates/bindings/bevy_mod_scripting_bevy_window_bindings/src/window.rs @@ -7,6 +7,7 @@ use bevy_mod_scripting_bindings::{ InteropError, ReflectReference, ScriptQueryBuilder, WorldExtensions, WorldGuard, function::{ from::{M, R, V}, + generics::ValueOf, script_function::FunctionCallContext, }, }; @@ -77,13 +78,12 @@ impl Window { } /// The primary window, or nil if there is none. - fn primary(ctxt: FunctionCallContext) -> Result, InteropError> { + fn primary(ctxt: FunctionCallContext) -> Result>, InteropError> { let world = ctxt.world()?; match primary_window_entity(&world)? { - Some(entity) => Ok(Some(ReflectReference::new_component_ref::( - entity, - world.clone(), - )?)), + Some(entity) => Ok(Some(ValueOf::new(ReflectReference::new_component_ref::< + Window, + >(entity, world.clone())?))), None => Ok(None), } } diff --git a/xtask/luals_baseline.json b/xtask/luals_baseline.json index 7104a6f5b6..8ea5b92e2d 100644 --- a/xtask/luals_baseline.json +++ b/xtask/luals_baseline.json @@ -2,7 +2,7 @@ "assign-type-mismatch": 2, "inject-field": 14, "need-check-nil": 112, - "param-type-mismatch": 160, - "undefined-field": 79, + "param-type-mismatch": 159, + "undefined-field": 51, "undefined-global": 3 }