mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made /waypoint admin-only, MR cleanup
This commit is contained in:
parent
a7b5d6b270
commit
444f2ecb45
@ -27,7 +27,7 @@ void main() {
|
||||
|
||||
// Small waves
|
||||
f_pos.xy += 0.01; // Avoid z-fighting
|
||||
f_pos.z -= 0.1 * (sin(tick.x * 2.0 + f_pos.x * 2.0 + f_pos.y * 2.0) + 1.0) * 0.5 - 0.1;
|
||||
f_pos.z -= 0.1 + 0.1 * (sin(tick.x * 2.0 + f_pos.x * 2.0 + f_pos.y * 2.0) + 1.0) * 0.5;
|
||||
|
||||
f_col = vec3(
|
||||
float((v_col_light >> 8) & 0xFFu),
|
||||
@ -39,8 +39,6 @@ void main() {
|
||||
|
||||
f_pos_norm = v_pos_norm;
|
||||
|
||||
f_pos.z -= 0.2;
|
||||
|
||||
gl_Position =
|
||||
all_mat *
|
||||
vec4(f_pos, 1);
|
||||
|
@ -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)) * 0.02; // Small-scale noise
|
||||
vec3 col = f_col + hash(vec4(floor(f_chunk_pos * 3.0 + 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);
|
||||
|
@ -19,10 +19,10 @@ out vec3 f_col;
|
||||
out float f_light;
|
||||
out float f_ao;
|
||||
|
||||
const float EXTRA_NEG_Z = 65536.0;
|
||||
const int EXTRA_NEG_Z = 65536;
|
||||
|
||||
void main() {
|
||||
f_chunk_pos = vec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0x1FFFFu)) - vec3(0, 0, EXTRA_NEG_Z);
|
||||
f_chunk_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0x1FFFFu)) - ivec3(0, 0, EXTRA_NEG_Z));
|
||||
f_pos = f_chunk_pos + model_offs;
|
||||
|
||||
f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
|
||||
|
@ -101,7 +101,7 @@ impl ChunkSupplement {
|
||||
pub fn add_entity(&mut self, entity: EntityInfo) { self.entities.push(entity); }
|
||||
}
|
||||
|
||||
fn get_npc_name<
|
||||
pub fn get_npc_name<
|
||||
'a,
|
||||
Species,
|
||||
SpeciesData: for<'b> core::ops::Index<&'b Species, Output = npc::SpeciesNames>,
|
||||
|
@ -114,6 +114,10 @@ impl<'a> System<'a> for Sys {
|
||||
const MIN_ATTACK_DIST: f32 = 3.25;
|
||||
|
||||
let scale = scales.get(entity).map(|s| s.0).unwrap_or(1.0);
|
||||
|
||||
// This controls how picky NPCs are about their pathfinding. Giants are larger and so
|
||||
// can afford to be less precise when trying to move around the world (especially since
|
||||
// they would otherwise get stuck on obstacles that smaller entities would not).
|
||||
let traversal_tolerance = scale;
|
||||
|
||||
let mut do_idle = false;
|
||||
|
@ -216,7 +216,7 @@ lazy_static! {
|
||||
"waypoint",
|
||||
"{}",
|
||||
"/waypoint : Set your waypoint to your current position",
|
||||
false,
|
||||
true,
|
||||
handle_waypoint,
|
||||
),
|
||||
ChatCommand::new(
|
||||
|
@ -5,9 +5,10 @@ use common::{
|
||||
comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos},
|
||||
event::{EventBus, ServerEvent},
|
||||
msg::ServerMsg,
|
||||
npc::{self, NPC_NAMES},
|
||||
npc::NPC_NAMES,
|
||||
state::TerrainChanges,
|
||||
terrain::TerrainGrid,
|
||||
generation::get_npc_name,
|
||||
};
|
||||
use rand::Rng;
|
||||
use specs::{Join, Read, ReadStorage, System, Write, WriteExpect, WriteStorage};
|
||||
@ -105,89 +106,6 @@ impl<'a> System<'a> for Sys {
|
||||
continue;
|
||||
}
|
||||
|
||||
fn get_npc_name<
|
||||
'a,
|
||||
Species,
|
||||
SpeciesData: for<'b> core::ops::Index<&'b Species, Output = npc::SpeciesNames>,
|
||||
>(
|
||||
body_data: &'a comp::BodyData<npc::BodyNames, SpeciesData>,
|
||||
species: Species,
|
||||
) -> &'a str {
|
||||
&body_data.species[&species].generic
|
||||
}
|
||||
|
||||
/*
|
||||
const SPAWN_NPCS: &'static [fn() -> (
|
||||
String,
|
||||
comp::Body,
|
||||
Option<comp::Item>,
|
||||
comp::Alignment,
|
||||
)] = &[
|
||||
(|| {
|
||||
let body = comp::humanoid::Body::random();
|
||||
(
|
||||
format!("{} Traveler", get_npc_name(&NPC_NAMES.humanoid, body.race)),
|
||||
comp::Body::Humanoid(body),
|
||||
Some(assets::load_expect_cloned(
|
||||
"common.items.weapons.starter_axe",
|
||||
)),
|
||||
comp::Alignment::Npc,
|
||||
)
|
||||
}) as _,
|
||||
(|| {
|
||||
let body = comp::humanoid::Body::random();
|
||||
(
|
||||
format!("{} Bandit", get_npc_name(&NPC_NAMES.humanoid, body.race)),
|
||||
comp::Body::Humanoid(body),
|
||||
Some(assets::load_expect_cloned(
|
||||
"common.items.weapons.short_sword_0",
|
||||
)),
|
||||
comp::Alignment::Enemy,
|
||||
)
|
||||
}) as _,
|
||||
(|| {
|
||||
let body = comp::quadruped_medium::Body::random();
|
||||
(
|
||||
get_npc_name(&NPC_NAMES.quadruped_medium, body.species).into(),
|
||||
comp::Body::QuadrupedMedium(body),
|
||||
None,
|
||||
comp::Alignment::Enemy,
|
||||
)
|
||||
}) as _,
|
||||
(|| {
|
||||
let body = comp::bird_medium::Body::random();
|
||||
(
|
||||
get_npc_name(&NPC_NAMES.bird_medium, body.species).into(),
|
||||
comp::Body::BirdMedium(body),
|
||||
None,
|
||||
comp::Alignment::Wild,
|
||||
)
|
||||
}) as _,
|
||||
(|| {
|
||||
let body = comp::critter::Body::random();
|
||||
(
|
||||
get_npc_name(&NPC_NAMES.critter, body.species).into(),
|
||||
comp::Body::Critter(body),
|
||||
None,
|
||||
comp::Alignment::Wild,
|
||||
)
|
||||
}) as _,
|
||||
(|| {
|
||||
let body = comp::quadruped_small::Body::random();
|
||||
(
|
||||
get_npc_name(&NPC_NAMES.quadruped_small, body.species).into(),
|
||||
comp::Body::QuadrupedSmall(body),
|
||||
None,
|
||||
comp::Alignment::Wild,
|
||||
)
|
||||
}),
|
||||
];
|
||||
let (name, mut body, main, alignment) = SPAWN_NPCS
|
||||
.choose(&mut rand::thread_rng())
|
||||
.expect("SPAWN_NPCS is nonempty")(
|
||||
);
|
||||
*/
|
||||
|
||||
let mut body = entity.body;
|
||||
let name = entity.name.unwrap_or("Unnamed".to_string());
|
||||
let alignment = entity.alignment;
|
||||
|
@ -44,15 +44,11 @@ impl Meshable<FigurePipeline, FigurePipeline> for Segment {
|
||||
for x in 0..3 {
|
||||
for y in 0..3 {
|
||||
for z in 0..3 {
|
||||
ls[z][y][x] = if self
|
||||
ls[z][y][x] = self
|
||||
.get(pos + Vec3::new(x as i32, y as i32, z as i32) - 1)
|
||||
.map(|v| v.is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
Some(1.0)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.then_some(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,15 +93,11 @@ impl Meshable<SpritePipeline, SpritePipeline> for Segment {
|
||||
for x in 0..3 {
|
||||
for y in 0..3 {
|
||||
for z in 0..3 {
|
||||
ls[z][y][x] = if self
|
||||
ls[z][y][x] = self
|
||||
.get(pos + Vec3::new(x as i32, y as i32, z as i32) - 1)
|
||||
.map(|v| v.is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
Some(1.0)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.then_some(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ impl Blendable for BlockKind {
|
||||
fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
bounds: Aabb<i32>,
|
||||
vol: &VolGrid2d<V>,
|
||||
) -> impl FnMut(Vec3<i32>) -> Option<f32> + '_ {
|
||||
) -> impl FnMut(Vec3<i32>) -> f32 + '_ {
|
||||
const UNKNOWN: u8 = 255;
|
||||
const OPAQUE: u8 = 254;
|
||||
const SUNLIGHT: u8 = 24;
|
||||
@ -189,22 +189,12 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
}
|
||||
|
||||
move |wpos| {
|
||||
if vol_cached
|
||||
.get(wpos)
|
||||
.map(|block| block.is_opaque())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
let pos = wpos - outer.min;
|
||||
Some(
|
||||
light_map
|
||||
.get(lm_idx(pos.x, pos.y, pos.z))
|
||||
.filter(|l| **l != OPAQUE && **l != UNKNOWN)
|
||||
.map(|l| *l as f32 / SUNLIGHT as f32)
|
||||
.unwrap_or(0.0),
|
||||
)
|
||||
}
|
||||
let pos = wpos - outer.min;
|
||||
light_map
|
||||
.get(lm_idx(pos.x, pos.y, pos.z))
|
||||
.filter(|l| **l != OPAQUE && **l != UNKNOWN)
|
||||
.map(|l| *l as f32 / SUNLIGHT as f32)
|
||||
.unwrap_or(0.0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,15 +297,32 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
|
||||
for x in 1..range.size().w - 1 {
|
||||
for y in 1..range.size().w - 1 {
|
||||
let mut blocks = [[[None; 3]; 3]; 3];
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
for k in 0..3 {
|
||||
blocks[k][j][i] = Some(flat_get(
|
||||
Vec3::new(x, y, z_start)
|
||||
+ Vec3::new(i as i32, j as i32, k as i32)
|
||||
- 1
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut lights = [[[None; 3]; 3]; 3];
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
for k in 0..3 {
|
||||
lights[k][j][i] = light(
|
||||
Vec3::new(x + range.min.x, y + range.min.y, z_start + range.min.z)
|
||||
+ Vec3::new(i as i32, j as i32, k as i32)
|
||||
- 1,
|
||||
);
|
||||
lights[k][j][i] = if blocks[k][j][i].map(|block| block.is_opaque()).unwrap_or(false) {
|
||||
None
|
||||
} else {
|
||||
Some(light(Vec3::new(
|
||||
x + range.min.x,
|
||||
y + range.min.y,
|
||||
z_start + range.min.z,
|
||||
) + Vec3::new(i as i32, j as i32, k as i32) - 1))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,19 +335,6 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
.unwrap_or(Rgba::zero())
|
||||
};
|
||||
|
||||
let mut blocks = [[[None; 3]; 3]; 3];
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
for k in 0..3 {
|
||||
let block = Some(flat_get(
|
||||
Vec3::new(x, y, z_start) + Vec3::new(i as i32, j as i32, k as i32)
|
||||
- 1,
|
||||
));
|
||||
blocks[k][j][i] = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for z in z_start..z_end + 1 {
|
||||
let pos = Vec3::new(x, y, z);
|
||||
let offs = (pos - Vec3::new(1, 1, -range.min.z)).map(|e| e as f32);
|
||||
@ -350,18 +344,22 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
blocks[0] = blocks[1];
|
||||
blocks[1] = blocks[2];
|
||||
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
lights[2][j][i] =
|
||||
light(pos + range.min + Vec3::new(i as i32, j as i32, 2) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
let block = Some(flat_get(pos + Vec3::new(i as i32, j as i32, 2) - 1));
|
||||
blocks[2][j][i] = block;
|
||||
}
|
||||
}
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
lights[2][j][i] = if blocks[2][j][i].map(|block| block.is_opaque()).unwrap_or(false) {
|
||||
None
|
||||
} else {
|
||||
Some(light(pos + range.min + Vec3::new(i as i32, j as i32, 2) - 1))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let block = blocks[1][1][1];
|
||||
let colors = if block.map_or(false, |vox| vox.is_blended()) {
|
||||
|
@ -18,13 +18,7 @@ fn get_ao_quad(
|
||||
.map(|offs| {
|
||||
let vox_opaque = |pos: Vec3<i32>| {
|
||||
let pos = (pos + 1).map(|e| e as usize);
|
||||
unsafe {
|
||||
darknesses
|
||||
.get_unchecked(pos.z)
|
||||
.get_unchecked(pos.y)
|
||||
.get_unchecked(pos.x)
|
||||
.is_none()
|
||||
}
|
||||
darknesses[pos.z][pos.y][pos.x].is_none()
|
||||
};
|
||||
|
||||
let (s1, s2) = (
|
||||
@ -45,12 +39,11 @@ fn get_ao_quad(
|
||||
for x in 0..2 {
|
||||
for y in 0..2 {
|
||||
let dark_pos = shift + offs[0] * x + offs[1] * y + 1;
|
||||
if let Some(dark) = unsafe {
|
||||
darknesses
|
||||
.get_unchecked(dark_pos.z as usize)
|
||||
.get_unchecked(dark_pos.y as usize)
|
||||
.get_unchecked(dark_pos.x as usize)
|
||||
} {
|
||||
if let Some(dark) = darknesses
|
||||
[dark_pos.z as usize]
|
||||
[dark_pos.y as usize]
|
||||
[dark_pos.x as usize]
|
||||
{
|
||||
darkness += dark;
|
||||
total += 1.0;
|
||||
}
|
||||
|
@ -66,8 +66,6 @@ impl<P: Pipeline> Mesh<P> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn verts(&self) -> &[P::Vertex] { &self.verts }
|
||||
|
||||
pub fn iter(&self) -> std::slice::Iter<P::Vertex> { self.verts.iter() }
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ impl Civs {
|
||||
|
||||
for _ in 0..INITIAL_CIV_COUNT {
|
||||
log::info!("Creating civilisation...");
|
||||
if let None = this.birth_civ(&mut ctx.reseed()) {
|
||||
if this.birth_civ(&mut ctx.reseed()).is_none() {
|
||||
log::warn!("Failed to find starting site for civilisation.");
|
||||
}
|
||||
}
|
||||
@ -481,8 +481,9 @@ fn find_path(
|
||||
.and_then(|path| astar.get_cheapest_cost().map(|cost| (path, cost)))
|
||||
}
|
||||
|
||||
/// Return true if travel between a location and a chunk next to it is permitted
|
||||
/// (TODO: by whom?)
|
||||
/// Return Some if travel between a location and a chunk next to it is permitted
|
||||
/// If permitted, the approximate relative const of traversal is given
|
||||
// (TODO: by whom?)
|
||||
fn walk_in_dir(sim: &WorldSim, a: Vec2<i32>, dir: Vec2<i32>) -> Option<f32> {
|
||||
if loc_suitable_for_walking(sim, a) && loc_suitable_for_walking(sim, a + dir) {
|
||||
let a_chunk = sim.get(a)?;
|
||||
|
@ -298,7 +298,7 @@ impl MapConfig {
|
||||
};
|
||||
|
||||
let rgba = if is_path {
|
||||
(0x20, 0x19, 0x13, 255)
|
||||
(0x20, 0x19, 0x13, 0xFF)
|
||||
} else {
|
||||
rgba
|
||||
};
|
||||
|
@ -44,19 +44,6 @@ pub fn intersect(a: [Vec2<f32>; 2], b: [Vec2<f32>; 2]) -> Option<Vec2<f32>> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dist_to_line(line: [Vec2<f32>; 2], p: Vec2<f32>) -> f32 {
|
||||
let lsq = line[0].distance_squared(line[1]);
|
||||
|
||||
if lsq == 0.0 {
|
||||
line[0].distance(p)
|
||||
} else {
|
||||
let t = ((p - line[0]).dot(line[1] - line[0]) / lsq)
|
||||
.max(0.0)
|
||||
.min(1.0);
|
||||
p.distance(line[0] + (line[1] - line[0]) * t)
|
||||
}
|
||||
}
|
||||
|
||||
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]]);
|
||||
|
Loading…
Reference in New Issue
Block a user