Merge branch 'zesterer/civsim' into 'master'

Added sites to the map

See merge request veloren/veloren!938
This commit is contained in:
Joshua Barretto 2020-04-23 21:06:21 +00:00
commit ae0db48308
5 changed files with 22 additions and 2 deletions

View File

@ -45,7 +45,7 @@ void main() {
diffuse_light *= f_light * ao;
diffuse_light += point_light * ao;
vec3 col = f_col + hash(vec4(floor(f_chunk_pos * 3.0 + 0.5), 0)) * 0.02; // Small-scale noise
vec3 col = f_col + hash(vec4(floor(f_chunk_pos * 3.0 - f_norm * 0.5), 0)) * 0.02; // Small-scale noise
vec3 surf_color = illuminate(srgb_to_linear(col), light, diffuse_light, ambient_light);
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);

View File

@ -156,6 +156,7 @@ impl MapConfig {
downhill,
river_kind,
is_path,
near_site,
) = sampler
.get(pos)
.map(|sample| {
@ -168,6 +169,9 @@ impl MapConfig {
sample.downhill,
sample.river.river_kind,
sample.path.is_path(),
sample.sites
.iter()
.any(|site| site.get_origin().distance_squared(pos * TerrainChunkSize::RECT_SIZE.x as i32) < 64i32.pow(2)),
)
})
.unwrap_or((
@ -179,6 +183,7 @@ impl MapConfig {
None,
None,
false,
false,
));
let humidity = humidity.min(1.0).max(0.0);
let temperature = temperature.min(1.0).max(-1.0) * 0.5 + 0.5;
@ -305,7 +310,9 @@ impl MapConfig {
),
};
let rgba = if is_path {
let rgba = if near_site {
(0x57, 0x39, 0x33, 0xFF)
} else if is_path {
(0x37, 0x29, 0x23, 0xFF)
} else {
rgba

View File

@ -67,6 +67,8 @@ impl Dungeon {
this
}
pub fn get_origin(&self) -> Vec2<i32> { self.origin }
pub fn radius(&self) -> f32 { 1200.0 }
pub fn spawn_rules(&self, _wpos: Vec2<i32>) -> SpawnRules {

View File

@ -74,6 +74,13 @@ impl Site {
}
}
pub fn get_origin(&self) -> Vec2<i32> {
match self {
Site::Settlement(s) => s.get_origin(),
Site::Dungeon(d) => d.get_origin(),
}
}
pub fn spawn_rules(&self, wpos: Vec2<i32>) -> SpawnRules {
match self {
Site::Settlement(s) => s.spawn_rules(wpos),

View File

@ -147,6 +147,10 @@ impl Settlement {
this
}
pub fn get_origin(&self) -> Vec2<i32> {
self.origin
}
/// Designate hazardous terrain based on world data
pub fn designate_from_world(&mut self, sim: &WorldSim, rng: &mut impl Rng) {
let tile_radius = self.radius() as i32 / AREA_SIZE as i32;