Skip to content

Commit e34d70a

Browse files
committed
Rewrite Velocity and NavMesh from tuple structs to regular structs.
This is just because of rust-lang/rust#73191. Otherwise, creating instances of the type-aliased versions doesn't work.
1 parent cc38531 commit e34d70a

File tree

1 file changed

+14
-7
lines changed
  • crates/bevy_landmass/src

1 file changed

+14
-7
lines changed

crates/bevy_landmass/src/lib.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ pub struct Island;
298298

299299
/// An asset holding a `landmass` nav mesh.
300300
#[derive(Asset, TypePath)]
301-
pub struct NavMesh<CS: CoordinateSystem>(pub Arc<ValidNavigationMesh<CS>>);
301+
pub struct NavMesh<CS: CoordinateSystem> {
302+
pub nav_mesh: Arc<ValidNavigationMesh<CS>>,
303+
// This can't be a tuple struct due to https://github.com/rust-lang/rust/issues/73191
304+
}
302305

303306
pub type NavMesh2d = NavMesh<TwoD>;
304307
pub type NavMesh3d = NavMesh<ThreeD>;
@@ -412,13 +415,13 @@ fn sync_island_nav_mesh<CS: CoordinateSystem>(
412415
None => true,
413416
Some((current_transform, current_nav_mesh)) => {
414417
current_transform != &island_transform
415-
|| !Arc::ptr_eq(&current_nav_mesh, &island_nav_mesh.0)
418+
|| !Arc::ptr_eq(&current_nav_mesh, &island_nav_mesh.nav_mesh)
416419
}
417420
};
418421

419422
if set_nav_mesh {
420423
landmass_island
421-
.set_nav_mesh(island_transform, Arc::clone(&island_nav_mesh.0));
424+
.set_nav_mesh(island_transform, Arc::clone(&island_nav_mesh.nav_mesh));
422425
}
423426
}
424427
}
@@ -458,14 +461,17 @@ impl<CS: CoordinateSystem> ArchipelagoRef<CS> {
458461
/// The current velocity of the agent/character. This must be set to match
459462
/// whatever speed the agent/character is going.
460463
#[derive(Component)]
461-
pub struct Velocity<CS: CoordinateSystem>(pub CS::Coordinate);
464+
pub struct Velocity<CS: CoordinateSystem> {
465+
pub velocity: CS::Coordinate,
466+
// This can't be a tuple struct due to https://github.com/rust-lang/rust/issues/73191
467+
}
462468

463469
pub type Velocity2d = Velocity<TwoD>;
464470
pub type Velocity3d = Velocity<ThreeD>;
465471

466472
impl<CS: CoordinateSystem> Default for Velocity<CS> {
467473
fn default() -> Self {
468-
Self(Default::default())
474+
Self { velocity: Default::default() }
469475
}
470476
}
471477

@@ -617,7 +623,7 @@ fn sync_agent_input_state<CS: CoordinateSystem>(
617623
let landmass_agent = archipelago.get_agent_mut(agent_entity);
618624
landmass_agent.position =
619625
CS::from_transform_position(transform.translation());
620-
if let Some(Velocity(velocity)) = velocity {
626+
if let Some(Velocity { velocity }) = velocity {
621627
landmass_agent.velocity = velocity.clone();
622628
}
623629
landmass_agent.radius = agent.radius;
@@ -746,7 +752,8 @@ fn sync_character_state<CS: CoordinateSystem>(
746752
let landmass_character = archipelago.get_character_mut(character_entity);
747753
landmass_character.position =
748754
CS::from_transform_position(transform.translation());
749-
landmass_character.velocity = if let Some(Velocity(velocity)) = velocity {
755+
landmass_character.velocity = if let Some(Velocity { velocity }) = velocity
756+
{
750757
velocity.clone()
751758
} else {
752759
CS::Coordinate::default()

0 commit comments

Comments
 (0)