mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
varius fixes
This commit is contained in:
parent
b3a70627e5
commit
134d0f0c04
@ -737,9 +737,11 @@ impl ServerChatCommand {
|
|||||||
"Send messages to everyone on the server",
|
"Send messages to everyone on the server",
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
ServerChatCommand::MakeVolume => {
|
ServerChatCommand::MakeVolume => cmd(
|
||||||
cmd(vec![Integer("size", 15, Optional)], "Create a volume (experimental)", Some(Admin))
|
vec![Integer("size", 15, Optional)],
|
||||||
},
|
"Create a volume (experimental)",
|
||||||
|
Some(Admin),
|
||||||
|
),
|
||||||
ServerChatCommand::Location => {
|
ServerChatCommand::Location => {
|
||||||
cmd(vec![Any("name", Required)], "Teleport to a location", None)
|
cmd(vec![Any("name", Required)], "Teleport to a location", None)
|
||||||
},
|
},
|
||||||
|
@ -243,7 +243,10 @@ pub mod figuredata {
|
|||||||
AssetExt::load("common.manifests.ship_manifest")?;
|
AssetExt::load("common.manifests.ship_manifest")?;
|
||||||
let mut colliders = HashMap::new();
|
let mut colliders = HashMap::new();
|
||||||
for (_, spec) in (manifest.read().0).0.iter() {
|
for (_, spec) in (manifest.read().0).0.iter() {
|
||||||
for (index, bone) in [&spec.bone0, &spec.bone1, &spec.bone2, &spec.bone3].iter().enumerate() {
|
for (index, bone) in [&spec.bone0, &spec.bone1, &spec.bone2, &spec.bone3]
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
// TODO: Currently both client and server load models and manifests from
|
// TODO: Currently both client and server load models and manifests from
|
||||||
// "common.voxel.". In order to support CSG procedural airships, we probably
|
// "common.voxel.". In order to support CSG procedural airships, we probably
|
||||||
// need to load them in the server and sync them as an ECS resource.
|
// need to load them in the server and sync them as an ECS resource.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// The limit on distance between the entity and a collectible (squared)
|
// The limit on distance between the entity and a collectible (squared)
|
||||||
pub const MAX_PICKUP_RANGE: f32 = 5.0;
|
pub const MAX_PICKUP_RANGE: f32 = 5.0;
|
||||||
pub const MAX_MOUNT_RANGE: f32 = 5.0;
|
pub const MAX_MOUNT_RANGE: f32 = 5.0;
|
||||||
pub const MAX_SPRITE_MOUNT_RANGE: f32 = 1.5;
|
pub const MAX_SPRITE_MOUNT_RANGE: f32 = 2.0;
|
||||||
pub const MAX_TRADE_RANGE: f32 = 20.0;
|
pub const MAX_TRADE_RANGE: f32 = 20.0;
|
||||||
|
|
||||||
pub const GRAVITY: f32 = 25.0;
|
pub const GRAVITY: f32 = 25.0;
|
||||||
|
@ -436,7 +436,8 @@ impl Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_controller(&self) -> bool {
|
pub fn is_controller(&self) -> bool {
|
||||||
self.get_sprite().map_or(false, |sprite| sprite.is_controller())
|
self.get_sprite()
|
||||||
|
.map_or(false, |sprite| sprite.is_controller())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -506,13 +506,14 @@ impl SpriteKind {
|
|||||||
pub fn is_mountable(&self) -> bool { self.mount_offset().is_some() }
|
pub fn is_mountable(&self) -> bool { self.mount_offset().is_some() }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_controller(&self) -> bool {
|
pub fn is_controller(&self) -> bool { matches!(self, SpriteKind::Helm) }
|
||||||
matches!(self, SpriteKind::Helm)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_door(&self) -> bool {
|
pub fn is_door(&self) -> bool {
|
||||||
matches!(self, SpriteKind::Door | SpriteKind::DoorWide | SpriteKind::DoorDark)
|
matches!(
|
||||||
|
self,
|
||||||
|
SpriteKind::Door | SpriteKind::DoorWide | SpriteKind::DoorDark
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Which tool (if any) is needed to collect this sprite?
|
/// Which tool (if any) is needed to collect this sprite?
|
||||||
|
@ -156,9 +156,7 @@ impl FindDist<Cylinder> for Vec3<f32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn min_distance(self, other: Cylinder) -> f32 {
|
fn min_distance(self, other: Cylinder) -> f32 { other.min_distance(self) }
|
||||||
other.min_distance(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1699,8 +1699,8 @@ fn handle_make_volume(
|
|||||||
let pos = position(server, target, "target")?;
|
let pos = position(server, target, "target")?;
|
||||||
let ship = comp::ship::Body::Volume;
|
let ship = comp::ship::Body::Volume;
|
||||||
let sz = parse_cmd_args!(args, u32).unwrap_or(15);
|
let sz = parse_cmd_args!(args, u32).unwrap_or(15);
|
||||||
if sz < 1 || sz > 127 {
|
if !(1..=127).contains(&sz) {
|
||||||
return Err(format!("Size has to be between 1 and 127."));
|
return Err("Size has to be between 1 and 127.".to_string());
|
||||||
};
|
};
|
||||||
let sz = Vec3::broadcast(sz);
|
let sz = Vec3::broadcast(sz);
|
||||||
let collider = {
|
let collider = {
|
||||||
@ -1715,9 +1715,12 @@ fn handle_make_volume(
|
|||||||
};
|
};
|
||||||
server
|
server
|
||||||
.state
|
.state
|
||||||
.create_ship(comp::Pos(pos.0 + Vec3::unit_z() * (50.0 + sz.z as f32 / 2.0)), comp::Ori::default(), ship, move |_| {
|
.create_ship(
|
||||||
collider
|
comp::Pos(pos.0 + Vec3::unit_z() * (50.0 + sz.z as f32 / 2.0)),
|
||||||
})
|
comp::Ori::default(),
|
||||||
|
ship,
|
||||||
|
move |_| collider,
|
||||||
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
server.notify_client(
|
server.notify_client(
|
||||||
|
@ -151,9 +151,9 @@ pub fn handle_mount_volume(server: &mut Server, rider: EcsEntity, volume_pos: Vo
|
|||||||
&state.ecs().read_storage(),
|
&state.ecs().read_storage(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some((transform, block)) = block_transform
|
if let Some((mat, block)) = block_transform
|
||||||
&& let Some(mount_offset) = block.mount_offset() {
|
&& let Some(mount_offset) = block.mount_offset() {
|
||||||
let mount_pos = (Mat4::from(transform) * mount_offset.0.with_w(1.0)).xyz();
|
let mount_pos = (mat * mount_offset.0.with_w(1.0)).xyz();
|
||||||
let within_range = {
|
let within_range = {
|
||||||
let positions = state.ecs().read_storage::<Pos>();
|
let positions = state.ecs().read_storage::<Pos>();
|
||||||
positions.get(rider).map_or(false, |pos| pos.0.distance_squared(mount_pos) < MAX_SPRITE_MOUNT_RANGE * MAX_SPRITE_MOUNT_RANGE)
|
positions.get(rider).map_or(false, |pos| pos.0.distance_squared(mount_pos) < MAX_SPRITE_MOUNT_RANGE * MAX_SPRITE_MOUNT_RANGE)
|
||||||
|
@ -13,6 +13,7 @@ use common::{
|
|||||||
InventoryUpdate,
|
InventoryUpdate,
|
||||||
},
|
},
|
||||||
consts::MAX_PICKUP_RANGE,
|
consts::MAX_PICKUP_RANGE,
|
||||||
|
mounting::VolumePos,
|
||||||
recipe::{
|
recipe::{
|
||||||
self, default_component_recipe_book, default_recipe_book, default_repair_recipe_book,
|
self, default_component_recipe_book, default_recipe_book, default_repair_recipe_book,
|
||||||
},
|
},
|
||||||
@ -21,7 +22,7 @@ use common::{
|
|||||||
trade::Trades,
|
trade::Trades,
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
util::find_dist::{self, FindDist},
|
util::find_dist::{self, FindDist},
|
||||||
vol::ReadVol, mounting::VolumePos,
|
vol::ReadVol,
|
||||||
};
|
};
|
||||||
use common_net::sync::WorldSyncExt;
|
use common_net::sync::WorldSyncExt;
|
||||||
use common_state::State;
|
use common_state::State;
|
||||||
@ -750,7 +751,14 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
|||||||
.filter(|pos| {
|
.filter(|pos| {
|
||||||
let entity_cylinder = get_cylinder(state, entity);
|
let entity_cylinder = get_cylinder(state, entity);
|
||||||
let in_range = within_pickup_range(entity_cylinder, || {
|
let in_range = within_pickup_range(entity_cylinder, || {
|
||||||
pos.get_block_and_transform(&state.terrain(), &state.ecs().read_resource(), &state.read_storage(), &state.read_storage(), &state.read_storage()).map(|(transform, _)| transform.mul_point(Vec3::broadcast(0.5)))
|
pos.get_block_and_transform(
|
||||||
|
&state.terrain(),
|
||||||
|
&state.ecs().read_resource(),
|
||||||
|
&state.read_storage(),
|
||||||
|
&state.read_storage(),
|
||||||
|
&state.read_storage(),
|
||||||
|
)
|
||||||
|
.map(|(transform, _)| transform.mul_point(Vec3::broadcast(0.5)))
|
||||||
});
|
});
|
||||||
if !in_range {
|
if !in_range {
|
||||||
debug!(
|
debug!(
|
||||||
@ -762,7 +770,13 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
|||||||
}
|
}
|
||||||
in_range
|
in_range
|
||||||
})
|
})
|
||||||
.and_then(|pos| pos.get_block(&state.terrain(), &state.ecs().read_resource(), &state.read_storage()))
|
.and_then(|pos| {
|
||||||
|
pos.get_block(
|
||||||
|
&state.terrain(),
|
||||||
|
&state.ecs().read_resource(),
|
||||||
|
&state.read_storage(),
|
||||||
|
)
|
||||||
|
})
|
||||||
.and_then(|block| block.get_sprite())
|
.and_then(|block| block.get_sprite())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,9 +38,10 @@ use common::{
|
|||||||
comp::{
|
comp::{
|
||||||
inventory::slot::EquipSlot,
|
inventory::slot::EquipSlot,
|
||||||
item::{tool::AbilityContext, Hands, ItemKind, ToolKind},
|
item::{tool::AbilityContext, Hands, ItemKind, ToolKind},
|
||||||
ship::{self, figuredata::VOXEL_COLLIDER_MANIFEST}, Body, CharacterActivity, CharacterState, Collider, Controller, Health, Inventory,
|
ship::{self, figuredata::VOXEL_COLLIDER_MANIFEST},
|
||||||
Item, ItemKey, Last, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos,
|
Body, CharacterActivity, CharacterState, Collider, Controller, Health, Inventory, Item,
|
||||||
Scale, SkillSet, Stance, Vel,
|
ItemKey, Last, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale,
|
||||||
|
SkillSet, Stance, Vel,
|
||||||
},
|
},
|
||||||
link::Is,
|
link::Is,
|
||||||
mounting::{Rider, VolumeRider},
|
mounting::{Rider, VolumeRider},
|
||||||
@ -6104,7 +6105,7 @@ impl FigureMgr {
|
|||||||
pos.0.into(),
|
pos.0.into(),
|
||||||
ori.into_vec4().into(),
|
ori.into_vec4().into(),
|
||||||
vk,
|
vk,
|
||||||
Arc::clone(&vol),
|
Arc::clone(vol),
|
||||||
tick,
|
tick,
|
||||||
&slow_jobs,
|
&slow_jobs,
|
||||||
terrain,
|
terrain,
|
||||||
@ -6346,7 +6347,8 @@ impl FigureMgr {
|
|||||||
if let Some((data, sprite_instances)) =
|
if let Some((data, sprite_instances)) =
|
||||||
self.get_sprite_instances(entity, body, collider)
|
self.get_sprite_instances(entity, body, collider)
|
||||||
{
|
{
|
||||||
let dist = collider.and_then(|collider| {
|
let dist = collider
|
||||||
|
.and_then(|collider| {
|
||||||
let vol = collider.get_vol(&voxel_colliders_manifest)?;
|
let vol = collider.get_vol(&voxel_colliders_manifest)?;
|
||||||
|
|
||||||
let mat = Mat4::from(ori.to_quat()).translated_3d(pos.0)
|
let mat = Mat4::from(ori.to_quat()).translated_3d(pos.0)
|
||||||
@ -6362,7 +6364,8 @@ impl FigureMgr {
|
|||||||
} else {
|
} else {
|
||||||
aabb.distance_to_point(p)
|
aabb.distance_to_point(p)
|
||||||
})
|
})
|
||||||
}).unwrap_or_else(|| pos.0.distance(cam_pos));
|
})
|
||||||
|
.unwrap_or_else(|| pos.0.distance(cam_pos));
|
||||||
|
|
||||||
if dist < sprite_render_distance {
|
if dist < sprite_render_distance {
|
||||||
let lod_level = if dist < sprite_high_detail_distance {
|
let lod_level = if dist < sprite_high_detail_distance {
|
||||||
|
@ -3,7 +3,10 @@ use super::{
|
|||||||
load::{BodySpec, ShipBoneMeshes},
|
load::{BodySpec, ShipBoneMeshes},
|
||||||
EcsEntity,
|
EcsEntity,
|
||||||
};
|
};
|
||||||
use common::{assets, comp::ship::{figuredata::VoxelCollider, AIRSHIP_SCALE}};
|
use common::{
|
||||||
|
assets,
|
||||||
|
comp::ship::figuredata::VoxelCollider,
|
||||||
|
};
|
||||||
use std::{convert::TryFrom, sync::Arc};
|
use std::{convert::TryFrom, sync::Arc};
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -690,8 +690,7 @@ impl Scene {
|
|||||||
.filter(|(pos, _, light_anim, h)| {
|
.filter(|(pos, _, light_anim, h)| {
|
||||||
light_anim.col != Rgb::zero()
|
light_anim.col != Rgb::zero()
|
||||||
&& light_anim.strength > 0.0
|
&& light_anim.strength > 0.0
|
||||||
&& pos.0.distance_squared(viewpoint_pos)
|
&& pos.0.distance_squared(viewpoint_pos) < max_light_dist
|
||||||
< max_light_dist
|
|
||||||
&& h.map_or(true, |h| !h.is_dead)
|
&& h.map_or(true, |h| !h.is_dead)
|
||||||
})
|
})
|
||||||
.map(|(pos, interpolated, light_anim, _)| {
|
.map(|(pos, interpolated, light_anim, _)| {
|
||||||
@ -714,7 +713,9 @@ impl Scene {
|
|||||||
&scene_data.state.read_storage::<comp::Ori>(),
|
&scene_data.state.read_storage::<comp::Ori>(),
|
||||||
&scene_data.state.read_storage::<comp::Body>(),
|
&scene_data.state.read_storage::<comp::Body>(),
|
||||||
&scene_data.state.read_storage::<comp::Collider>(),
|
&scene_data.state.read_storage::<comp::Collider>(),
|
||||||
).join().filter_map(|(entity, pos, ori, body, collider)| {
|
)
|
||||||
|
.join()
|
||||||
|
.filter_map(|(entity, pos, ori, body, collider)| {
|
||||||
let vol = collider.get_vol(&voxel_colliders_manifest)?;
|
let vol = collider.get_vol(&voxel_colliders_manifest)?;
|
||||||
|
|
||||||
let mat = Mat4::from(ori.to_quat()).translated_3d(pos.0)
|
let mat = Mat4::from(ori.to_quat()).translated_3d(pos.0)
|
||||||
@ -729,18 +730,25 @@ impl Scene {
|
|||||||
figure_mgr
|
figure_mgr
|
||||||
.get_blocks_of_interest(entity, body, Some(collider))
|
.get_blocks_of_interest(entity, body, Some(collider))
|
||||||
.map(move |(blocks_of_interest, _)| {
|
.map(move |(blocks_of_interest, _)| {
|
||||||
blocks_of_interest.lights.iter().map(
|
blocks_of_interest
|
||||||
move |(block_offset, level)| {
|
.lights
|
||||||
|
.iter()
|
||||||
|
.map(move |(block_offset, level)| {
|
||||||
let wpos = mat.mul_point(block_offset.as_() + 0.5);
|
let wpos = mat.mul_point(block_offset.as_() + 0.5);
|
||||||
(wpos, level)
|
(wpos, level)
|
||||||
},
|
})
|
||||||
).filter(move |(wpos, _)| wpos.distance_squared(viewpoint_pos) < max_light_dist)
|
.filter(move |(wpos, _)| {
|
||||||
.map(|(wpos, level)| Light::new(wpos, Rgb::white(), *level as f32 / 7.0))
|
wpos.distance_squared(viewpoint_pos) < max_light_dist
|
||||||
|
})
|
||||||
|
.map(|(wpos, level)| {
|
||||||
|
Light::new(wpos, Rgb::white(), *level as f32 / 7.0)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}).flatten()
|
})
|
||||||
|
.flatten(),
|
||||||
);
|
);
|
||||||
lights.sort_by_key(|light| light.get_pos().distance_squared(viewpoint_pos) as i32);
|
lights.sort_by_key(|light| light.get_pos().distance_squared(viewpoint_pos) as i32);
|
||||||
lights.truncate(MAX_LIGHT_COUNT);
|
lights.truncate(MAX_LIGHT_COUNT);
|
||||||
|
@ -312,8 +312,9 @@ pub(super) fn select_interactable(
|
|||||||
.chain(volumes)
|
.chain(volumes)
|
||||||
.filter(|(wpos, volume_pos, interaction)| {
|
.filter(|(wpos, volume_pos, interaction)| {
|
||||||
match interaction {
|
match interaction {
|
||||||
Interaction::Mount => !is_volume_rider.contains(player_entity) && wpos.distance_squared(player_pos) < MAX_SPRITE_MOUNT_RANGE * MAX_SPRITE_MOUNT_RANGE &&
|
Interaction::Mount => !is_volume_rider.contains(player_entity)
|
||||||
is_volume_rider.join().find(|is_volume_rider| is_volume_rider.pos == *volume_pos).is_none(),
|
&& wpos.distance_squared(player_pos) < MAX_SPRITE_MOUNT_RANGE * MAX_SPRITE_MOUNT_RANGE
|
||||||
|
&& !is_volume_rider.join().any(|is_volume_rider| is_volume_rider.pos == *volume_pos),
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -333,7 +334,7 @@ pub(super) fn select_interactable(
|
|||||||
&ecs.read_resource::<UidAllocator>(),
|
&ecs.read_resource::<UidAllocator>(),
|
||||||
&ecs.read_storage(),
|
&ecs.read_storage(),
|
||||||
block_pos,
|
block_pos,
|
||||||
interaction.clone(),
|
*interaction,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.or_else(|| closest_interactable_entity.map(|(e, _)| Interactable::Entity(e)))
|
.or_else(|| closest_interactable_entity.map(|(e, _)| Interactable::Entity(e)))
|
||||||
|
@ -951,9 +951,7 @@ impl PlayState for SessionState {
|
|||||||
BlockInteraction::Craft(tab) => {
|
BlockInteraction::Craft(tab) => {
|
||||||
self.hud.show.open_crafting_tab(
|
self.hud.show.open_crafting_tab(
|
||||||
*tab,
|
*tab,
|
||||||
block
|
block.get_sprite().map(|s| (*pos, s)),
|
||||||
.get_sprite()
|
|
||||||
.map(|s| (*pos, s)),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
BlockInteraction::Mount => {
|
BlockInteraction::Mount => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user