rework pathfinding, game entity fog rendering, and tilemap usage
This commit is contained in:
+9
-8
@@ -1,4 +1,5 @@
|
||||
use crate::tile::{FixtureTile, FloorTile, TileState};
|
||||
use crate::tilemap::Z_BELOW;
|
||||
use crate::{constants::*, tilemap};
|
||||
use bevy::asset::RenderAssetUsages;
|
||||
use bevy::prelude::*;
|
||||
@@ -33,6 +34,9 @@ const LOG_PATH: &str = "log.png";
|
||||
const LEAVES_PATH: &str = "leaves.png";
|
||||
|
||||
pub fn initialize_textures(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
println!("");
|
||||
println!("####################");
|
||||
let start = Instant::now();
|
||||
let mut textures: HashMap<String, Handle<Image>> = HashMap::new();
|
||||
let mut texture_ids: HashMap<u32, String> = HashMap::new();
|
||||
texture_ids.insert(u32::MAX, DEFAULT_TEXTURE.to_string());
|
||||
@@ -82,6 +86,7 @@ pub fn initialize_textures(mut commands: Commands, asset_server: Res<AssetServer
|
||||
|
||||
commands.insert_resource(Textures { handles: textures });
|
||||
commands.insert_resource(TextureIDs { refs: texture_ids });
|
||||
println!("Textures initialized in {:.2?}", start.elapsed());
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -97,6 +102,7 @@ pub struct CurrentWorldSpriteState {
|
||||
pub state: TerrainSpriteState,
|
||||
}
|
||||
|
||||
use std::process::exit;
|
||||
use std::sync::Mutex;
|
||||
use std::time::Instant;
|
||||
|
||||
@@ -153,9 +159,7 @@ pub fn build_quilted_terrain_sprites(
|
||||
let position = Vec2::new(transform.translation.x, transform.translation.y);
|
||||
|
||||
for z_index in 0..=tilemap::Z_TOTAL as usize {
|
||||
let is_visible =
|
||||
(floortile.visible_range[z_index / 32] & (1 << (z_index % 32) as u32)) != 0;
|
||||
if is_visible {
|
||||
if (floortile.visible_range[z_index / 32] & (1 << (z_index % 32) as u32)) != 0 {
|
||||
tiles_by_z
|
||||
.entry(z_index)
|
||||
.or_default()
|
||||
@@ -306,7 +310,7 @@ pub fn build_quilted_terrain_sprites(
|
||||
Transform::from_xyz(
|
||||
center_x - TILE_SIZE / 2.0,
|
||||
center_y - TILE_SIZE / 2.0,
|
||||
-10.0 * TILE_SIZE,
|
||||
-Z_BELOW * TILE_SIZE,
|
||||
)
|
||||
.with_scale(Vec3::splat(PIXEL_RATIO)),
|
||||
Visibility::Hidden,
|
||||
@@ -317,10 +321,7 @@ pub fn build_quilted_terrain_sprites(
|
||||
|
||||
quilt_cache.dirty_indices.clear();
|
||||
cwss.state = TerrainSpriteState::RenderReady;
|
||||
println!(
|
||||
"Quilted world sprites built. Elapsed: {:.2?}",
|
||||
now.elapsed()
|
||||
);
|
||||
println!("Terrain sprites baked in: {:.2?}", now.elapsed());
|
||||
}
|
||||
|
||||
// Helper function to blit a texture onto another texture
|
||||
|
||||
Reference in New Issue
Block a user