mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better wheeled ship movement
This commit is contained in:
@ -84,7 +84,7 @@ impl Body {
|
|||||||
Body::Galleon => Vec3::new(14.0, 48.0, 10.0),
|
Body::Galleon => Vec3::new(14.0, 48.0, 10.0),
|
||||||
Body::Skiff => Vec3::new(7.0, 15.0, 10.0),
|
Body::Skiff => Vec3::new(7.0, 15.0, 10.0),
|
||||||
Body::Submarine => Vec3::new(2.0, 15.0, 8.0),
|
Body::Submarine => Vec3::new(2.0, 15.0, 8.0),
|
||||||
Body::Carriage => Vec3::new(2.0, 15.0, 8.0),
|
Body::Carriage => Vec3::new(6.0, 12.0, 8.0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ impl Body {
|
|||||||
pub fn flying_height(&self) -> f32 { if self.can_fly() { 200.0 } else { 0.0 } }
|
pub fn flying_height(&self) -> f32 { if self.can_fly() { 200.0 } else { 0.0 } }
|
||||||
|
|
||||||
pub fn has_water_thrust(&self) -> bool {
|
pub fn has_water_thrust(&self) -> bool {
|
||||||
!self.can_fly() && !matches!(self, Body::Carriage) // TODO: Differentiate this more carefully
|
matches!(self, Body::SailBoat | Body::Galleon | Body::Skiff)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_wheels(&self) -> bool { matches!(self, Body::Carriage) }
|
pub fn has_wheels(&self) -> bool { matches!(self, Body::Carriage) }
|
||||||
|
@ -153,7 +153,7 @@ impl Collider {
|
|||||||
|
|
||||||
pub fn get_z_limits(&self, modifier: f32) -> (f32, f32) {
|
pub fn get_z_limits(&self, modifier: f32) -> (f32, f32) {
|
||||||
match self {
|
match self {
|
||||||
Collider::Voxel { .. } | Collider::Volume(_) => (0.0, 1.0),
|
Collider::Voxel { .. } | Collider::Volume(_) => (0.0, 2.0),
|
||||||
Collider::CapsulePrism { z_min, z_max, .. } => (*z_min * modifier, *z_max * modifier),
|
Collider::CapsulePrism { z_min, z_max, .. } => (*z_min * modifier, *z_max * modifier),
|
||||||
Collider::Point => (0.0, 0.0),
|
Collider::Point => (0.0, 0.0),
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ use crate::{
|
|||||||
item::{tool::AbilityMap, MaterialStatManifest},
|
item::{tool::AbilityMap, MaterialStatManifest},
|
||||||
ActiveAbilities, Beam, Body, CharacterActivity, CharacterState, Combo, ControlAction,
|
ActiveAbilities, Beam, Body, CharacterActivity, CharacterState, Combo, ControlAction,
|
||||||
Controller, ControllerInputs, Density, Energy, Health, InputAttr, InputKind, Inventory,
|
Controller, ControllerInputs, Density, Energy, Health, InputAttr, InputKind, Inventory,
|
||||||
InventoryAction, Mass, Melee, Ori, PhysicsState, Pos, PreviousPhysCache, Scale, SkillSet,
|
InventoryAction, Mass, Melee, Ori, PhysicsState, Pos, Scale, SkillSet, Stance, StateUpdate,
|
||||||
Stance, StateUpdate, Stats, Vel,
|
Stats, Vel,
|
||||||
},
|
},
|
||||||
link::Is,
|
link::Is,
|
||||||
mounting::{Rider, VolumeRider},
|
mounting::{Rider, VolumeRider},
|
||||||
@ -149,7 +149,6 @@ pub struct JoinData<'a> {
|
|||||||
pub mount_data: Option<&'a Is<Rider>>,
|
pub mount_data: Option<&'a Is<Rider>>,
|
||||||
pub volume_mount_data: Option<&'a Is<VolumeRider>>,
|
pub volume_mount_data: Option<&'a Is<VolumeRider>>,
|
||||||
pub stance: Option<&'a Stance>,
|
pub stance: Option<&'a Stance>,
|
||||||
pub previous_physics: Option<&'a PreviousPhysCache>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct JoinStruct<'a> {
|
pub struct JoinStruct<'a> {
|
||||||
@ -180,7 +179,6 @@ pub struct JoinStruct<'a> {
|
|||||||
pub mount_data: Option<&'a Is<Rider>>,
|
pub mount_data: Option<&'a Is<Rider>>,
|
||||||
pub volume_mount_data: Option<&'a Is<VolumeRider>>,
|
pub volume_mount_data: Option<&'a Is<VolumeRider>>,
|
||||||
pub stance: Option<&'a Stance>,
|
pub stance: Option<&'a Stance>,
|
||||||
pub previous_physics: Option<&'a PreviousPhysCache>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> JoinData<'a> {
|
impl<'a> JoinData<'a> {
|
||||||
@ -225,7 +223,6 @@ impl<'a> JoinData<'a> {
|
|||||||
mount_data: j.mount_data,
|
mount_data: j.mount_data,
|
||||||
volume_mount_data: j.volume_mount_data,
|
volume_mount_data: j.volume_mount_data,
|
||||||
stance: j.stance,
|
stance: j.stance,
|
||||||
previous_physics: j.previous_physics,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,7 @@ pub fn handle_orientation(
|
|||||||
(a.to_quat().into_vec4() - b.to_quat().into_vec4()).reduce(|a, b| a.abs() + b.abs())
|
(a.to_quat().into_vec4() - b.to_quat().into_vec4()).reduce(|a, b| a.abs() + b.abs())
|
||||||
}
|
}
|
||||||
|
|
||||||
let (tilt_ori, efficiency) = if let Body::Ship(ship) = data.body && ship.has_wheels() && data.physics.on_ground.is_some() {
|
let (tilt_ori, efficiency) = if let Body::Ship(ship) = data.body && ship.has_wheels() {
|
||||||
let height_at = |rpos| data
|
let height_at = |rpos| data
|
||||||
.terrain
|
.terrain
|
||||||
.ray(
|
.ray(
|
||||||
@ -600,6 +600,7 @@ pub fn handle_orientation(
|
|||||||
.cast()
|
.cast()
|
||||||
.0;
|
.0;
|
||||||
|
|
||||||
|
// Do some cheap raycasting with the ground to determine the appropriate orientation for the vehicle
|
||||||
let x_diff = (height_at(data.ori.to_horizontal().right().to_vec() * 3.0) - height_at(data.ori.to_horizontal().right().to_vec() * -3.0)) / 10.0;
|
let x_diff = (height_at(data.ori.to_horizontal().right().to_vec() * 3.0) - height_at(data.ori.to_horizontal().right().to_vec() * -3.0)) / 10.0;
|
||||||
let y_diff = (height_at(data.ori.to_horizontal().look_dir().to_vec() * -4.5) - height_at(data.ori.to_horizontal().look_dir().to_vec() * 4.5)) / 10.0;
|
let y_diff = (height_at(data.ori.to_horizontal().look_dir().to_vec() * -4.5) - height_at(data.ori.to_horizontal().look_dir().to_vec() * 4.5)) / 10.0;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use common::{
|
|||||||
inventory::item::{tool::AbilityMap, MaterialStatManifest},
|
inventory::item::{tool::AbilityMap, MaterialStatManifest},
|
||||||
ActiveAbilities, Beam, Body, CharacterActivity, CharacterState, Combo, Controller, Density,
|
ActiveAbilities, Beam, Body, CharacterActivity, CharacterState, Combo, Controller, Density,
|
||||||
Energy, Health, Inventory, InventoryManip, Mass, Melee, Ori, PhysicsState, Poise, Pos,
|
Energy, Health, Inventory, InventoryManip, Mass, Melee, Ori, PhysicsState, Poise, Pos,
|
||||||
PreviousPhysCache, Scale, SkillSet, Stance, StateUpdate, Stats, Vel,
|
Scale, SkillSet, Stance, StateUpdate, Stats, Vel,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
link::Is,
|
link::Is,
|
||||||
@ -54,7 +54,6 @@ pub struct ReadData<'a> {
|
|||||||
terrain: ReadExpect<'a, TerrainGrid>,
|
terrain: ReadExpect<'a, TerrainGrid>,
|
||||||
inventories: ReadStorage<'a, Inventory>,
|
inventories: ReadStorage<'a, Inventory>,
|
||||||
stances: ReadStorage<'a, Stance>,
|
stances: ReadStorage<'a, Stance>,
|
||||||
previous_physics: ReadStorage<'a, PreviousPhysCache>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ## Character Behavior System
|
/// ## Character Behavior System
|
||||||
@ -121,7 +120,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
controller,
|
controller,
|
||||||
health,
|
health,
|
||||||
body,
|
body,
|
||||||
(physics, scale, stat, skill_set, active_abilities, previous_physics, is_rider),
|
(physics, scale, stat, skill_set, active_abilities, is_rider),
|
||||||
combo,
|
combo,
|
||||||
) in (
|
) in (
|
||||||
&read_data.entities,
|
&read_data.entities,
|
||||||
@ -144,7 +143,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
&read_data.stats,
|
&read_data.stats,
|
||||||
&read_data.skill_sets,
|
&read_data.skill_sets,
|
||||||
read_data.active_abilities.maybe(),
|
read_data.active_abilities.maybe(),
|
||||||
read_data.previous_physics.maybe(),
|
|
||||||
read_data.is_riders.maybe(),
|
read_data.is_riders.maybe(),
|
||||||
),
|
),
|
||||||
read_data.combos.maybe(),
|
read_data.combos.maybe(),
|
||||||
@ -212,7 +210,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
mount_data: read_data.is_riders.get(entity),
|
mount_data: read_data.is_riders.get(entity),
|
||||||
volume_mount_data: read_data.is_volume_riders.get(entity),
|
volume_mount_data: read_data.is_volume_riders.get(entity),
|
||||||
stance: read_data.stances.get(entity),
|
stance: read_data.stances.get(entity),
|
||||||
previous_physics,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for action in actions {
|
for action in actions {
|
||||||
|
Reference in New Issue
Block a user