mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Cultists no longer attack the starting town.
This commit is contained in:
parent
b4697555d2
commit
9675d2b45a
@ -127,7 +127,7 @@ use world::{
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct SpawnPoint(Vec3<f32>);
|
||||
pub struct SpawnPoint(pub Vec3<f32>);
|
||||
|
||||
impl Default for SpawnPoint {
|
||||
fn default() -> Self { Self(Vec3::new(0.0, 0.0, 256.0)) }
|
||||
@ -492,7 +492,7 @@ impl Server {
|
||||
|
||||
// Initiate real-time world simulation
|
||||
#[cfg(feature = "worldgen")]
|
||||
rtsim::init(&mut state, &world, index.as_index_ref());
|
||||
rtsim::init(&mut state, &world, index.as_index_ref(), spawn_point);
|
||||
#[cfg(not(feature = "worldgen"))]
|
||||
rtsim::init(&mut state);
|
||||
|
||||
|
@ -108,6 +108,7 @@ pub fn init(
|
||||
state: &mut State,
|
||||
#[cfg(feature = "worldgen")] world: &world::World,
|
||||
#[cfg(feature = "worldgen")] index: world::IndexRef,
|
||||
#[cfg(feature = "worldgen")] spawn_point: crate::SpawnPoint,
|
||||
) {
|
||||
#[cfg(feature = "worldgen")]
|
||||
let mut rtsim = RtSim::new(world.sim().get_size());
|
||||
@ -143,6 +144,16 @@ pub fn init(
|
||||
.filter_map(|(site_id, site)| site.site_tmp.map(|id| (site_id, &index.sites[id])))
|
||||
{
|
||||
use world::site::SiteKind;
|
||||
let spawn_town_id = world
|
||||
.civs()
|
||||
.sites
|
||||
.iter()
|
||||
.filter(|(_, site)| site.is_settlement())
|
||||
.min_by_key(|(_, site)| {
|
||||
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|x| x as i32);
|
||||
wpos.distance_squared(spawn_point.0.xy().map(|x| x as i32))
|
||||
})
|
||||
.map(|(id, _)| id);
|
||||
#[allow(clippy::single_match)]
|
||||
match &site.kind {
|
||||
#[allow(clippy::single_match)]
|
||||
@ -153,7 +164,11 @@ pub fn init(
|
||||
.civs()
|
||||
.sites
|
||||
.iter()
|
||||
.filter(|s| s.1.is_settlement())
|
||||
.filter(|&(site_id, site)| {
|
||||
site.is_settlement()
|
||||
// TODO: Remove this later, starting town should not be special-cased
|
||||
&& spawn_town_id.map_or(false, |spawn_id| spawn_id != site_id)
|
||||
})
|
||||
.min_by_key(|(_, site)| {
|
||||
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|e| e as i32);
|
||||
wpos.map(|e| e as f32)
|
||||
|
Loading…
Reference in New Issue
Block a user