Skip to content

Commit f1a200b

Browse files
committed
Fix compile issues not seen when using as branch
1 parent 922ab68 commit f1a200b

File tree

9 files changed

+32
-15
lines changed

9 files changed

+32
-15
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ bevy_mod_scripting_derive = { workspace = true }
8484

8585
[workspace.dependencies]
8686
profiling = { version = "1.0" }
87+
bevy_math = { version = "0.16.0", default-features = false }
88+
bevy_reflect = { version = "0.16.0", default-features = false }
89+
bevy_input = { version = "0.16.0", default-features = false }
8790
bevy = { version = "0.16.0", default-features = false }
8891
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.13.0" }
8992
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.13.0", default-features = false }

crates/bevy_mod_scripting_core/src/bindings/reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl ReflectReference {
214214

215215
self.with_reflect(world.clone(), |r| {
216216
<dyn PartialReflect>::from_reflect_or_clone(r, world.clone())
217-
})
217+
})?
218218
}
219219

220220
/// The way to access the value of the reference, that is the pointed-to value.

crates/bevy_mod_scripting_core/src/bindings/script_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use bevy::{
2828
query::{Access, FilteredAccess, FilteredAccessSet, QueryState},
2929
reflect::AppTypeRegistry,
3030
schedule::{
31-
SystemSet, Infallible, graph::GraphInfo,
31+
SystemSet, Infallible
3232
},
3333
system::{IntoSystem, System, SystemParamValidationError},
3434
world::{unsafe_world_cell::UnsafeWorldCell, World},

crates/bevy_mod_scripting_core/src/bindings/world.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,10 @@ impl WorldAccessGuard<'_> {
818818
// try to construct type from reflect
819819
// TODO: it would be nice to have a <dyn PartialReflect>::from_reflect_with_fallback equivalent, that does exactly that
820820
// only using this as it's already there and convenient, the clone variant hitting will be confusing to end users
821-
Ok(<dyn PartialReflect>::from_reflect_or_clone(
821+
<dyn PartialReflect>::from_reflect_or_clone(
822822
dynamic.as_ref(),
823823
self.clone(),
824-
))
824+
)
825825
}
826826

827827
/// Spawns a new entity in the world

crates/bevy_mod_scripting_core/src/extractors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use bevy::{
1111
event::{Event, EventCursor, EventIterator, Events},
1212
query::{Access, AccessConflicts},
1313
storage::SparseSetIndex,
14-
system::{Local, SystemParam, SystemState},
14+
system::{Local, SystemParam, SystemState, SystemParamValidationError},
1515
world::World,
1616
},
1717
prelude::Resource
@@ -368,8 +368,8 @@ unsafe impl<T: SystemParam> SystemParam for WithWorldGuard<'_, '_, T> {
368368
state: &Self::State,
369369
system_meta: &bevy::ecs::system::SystemMeta,
370370
world: bevy::ecs::world::unsafe_world_cell::UnsafeWorldCell,
371-
) -> bool {
372-
T::validate_param(&state.0, system_meta, world).is_ok()
371+
) -> Result<(), SystemParamValidationError> {
372+
T::validate_param(&state.0, system_meta, world)
373373
}
374374
}
375375

crates/bevy_mod_scripting_core/src/reflection_extensions.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ use crate::{
44
bindings::{ReflectReference, WorldGuard},
55
error::InteropError,
66
};
7-
use bevy::reflect::{PartialReflect, Reflect, ReflectFromReflect, ReflectMut, TypeInfo};
7+
use bevy::reflect::{
8+
PartialReflect, Reflect, ReflectFromReflect, ReflectMut, TypeInfo,
9+
};
810
use std::{
911
any::{Any, TypeId},
1012
cmp::max,
1113
};
14+
1215
/// Extension trait for [`PartialReflect`] providing additional functionality for working with specific types.
1316
pub trait PartialReflectExt {
1417
/// Try to get a reference to the given key in an underyling map, if the type is a map.
@@ -30,7 +33,7 @@ pub trait PartialReflectExt {
3033
fn from_reflect_or_clone(
3134
reflect: &dyn PartialReflect,
3235
world: WorldGuard,
33-
) -> Box<dyn PartialReflect>;
36+
) -> Result<Box<dyn PartialReflect>, InteropError>;
3437

3538
/// Allocate a new boxed reflect reference from a boxed reflect.
3639
fn allocate(boxed: Box<dyn Reflect>, world: WorldGuard) -> ReflectReference;
@@ -424,11 +427,19 @@ impl<T: PartialReflect + ?Sized> PartialReflectExt for T {
424427
fn from_reflect_or_clone(
425428
reflect: &dyn PartialReflect,
426429
world: WorldGuard,
427-
) -> Box<dyn PartialReflect> {
430+
) -> Result<Box<dyn PartialReflect>, InteropError> {
428431
// try from reflect
429432
match <dyn PartialReflect>::from_reflect(reflect, world.clone()) {
430-
Ok(v) => v.into_partial_reflect(),
431-
Err(_) => reflect.clone_value(),
433+
Ok(v) => Ok(v.into_partial_reflect()),
434+
Err(_) => reflect
435+
.reflect_clone()
436+
.map(|v| v.into_partial_reflect())
437+
.map_err(|e| {
438+
InteropError::failed_from_reflect(
439+
reflect.get_represented_type_info().map(|ti| ti.type_id()),
440+
e.to_string(),
441+
)
442+
}),
432443
}
433444
}
434445

@@ -667,7 +678,7 @@ mod test {
667678
let mut map =
668679
std::collections::HashMap::<i32, std::collections::HashMap<i32, i32>>::default();
669680
let value = DynamicMap::from_iter(vec![(1, 2), (2, 3), (3, 4)]);
670-
let value_ref: Box<dyn PartialReflect> = Box::new(value.clone_dynamic());
681+
let value_ref: Box<dyn PartialReflect> = Box::new(value.to_dynamic_map());
671682
map.insert(1, std::collections::HashMap::<i32, i32>::default());
672683
map.insert(2, std::collections::HashMap::<i32, i32>::default());
673684
map.insert(3, std::collections::HashMap::<i32, i32>::default());

crates/bevy_mod_scripting_functions/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ rhai_bindings = ["bevy_mod_scripting_rhai"]
2828

2929
[dependencies]
3030
bevy = { workspace = true }
31+
bevy_math = { workspace = true, features = ["curve"]}
32+
bevy_reflect = { workspace = true, features = ["smol_str"]}
33+
bevy_input = { workspace = true, features = ["smol_str"]}
3134
profiling = { workspace = true }
3235
uuid = "1.11"
3336
smol_str = "0.2.2"

crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_math.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4560,7 +4560,7 @@ impl bevy::math::bounding::BoundingSphereCast {
45604560
bms_core_path = "bevy_mod_scripting_core",
45614561
generated
45624562
)]
4563-
impl bevy::math::curve::interval::Interval {
4563+
impl bevy::math::curve::Interval {
45644564
/// Clamp the given `value` to lie within this interval.
45654565
fn clamp(_self: Val<bevy::math::curve::interval::Interval>, value: f32) -> f32 {
45664566
let output: f32 = bevy::math::curve::interval::Interval::clamp(

crates/bevy_system_reflection/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories = ["game-development"]
1212
readme = "readme.md"
1313

1414
[dependencies]
15-
bevy = { workspace = true, default-features = false }
15+
bevy = { workspace = true, default-features = false, features = ["bevy_log"]}
1616
dot-writer = "0.1.4"
1717

1818

0 commit comments

Comments
 (0)