Initial port to Bevy 0.15.

This commit is contained in:
Nolan Darilek 2025-01-03 14:19:57 -05:00
parent f6c34057aa
commit 380506b75c
7 changed files with 31 additions and 27 deletions

View File

@ -14,7 +14,7 @@ speech_dispatcher_0_10 = ["bevy_tts/speech_dispatcher_0_10"]
speech_dispatcher_0_11 = ["bevy_tts/speech_dispatcher_0_11"] speech_dispatcher_0_11 = ["bevy_tts/speech_dispatcher_0_11"]
[dependencies.bevy] [dependencies.bevy]
version = "0.14" version = "0.15"
default-features = false default-features = false
features = [ features = [
"android_shared_stdcxx", "android_shared_stdcxx",
@ -48,12 +48,12 @@ features = [
] ]
[dependencies] [dependencies]
avian2d = "0.1" avian2d = "0.2"
bevy_synthizer = "0.8" bevy_synthizer = "0.9"
bevy_tts = { version = "0.9", default-features = false, features = ["tolk"] } bevy_tts = { version = "0.10", default-features = false, features = ["tolk"] }
coord_2d = "0.3" coord_2d = "0.3"
here_be_dragons = { version = "0.3", features = ["serde"] } here_be_dragons = { version = "0.3", features = ["serde"] }
leafwing-input-manager = "0.15" leafwing-input-manager = "0.16"
maze_generator = "2" maze_generator = "2"
once_cell = "1" once_cell = "1"
pathfinding = "4" pathfinding = "4"

View File

@ -333,7 +333,7 @@ where
&shape, &shape,
exploring, exploring,
0., 0.,
SpatialQueryFilter::default(), &default(),
|entity| { |entity| {
if explorable.contains(entity) { if explorable.contains(entity) {
commands.entity(entity).insert(ExplorationFocused); commands.entity(entity).insert(ExplorationFocused);

View File

@ -73,7 +73,7 @@ impl ITileType for Tile {
#[derive(Bundle, Default)] #[derive(Bundle, Default)]
pub struct PortalBundle { pub struct PortalBundle {
pub transform: TransformBundle, pub transform: Transform,
pub portal: Portal, pub portal: Portal,
pub mappable: Mappable, pub mappable: Mappable,
} }
@ -83,12 +83,12 @@ pub struct MapBundle<D: 'static + Clone + Default + Send + Sync> {
pub map: Map<D>, pub map: Map<D>,
pub spawn_colliders: SpawnColliders, pub spawn_colliders: SpawnColliders,
pub spawn_portals: SpawnPortals, pub spawn_portals: SpawnPortals,
pub transform: TransformBundle, pub transform: Transform,
} }
#[derive(Bundle, Clone, Debug)] #[derive(Bundle, Clone, Debug)]
pub struct TileBundle { pub struct TileBundle {
pub transform: TransformBundle, pub transform: Transform,
pub collider: Collider, pub collider: Collider,
pub rigid_body: RigidBody, pub rigid_body: RigidBody,
pub map_obstruction: MapObstruction, pub map_obstruction: MapObstruction,
@ -117,7 +117,7 @@ impl TileBundle {
#[derive(Bundle, Clone, Debug)] #[derive(Bundle, Clone, Debug)]
pub struct ZoneBundle { pub struct ZoneBundle {
pub collider: Collider, pub collider: Collider,
pub transform: TransformBundle, pub transform: Transform,
pub zone: Zone, pub zone: Zone,
pub sensor: Sensor, pub sensor: Sensor,
} }
@ -239,7 +239,7 @@ fn spawn_colliders<D: 'static + Clone + Default + Send + Sync>(
if tile.blocks_visibility() { if tile.blocks_visibility() {
commands.entity(id).insert(Visible::opaque()); commands.entity(id).insert(Visible::opaque());
} }
commands.entity(map_entity).push_children(&[id]); commands.entity(map_entity).add_children(&[id]);
} }
} }
} }

View File

@ -227,9 +227,12 @@ fn controls(
transform.translation.truncate(), transform.translation.truncate(),
transform.yaw().as_radians(), transform.yaw().as_radians(),
dir, dir,
pair.length(), &ShapeCastConfig {
true, max_distance: pair.length(),
SpatialQueryFilter::from_excluded_entities(&sensors), ignore_origin_penetration: true,
..default()
},
&SpatialQueryFilter::from_excluded_entities(&sensors),
|hit| { |hit| {
if hit.entity != entity { if hit.entity != entity {
can_translate = false; can_translate = false;
@ -255,7 +258,7 @@ fn controls(
// velocity.angvel = // velocity.angvel =
// actions.value(&NavigationAction::SetAngularVelocity); // actions.value(&NavigationAction::SetAngularVelocity);
transform.rotation *= Quat::from_rotation_z( transform.rotation *= Quat::from_rotation_z(
actions.value(&NavigationAction::SetAngularVelocity) * time.delta_seconds(), actions.value(&NavigationAction::SetAngularVelocity) * time.delta_secs(),
); );
} }
} }

View File

@ -139,7 +139,7 @@ fn calculate_path(
collider, collider,
check, check,
transform.yaw().as_radians(), transform.yaw().as_radians(),
SpatialQueryFilter::from_excluded_entities(&sensors), &SpatialQueryFilter::from_excluded_entities(&sensors),
); );
for entity in &hits { for entity in &hits {
if obstructions.contains(*entity) { if obstructions.contains(*entity) {
@ -245,9 +245,12 @@ fn negotiate_path(
start, start,
global_transform.yaw().as_radians(), global_transform.yaw().as_radians(),
Dir2::new_unchecked(direction.normalize()), Dir2::new_unchecked(direction.normalize()),
time.delta_seconds(), &ShapeCastConfig {
true, max_distance: time.delta_secs(),
SpatialQueryFilter::from_excluded_entities(&sensors), ignore_origin_penetration: true,
..default()
},
&SpatialQueryFilter::from_excluded_entities(&sensors),
|hit| { |hit| {
if obstructions.contains(hit.entity) { if obstructions.contains(hit.entity) {
hits.push(hit.entity); hits.push(hit.entity);
@ -261,7 +264,7 @@ fn negotiate_path(
next.y = next.y.trunc(); next.y = next.y.trunc();
transform.translation = next.extend(0.); transform.translation = next.extend(0.);
} else { } else {
let delta = direction * time.delta_seconds(); let delta = direction * time.delta_secs();
navigation_actions.set_axis_pair(&NavigationAction::Translate, delta); navigation_actions.set_axis_pair(&NavigationAction::Translate, delta);
} }
if rotation_speed.is_some() { if rotation_speed.is_some() {

View File

@ -39,9 +39,7 @@ fn update(
); );
commands commands
.entity(sound_entity) .entity(sound_entity)
.insert(TransformBundle::from_transform( .insert(Transform::from_translation(sound_translation));
Transform::from_translation(sound_translation),
));
} }
} else if closest == ClosestPoints::Intersecting && sound_transform.is_some() { } else if closest == ClosestPoints::Intersecting && sound_transform.is_some() {
commands commands
@ -60,7 +58,7 @@ fn removed(
) { ) {
for entity in removed.read() { for entity in removed.read() {
if transforms.get(entity).is_ok() { if transforms.get(entity).is_ok() {
commands.entity(entity).insert(TransformBundle::default()); commands.entity(entity).insert(Transform::default());
} }
} }
} }

View File

@ -87,7 +87,7 @@ impl Viewshed {
dir, dir,
dir.distance(*start), dir.distance(*start),
true, true,
default(), &default(),
&|entity| { &|entity| {
if *e != entity && entities.contains(e) { if *e != entity && entities.contains(e) {
// println!("{entities:?} contains {e}"); // println!("{entities:?} contains {e}");
@ -161,7 +161,7 @@ impl OpacityMap {
&shape, &shape,
shape_pos, shape_pos,
0., 0.,
default(), &default(),
|entity| { |entity| {
if let Ok((_, _, _, visible)) = visible.get(entity) { if let Ok((_, _, _, visible)) = visible.get(entity) {
coord_entities.insert(entity); coord_entities.insert(entity);
@ -451,6 +451,6 @@ impl<MapData: 'static + Clone + Default + Send + Sync> Plugin for VisibilityPlug
), ),
) )
.add_systems(FixedPostUpdate, (viewshed_removed, remove_visible)) .add_systems(FixedPostUpdate, (viewshed_removed, remove_visible))
.observe(log_visible); .add_observer(log_visible);
} }
} }