Bump mapgen.
This commit is contained in:
parent
4749a09c5b
commit
1391856478
|
@ -29,7 +29,7 @@ coord_2d = "0.3"
|
|||
crossbeam-channel = "0.5"
|
||||
derive_more = "0.99"
|
||||
gilrs = "0.8"
|
||||
mapgen = "0.4"
|
||||
mapgen = { git = "https://github.com/ndarilek/mapgen.rs" }
|
||||
maze_generator = "1"
|
||||
pathfinding = "2"
|
||||
rand = "0.8"
|
||||
|
|
|
@ -5,7 +5,7 @@ use bevy_input_actionmap::InputMap;
|
|||
use bevy_rapier2d::prelude::*;
|
||||
use bevy_tts::Tts;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use mapgen::TileType;
|
||||
use mapgen::Tile;
|
||||
|
||||
use crate::{
|
||||
core::{Coordinates, Player, PointLike},
|
||||
|
@ -374,9 +374,11 @@ fn exploration_changed_announcement(
|
|||
},
|
||||
);
|
||||
if tokens.is_empty() {
|
||||
match map.tiles[idx] {
|
||||
TileType::Floor => "Floor".to_string(),
|
||||
TileType::Wall => "Wall".to_string(),
|
||||
let tile = map.tiles[idx];
|
||||
if tile.is_blocked() {
|
||||
"wall".to_string()
|
||||
} else {
|
||||
"floor".to_string()
|
||||
}
|
||||
} else {
|
||||
tokens.join(": ")
|
||||
|
|
42
src/map.rs
42
src/map.rs
|
@ -4,7 +4,7 @@ use bevy::prelude::*;
|
|||
use bevy_rapier2d::prelude::*;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
pub use mapgen::Map;
|
||||
use mapgen::{geometry::Rect as MRect, MapFilter, TileType};
|
||||
use mapgen::{geometry::Rect as MRect, MapFilter, Tile};
|
||||
use maze_generator::{prelude::*, recursive_backtracking::RbGenerator};
|
||||
use rand::prelude::StdRng;
|
||||
|
||||
|
@ -39,19 +39,13 @@ pub trait ITileType {
|
|||
fn blocks_visibility(&self) -> bool;
|
||||
}
|
||||
|
||||
impl ITileType for TileType {
|
||||
impl ITileType for Tile {
|
||||
fn blocks_motion(&self) -> bool {
|
||||
match self {
|
||||
TileType::Wall => true,
|
||||
TileType::Floor => false,
|
||||
}
|
||||
self.is_blocked()
|
||||
}
|
||||
|
||||
fn blocks_visibility(&self) -> bool {
|
||||
match self {
|
||||
TileType::Wall => true,
|
||||
TileType::Floor => false,
|
||||
}
|
||||
self.is_blocked()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,22 +147,22 @@ impl MapFilter for GridBuilder {
|
|||
if field.has_passage(&North) {
|
||||
let x = x_offset + half_width;
|
||||
let y = y_offset + self.room_height;
|
||||
map.set_tile(x as usize, y as usize, TileType::Floor);
|
||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||
}
|
||||
if field.has_passage(&South) {
|
||||
let x = x_offset + half_width;
|
||||
let y = y_offset;
|
||||
map.set_tile(x as usize, y as usize, TileType::Floor);
|
||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||
}
|
||||
if field.has_passage(&East) {
|
||||
let x = x_offset + self.room_width;
|
||||
let y = y_offset + half_height;
|
||||
map.set_tile(x as usize, y as usize, TileType::Floor);
|
||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||
}
|
||||
if field.has_passage(&West) {
|
||||
let x = x_offset;
|
||||
let y = y_offset + half_height;
|
||||
map.set_tile(x as usize, y as usize, TileType::Floor);
|
||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,19 +232,19 @@ fn portal_spawner(
|
|||
let mut spawn_portal = false;
|
||||
if map.get_available_exits(x, y).len() > 2 {
|
||||
let idx = (x, y).to_index(map.width);
|
||||
if map.tiles[idx] == TileType::Floor
|
||||
&& (x > 1 && map.tiles[idx - 1] == TileType::Floor)
|
||||
&& (x < map.width - 2 && map.tiles[idx + 1] == TileType::Floor)
|
||||
&& (y > 1 && map.tiles[idx - map.width] == TileType::Wall)
|
||||
&& (y < map.height - 2 && map.tiles[idx + map.width] == TileType::Wall)
|
||||
if map.tiles[idx].is_walkable()
|
||||
&& (x > 1 && map.tiles[idx - 1].is_walkable())
|
||||
&& (x < map.width - 2 && map.tiles[idx + 1].is_walkable())
|
||||
&& (y > 1 && map.tiles[idx - map.width].is_blocked())
|
||||
&& (y < map.height - 2 && map.tiles[idx + map.width].is_blocked())
|
||||
{
|
||||
spawn_portal = true;
|
||||
}
|
||||
if map.tiles[idx] == TileType::Floor
|
||||
&& (x > 1 && map.tiles[idx - 1] == TileType::Wall)
|
||||
&& (x < map.width - 2 && map.tiles[idx + 1] == TileType::Wall)
|
||||
&& (y > 1 && map.tiles[idx - map.width] == TileType::Floor)
|
||||
&& (y < map.height - 2 && map.tiles[idx + map.width] == TileType::Floor)
|
||||
if map.tiles[idx].is_walkable()
|
||||
&& (x > 1 && map.tiles[idx - 1].is_blocked())
|
||||
&& (x < map.width - 2 && map.tiles[idx + 1].is_blocked())
|
||||
&& (y > 1 && map.tiles[idx - map.width].is_walkable())
|
||||
&& (y < map.height - 2 && map.tiles[idx + map.width].is_walkable())
|
||||
{
|
||||
spawn_portal = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user