mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added site2 worldgen feature
This commit is contained in:
parent
16889b2b3e
commit
de087ae992
@ -9,4 +9,5 @@
|
||||
scatter: true,
|
||||
paths: true,
|
||||
spots: true,
|
||||
site2: false,
|
||||
)
|
||||
|
@ -90,20 +90,26 @@ impl Entity {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_trade_info(&self, world: &World, index: &world::IndexOwned) -> Option<trade::SiteInformation> {
|
||||
pub fn get_trade_info(
|
||||
&self,
|
||||
world: &World,
|
||||
index: &world::IndexOwned,
|
||||
) -> Option<trade::SiteInformation> {
|
||||
let site = match self.kind {
|
||||
RtSimEntityKind::Random if self.rng(PERM_TRADE).gen_bool(0.5) && false => match self.brain.route {
|
||||
Travel::Path { target_id, .. } => Some(target_id),
|
||||
_ => None,
|
||||
/*
|
||||
// Travelling merchants (don't work for some reason currently)
|
||||
RtSimEntityKind::Random if self.rng(PERM_TRADE).gen_bool(0.5) => {
|
||||
match self.brain.route {
|
||||
Travel::Path { target_id, .. } => Some(target_id),
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
*/
|
||||
RtSimEntityKind::Merchant => self.brain.begin_site(),
|
||||
_ => None,
|
||||
}?;
|
||||
|
||||
let site = world
|
||||
.civs()
|
||||
.sites[site]
|
||||
.site_tmp?;
|
||||
let site = world.civs().sites[site].site_tmp?;
|
||||
index.sites[site].trade_information(site.id())
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,15 @@ fn main() -> Result {
|
||||
for z in aabb.min.z..aabb.max.z {
|
||||
let pos = Vec3::new(x, y, z);
|
||||
|
||||
if let Some(block) = fill.sample_at(&prim_tree, prim, pos, canvas) {
|
||||
let _ = volume.set(pos, block);
|
||||
}
|
||||
let _ = volume.map(pos, |block| {
|
||||
if let Some(block) =
|
||||
fill.sample_at(&prim_tree, prim, pos, canvas, block)
|
||||
{
|
||||
block
|
||||
} else {
|
||||
block
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ fn main() {
|
||||
|
||||
let mut focus = Vec2::<f32>::zero();
|
||||
let mut zoom = 1.0;
|
||||
let colors = &**index.colors().read();
|
||||
let features = &**index.features().read();
|
||||
let colors = &*index.colors();
|
||||
let features = &*index.features();
|
||||
let index = IndexRef {
|
||||
colors,
|
||||
features,
|
||||
|
@ -108,7 +108,7 @@ impl Civs {
|
||||
attempt(5, || {
|
||||
let (kind, size) = match ctx.rng.gen_range(0..64) {
|
||||
0..=4 => (SiteKind::Castle, 3),
|
||||
5..=28 => (SiteKind::Refactor, 6),
|
||||
5..=28 if index.features().site2 => (SiteKind::Refactor, 6),
|
||||
29..=31 => (SiteKind::Tree, 4),
|
||||
_ => (SiteKind::Dungeon, 0),
|
||||
};
|
||||
|
@ -82,6 +82,7 @@ pub struct Features {
|
||||
pub scatter: bool,
|
||||
pub paths: bool,
|
||||
pub spots: bool,
|
||||
pub site2: bool,
|
||||
}
|
||||
|
||||
impl assets::Asset for Features {
|
||||
|
@ -82,9 +82,9 @@ impl Index {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn colors(&self) -> AssetHandle<Arc<Colors>> { self.colors }
|
||||
pub fn colors(&self) -> impl Deref<Target = Arc<Colors>> + '_ { self.colors.read() }
|
||||
|
||||
pub fn features(&self) -> AssetHandle<Arc<Features>> { self.features }
|
||||
pub fn features(&self) -> impl Deref<Target = Arc<Features>> + '_ { self.features.read() }
|
||||
|
||||
pub fn get_site_prices(&self, site_id: SiteId) -> Option<SitePrices> {
|
||||
self.sites
|
||||
|
@ -76,7 +76,7 @@ impl Primitive {
|
||||
}
|
||||
|
||||
pub fn sampling(a: impl Into<Id<Primitive>>, f: Box<dyn Fn(Vec3<i32>) -> bool>) -> Self {
|
||||
Self::Sampling(a.into(), f.into())
|
||||
Self::Sampling(a.into(), f)
|
||||
}
|
||||
|
||||
pub fn rotate(a: impl Into<Id<Primitive>>, rot: Mat3<i32>) -> Self {
|
||||
@ -447,8 +447,8 @@ pub struct PrimitiveRef<'a> {
|
||||
painter: &'a Painter,
|
||||
}
|
||||
|
||||
impl<'a> Into<Id<Primitive>> for PrimitiveRef<'a> {
|
||||
fn into(self) -> Id<Primitive> { self.id }
|
||||
impl<'a> From<PrimitiveRef<'a>> for Id<Primitive> {
|
||||
fn from(r: PrimitiveRef<'a>) -> Self { r.id }
|
||||
}
|
||||
|
||||
impl<'a> PrimitiveRef<'a> {
|
||||
|
@ -250,7 +250,7 @@ impl Site {
|
||||
|
||||
let mut already_pathed = vec![];
|
||||
// One major, one minor road
|
||||
for i in (0..rng.gen_range(1.25..2.25) as u16).rev() {
|
||||
for _ in (0..rng.gen_range(1.25..2.25) as u16).rev() {
|
||||
if let Some(&p) = self
|
||||
.plazas
|
||||
.iter()
|
||||
|
@ -6,10 +6,6 @@ use vek::*;
|
||||
|
||||
/// Represents house data generated by the `generate()` method
|
||||
pub struct Workshop {
|
||||
/// Tile position of the door tile
|
||||
door_tile: Vec2<i32>,
|
||||
/// Axis aligned bounding region of tiles
|
||||
tile_aabr: Aabr<i32>,
|
||||
/// Axis aligned bounding region for the house
|
||||
bounds: Aabr<i32>,
|
||||
/// Approximate altitude of the door tile
|
||||
@ -19,22 +15,18 @@ pub struct Workshop {
|
||||
impl Workshop {
|
||||
pub fn generate(
|
||||
land: &Land,
|
||||
rng: &mut impl Rng,
|
||||
_rng: &mut impl Rng,
|
||||
site: &Site,
|
||||
door_tile: Vec2<i32>,
|
||||
door_dir: Vec2<i32>,
|
||||
tile_aabr: Aabr<i32>,
|
||||
) -> Self {
|
||||
let levels = rng.gen_range(1..2 + (tile_aabr.max - tile_aabr.min).product() / 6) as u32;
|
||||
let door_tile_pos = site.tile_center_wpos(door_tile);
|
||||
let bounds = Aabr {
|
||||
min: site.tile_wpos(tile_aabr.min),
|
||||
max: site.tile_wpos(tile_aabr.max),
|
||||
};
|
||||
|
||||
Self {
|
||||
door_tile: door_tile_pos,
|
||||
tile_aabr,
|
||||
bounds,
|
||||
alt: land.get_alt_approx(site.tile_center_wpos(door_tile + door_dir)) as i32,
|
||||
}
|
||||
@ -42,7 +34,7 @@ impl Workshop {
|
||||
}
|
||||
|
||||
impl Structure for Workshop {
|
||||
fn render(&self, site: &Site, _land: &Land, painter: &Painter) {
|
||||
fn render(&self, _site: &Site, _land: &Land, painter: &Painter) {
|
||||
let brick = Fill::Brick(BlockKind::Rock, Rgb::new(80, 75, 85), 24);
|
||||
|
||||
let base = self.alt + 1;
|
||||
|
@ -140,6 +140,7 @@ impl TileGrid {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn grow_organic(
|
||||
&self,
|
||||
rng: &mut impl Rng,
|
||||
|
Loading…
Reference in New Issue
Block a user