mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Warning cleanup
This commit is contained in:
parent
840078d2b7
commit
01e2cd2b88
@ -19,8 +19,6 @@ impl Animation for RunAnimation {
|
||||
|
||||
let lab = 10.0;
|
||||
|
||||
let legl = (anim_time as f32 * lab as f32).sin();
|
||||
let legr = (anim_time as f32 * lab as f32 + PI).sin();
|
||||
let belt = (anim_time as f32 * lab as f32 + 1.5 * PI).sin();
|
||||
|
||||
let foothoril = (anim_time as f32 * lab as f32 + PI * 1.4).sin();
|
||||
|
@ -172,7 +172,6 @@ impl<'a> BlockGen<'a> {
|
||||
close_cliffs,
|
||||
temp,
|
||||
humidity,
|
||||
chunk,
|
||||
stone_col,
|
||||
..
|
||||
} = sample;
|
||||
@ -181,7 +180,7 @@ impl<'a> BlockGen<'a> {
|
||||
|
||||
let wposf = wpos.map(|e| e as f64);
|
||||
|
||||
let (block, height) = if !only_structures {
|
||||
let (block, _height) = if !only_structures {
|
||||
let (_definitely_underground, height, on_cliff, basement_height, water_height) =
|
||||
if (wposf.z as f32) < alt - 64.0 * chaos {
|
||||
// Shortcut warping
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use super::GenCtx;
|
||||
use rand::prelude::*;
|
||||
|
||||
@ -25,7 +27,7 @@ impl Belief {
|
||||
self.price + ctx.rng.gen_range(-1.0, 1.0) * self.confidence
|
||||
}
|
||||
|
||||
pub fn update_buyer(&mut self, years: f32, new_price: f32) {
|
||||
pub fn update_buyer(&mut self, _years: f32, new_price: f32) {
|
||||
if (self.price - new_price).abs() < self.confidence {
|
||||
self.confidence *= 0.8;
|
||||
} else {
|
||||
@ -41,7 +43,7 @@ impl Belief {
|
||||
}
|
||||
|
||||
pub fn buy_units<'a>(
|
||||
ctx: &mut GenCtx<impl Rng>,
|
||||
_ctx: &mut GenCtx<impl Rng>,
|
||||
sellers: impl Iterator<Item = &'a mut SellOrder>,
|
||||
max_quantity: f32,
|
||||
max_price: f32,
|
||||
|
@ -1,7 +1,9 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod econ;
|
||||
|
||||
use crate::{
|
||||
sim::{SimChunk, WorldSim},
|
||||
sim::WorldSim,
|
||||
site::{Dungeon, Settlement, Site as WorldSite},
|
||||
util::{attempt, seed_expan, CARDINALS, NEIGHBORS},
|
||||
};
|
||||
@ -169,6 +171,7 @@ impl Civs {
|
||||
|
||||
pub fn sites(&self) -> impl Iterator<Item = &Site> + '_ { self.sites.iter() }
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn display_info(&self) {
|
||||
for (id, civ) in self.civs.iter_ids() {
|
||||
println!("# Civilisation {:?}", id);
|
||||
@ -336,7 +339,7 @@ impl Civs {
|
||||
.sites
|
||||
.iter_ids()
|
||||
.map(|(id, p)| (id, (p.center.distance_squared(loc) as f32).sqrt()))
|
||||
.filter(|(p, dist)| *dist < MAX_NEIGHBOR_DISTANCE)
|
||||
.filter(|(_, dist)| *dist < MAX_NEIGHBOR_DISTANCE)
|
||||
.collect::<Vec<_>>();
|
||||
nearby.sort_by_key(|(_, dist)| *dist as i32);
|
||||
|
||||
@ -386,7 +389,7 @@ impl Civs {
|
||||
Some(site)
|
||||
}
|
||||
|
||||
fn tick(&mut self, ctx: &mut GenCtx<impl Rng>, years: f32) {
|
||||
fn tick(&mut self, _ctx: &mut GenCtx<impl Rng>, years: f32) {
|
||||
for site in self.sites.iter_mut() {
|
||||
site.simulate(years, &self.places.get(site.place).nat_res);
|
||||
}
|
||||
@ -761,7 +764,7 @@ impl Site {
|
||||
let stocks = &self.stocks;
|
||||
self.surplus = demand
|
||||
.clone()
|
||||
.map(|stock, tgt| supply[stock] + stocks[stock] - demand[stock] - last_exports[stock]);
|
||||
.map(|stock, _| supply[stock] + stocks[stock] - demand[stock] - last_exports[stock]);
|
||||
|
||||
// Update values according to the surplus of each stock
|
||||
let values = &mut self.values;
|
||||
@ -783,7 +786,6 @@ impl Site {
|
||||
/ values.iter().filter(|(_, v)| v.is_some()).count() as f32;
|
||||
let export_targets = &mut self.export_targets;
|
||||
let last_exports = &self.last_exports;
|
||||
let trade_states = &self.trade_states;
|
||||
self.values.iter().for_each(|(stock, value)| {
|
||||
let rvalue = (*value).map(|v| v - value_avg).unwrap_or(0.0);
|
||||
//let factor = if export_targets[stock] > 0.0 { 1.0 / rvalue } else { rvalue };
|
||||
@ -823,7 +825,7 @@ impl Site {
|
||||
.iter()
|
||||
.map(|(stock, amount)| {
|
||||
// What quantity is this order requesting?
|
||||
let quantity = *amount * scale;
|
||||
let _quantity = *amount * scale;
|
||||
// What proportion of this order is the economy able to satisfy?
|
||||
let satisfaction = (stocks_before[*stock] / demand[*stock]).min(1.0);
|
||||
satisfaction
|
||||
@ -946,7 +948,7 @@ impl<K: Copy + Eq + Hash, T: Default + Clone> MapVec<K, T> {
|
||||
|
||||
pub fn get(&self, entry: K) -> &T { self.entries.get(&entry).unwrap_or(&self.default) }
|
||||
|
||||
pub fn map<U: Default>(mut self, mut f: impl FnMut(K, T) -> U) -> MapVec<K, U> {
|
||||
pub fn map<U: Default>(self, mut f: impl FnMut(K, T) -> U) -> MapVec<K, U> {
|
||||
MapVec {
|
||||
entries: self
|
||||
.entries
|
||||
|
@ -217,7 +217,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
|
||||
let sim = &self.sim;
|
||||
|
||||
let turb = Vec2::new(
|
||||
let _turb = Vec2::new(
|
||||
sim.gen_ctx.turb_x_nz.get((wposf.div(48.0)).into_array()) as f32,
|
||||
sim.gen_ctx.turb_y_nz.get((wposf.div(48.0)).into_array()) as f32,
|
||||
) * 12.0;
|
||||
@ -590,7 +590,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let near_cliffs = sim_chunk.near_cliffs;
|
||||
|
||||
let river_gouge = 0.5;
|
||||
let (in_water, water_dist, alt_, water_level, riverless_alt, warp_factor) = if let Some((
|
||||
let (_in_water, water_dist, alt_, water_level, riverless_alt, warp_factor) = if let Some((
|
||||
max_border_river_pos,
|
||||
river_chunk,
|
||||
max_border_river,
|
||||
|
@ -2,8 +2,7 @@ use std::f32;
|
||||
use vek::*;
|
||||
use common::{
|
||||
terrain::{Block, BlockKind},
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, RectVolSize, Vox, WriteVol},
|
||||
spiral::Spiral2d,
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, Vox, WriteVol},
|
||||
};
|
||||
use crate::{
|
||||
column::ColumnSample,
|
||||
@ -67,7 +66,7 @@ pub fn apply_paths_to<'a>(
|
||||
let surface_z = (riverless_alt + bridge_offset).floor() as i32;
|
||||
|
||||
for z in inset - depth..inset {
|
||||
vol.set(
|
||||
let _ = vol.set(
|
||||
Vec3::new(offs.x, offs.y, surface_z + z),
|
||||
if bridge_offset >= 2.0 && path_dist >= 3.0 || z < inset - 1 {
|
||||
Block::new(BlockKind::Normal, noisy_color(Rgb::new(80, 80, 100), 8))
|
||||
@ -81,7 +80,7 @@ pub fn apply_paths_to<'a>(
|
||||
for z in inset..inset + head_space {
|
||||
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
||||
if vol.get(pos).unwrap().kind() != BlockKind::Water {
|
||||
vol.set(pos, Block::empty());
|
||||
let _ = vol.set(pos, Block::empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use crate::{
|
||||
util::{Grid, Sampler},
|
||||
};
|
||||
use common::{
|
||||
comp::{self, bird_medium, critter, humanoid, quadruped_medium, quadruped_small, Alignment},
|
||||
comp::{self, bird_medium, critter, quadruped_medium, quadruped_small},
|
||||
generation::{ChunkSupplement, EntityInfo},
|
||||
terrain::{Block, BlockKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize},
|
||||
vol::{ReadVol, RectVolSize, Vox, WriteVol},
|
||||
@ -124,7 +124,6 @@ impl World {
|
||||
};
|
||||
|
||||
let offs = Vec2::new(x, y);
|
||||
let wpos2d = chunk_wpos2d + offs;
|
||||
|
||||
let z_cache = match zcache_grid.get(grid_border + offs) {
|
||||
Some(Some(z_cache)) => z_cache,
|
||||
@ -187,7 +186,6 @@ impl World {
|
||||
};
|
||||
|
||||
const SPAWN_RATE: f32 = 0.1;
|
||||
const BOSS_RATE: f32 = 0.03;
|
||||
let mut supplement = ChunkSupplement {
|
||||
entities: if rng.gen::<f32>() < SPAWN_RATE
|
||||
&& sim_chunk.chaos < 0.5
|
||||
|
@ -25,12 +25,10 @@ pub use self::{
|
||||
|
||||
use crate::{
|
||||
all::ForestKind,
|
||||
block::BlockGen,
|
||||
civ::Place,
|
||||
column::ColumnGen,
|
||||
site::{Settlement, Site},
|
||||
site::Site,
|
||||
util::{
|
||||
seed_expan, FastNoise, RandomField, Sampler, StructureGen2d, CARDINAL_LOCALITY, LOCALITY,
|
||||
seed_expan, FastNoise, RandomField, StructureGen2d, LOCALITY,
|
||||
NEIGHBORS,
|
||||
},
|
||||
CONFIG,
|
||||
@ -41,7 +39,6 @@ use common::{
|
||||
terrain::{BiomeKind, TerrainChunkSize},
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use noise::{
|
||||
BasicMulti, Billow, Fbm, HybridMulti, MultiFractal, NoiseFn, RangeFunction, RidgedMulti,
|
||||
Seedable, SuperSimplex, Worley,
|
||||
@ -57,7 +54,6 @@ use std::{
|
||||
io::{BufReader, BufWriter},
|
||||
ops::{Add, Div, Mul, Neg, Sub},
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
};
|
||||
use vek::*;
|
||||
|
||||
@ -1392,9 +1388,9 @@ impl WorldSim {
|
||||
});
|
||||
|
||||
// Place the locations onto the world
|
||||
/*
|
||||
let gen = StructureGen2d::new(self.seed, cell_size as u32, cell_size as u32 / 2);
|
||||
|
||||
/*
|
||||
self.chunks
|
||||
.par_iter_mut()
|
||||
.enumerate()
|
||||
@ -1432,69 +1428,6 @@ impl WorldSim {
|
||||
.cloned()
|
||||
.unwrap_or(None)
|
||||
.map(|loc_idx| LocationInfo { loc_idx, near });
|
||||
|
||||
let town_size = 200;
|
||||
let in_town = chunk
|
||||
.location
|
||||
.as_ref()
|
||||
.map(|l| {
|
||||
locations[l.loc_idx]
|
||||
.center
|
||||
.map(|e| e as i64)
|
||||
.distance_squared(block_pos.map(|e| e as i64))
|
||||
< town_size * town_size
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
if in_town {
|
||||
chunk.spawn_rate = 0.0;
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// Stage 2 - towns!
|
||||
/*
|
||||
let chunk_idx_center = |e: Vec2<i32>| {
|
||||
e.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| {
|
||||
e * sz as i32 + sz as i32 / 2
|
||||
})
|
||||
};
|
||||
let sites = self
|
||||
.gen_ctx
|
||||
.town_gen
|
||||
.par_iter(
|
||||
chunk_idx_center(Vec2::zero()),
|
||||
chunk_idx_center(WORLD_SIZE.map(|e| e as i32)),
|
||||
)
|
||||
.map_init(
|
||||
|| (),
|
||||
|_, (pos, seed)| {
|
||||
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
||||
(
|
||||
pos,
|
||||
Site::from(Settlement::generate(pos, Some(self), &mut rng)),
|
||||
)
|
||||
},
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let gen_ctx = &self.gen_ctx;
|
||||
self.chunks
|
||||
.par_iter_mut()
|
||||
.enumerate()
|
||||
.for_each(|(ij, chunk)| {
|
||||
let chunk_pos = uniform_idx_as_vec2(ij);
|
||||
let wpos = chunk_idx_center(chunk_pos);
|
||||
|
||||
if let Some((pos, site)) = sites
|
||||
.iter()
|
||||
.filter(|(pos, site)| {
|
||||
pos.map(|e| e as f32).distance(wpos.map(|e| e as f32)) < site.radius()
|
||||
})
|
||||
.min_by_key(|(pos, _)| wpos.distance_squared(*pos))
|
||||
{
|
||||
chunk.sites.push(site.clone());
|
||||
}
|
||||
});
|
||||
*/
|
||||
@ -1798,7 +1731,7 @@ impl WorldSim {
|
||||
return None;
|
||||
}
|
||||
|
||||
let (start_pos, start_idx) = if chunk_connections != 2 {
|
||||
let (start_pos, _start_idx) = if chunk_connections != 2 {
|
||||
(ctrl_pos, None)
|
||||
} else {
|
||||
let (start_idx, start_rpos) = NEIGHBORS
|
||||
@ -1820,7 +1753,7 @@ impl WorldSim {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(move |(i, _)| chunk.path.neighbors & (1 << *i as u8) != 0)
|
||||
.filter_map(move |(i, end_rpos)| {
|
||||
.filter_map(move |(_, end_rpos)| {
|
||||
let end_pos_chunk = chunk_pos + *ctrl + end_rpos;
|
||||
let end_pos = get_chunk_centre(end_pos_chunk).map(|e| e as f32)
|
||||
+ self.get(end_pos_chunk)?.path.offset;
|
||||
@ -2116,7 +2049,7 @@ impl SimChunk {
|
||||
|
||||
pub fn get_base_z(&self) -> f32 { self.alt - self.chaos * 50.0 - 16.0 }
|
||||
|
||||
pub fn get_name(&self, world: &WorldSim) -> Option<String> {
|
||||
pub fn get_name(&self, _world: &WorldSim) -> Option<String> {
|
||||
// TODO
|
||||
None
|
||||
|
||||
|
@ -1,27 +1,25 @@
|
||||
use super::SpawnRules;
|
||||
use crate::{
|
||||
column::ColumnSample,
|
||||
sim::{SimChunk, WorldSim},
|
||||
sim::WorldSim,
|
||||
site::BlockMask,
|
||||
util::{attempt, DIRS, CARDINALS, Grid, RandomField, Sampler, StructureGen2d},
|
||||
util::{attempt, DIRS, CARDINALS, Grid, RandomField, Sampler},
|
||||
};
|
||||
use common::{
|
||||
assets,
|
||||
astar::Astar,
|
||||
comp,
|
||||
generation::{ChunkSupplement, EntityInfo},
|
||||
path::Path,
|
||||
spiral::Spiral2d,
|
||||
store::{Id, Store},
|
||||
terrain::{Block, BlockKind, TerrainChunkSize},
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, RectVolSize, Vox, WriteVol},
|
||||
};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use rand::prelude::*;
|
||||
use std::{collections::VecDeque, f32};
|
||||
use std::f32;
|
||||
use vek::*;
|
||||
|
||||
impl WorldSim {
|
||||
#[allow(dead_code)]
|
||||
fn can_host_dungeon(&self, pos: Vec2<i32>) -> bool {
|
||||
self.get(pos)
|
||||
.map(|chunk| !chunk.near_cliffs && !chunk.river.is_river() && !chunk.river.is_lake())
|
||||
@ -36,6 +34,7 @@ impl WorldSim {
|
||||
pub struct Dungeon {
|
||||
origin: Vec2<i32>,
|
||||
alt: i32,
|
||||
#[allow(dead_code)]
|
||||
noise: RandomField,
|
||||
floors: Vec<Floor>,
|
||||
}
|
||||
@ -48,7 +47,7 @@ pub struct GenCtx<'a, R: Rng> {
|
||||
impl Dungeon {
|
||||
pub fn generate(wpos: Vec2<i32>, sim: Option<&WorldSim>, rng: &mut impl Rng) -> Self {
|
||||
let mut ctx = GenCtx { sim, rng };
|
||||
let mut this = Self {
|
||||
let this = Self {
|
||||
origin: wpos,
|
||||
alt: ctx
|
||||
.sim
|
||||
@ -70,7 +69,7 @@ impl Dungeon {
|
||||
|
||||
pub fn radius(&self) -> f32 { 1200.0 }
|
||||
|
||||
pub fn spawn_rules(&self, wpos: Vec2<i32>) -> SpawnRules {
|
||||
pub fn spawn_rules(&self, _wpos: Vec2<i32>) -> SpawnRules {
|
||||
SpawnRules {
|
||||
..SpawnRules::default()
|
||||
}
|
||||
@ -79,11 +78,9 @@ impl Dungeon {
|
||||
pub fn apply_to<'a>(
|
||||
&'a self,
|
||||
wpos2d: Vec2<i32>,
|
||||
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
_get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
vol: &mut (impl BaseVol<Vox = Block> + RectSizedVol + ReadVol + WriteVol),
|
||||
) {
|
||||
let rand_field = RandomField::new(0);
|
||||
|
||||
for y in 0..vol.size_xy().y as i32 {
|
||||
for x in 0..vol.size_xy().x as i32 {
|
||||
let offs = Vec2::new(x, y);
|
||||
@ -91,17 +88,6 @@ impl Dungeon {
|
||||
let wpos2d = wpos2d + offs;
|
||||
let rpos = wpos2d - self.origin;
|
||||
|
||||
// Sample terrain
|
||||
let col_sample = if let Some(col_sample) = get_column(offs) {
|
||||
col_sample
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
let surface_z = col_sample.riverless_alt.floor() as i32;
|
||||
|
||||
let tile_pos = rpos.map(|e| e.div_euclid(TILE_SIZE));
|
||||
let tile_center = tile_pos * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
let mut z = self.alt;
|
||||
for floor in &self.floors {
|
||||
z -= floor.total_depth();
|
||||
@ -110,7 +96,7 @@ impl Dungeon {
|
||||
|
||||
for rz in 0..floor.total_depth() {
|
||||
if let Some(block) = sampler(rz).finish() {
|
||||
vol.set(Vec3::new(offs.x, offs.y, z + rz), block);
|
||||
let _ = vol.set(Vec3::new(offs.x, offs.y, z + rz), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,7 +108,7 @@ impl Dungeon {
|
||||
&'a self,
|
||||
rng: &mut impl Rng,
|
||||
wpos2d: Vec2<i32>,
|
||||
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
_get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
supplement: &mut ChunkSupplement,
|
||||
) {
|
||||
let rpos = wpos2d - self.origin;
|
||||
@ -189,6 +175,7 @@ pub struct Floor {
|
||||
rooms: Store<Room>,
|
||||
solid_depth: i32,
|
||||
hollow_depth: i32,
|
||||
#[allow(dead_code)]
|
||||
stair_tile: Vec2<i32>,
|
||||
}
|
||||
|
||||
@ -295,8 +282,7 @@ impl Floor {
|
||||
}
|
||||
}
|
||||
|
||||
fn create_route(&mut self, ctx: &mut GenCtx<impl Rng>, a: Vec2<i32>, b: Vec2<i32>) {
|
||||
let sim = &ctx.sim;
|
||||
fn create_route(&mut self, _ctx: &mut GenCtx<impl Rng>, a: Vec2<i32>, b: Vec2<i32>) {
|
||||
let heuristic = move |l: &Vec2<i32>| (l - b).map(|e| e.abs()).reduce_max() as f32;
|
||||
let neighbors = |l: &Vec2<i32>| {
|
||||
let l = *l;
|
||||
@ -305,7 +291,7 @@ impl Floor {
|
||||
.map(move |dir| l + dir)
|
||||
.filter(|pos| self.tiles.get(*pos).is_some())
|
||||
};
|
||||
let transition = |a: &Vec2<i32>, b: &Vec2<i32>| match self.tiles.get(*b) {
|
||||
let transition = |_a: &Vec2<i32>, b: &Vec2<i32>| match self.tiles.get(*b) {
|
||||
Some(Tile::Room(_)) | Some(Tile::Tunnel) => 1.0,
|
||||
Some(Tile::Solid) => 25.0,
|
||||
Some(Tile::UpStair) | Some(Tile::DownStair) => 0.0,
|
||||
@ -401,7 +387,6 @@ impl Floor {
|
||||
|
||||
pub fn nearest_wall(&self, rpos: Vec2<i32>) -> Option<Vec2<i32>> {
|
||||
let tile_pos = rpos.map(|e| e.div_euclid(TILE_SIZE));
|
||||
let tile_center = tile_pos * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
DIRS.iter()
|
||||
.map(|dir| tile_pos + *dir)
|
||||
|
@ -4,10 +4,7 @@ mod settlement;
|
||||
// Reexports
|
||||
pub use self::{dungeon::Dungeon, settlement::Settlement};
|
||||
|
||||
use crate::{
|
||||
column::ColumnSample,
|
||||
util::{Grid, Sampler},
|
||||
};
|
||||
use crate::column::ColumnSample;
|
||||
use common::{
|
||||
generation::ChunkSupplement,
|
||||
terrain::Block,
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use super::{super::skeleton::*, Archetype};
|
||||
use crate::{
|
||||
site::BlockMask,
|
||||
|
@ -46,9 +46,9 @@ impl Archetype for Keep {
|
||||
&self,
|
||||
dist: i32,
|
||||
bound_offset: Vec2<i32>,
|
||||
center_offset: Vec2<i32>,
|
||||
_center_offset: Vec2<i32>,
|
||||
z: i32,
|
||||
ori: Ori,
|
||||
_ori: Ori,
|
||||
branch: &Branch<Self::Attr>,
|
||||
) -> BlockMask {
|
||||
let profile = Vec2::new(bound_offset.x, z);
|
||||
@ -57,14 +57,12 @@ impl Archetype for Keep {
|
||||
|r, g, b| BlockMask::new(Block::new(BlockKind::Normal, Rgb::new(r, g, b)), 2);
|
||||
|
||||
let foundation = make_block(100, 100, 100);
|
||||
let log = make_block(60, 45, 30);
|
||||
let wall = make_block(75, 100, 125);
|
||||
let roof = make_block(150, 120, 50);
|
||||
let empty = BlockMask::new(Block::empty(), 2);
|
||||
|
||||
let width = branch.locus;
|
||||
let rampart_width = 5 + branch.locus;
|
||||
let roof_height = 12 + width;
|
||||
let ceil_height = 16;
|
||||
|
||||
if profile.y <= 1 - (dist - width - 1).max(0) && dist < width + 3 {
|
||||
|
@ -22,7 +22,6 @@ impl<A: Archetype> Building<A> {
|
||||
where
|
||||
A: Sized,
|
||||
{
|
||||
let len = rng.gen_range(-8, 12).max(0);
|
||||
let (archetype, skel) = A::generate(rng);
|
||||
Self {
|
||||
skel,
|
||||
|
@ -4,12 +4,12 @@ use self::building::HouseBuilding;
|
||||
use super::SpawnRules;
|
||||
use crate::{
|
||||
column::ColumnSample,
|
||||
sim::{SimChunk, WorldSim},
|
||||
util::{Grid, RandomField, Sampler, StructureGen2d},
|
||||
sim::WorldSim,
|
||||
util::{RandomField, Sampler, StructureGen2d},
|
||||
};
|
||||
use common::{
|
||||
astar::Astar,
|
||||
comp::{self, bird_medium, critter, humanoid, quadruped_medium, quadruped_small},
|
||||
comp::{self, bird_medium, humanoid, quadruped_small},
|
||||
generation::{ChunkSupplement, EntityInfo},
|
||||
path::Path,
|
||||
spiral::Spiral2d,
|
||||
@ -23,11 +23,13 @@ use rand::prelude::*;
|
||||
use std::{collections::VecDeque, f32};
|
||||
use vek::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn gradient(line: [Vec2<f32>; 2]) -> f32 {
|
||||
let r = (line[0].y - line[1].y) / (line[0].x - line[1].x);
|
||||
if r.is_nan() { 100000.0 } else { r }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn intersect(a: [Vec2<f32>; 2], b: [Vec2<f32>; 2]) -> Option<Vec2<f32>> {
|
||||
let ma = gradient(a);
|
||||
let mb = gradient(b);
|
||||
@ -45,6 +47,7 @@ pub fn intersect(a: [Vec2<f32>; 2], b: [Vec2<f32>; 2]) -> Option<Vec2<f32>> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn center_of(p: [Vec2<f32>; 3]) -> Vec2<f32> {
|
||||
let ma = -1.0 / gradient([p[0], p[1]]);
|
||||
let mb = -1.0 / gradient([p[1], p[2]]);
|
||||
@ -108,6 +111,7 @@ pub struct Town {
|
||||
}
|
||||
|
||||
pub struct Farm {
|
||||
#[allow(dead_code)]
|
||||
base_tile: Vec2<i32>,
|
||||
}
|
||||
|
||||
@ -524,7 +528,7 @@ impl Settlement {
|
||||
let surface_z = (col.riverless_alt + bridge_offset).floor() as i32;
|
||||
|
||||
for z in inset - depth..inset {
|
||||
vol.set(
|
||||
let _ = vol.set(
|
||||
Vec3::new(offs.x, offs.y, surface_z + z),
|
||||
if bridge_offset >= 2.0 && dist >= 3.0 || z < inset - 1 {
|
||||
Block::new(BlockKind::Normal, noisy_color(Rgb::new(80, 80, 100), 8))
|
||||
@ -537,11 +541,11 @@ impl Settlement {
|
||||
for z in inset..inset + head_space {
|
||||
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
||||
if vol.get(pos).unwrap().kind() != BlockKind::Water {
|
||||
vol.set(pos, Block::empty());
|
||||
let _ = vol.set(pos, Block::empty());
|
||||
}
|
||||
}
|
||||
// Ground colour
|
||||
} else if let Some(color) = self.get_color(rpos) {
|
||||
} else {
|
||||
let mut surface_block = None;
|
||||
|
||||
let roll = |seed, n| {
|
||||
@ -553,7 +557,7 @@ impl Settlement {
|
||||
Some(Plot::Grass) => Some(Rgb::new(100, 200, 0)),
|
||||
Some(Plot::Water) => Some(Rgb::new(100, 150, 250)),
|
||||
Some(Plot::Town) => {
|
||||
if let Some((path_dist, path_nearest)) = col_sample.path {
|
||||
if let Some((_, path_nearest)) = col_sample.path {
|
||||
let path_dir = (path_nearest - wpos2d.map(|e| e as f32)).rotated_z(f32::consts::PI / 2.0).normalized();
|
||||
let is_lamp = if path_dir.x.abs() > path_dir.y.abs() {
|
||||
wpos2d.x as f32 % 20.0 / path_dir.dot(Vec2::unit_y()).abs() <= 1.0
|
||||
@ -647,13 +651,13 @@ impl Settlement {
|
||||
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
||||
|
||||
if let (0, Some(block)) = (z, surface_block) {
|
||||
vol.set(pos, block);
|
||||
let _ = vol.set(pos, block);
|
||||
} else if z >= 0 {
|
||||
if vol.get(pos).unwrap().kind() != BlockKind::Water {
|
||||
vol.set(pos, Block::empty());
|
||||
let _ = vol.set(pos, Block::empty());
|
||||
}
|
||||
} else {
|
||||
vol.set(
|
||||
let _ = vol.set(
|
||||
pos,
|
||||
Block::new(BlockKind::Normal, noisy_color(color, 4)),
|
||||
);
|
||||
@ -681,7 +685,7 @@ impl Settlement {
|
||||
|
||||
for z in z_offset..12 {
|
||||
if dist / WayKind::Wall.width() < ((1.0 - z as f32 / 12.0) * 2.0).min(1.0) {
|
||||
vol.set(
|
||||
let _ = vol.set(
|
||||
Vec3::new(offs.x, offs.y, surface_z + z),
|
||||
Block::new(BlockKind::Normal, color),
|
||||
);
|
||||
@ -692,7 +696,7 @@ impl Settlement {
|
||||
// Towers
|
||||
if let Some((Tower::Wall, _pos)) = sample.tower {
|
||||
for z in -2..16 {
|
||||
vol.set(
|
||||
let _ = vol.set(
|
||||
Vec3::new(offs.x, offs.y, surface_z + z),
|
||||
Block::new(BlockKind::Normal, Rgb::new(50, 50, 50)),
|
||||
);
|
||||
@ -715,7 +719,6 @@ impl Settlement {
|
||||
|
||||
match &structure.kind {
|
||||
StructureKind::House(b) => {
|
||||
let centre = b.bounds_2d().center();
|
||||
let bounds = b.bounds();
|
||||
|
||||
for x in bounds.min.x..bounds.max.x + 1 {
|
||||
@ -735,7 +738,7 @@ impl Settlement {
|
||||
let coffs = wpos - Vec3::from(wpos2d);
|
||||
|
||||
if let Some(block) = b.sample(rpos) {
|
||||
vol.set(coffs, block);
|
||||
let _ = vol.set(coffs, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -765,7 +768,6 @@ impl Settlement {
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
let surface_z = col_sample.riverless_alt.floor() as i32;
|
||||
|
||||
let sample = self.land.get_at_block(rpos);
|
||||
|
||||
@ -907,7 +909,7 @@ const CARDINALS: [Vec2<i32>; 4] = [
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum WayKind {
|
||||
Path,
|
||||
Hedge,
|
||||
#[allow(dead_code)]
|
||||
Wall,
|
||||
}
|
||||
|
||||
@ -915,14 +917,14 @@ impl WayKind {
|
||||
pub fn width(&self) -> f32 {
|
||||
match self {
|
||||
WayKind::Path => 4.0,
|
||||
WayKind::Hedge => 1.5,
|
||||
WayKind::Wall => 2.5,
|
||||
WayKind::Wall => 3.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum Tower {
|
||||
#[allow(dead_code)]
|
||||
Wall,
|
||||
}
|
||||
|
||||
@ -988,7 +990,7 @@ impl Land {
|
||||
}
|
||||
}
|
||||
|
||||
for (i, dir) in CARDINALS.iter().enumerate() {
|
||||
for (i, _) in CARDINALS.iter().enumerate() {
|
||||
let map = [1, 5, 7, 3];
|
||||
let line = LineSegment2 {
|
||||
start: neighbors[4].0.map(|e| e as f32),
|
||||
@ -1013,6 +1015,7 @@ impl Land {
|
||||
|
||||
pub fn tile_at(&self, pos: Vec2<i32>) -> Option<&Tile> { self.tiles.get(&pos) }
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn tile_at_mut(&mut self, pos: Vec2<i32>) -> Option<&mut Tile> { self.tiles.get_mut(&pos) }
|
||||
|
||||
pub fn plot(&self, id: Id<Plot>) -> &Plot { self.plots.get(id) }
|
||||
@ -1046,6 +1049,7 @@ impl Land {
|
||||
.find(|pos| match_fn(self.plot_at(*pos)))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn find_tile_dir(
|
||||
&self,
|
||||
origin: Vec2<i32>,
|
||||
@ -1081,7 +1085,7 @@ impl Land {
|
||||
&self,
|
||||
start: Vec2<i32>,
|
||||
max_size: usize,
|
||||
rng: &mut impl Rng,
|
||||
_rng: &mut impl Rng,
|
||||
mut match_fn: impl FnMut(Option<&Plot>) -> bool,
|
||||
) -> HashSet<Vec2<i32>> {
|
||||
let mut open = VecDeque::new();
|
||||
@ -1137,7 +1141,7 @@ impl Land {
|
||||
if self.tile_at(tiles[0]).is_none() {
|
||||
self.set(tiles[0], self.hazard);
|
||||
}
|
||||
let mut plots = &self.plots;
|
||||
let plots = &self.plots;
|
||||
|
||||
self.tiles
|
||||
.get_mut(&tiles[1])
|
||||
|
Loading…
Reference in New Issue
Block a user