new movement code
This commit is contained in:
parent
1eeaf80a93
commit
39631fb4ac
5 changed files with 185 additions and 44 deletions
|
@ -2,8 +2,7 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use crate::assets::ASSETS;
|
||||
use comfy::{IVec2, TextureHandle, UVec2};
|
||||
use log::info;
|
||||
use comfy::{info, IVec2, TextureHandle, UVec2};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub enum MovementCost {
|
||||
|
@ -403,7 +402,15 @@ fn world_to_chunk_and_local_coords(world_coords: IVec2) -> (IVec2, UVec2) {
|
|||
}
|
||||
|
||||
impl Overworld {
|
||||
fn get_tile(&self, world_coords: IVec2) -> Option<&Tile> {
|
||||
/// Return a [`Tile`] at the given world coordinates, or `None` if that tile has not
|
||||
/// been generated yet. Uses engine/world cordinates.
|
||||
pub fn get_tile(&self, world_coords: IVec2) -> Option<&Tile> {
|
||||
let mut coords = world_coords;
|
||||
coords.y *= -1;
|
||||
self.get_tile_private(coords)
|
||||
}
|
||||
|
||||
fn get_tile_private(&self, world_coords: IVec2) -> Option<&Tile> {
|
||||
let (chunk_coords, local_chunk_coords) =
|
||||
world_to_chunk_and_local_coords(world_coords);
|
||||
|
||||
|
@ -411,15 +418,15 @@ impl Overworld {
|
|||
chunk.get_tile(local_chunk_coords)
|
||||
}
|
||||
|
||||
/// Return a [`Tile`] at the given world coordinates, or `None` if that tile has not
|
||||
/// been generated yet. use engine/world cordinates.
|
||||
/// Return a [`Tile`] at the given world coordinates. Generates tiles if necessary.
|
||||
/// Uses engine/world cordinates.
|
||||
pub fn get_or_generate_tile(&mut self, world_coords: IVec2) -> &Tile {
|
||||
let mut coords = world_coords;
|
||||
coords.y *= -1;
|
||||
self.get_or_generate_tiles_private(coords)
|
||||
self.get_or_generate_tile_private(coords)
|
||||
}
|
||||
|
||||
fn get_or_generate_tiles_private(&mut self, world_coords: IVec2) -> &Tile {
|
||||
fn get_or_generate_tile_private(&mut self, world_coords: IVec2) -> &Tile {
|
||||
let (chunk_coords, local_chunk_coords) =
|
||||
world_to_chunk_and_local_coords(world_coords);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue