Mutably borrows from an owned value. Read more
diff --git a/rustdoc/src/game_logic/rendering/utilities/map_render.rs.html b/rustdoc/src/game_logic/rendering/utilities/map_render.rs.html
index 2118691f..35ed2436 100644
--- a/rustdoc/src/game_logic/rendering/utilities/map_render.rs.html
+++ b/rustdoc/src/game_logic/rendering/utilities/map_render.rs.html
@@ -598,6 +598,23 @@
596
597
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use crate::{
@@ -879,6 +896,9 @@
camera,
);
let player_position = na::Vector2::new(player_position.x, player_position.y * -1.0);
+
+ let tile_width = 128;
+ let tile_height = 128;
for layer in self.map.layers() {
@@ -889,10 +909,6 @@
let mut sampler_x = 0;
let mut sampler_y = 0;
-
- let tile_width = 128;
- let tile_height = 128;
-
for y in (world_win_top_left.y as i64)..(world_win_bottom_right.y as i64) {
@@ -931,154 +947,6 @@
Color::WHITE,
);
}
-
-
- for obj_ref in &self.world_objects.object_references {
- if obj_ref.get_tile_space_position().x == sampler_x as f32
- && obj_ref.get_tile_space_position().y
- == sampler_y as f32
- {
-
- let object_key = obj_ref.into_key();
-
- let obj_def = self
- .world_objects
- .object_definitions
- .get(&object_key)
- .unwrap();
-
-
- if obj_def.bottom_texture.animated.unwrap_or(false) {
- let tex = self
- .world_objects
- .bottom_animated_textures
- .get_mut(&object_key)
- .unwrap();
- tex.render_automatic(
- draw_handle,
- obj_ref.get_world_space_position()
- - (tex.size() / 2.0),
- None,
- Some(tex.size() / 2.0),
- Some(obj_ref.rotation_degrees),
- None,
- );
- } else {
- let tex = self
- .world_objects
- .bottom_static_textures
- .get_mut(&object_key)
- .unwrap();
- let p: Vector2 =
- obj_ref.get_world_space_position().into();
- let r1 = Rectangle {
- x: 0.0,
- y: 0.0,
- width: tex.width as f32,
- height: tex.height as f32,
- };
- let r2 = Rectangle {
- x: p.x,
- y: p.y,
- width: tex.width as f32,
- height: tex.height as f32,
- };
-
- draw_handle.draw_texture_pro(
- &tex,
- r1,
- r2,
- Vector2::new(
- tex.width as f32 / 2.0,
- tex.height as f32 / 2.0,
- ),
- obj_ref.rotation_degrees,
- Color::WHITE,
- );
- }
-
-
- if let Some(top_texture) = &obj_def.top_texture {
-
- let mut tint = Color::WHITE;
- if let Some(footprint_radius) =
- obj_def.visualization_radius
- {
- let player_dist_to_object = (obj_ref
- .get_world_space_position()
- - player_position)
- .norm();
-
-
-
-
- if player_dist_to_object <= footprint_radius {
- tint.a = 128;
- }
- }
-
- if top_texture.animated.unwrap_or(false) {
- let tex = self
- .world_objects
- .top_animated_textures
- .get_mut(&object_key)
- .unwrap();
- tex.render_automatic(
- draw_handle,
- obj_ref.get_world_space_position()
- - (tex.size() / 2.0),
- None,
- Some(tex.size() / 2.0),
- Some(obj_ref.rotation_degrees),
- Some(tint),
- );
- } else {
- let tex = self
- .world_objects
- .top_static_textures
- .get_mut(&object_key)
- .unwrap();
- let p: Vector2 =
- obj_ref.get_world_space_position().into();
- let r1 = Rectangle {
- x: 0.0,
- y: 0.0,
- width: tex.width as f32,
- height: tex.height as f32,
- };
- let r2 = Rectangle {
- x: p.x,
- y: p.y,
- width: tex.width as f32,
- height: tex.height as f32,
- };
-
- draw_handle.draw_texture_pro(
- &tex,
- r1,
- r2,
- Vector2::new(
- tex.width as f32 / 2.0,
- tex.height as f32 / 2.0,
- ),
- obj_ref.rotation_degrees,
- tint,
- );
- }
- }
- }
- }
-
- if show_debug_grid {
- draw_handle.draw_rectangle_lines(
- tile_x * tile_width as i32,
- tile_y * tile_height as i32,
- self.map.tile_width as i32,
- self.map.tile_height as i32,
- Color::RED,
- );
- draw_handle.draw_pixel(x as i32, y as i32, Color::BLUE);
- }
}
}
}
@@ -1089,6 +957,172 @@
tiled::LayerType::GroupLayer(_) => todo!(),
}
}
+
+
+ let mut sampler_x = 0;
+ let mut sampler_y = 0;
+
+
+ for y in (world_win_top_left.y as i64)..(world_win_bottom_right.y as i64) {
+
+ let tile_y = (y as f32 / tile_height as f32).floor() as i32;
+
+
+ if sampler_y != tile_y {
+ sampler_y = tile_y;
+
+ for x in (world_win_top_left.x as i64)..(world_win_bottom_right.x as i64) {
+
+ let tile_x = (x as f32 / tile_width as f32).floor() as i32;
+
+
+
+ if sampler_x != tile_x {
+ sampler_x = tile_x;
+
+
+ for obj_ref in &self.world_objects.object_references {
+ if obj_ref.get_tile_space_position().x == sampler_x as f32
+ && obj_ref.get_tile_space_position().y == sampler_y as f32
+ {
+
+ let object_key = obj_ref.into_key();
+
+ let obj_def = self
+ .world_objects
+ .object_definitions
+ .get(&object_key)
+ .unwrap();
+
+
+ if obj_def.bottom_texture.animated.unwrap_or(false) {
+ let tex = self
+ .world_objects
+ .bottom_animated_textures
+ .get_mut(&object_key)
+ .unwrap();
+ tex.render_automatic(
+ draw_handle,
+ obj_ref.get_world_space_position() - (tex.size() / 2.0),
+ None,
+ Some(tex.size() / 2.0),
+ Some(obj_ref.rotation_degrees),
+ None,
+ );
+ } else {
+ let tex = self
+ .world_objects
+ .bottom_static_textures
+ .get_mut(&object_key)
+ .unwrap();
+ let p: Vector2 = obj_ref.get_world_space_position().into();
+ let r1 = Rectangle {
+ x: 0.0,
+ y: 0.0,
+ width: tex.width as f32,
+ height: tex.height as f32,
+ };
+ let r2 = Rectangle {
+ x: p.x,
+ y: p.y,
+ width: tex.width as f32,
+ height: tex.height as f32,
+ };
+
+ draw_handle.draw_texture_pro(
+ &tex,
+ r1,
+ r2,
+ Vector2::new(
+ tex.width as f32 / 2.0,
+ tex.height as f32 / 2.0,
+ ),
+ obj_ref.rotation_degrees,
+ Color::WHITE,
+ );
+ }
+
+
+ if let Some(top_texture) = &obj_def.top_texture {
+
+ let mut tint = Color::WHITE;
+ if let Some(footprint_radius) = obj_def.visualization_radius {
+ let player_dist_to_object =
+ (obj_ref.get_world_space_position() - player_position)
+ .norm();
+
+
+
+
+ if player_dist_to_object <= footprint_radius {
+ tint.a = 128;
+ }
+ }
+
+ if top_texture.animated.unwrap_or(false) {
+ let tex = self
+ .world_objects
+ .top_animated_textures
+ .get_mut(&object_key)
+ .unwrap();
+ tex.render_automatic(
+ draw_handle,
+ obj_ref.get_world_space_position() - (tex.size() / 2.0),
+ None,
+ Some(tex.size() / 2.0),
+ Some(obj_ref.rotation_degrees),
+ Some(tint),
+ );
+ } else {
+ let tex = self
+ .world_objects
+ .top_static_textures
+ .get_mut(&object_key)
+ .unwrap();
+ let p: Vector2 = obj_ref.get_world_space_position().into();
+ let r1 = Rectangle {
+ x: 0.0,
+ y: 0.0,
+ width: tex.width as f32,
+ height: tex.height as f32,
+ };
+ let r2 = Rectangle {
+ x: p.x,
+ y: p.y,
+ width: tex.width as f32,
+ height: tex.height as f32,
+ };
+
+ draw_handle.draw_texture_pro(
+ &tex,
+ r1,
+ r2,
+ Vector2::new(
+ tex.width as f32 / 2.0,
+ tex.height as f32 / 2.0,
+ ),
+ obj_ref.rotation_degrees,
+ tint,
+ );
+ }
+ }
+ }
+ }
+
+ if show_debug_grid {
+ draw_handle.draw_rectangle_lines(
+ tile_x * tile_width as i32,
+ tile_y * tile_height as i32,
+ self.map.tile_width as i32,
+ self.map.tile_height as i32,
+ Color::RED,
+ );
+ draw_handle.draw_pixel(x as i32, y as i32, Color::BLUE);
+ }
+ }
+ }
+ }
+ }
}