mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
More cemetary work
This commit is contained in:
parent
858b4c0bc8
commit
138eb8a7ae
41
Cargo.lock
generated
41
Cargo.lock
generated
@ -2162,13 +2162,22 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||||
|
dependencies = [
|
||||||
|
"ahash 0.7.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashlink"
|
name = "hashlink"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d99cf782f0dc4372d26846bec3de7804ceb5df083c2d4462c0b8d2330e894fa8"
|
checksum = "d99cf782f0dc4372d26846bec3de7804ceb5df083c2d4462c0b8d2330e894fa8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2395,7 +2404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -3584,9 +3593,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "packed_simd_2"
|
name = "packed_simd_2"
|
||||||
version = "0.3.4"
|
version = "0.3.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3278e0492f961fd4ae70909f56b2723a7e8d01a228427294e19cdfdebda89a17"
|
checksum = "0e64858a2d3733fdd61adfdd6da89aa202f7ff0e741d2fc7ed1e452ba9dc99d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"libm 0.1.4",
|
"libm 0.1.4",
|
||||||
@ -4639,7 +4648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "e3a9dff29ab65f4b7b4a5a38ca78e73b35eb8ffd7d4b5e5a77fc6936a1735eab"
|
checksum = "e3a9dff29ab65f4b7b4a5a38ca78e73b35eb8ffd7d4b5e5a77fc6936a1735eab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"mopa",
|
"mopa",
|
||||||
"rayon",
|
"rayon",
|
||||||
"shred-derive",
|
"shred-derive",
|
||||||
@ -4778,7 +4787,7 @@ version = "0.16.1"
|
|||||||
source = "git+https://github.com/amethyst/specs.git?rev=5a9b71035007be0e3574f35184acac1cd4530496#5a9b71035007be0e3574f35184acac1cd4530496"
|
source = "git+https://github.com/amethyst/specs.git?rev=5a9b71035007be0e3574f35184acac1cd4530496#5a9b71035007be0e3574f35184acac1cd4530496"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"hibitset",
|
"hibitset",
|
||||||
"log",
|
"log",
|
||||||
"rayon",
|
"rayon",
|
||||||
@ -5496,7 +5505,7 @@ dependencies = [
|
|||||||
"byteorder",
|
"byteorder",
|
||||||
"clap",
|
"clap",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"image",
|
"image",
|
||||||
"num 0.4.0",
|
"num 0.4.0",
|
||||||
"rayon",
|
"rayon",
|
||||||
@ -5531,7 +5540,7 @@ dependencies = [
|
|||||||
"csv",
|
"csv",
|
||||||
"dot_vox",
|
"dot_vox",
|
||||||
"enum-iterator",
|
"enum-iterator",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"image",
|
"image",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@ -5598,7 +5607,7 @@ version = "0.9.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"flate2",
|
"flate2",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"image",
|
"image",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"serde",
|
"serde",
|
||||||
@ -5615,7 +5624,7 @@ name = "veloren-common-state"
|
|||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"rayon",
|
"rayon",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
@ -5637,7 +5646,7 @@ dependencies = [
|
|||||||
name = "veloren-common-systems"
|
name = "veloren-common-systems"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"ordered-float 2.1.1",
|
"ordered-float 2.1.1",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
@ -5666,7 +5675,7 @@ dependencies = [
|
|||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown",
|
"hashbrown 0.11.2",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lz-fear",
|
"lz-fear",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
@ -5692,7 +5701,7 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
"bytes",
|
"bytes",
|
||||||
"criterion",
|
"criterion",
|
||||||
"hashbrown",
|
"hashbrown 0.11.2",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
"tokio",
|
"tokio",
|
||||||
@ -5735,7 +5744,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
@ -5819,7 +5828,7 @@ dependencies = [
|
|||||||
"glutin",
|
"glutin",
|
||||||
"glyph_brush",
|
"glyph_brush",
|
||||||
"guillotiere",
|
"guillotiere",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"iced_native",
|
"iced_native",
|
||||||
"iced_winit",
|
"iced_winit",
|
||||||
"image",
|
"image",
|
||||||
@ -5893,7 +5902,7 @@ dependencies = [
|
|||||||
"enum-iterator",
|
"enum-iterator",
|
||||||
"flate2",
|
"flate2",
|
||||||
"fxhash",
|
"fxhash",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"image",
|
"image",
|
||||||
"inline_tweak",
|
"inline_tweak",
|
||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
|
@ -32,11 +32,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
|
use std::{convert::AsRef, marker::PhantomData};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use std::{
|
|
||||||
convert::AsRef,
|
|
||||||
marker::PhantomData,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||||
pub struct Lottery<T, Items: AsRef<[(f32, T)]> = Vec<(f32, T)>> {
|
pub struct Lottery<T, Items: AsRef<[(f32, T)]> = Vec<(f32, T)>> {
|
||||||
@ -60,7 +57,11 @@ impl<T> From<Vec<(f32, T)>> for Lottery<T> {
|
|||||||
*rate = total - *rate;
|
*rate = total - *rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { items, total, phantom: PhantomData }
|
Self {
|
||||||
|
items,
|
||||||
|
total,
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +74,11 @@ impl<'a, T> Lottery<T, &'a mut [(f32, T)]> {
|
|||||||
*rate = total - *rate;
|
*rate = total - *rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { items, total, phantom: PhantomData }
|
Self {
|
||||||
|
items,
|
||||||
|
total,
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ impl Fill {
|
|||||||
let inner = Aabr {
|
let inner = Aabr {
|
||||||
min: aabb.min.xy() - 1 + inset,
|
min: aabb.min.xy() - 1 + inset,
|
||||||
max: aabb.max.xy() - inset,
|
max: aabb.max.xy() - inset,
|
||||||
}.made_valid();
|
}
|
||||||
|
.made_valid();
|
||||||
aabb_contains(*aabb, pos)
|
aabb_contains(*aabb, pos)
|
||||||
&& ((inner.projected_point(pos.xy()) - pos.xy())
|
&& ((inner.projected_point(pos.xy()) - pos.xy())
|
||||||
.map(|e| e.abs())
|
.map(|e| e.abs())
|
||||||
|
@ -21,7 +21,7 @@ impl Structure for Cemetary {
|
|||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
let (tile_aabr, root) = site.tiles.find_near(Vec2::zero(), |tile, _| {
|
let (tile_aabr, root) = site.tiles.find_near(Vec2::zero(), |tile, _| {
|
||||||
if rng.gen_range(0..16) == 0 {
|
if rng.gen_range(0..16) == 0 {
|
||||||
site.tiles.grow_aabr(tile, 15..20, (2, 2), 2).ok()
|
site.tiles.grow_aabr(tile, 45..50, (2, 2), 2).ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -84,6 +84,17 @@ impl Render for Cemetary {
|
|||||||
}),
|
}),
|
||||||
false => Block::empty(),
|
false => Block::empty(),
|
||||||
});
|
});
|
||||||
|
let flower_sprite = Fill::Block(match rng.gen_bool(0.1) {
|
||||||
|
true => Block::air(match rng.gen_range(0..6) {
|
||||||
|
0 => SpriteKind::BlueFlower,
|
||||||
|
1 => SpriteKind::PinkFlower,
|
||||||
|
2 => SpriteKind::PurpleFlower,
|
||||||
|
3 => SpriteKind::RedFlower,
|
||||||
|
4 => SpriteKind::WhiteFlower,
|
||||||
|
_ => SpriteKind::YellowFlower,
|
||||||
|
}),
|
||||||
|
false => Block::empty(),
|
||||||
|
});
|
||||||
let structural_wood = Fill::Block(Block::new(BlockKind::Rock, Rgb::new(80, 80, 80)));
|
let structural_wood = Fill::Block(Block::new(BlockKind::Rock, Rgb::new(80, 80, 80)));
|
||||||
let path = Fill::Block(Block::new(
|
let path = Fill::Block(Block::new(
|
||||||
BlockKind::Rock,
|
BlockKind::Rock,
|
||||||
@ -93,7 +104,7 @@ impl Render for Cemetary {
|
|||||||
// Walls
|
// Walls
|
||||||
let inner = prim(Primitive::Aabb(Aabb {
|
let inner = prim(Primitive::Aabb(Aabb {
|
||||||
min: (self.bounds.min + 1).with_z(self.alt),
|
min: (self.bounds.min + 1).with_z(self.alt),
|
||||||
max: self.bounds.max.with_z(self.alt + roof),
|
max: (self.bounds.max).with_z(self.alt + roof),
|
||||||
}));
|
}));
|
||||||
let outer = prim(Primitive::Aabb(Aabb {
|
let outer = prim(Primitive::Aabb(Aabb {
|
||||||
min: self.bounds.min.with_z(self.alt),
|
min: self.bounds.min.with_z(self.alt),
|
||||||
@ -103,8 +114,6 @@ impl Render for Cemetary {
|
|||||||
|
|
||||||
let walls = prim(Primitive::Xor(outer, inner));
|
let walls = prim(Primitive::Xor(outer, inner));
|
||||||
|
|
||||||
// lol
|
|
||||||
|
|
||||||
// Windows x axis
|
// Windows x axis
|
||||||
{
|
{
|
||||||
let mut windows = prim(Primitive::Empty);
|
let mut windows = prim(Primitive::Empty);
|
||||||
@ -141,9 +150,9 @@ impl Render for Cemetary {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wall pillars
|
// Wall pillars
|
||||||
let mut pillars_y = prim(Primitive::Empty);
|
let mut pillars_y = prim(Primitive::Empty);
|
||||||
for x in self.tile_aabr.min.x..self.tile_aabr.max.x + 2 {
|
for x in self.tile_aabr.min.x..self.tile_aabr.max.x + 1 {
|
||||||
let pillar = prim(Primitive::Aabb(Aabb {
|
let pillar = prim(Primitive::Aabb(Aabb {
|
||||||
min: site
|
min: site
|
||||||
.tile_wpos(Vec2::new(x, self.tile_aabr.min.y))
|
.tile_wpos(Vec2::new(x, self.tile_aabr.min.y))
|
||||||
@ -154,7 +163,7 @@ impl Render for Cemetary {
|
|||||||
pillars_y = prim(Primitive::Or(pillars_y, pillar));
|
pillars_y = prim(Primitive::Or(pillars_y, pillar));
|
||||||
}
|
}
|
||||||
let mut pillars_x = prim(Primitive::Empty);
|
let mut pillars_x = prim(Primitive::Empty);
|
||||||
for y in self.tile_aabr.min.y..self.tile_aabr.max.y + 2 {
|
for y in self.tile_aabr.min.y..self.tile_aabr.max.y + 1 {
|
||||||
let pillar = prim(Primitive::Aabb(Aabb {
|
let pillar = prim(Primitive::Aabb(Aabb {
|
||||||
min: site
|
min: site
|
||||||
.tile_wpos(Vec2::new(self.tile_aabr.min.x, y))
|
.tile_wpos(Vec2::new(self.tile_aabr.min.x, y))
|
||||||
@ -166,8 +175,47 @@ impl Render for Cemetary {
|
|||||||
}
|
}
|
||||||
let pillars = prim(Primitive::And(pillars_x, pillars_y));
|
let pillars = prim(Primitive::And(pillars_x, pillars_y));
|
||||||
fill(pillars, structural_wood);
|
fill(pillars, structural_wood);
|
||||||
|
|
||||||
|
// Fill inner
|
||||||
fill(inner, Fill::Block(Block::empty()));
|
fill(inner, Fill::Block(Block::empty()));
|
||||||
|
|
||||||
|
// Slice
|
||||||
|
let slice = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: self.bounds.min.with_z(self.alt),
|
||||||
|
max: (self.bounds.max + 1).with_z(self.alt + 2),
|
||||||
|
}));
|
||||||
|
fill(slice, structural_wood);
|
||||||
|
|
||||||
|
// Entrance
|
||||||
|
let high = prim(Primitive::Pyramid {
|
||||||
|
aabb: Aabb {
|
||||||
|
min: Vec2::new(mid.x - 3, self.bounds.min.y).with_z(self.alt + 6),
|
||||||
|
max: Vec2::new(mid.x + 3, self.bounds.min.y + 1).with_z(self.alt + 9),
|
||||||
|
},
|
||||||
|
inset: Vec2::broadcast(5),
|
||||||
|
});
|
||||||
|
let door = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(mid.x - 3, self.bounds.min.y).with_z(self.alt),
|
||||||
|
max: Vec2::new(mid.x + 3, self.bounds.min.y + 1).with_z(self.alt + 6),
|
||||||
|
}));
|
||||||
|
let door_empty = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(mid.x - 2, self.bounds.min.y).with_z(self.alt),
|
||||||
|
max: Vec2::new(mid.x + 2, self.bounds.min.y + 1).with_z(self.alt + 6),
|
||||||
|
}));
|
||||||
|
let lamp_1 = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(mid.x - 3, self.bounds.min.y - 1).with_z(self.alt + 3),
|
||||||
|
max: Vec2::new(mid.x - 2, self.bounds.min.y).with_z(self.alt + 4),
|
||||||
|
}));
|
||||||
|
let lamp_2 = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(mid.x + 2, self.bounds.min.y - 1).with_z(self.alt + 3),
|
||||||
|
max: Vec2::new(mid.x + 3, self.bounds.min.y).with_z(self.alt + 4),
|
||||||
|
}));
|
||||||
|
fill(door, structural_wood);
|
||||||
|
fill(door_empty, Fill::Block(Block::empty()));
|
||||||
|
fill(high, structural_wood);
|
||||||
|
fill(lamp_1, lamp);
|
||||||
|
fill(lamp_2, lamp);
|
||||||
|
|
||||||
// Floor
|
// Floor
|
||||||
let floor = prim(Primitive::Aabb(Aabb {
|
let floor = prim(Primitive::Aabb(Aabb {
|
||||||
min: (self.bounds.min).with_z(self.alt),
|
min: (self.bounds.min).with_z(self.alt),
|
||||||
@ -181,12 +229,6 @@ impl Render for Cemetary {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let slice = prim(Primitive::Aabb(Aabb {
|
|
||||||
min: self.bounds.min.with_z(self.alt),
|
|
||||||
max: (self.bounds.max + 1).with_z(self.alt + 2),
|
|
||||||
}));
|
|
||||||
fill(prim(Primitive::AndNot(slice, floor)), structural_wood);
|
|
||||||
|
|
||||||
// Grass
|
// Grass
|
||||||
let grass = Aabb {
|
let grass = Aabb {
|
||||||
min: (self.bounds.min + 1).with_z(self.alt + 1),
|
min: (self.bounds.min + 1).with_z(self.alt + 1),
|
||||||
@ -211,8 +253,25 @@ impl Render for Cemetary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tombstones
|
// Horizontal paths
|
||||||
|
let cemetary = Aabb {
|
||||||
|
min: (self.bounds.min + 1).with_z(self.alt),
|
||||||
|
max: Vec2::new(self.bounds.max.x, self.bounds.max.y - 8).with_z(self.alt + roof),
|
||||||
|
};
|
||||||
|
|
||||||
|
for x in cemetary.min.x..cemetary.max.x {
|
||||||
|
for y in cemetary.min.y..cemetary.max.y {
|
||||||
|
let block = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(x, y).with_z(self.alt),
|
||||||
|
max: Vec2::new(x + 1, y + 1).with_z(self.alt + 1),
|
||||||
|
}));
|
||||||
|
if (y % 5 == 3 || y % 5 == 4) && rng.gen_bool(0.95) {
|
||||||
|
fill(block, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tombstones
|
||||||
let dalle_block = Fill::Block(Block::new(BlockKind::Rock, Rgb::new(40, 40, 40)));
|
let dalle_block = Fill::Block(Block::new(BlockKind::Rock, Rgb::new(40, 40, 40)));
|
||||||
|
|
||||||
for x in grass.min.x..grass.max.x {
|
for x in grass.min.x..grass.max.x {
|
||||||
@ -235,82 +294,96 @@ impl Render for Cemetary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paths
|
// Floor
|
||||||
for x in grass.min.x..grass.max.x {
|
let floor = Aabb {
|
||||||
for y in grass.min.y..grass.max.y {
|
min: Vec2::new(self.bounds.min.x + 1, self.bounds.max.y - 8).with_z(self.alt + 1),
|
||||||
|
max: Vec2::new(self.bounds.max.x, self.bounds.max.y).with_z(self.alt + 2),
|
||||||
|
};
|
||||||
|
for x in floor.min.x..floor.max.x {
|
||||||
|
for y in floor.min.y..floor.max.y {
|
||||||
let block = prim(Primitive::Aabb(Aabb {
|
let block = prim(Primitive::Aabb(Aabb {
|
||||||
min: Vec2::new(x, y).with_z(self.alt),
|
min: Vec2::new(x, y).with_z(self.alt + 1),
|
||||||
max: Vec2::new(x + 1, y + 1).with_z(self.alt + 1),
|
max: Vec2::new(x + 1, y + 1).with_z(self.alt + 2),
|
||||||
}));
|
}));
|
||||||
if (y % 5 == 3 || y % 5 == 4) && rng.gen_bool(0.95) {
|
let flower_sprite = Fill::Block(match rng.gen_bool(0.3) {
|
||||||
fill(block, path);
|
true => Block::air(match rng.gen_range(0..6) {
|
||||||
}
|
0 => SpriteKind::BlueFlower,
|
||||||
|
1 => SpriteKind::PinkFlower,
|
||||||
|
2 => SpriteKind::PurpleFlower,
|
||||||
|
3 => SpriteKind::RedFlower,
|
||||||
|
4 => SpriteKind::WhiteFlower,
|
||||||
|
_ => SpriteKind::YellowFlower,
|
||||||
|
}),
|
||||||
|
false => Block::empty(),
|
||||||
|
});
|
||||||
|
fill(block, flower_sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*let path_x = prim(Primitive::Aabb(Aabb {
|
// Crypt
|
||||||
min: Vec3::new(mid.x - 2, grass.min.y, self.alt),
|
let crypt = prim(Primitive::Aabb(Aabb {
|
||||||
max: Vec3::new(mid.x + 3, grass.max.y, self.alt + 1),
|
min: Vec2::new(mid.x - 6, self.bounds.max.y - 8).with_z(self.alt + 1),
|
||||||
}));*/
|
max: Vec2::new(mid.x + 6, self.bounds.max.y).with_z(self.alt + 6),
|
||||||
for x in grass.min.x..grass.max.x {
|
|
||||||
for y in grass.min.y..grass.max.y {
|
|
||||||
let block = prim(Primitive::Aabb(Aabb {
|
|
||||||
min: Vec2::new(x, y).with_z(self.alt),
|
|
||||||
max: Vec2::new(x + 1, y + 1).with_z(self.alt + 1),
|
|
||||||
}));
|
|
||||||
if x > mid.x - 2 && x < mid.x + 2 && rng.gen_bool(0.95) {
|
|
||||||
fill(block, path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//fill(path_x, path);
|
|
||||||
|
|
||||||
/*let test1 = prim(Primitive::Cylinder(Aabb {
|
|
||||||
min: Vec3::new(mid.x - inline_tweak::tweak!(5), self.bounds.min.y - inline_tweak::tweak!(5), self.alt),
|
|
||||||
max: Vec3::new(mid.x + inline_tweak::tweak!(5), self.bounds.min.y + inline_tweak::tweak!(5), self.alt + 3),
|
|
||||||
}));
|
}));
|
||||||
let test2 = prim(Primitive::Cylinder(Aabb {
|
|
||||||
min: Vec3::new(mid.x - 3, mid.y - 4, self.alt),
|
let crypt_inner = prim(Primitive::Aabb(Aabb {
|
||||||
max: Vec3::new(mid.x + 3, mid.y + 4, self.alt),
|
min: Vec2::new(mid.x - 5, self.bounds.max.y - 7).with_z(self.alt + 1),
|
||||||
|
max: Vec2::new(mid.x + 5, self.bounds.max.y - 1).with_z(self.alt + 6),
|
||||||
}));
|
}));
|
||||||
let xor = prim(Primitive::Xor(test1, test2));
|
|
||||||
|
|
||||||
let rotation = Mat3::new(
|
let crypt_door = prim(Primitive::Aabb(Aabb {
|
||||||
1, 0, 0,
|
min: Vec2::new(mid.x - 2, self.bounds.max.y - 8).with_z(self.alt + 1),
|
||||||
0, 0, -1,
|
max: Vec2::new(mid.x + 2, self.bounds.max.y - 7).with_z(self.alt + 4),
|
||||||
0, 1, 0
|
}));
|
||||||
);
|
|
||||||
let rotated = prim(Primitive::Rotate(test1, rotation));
|
|
||||||
let translated = prim(Primitive::Offset(rotated, Vec3::new(0, 5, 0)));
|
|
||||||
fill(translated, structural_wood);*/
|
|
||||||
|
|
||||||
let high = prim(Primitive::Pyramid {
|
let roof = prim(Primitive::Pyramid {
|
||||||
aabb: Aabb {
|
aabb: Aabb {
|
||||||
min: Vec2::new(mid.x - 3, self.bounds.min.y).with_z(self.alt + 6),
|
min: Vec2::new(mid.x - 8, self.bounds.max.y - 8).with_z(self.alt + 6),
|
||||||
max: Vec2::new(mid.x + 3, self.bounds.min.y + 1).with_z(self.alt + 9),
|
max: Vec2::new(mid.x + 8, self.bounds.max.y).with_z(self.alt + 10),
|
||||||
},
|
},
|
||||||
inset: Vec2::broadcast(5),
|
inset: Vec2::broadcast(4),
|
||||||
});
|
});
|
||||||
let door = prim(Primitive::Aabb(Aabb {
|
|
||||||
min: Vec2::new(mid.x - 3, self.bounds.min.y).with_z(self.alt + 1),
|
|
||||||
max: Vec2::new(mid.x + 3, self.bounds.min.y + 1).with_z(self.alt + 6),
|
|
||||||
}));
|
|
||||||
let door_empty = prim(Primitive::Aabb(Aabb {
|
|
||||||
min: Vec2::new(mid.x - 2, self.bounds.min.y).with_z(self.alt + 1),
|
|
||||||
max: Vec2::new(mid.x + 2, self.bounds.min.y + 1).with_z(self.alt + 6),
|
|
||||||
}));
|
|
||||||
let lamp_1 = prim(Primitive::Aabb(Aabb {
|
let lamp_1 = prim(Primitive::Aabb(Aabb {
|
||||||
min: Vec2::new(mid.x - 3, self.bounds.min.y - 1).with_z(self.alt + 3),
|
min: Vec2::new(mid.x - 3, self.bounds.max.y - 9).with_z(self.alt + 2),
|
||||||
max: Vec2::new(mid.x - 2, self.bounds.min.y).with_z(self.alt + 4),
|
max: Vec2::new(mid.x - 2, self.bounds.max.y - 8).with_z(self.alt + 3),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let lamp_2 = prim(Primitive::Aabb(Aabb {
|
let lamp_2 = prim(Primitive::Aabb(Aabb {
|
||||||
min: Vec2::new(mid.x + 2, self.bounds.min.y - 1).with_z(self.alt + 3),
|
min: Vec2::new(mid.x + 2, self.bounds.max.y - 9).with_z(self.alt + 2),
|
||||||
max: Vec2::new(mid.x + 3, self.bounds.min.y).with_z(self.alt + 4),
|
max: Vec2::new(mid.x + 3, self.bounds.max.y - 8).with_z(self.alt + 3),
|
||||||
}));
|
}));
|
||||||
fill(door, structural_wood);
|
|
||||||
fill(door_empty, Fill::Block(Block::empty()));
|
fill(crypt, structural_wood);
|
||||||
fill(high, structural_wood);
|
fill(crypt_inner, Fill::Block(Block::empty()));
|
||||||
|
fill(crypt_door, Fill::Block(Block::empty()));
|
||||||
|
fill(roof, structural_wood);
|
||||||
fill(lamp_1, lamp);
|
fill(lamp_1, lamp);
|
||||||
fill(lamp_2, lamp);
|
fill(lamp_2, lamp);
|
||||||
|
|
||||||
|
for x in cemetary.min.x..cemetary.max.x {
|
||||||
|
for y in cemetary.min.y..cemetary.max.y {
|
||||||
|
let block = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(x, y).with_z(self.alt),
|
||||||
|
max: Vec2::new(x + 1, y + 1).with_z(self.alt + 1),
|
||||||
|
}));
|
||||||
|
if x > mid.x - 3 && x < mid.x + 2 && rng.gen_bool(0.95) {
|
||||||
|
fill(block, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vertical path
|
||||||
|
for x in cemetary.min.x..cemetary.max.x {
|
||||||
|
for y in cemetary.min.y..cemetary.max.y {
|
||||||
|
let block = prim(Primitive::Aabb(Aabb {
|
||||||
|
min: Vec2::new(x, y).with_z(self.alt + 1),
|
||||||
|
max: Vec2::new(x + 1, y + 1).with_z(self.alt + 2),
|
||||||
|
}));
|
||||||
|
if x > mid.x - 3 && x < mid.x + 2 {
|
||||||
|
fill(block, Fill::Block(Block::empty()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,19 @@ pub struct Hut {
|
|||||||
impl Structure for Hut {
|
impl Structure for Hut {
|
||||||
type Config = ();
|
type Config = ();
|
||||||
|
|
||||||
fn choose_location<R: Rng>(cfg: Self::Config, land: &Land, site: &Site, rng: &mut R) -> Option<Self> {
|
fn choose_location<R: Rng>(
|
||||||
let (tile_aabr, root) = site.tiles.find_near(
|
cfg: Self::Config,
|
||||||
Vec2::zero(),
|
land: &Land,
|
||||||
|tile, _| if rng.gen_range(0..16) == 0 {
|
site: &Site,
|
||||||
|
rng: &mut R,
|
||||||
|
) -> Option<Self> {
|
||||||
|
let (tile_aabr, root) = site.tiles.find_near(Vec2::zero(), |tile, _| {
|
||||||
|
if rng.gen_range(0..16) == 0 {
|
||||||
site.tiles.grow_aabr(tile, 4..9, (2, 2), 2).ok()
|
site.tiles.grow_aabr(tile, 4..9, (2, 2), 2).ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
}
|
||||||
)?;
|
})?;
|
||||||
let center = (tile_aabr.min + (tile_aabr.max - 1)) / 2;
|
let center = (tile_aabr.min + (tile_aabr.max - 1)) / 2;
|
||||||
|
|
||||||
Some(Self {
|
Some(Self {
|
||||||
@ -79,10 +83,13 @@ impl Render for Hut {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
let door_pos = site.tile_center_wpos(self.root);
|
let door_pos = site.tile_center_wpos(self.root);
|
||||||
let door = prim(Primitive::Aabb(Aabb {
|
let door = prim(Primitive::Aabb(
|
||||||
min: door_pos.with_z(self.alt),
|
Aabb {
|
||||||
max: (door_pos + self.door_dir * 32).with_z(self.alt + 2),
|
min: door_pos.with_z(self.alt),
|
||||||
}.made_valid()));
|
max: (door_pos + self.door_dir * 32).with_z(self.alt + 2),
|
||||||
|
}
|
||||||
|
.made_valid(),
|
||||||
|
));
|
||||||
|
|
||||||
let space = prim(Primitive::And(inner, door));
|
let space = prim(Primitive::And(inner, door));
|
||||||
|
|
||||||
@ -98,7 +105,7 @@ impl Render for Hut {
|
|||||||
/ 2
|
/ 2
|
||||||
+ roof_lip
|
+ roof_lip
|
||||||
+ 1;
|
+ 1;
|
||||||
let roof = prim(Primitive::Pyramid{
|
let roof = prim(Primitive::Pyramid {
|
||||||
aabb: Aabb {
|
aabb: Aabb {
|
||||||
min: (self.bounds.min + 1 - roof_lip).with_z(self.alt + self.height),
|
min: (self.bounds.min + 1 - roof_lip).with_z(self.alt + self.height),
|
||||||
max: (self.bounds.max - 1 + roof_lip).with_z(self.alt + self.height + roof_height),
|
max: (self.bounds.max - 1 + roof_lip).with_z(self.alt + self.height + roof_height),
|
||||||
|
@ -94,11 +94,13 @@ impl TileGrid {
|
|||||||
let mut last_growth = 0;
|
let mut last_growth = 0;
|
||||||
for i in 0..32 {
|
for i in 0..32 {
|
||||||
if i - last_growth >= 4
|
if i - last_growth >= 4
|
||||||
|| (inner_size(aabr) + if i % 2 == 0 {
|
|| (inner_size(aabr)
|
||||||
|
+ if i % 2 == 0 {
|
||||||
Extent2::new(0, 1)
|
Extent2::new(0, 1)
|
||||||
} else {
|
} else {
|
||||||
Extent2::new(1, 0)
|
Extent2::new(1, 0)
|
||||||
}).product()
|
})
|
||||||
|
.product()
|
||||||
> area_range.end as i32
|
> area_range.end as i32
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user