Simplify some conversions.

This commit is contained in:
Nolan Darilek 2022-01-19 18:37:04 -06:00
parent c0980f66c1
commit 488037d074

View File

@ -227,7 +227,7 @@ fn spawn_colliders(
if tile.blocks_motion() { if tile.blocks_motion() {
let id = commands let id = commands
.spawn_bundle(ColliderBundle { .spawn_bundle(ColliderBundle {
shape: ColliderShapeComponent(ColliderShape::cuboid(0.5, 0.5)), shape: ColliderShape::cuboid(0.5, 0.5).into(),
position: Vec2::new(x as f32 + 0.5, y as f32 + 0.5).into(), position: Vec2::new(x as f32 + 0.5, y as f32 + 0.5).into(),
..Default::default() ..Default::default()
}) })
@ -322,10 +322,7 @@ fn spawn_colliders(
);*/ );*/
let id = commands let id = commands
.spawn_bundle(ColliderBundle { .spawn_bundle(ColliderBundle {
shape: ColliderShapeComponent(ColliderShape::cuboid( shape: ColliderShape::cuboid(half_width, half_height).into(),
half_width,
half_height,
)),
position: Vec2::new(x, y).into(), position: Vec2::new(x, y).into(),
..Default::default() ..Default::default()
}) })
@ -349,8 +346,8 @@ fn spawn_colliders(
let aabb = shape.compute_aabb(&position); let aabb = shape.compute_aabb(&position);
let id = commands let id = commands
.spawn_bundle(ColliderBundle { .spawn_bundle(ColliderBundle {
collider_type: ColliderTypeComponent(ColliderType::Sensor), collider_type: ColliderType::Sensor.into(),
shape: ColliderShapeComponent(shape.clone()), shape: shape.clone().into(),
flags: ActiveEvents::INTERSECTION_EVENTS.into(), flags: ActiveEvents::INTERSECTION_EVENTS.into(),
position, position,
..Default::default() ..Default::default()
@ -431,7 +428,7 @@ fn spawn_portal_colliders(
.entity(portal_entity) .entity(portal_entity)
.insert_bundle(ColliderBundle { .insert_bundle(ColliderBundle {
collider_type: ColliderTypeComponent(ColliderType::Sensor), collider_type: ColliderTypeComponent(ColliderType::Sensor),
shape: ColliderShapeComponent(ColliderShape::cuboid(0.5, 0.5)), shape: ColliderShape::cuboid(0.5, 0.5).into(),
position, position,
flags: ActiveEvents::INTERSECTION_EVENTS.into(), flags: ActiveEvents::INTERSECTION_EVENTS.into(),
..Default::default() ..Default::default()