Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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<ScriptTypeRegistration>,
) -> Result<Option<ReflectReference>, InteropError> {
state_type: TypeOf<V<ScriptTypeRegistration>, A>,
) -> Result<Option<ValueOf<A>>, 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()
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use bevy_mod_scripting_bindings::{
InteropError, ReflectReference,
function::{
from::{M, R, V},
generics::ValueOf,
script_function::FunctionCallContext,
},
};
Expand Down Expand Up @@ -159,23 +160,23 @@ impl Time<Fixed> {
)]
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, InteropError> {
ReflectReference::new_resource_ref::<Time<()>>(ctxt.world()?)
fn time(ctxt: FunctionCallContext) -> Result<ValueOf<Time<()>>, InteropError> {
ReflectReference::new_resource_ref::<Time<()>>(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, InteropError> {
ReflectReference::new_resource_ref::<Time<Virtual>>(ctxt.world()?)
fn virtual_time(ctxt: FunctionCallContext) -> Result<ValueOf<Time<Virtual>>, InteropError> {
ReflectReference::new_resource_ref::<Time<Virtual>>(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, InteropError> {
ReflectReference::new_resource_ref::<Time<Real>>(ctxt.world()?)
fn real_time(ctxt: FunctionCallContext) -> Result<ValueOf<Time<Real>>, InteropError> {
ReflectReference::new_resource_ref::<Time<Real>>(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, InteropError> {
ReflectReference::new_resource_ref::<Time<Fixed>>(ctxt.world()?)
fn fixed_time(ctxt: FunctionCallContext) -> Result<ValueOf<Time<Fixed>>, InteropError> {
ReflectReference::new_resource_ref::<Time<Fixed>>(ctxt.world()?).map(ValueOf::new)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bevy_mod_scripting_bindings::{
InteropError, ReflectReference, ScriptQueryBuilder, WorldExtensions, WorldGuard,
function::{
from::{M, R, V},
generics::ValueOf,
script_function::FunctionCallContext,
},
};
Expand Down Expand Up @@ -77,13 +78,12 @@ impl Window {
}

/// The primary window, or nil if there is none.
fn primary(ctxt: FunctionCallContext) -> Result<Option<ReflectReference>, InteropError> {
fn primary(ctxt: FunctionCallContext) -> Result<Option<ValueOf<Window>>, InteropError> {
let world = ctxt.world()?;
match primary_window_entity(&world)? {
Some(entity) => Ok(Some(ReflectReference::new_component_ref::<Window>(
entity,
world.clone(),
)?)),
Some(entity) => Ok(Some(ValueOf::new(ReflectReference::new_component_ref::<
Window,
>(entity, world.clone())?))),
None => Ok(None),
}
}
Expand Down
4 changes: 2 additions & 2 deletions xtask/luals_baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading