Skip to content
Snippets Groups Projects
debug.rs 720 B
Newer Older
use bevy::prelude::*;

use crate::assets::AssetHandles;
use crate::world::TravelPath;

#[derive(Component)]
pub struct Tombstone;

pub fn create_tombstones(
	mut commands: Commands,
	assets: Res<AssetHandles>,
	query: Query<&TravelPath, Or<(Added<TravelPath>, Changed<TravelPath>)>>,
	existing: Query<Entity, With<Tombstone>>,
) {
	for path in &query {
		for entity in &existing {
			commands.entity(entity).despawn_recursive();
		}

		for point in &path.path {
			commands.spawn((
				SpriteSheetBundle {
					transform: Transform::from_translation(point.extend(900.0)),
Louis's avatar
Louis committed
					texture_atlas: assets.atlas("icons"),
					sprite: TextureAtlasSprite::new(1),
					..Default::default()
				},
				Tombstone,
			));
		}
	}
}