Skip to content

Commit

Permalink
Merge pull request #209 from StarArawn/force_copy_src
Browse files Browse the repository at this point in the history
Removed copy_src requirement and remove TilemapTextureSize component.
  • Loading branch information
StarArawn authored Aug 6, 2022
2 parents 673764e + 6f08f10 commit f69316a
Show file tree
Hide file tree
Showing 27 changed files with 109 additions and 123 deletions.
5 changes: 2 additions & 3 deletions examples/accessing_tiles.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;

mod helpers;
Expand Down Expand Up @@ -81,7 +81,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 96.0, y: 16.0 },
texture: TilemapTexture(texture_handle),
tile_size,
transform: bevy_ecs_tilemap::helpers::get_centered_transform_2d(
Expand Down Expand Up @@ -144,11 +143,11 @@ fn main() {
title: String::from("Basic Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.add_system(update_map)
.run();
}
10 changes: 2 additions & 8 deletions examples/animation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
render::texture::ImageSettings,
};
use bevy_ecs_tilemap::prelude::*;
use bevy_ecs_tilemap::tiles::{AnimatedTile, TileBundle, TilePos, TileStorage, TileTexture};
Expand All @@ -11,23 +12,20 @@ use rand::thread_rng;
mod helpers;

struct TilemapMetadata {
texture_size: TilemapTextureSize,
size: TilemapSize,
tile_size: TilemapTileSize,
grid_size: TilemapGridSize,
}

const BACKGROUND: &'static str = "tiles.png";
const BACKGROUND_METADATA: TilemapMetadata = TilemapMetadata {
texture_size: TilemapTextureSize { x: 96.0, y: 16.0 },
size: TilemapSize { x: 20, y: 20 },
tile_size: TilemapTileSize { x: 16.0, y: 16.0 },
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
};

const FLOWERS: &'static str = "flower_sheet.png";
const FLOWERS_METADATA: TilemapMetadata = TilemapMetadata {
texture_size: TilemapTextureSize { x: 32.0, y: 448.0 },
size: TilemapSize { x: 10, y: 10 },
tile_size: TilemapTileSize { x: 32.0, y: 32.0 },
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
Expand All @@ -39,7 +37,6 @@ fn create_background(mut commands: Commands, asset_server: Res<AssetServer>) {
let tilemap_entity = commands.spawn().id();

let TilemapMetadata {
texture_size,
size,
grid_size,
tile_size,
Expand Down Expand Up @@ -68,7 +65,6 @@ fn create_background(mut commands: Commands, asset_server: Res<AssetServer>) {
.insert_bundle(TilemapBundle {
size,
grid_size,
texture_size,
tile_size,
storage: tilemap_storage,
texture: TilemapTexture(texture_handle.clone()),
Expand All @@ -81,7 +77,6 @@ fn create_animated_flowers(mut commands: Commands, asset_server: Res<AssetServer
let texture_handle: Handle<Image> = asset_server.load(FLOWERS);

let TilemapMetadata {
texture_size,
size,
grid_size,
tile_size,
Expand Down Expand Up @@ -126,7 +121,6 @@ fn create_animated_flowers(mut commands: Commands, asset_server: Res<AssetServer
grid_size,
size,
storage: tilemap_storage,
texture_size,
texture: TilemapTexture(texture_handle.clone()),
tile_size,
transform: bevy_ecs_tilemap::helpers::get_centered_transform_2d(&size, &tile_size, 1.0),
Expand All @@ -146,6 +140,7 @@ fn main() {
title: String::from("Animated Map Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(LogDiagnosticsPlugin::default())
.add_plugin(FrameTimeDiagnosticsPlugin::default())
Expand All @@ -154,6 +149,5 @@ fn main() {
.add_startup_system(create_background)
.add_startup_system(create_animated_flowers)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.run();
}
5 changes: 2 additions & 3 deletions examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;
mod helpers;

Expand Down Expand Up @@ -46,7 +46,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 96.0, y: 16.0 },
texture: TilemapTexture(texture_handle),
tile_size,
transform: bevy_ecs_tilemap::helpers::get_centered_transform_2d(
Expand Down Expand Up @@ -95,11 +94,11 @@ fn main() {
),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.add_system(swap_texture_or_hide)
.run();
}
4 changes: 2 additions & 2 deletions examples/bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
render::texture::ImageSettings,
};
use bevy_ecs_tilemap::prelude::*;

Expand Down Expand Up @@ -31,7 +32,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 96.0, y: 16.0 },
texture: TilemapTexture(texture_handle),
tile_size,
transform: bevy_ecs_tilemap::helpers::get_centered_transform_2d(
Expand All @@ -51,12 +51,12 @@ fn main() {
title: String::from("Benchmark Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(LogDiagnosticsPlugin::default())
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.run();
}
6 changes: 2 additions & 4 deletions examples/chunking.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use bevy::{math::Vec3Swizzles, prelude::*, utils::HashSet};
use bevy::{math::Vec3Swizzles, prelude::*, render::texture::ImageSettings, utils::HashSet};
use bevy_ecs_tilemap::prelude::*;
mod helpers;

const TILE_SIZE: TilemapTileSize = TilemapTileSize { x: 16.0, y: 16.0 };
const TEXTURE_SIZE: TilemapTextureSize = TilemapTextureSize { x: 96.0, y: 16.0 };
const CHUNK_SIZE: TilemapSize = TilemapSize { x: 32, y: 32 };

fn spawn_chunk(commands: &mut Commands, asset_server: &AssetServer, chunk_pos: IVec2) {
Expand Down Expand Up @@ -37,7 +36,6 @@ fn spawn_chunk(commands: &mut Commands, asset_server: &AssetServer, chunk_pos: I
grid_size: TILE_SIZE.into(),
size: CHUNK_SIZE,
storage: tile_storage,
texture_size: TEXTURE_SIZE,
texture: TilemapTexture(texture_handle),
tile_size: TILE_SIZE,
transform,
Expand Down Expand Up @@ -108,12 +106,12 @@ fn main() {
title: String::from("Basic Chunking Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.insert_resource(ChunkManager::default())
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.add_system(spawn_chunks_around_camera)
.add_system(despawn_outofrange_chunks)
.run();
Expand Down
5 changes: 2 additions & 3 deletions examples/colors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;

mod helpers;
Expand Down Expand Up @@ -88,7 +88,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 96.0, y: 16.0 },
texture: TilemapTexture(texture_handle),
tile_size,
mesh_type: TilemapMeshType::Square,
Expand All @@ -104,10 +103,10 @@ fn main() {
title: String::from("Iso Diamond Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.run();
}
5 changes: 2 additions & 3 deletions examples/game_of_life.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;

mod helpers;
Expand Down Expand Up @@ -38,7 +38,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 16.0, y: 16.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 96.0, y: 16.0 },
texture: TilemapTexture(texture_handle),
tile_size,
transform: bevy_ecs_tilemap::helpers::get_centered_transform_2d(
Expand Down Expand Up @@ -107,11 +106,11 @@ fn main() {
title: String::from("Game of Life Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.add_system(update)
.run();
}
1 change: 0 additions & 1 deletion examples/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod camera;
pub mod texture;
pub mod tiled;
20 changes: 0 additions & 20 deletions examples/helpers/texture.rs

This file was deleted.

6 changes: 0 additions & 6 deletions examples/helpers/tiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ pub fn process_loaded_maps(
y: tiled_map.map.height,
};

let texture_size = TilemapTextureSize {
x: tileset.images[0].width as f32,
y: tileset.images[0].height as f32,
};

let grid_size = TilemapGridSize {
x: tiled_map.map.tile_width as f32,
y: tiled_map.map.tile_height as f32,
Expand Down Expand Up @@ -231,7 +226,6 @@ pub fn process_loaded_maps(
grid_size,
size: map_size,
storage: tile_storage,
texture_size,
texture: TilemapTexture(
tiled_map
.tilesets
Expand Down
5 changes: 2 additions & 3 deletions examples/hexagon_column.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;

mod helpers;
Expand Down Expand Up @@ -57,7 +57,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: tile_size.into(),
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 17.0, y: 105.0 },
texture: TilemapTexture(texture_handle),
tile_size,
mesh_type: TilemapMeshType::Hexagon(HexType::Column),
Expand Down Expand Up @@ -92,11 +91,11 @@ fn main() {
title: String::from("Hexagon Column Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.add_system(swap_mesh_type)
.run();
}
5 changes: 2 additions & 3 deletions examples/hexagon_row.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;
mod helpers;

Expand Down Expand Up @@ -56,7 +56,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: tile_size.into(),
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 105.0, y: 17.0 },
texture: TilemapTexture(texture_handle),
tile_size,
mesh_type: TilemapMeshType::Hexagon(HexType::Row),
Expand Down Expand Up @@ -91,11 +90,11 @@ fn main() {
title: String::from("Hexagon Row Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.add_system(swap_mesh_type)
.run();
}
5 changes: 2 additions & 3 deletions examples/iso_diamond.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;
mod helpers;

Expand Down Expand Up @@ -56,7 +56,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 64.0, y: 32.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 384.0, y: 32.0 },
texture: TilemapTexture(texture_handle),
tile_size,
mesh_type: TilemapMeshType::Isometric(IsoType::Diamond),
Expand All @@ -72,10 +71,10 @@ fn main() {
title: String::from("Iso Diamond Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.run();
}
5 changes: 2 additions & 3 deletions examples/iso_staggered.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, render::texture::ImageSettings};
use bevy_ecs_tilemap::prelude::*;

mod helpers;
Expand Down Expand Up @@ -57,7 +57,6 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: TilemapGridSize { x: 64.0, y: 32.0 },
size: tilemap_size,
storage: tile_storage,
texture_size: TilemapTextureSize { x: 384.0, y: 32.0 },
texture: TilemapTexture(texture_handle),
tile_size,
mesh_type: TilemapMeshType::Isometric(IsoType::Staggered),
Expand All @@ -73,10 +72,10 @@ fn main() {
title: String::from("Iso Staggered Example"),
..Default::default()
})
.insert_resource(ImageSettings::default_nearest())
.add_plugins(DefaultPlugins)
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
.add_system(helpers::texture::set_texture_filters_to_nearest)
.run();
}
Loading

0 comments on commit f69316a

Please sign in to comment.