various fixes: moved turnloss handling into energy system, anims
This commit is contained in:
parent
7b5cd0ec70
commit
1b12d70b23
11 changed files with 235 additions and 53 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use super::{ BuilderMap, MetaMapBuilder, TileType };
|
||||
use crate::tile_walkable;
|
||||
use rltk::RandomNumberGenerator;
|
||||
|
||||
pub struct CullUnreachable {}
|
||||
|
|
@ -28,7 +29,7 @@ impl CullUnreachable {
|
|||
1000.0
|
||||
);
|
||||
for (i, tile) in build_data.map.tiles.iter_mut().enumerate() {
|
||||
if *tile == TileType::Floor {
|
||||
if tile_walkable(*tile) {
|
||||
let distance_to_start = dijkstra_map.map[i];
|
||||
// We can't get to this tile - so we'll make it a wall
|
||||
if distance_to_start == std::f32::MAX {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use super::{ BuilderMap, MetaMapBuilder, TileType };
|
||||
use crate::tile_walkable;
|
||||
use rltk::RandomNumberGenerator;
|
||||
|
||||
pub struct DistantExit {}
|
||||
|
|
@ -29,7 +30,7 @@ impl DistantExit {
|
|||
);
|
||||
let mut exit_tile = (0, 0.0f32);
|
||||
for (i, tile) in build_data.map.tiles.iter_mut().enumerate() {
|
||||
if *tile == TileType::Floor {
|
||||
if tile_walkable(*tile) {
|
||||
let distance_to_start = dijkstra_map.map[i];
|
||||
if distance_to_start != std::f32::MAX {
|
||||
// If it is further away than our current exit candidate, move the exit
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ pub fn forest_builder(
|
|||
chain.with(CullUnreachable::new());
|
||||
chain.with(AreaStartingPosition::new(XStart::LEFT, YStart::CENTRE));
|
||||
// Setup an exit and spawn mobs
|
||||
chain.with(VoronoiSpawning::new());
|
||||
chain.with(RoadExit::new());
|
||||
chain.with(Foliage::percent(TileType::Grass, 30));
|
||||
chain.with(VoronoiSpawning::new());
|
||||
return chain;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,10 @@ impl RoadExit {
|
|||
available_floors.push((
|
||||
idx,
|
||||
DistanceAlg::PythagorasSquared.distance2d(
|
||||
Point::new((idx as i32) % build_data.map.width, (idx as i32) / build_data.map.width),
|
||||
Point::new(
|
||||
(idx as i32) % build_data.map.width,
|
||||
(idx as i32) / build_data.map.width
|
||||
),
|
||||
Point::new(seed_x, seed_y)
|
||||
),
|
||||
));
|
||||
|
|
@ -94,7 +97,11 @@ impl RoadExit {
|
|||
fn build(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
|
||||
let starting_pos = build_data.starting_position.as_ref().unwrap().clone();
|
||||
let start_idx = build_data.map.xy_idx(starting_pos.x, starting_pos.y);
|
||||
let (end_x, end_y) = self.find_exit(build_data, build_data.map.width - 2, build_data.height / 2);
|
||||
let (end_x, end_y) = self.find_exit(
|
||||
build_data,
|
||||
build_data.map.width - 2,
|
||||
build_data.height / 2
|
||||
);
|
||||
let end_idx = build_data.map.xy_idx(end_x, end_y);
|
||||
build_data.map.populate_blocked();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use super::{ spawner, BuilderMap, MetaMapBuilder, TileType };
|
||||
use crate::tile_walkable;
|
||||
use rltk::RandomNumberGenerator;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ impl VoronoiSpawning {
|
|||
for y in 1..build_data.map.height - 1 {
|
||||
for x in 1..build_data.map.width - 1 {
|
||||
let idx = build_data.map.xy_idx(x, y);
|
||||
if build_data.map.tiles[idx] == TileType::Floor {
|
||||
if tile_walkable(build_data.map.tiles[idx]) {
|
||||
let cell_value_f = noise.get_noise(x as f32, y as f32) * 10240.0;
|
||||
let cell_value = cell_value_f as i32;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue