Update WaveformColapse builder to use the proper tileset
This commit is contained in:
parent
a40f43b839
commit
6d57020327
@ -7,7 +7,7 @@ use common::*;
|
||||
use constraints::*;
|
||||
use solver::*;
|
||||
|
||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||
use super::{BuilderMap, MetaMapBuilder};
|
||||
use crate::Map;
|
||||
|
||||
pub struct WaveformCollapseBuilder {}
|
||||
@ -33,12 +33,18 @@ impl WaveformCollapseBuilder {
|
||||
let constraints = patterns_to_constraints(patterns, CHUNK_SIZE);
|
||||
self.render_tile_gallery(&constraints, CHUNK_SIZE, build_data);
|
||||
|
||||
let old_map = build_data.map.clone();
|
||||
|
||||
build_data.map = Map::new(
|
||||
build_data.map.depth,
|
||||
build_data.width,
|
||||
build_data.height,
|
||||
&build_data.map.name,
|
||||
);
|
||||
build_data.spawn_list.clear();
|
||||
build_data.rooms = None;
|
||||
build_data.corridors = None;
|
||||
let mut tries = 0;
|
||||
loop {
|
||||
let mut solver = Solver::new(constraints.clone(), CHUNK_SIZE, &build_data.map);
|
||||
while !solver.iteration(&mut build_data.map, rng) {
|
||||
@ -48,9 +54,16 @@ impl WaveformCollapseBuilder {
|
||||
if solver.possible {
|
||||
break;
|
||||
} // If it has hit an impossible condition, try again
|
||||
tries += 1;
|
||||
if tries > 10 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
build_data.spawn_list.clear();
|
||||
if tries > 10 {
|
||||
// Restore the old one
|
||||
build_data.map = old_map;
|
||||
}
|
||||
}
|
||||
|
||||
fn render_tile_gallery(
|
||||
@ -59,7 +72,12 @@ impl WaveformCollapseBuilder {
|
||||
chunk_size: i32,
|
||||
build_data: &mut BuilderMap,
|
||||
) {
|
||||
build_data.map = Map::new(0, build_data.width, build_data.height, &build_data.map.name);
|
||||
build_data.map = Map::new(
|
||||
build_data.map.depth,
|
||||
build_data.width,
|
||||
build_data.height,
|
||||
&build_data.map.name,
|
||||
);
|
||||
let mut counter = 0;
|
||||
let mut x = 1;
|
||||
let mut y = 1;
|
||||
|
@ -1,7 +1,6 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::MapChunk;
|
||||
use crate::map_builders::waveform_collapse::common::tile_idx_in_chunk;
|
||||
use super::{tile_idx_in_chunk, MapChunk};
|
||||
use crate::{Map, TileType};
|
||||
|
||||
pub fn build_patterns(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::common::MapChunk;
|
||||
use super::MapChunk;
|
||||
use crate::Map;
|
||||
|
||||
pub struct Solver {
|
||||
|
Loading…
Reference in New Issue
Block a user