mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Various fixes to beam, body based interp
This commit is contained in:
@ -11,5 +11,5 @@ BasicBeam(
|
|||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_cost: 0,
|
energy_cost: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Turret(5.0),
|
orientation_behavior: Turret,
|
||||||
)
|
)
|
@ -225,7 +225,7 @@ pub enum CharacterAbility {
|
|||||||
energy_regen: u32,
|
energy_regen: u32,
|
||||||
energy_cost: u32,
|
energy_cost: u32,
|
||||||
energy_drain: u32,
|
energy_drain: u32,
|
||||||
orientation_behavior: basic_beam::OrientationBehavior,
|
orientation_behavior: basic_beam::MovementBehavior,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,10 @@ impl Body {
|
|||||||
_ => 4.6,
|
_ => 4.6,
|
||||||
},
|
},
|
||||||
Body::Golem(_) => 5.0,
|
Body::Golem(_) => 5.0,
|
||||||
Body::Object(_) => 1.0,
|
Body::Object(object) => match object {
|
||||||
|
object::Body::Crossbow => 1.7,
|
||||||
|
_ => 1.0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +227,7 @@ impl LoadoutBuilder {
|
|||||||
));
|
));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
#[allow(clippy::collapsible_match)] // to be removed when more entries are added
|
||||||
Body::Object(object) => match object {
|
Body::Object(object) => match object {
|
||||||
object::Body::Crossbow => {
|
object::Body::Crossbow => {
|
||||||
main_tool = Some(Item::new_from_asset_expect(
|
main_tool = Some(Item::new_from_asset_expect(
|
||||||
|
@ -10,7 +10,6 @@ use crate::{
|
|||||||
utils::*,
|
utils::*,
|
||||||
},
|
},
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
util::Dir,
|
|
||||||
Damage, DamageSource, GroupTarget,
|
Damage, DamageSource, GroupTarget,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -46,7 +45,7 @@ pub struct StaticData {
|
|||||||
/// Energy drained per
|
/// Energy drained per
|
||||||
pub energy_drain: u32,
|
pub energy_drain: u32,
|
||||||
/// Used to dictate how orientation functions in this state
|
/// Used to dictate how orientation functions in this state
|
||||||
pub orientation_behavior: OrientationBehavior,
|
pub orientation_behavior: MovementBehavior,
|
||||||
/// What key is used to press ability
|
/// What key is used to press ability
|
||||||
pub ability_info: AbilityInfo,
|
pub ability_info: AbilityInfo,
|
||||||
}
|
}
|
||||||
@ -69,16 +68,9 @@ impl CharacterBehavior for Data {
|
|||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
|
|
||||||
match self.static_data.orientation_behavior {
|
match self.static_data.orientation_behavior {
|
||||||
OrientationBehavior::Normal => {},
|
MovementBehavior::Normal => {},
|
||||||
OrientationBehavior::Turret(speed) => {
|
MovementBehavior::Turret => {
|
||||||
update.ori.0 = data.inputs.look_dir;
|
update.ori.0 = data.inputs.look_dir;
|
||||||
/*update.ori.0 = Dir::new(
|
|
||||||
Quaternion::from_xyzw(update.ori.0.x, update.ori.0.y, update.ori.0.z, 0.0)
|
|
||||||
.rotated_z(data.dt.0 as f32 * speed)
|
|
||||||
.into_vec3()
|
|
||||||
.try_normalized()
|
|
||||||
.unwrap_or_default(),
|
|
||||||
);*/
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +106,8 @@ impl CharacterBehavior for Data {
|
|||||||
});
|
});
|
||||||
// Gets offsets
|
// Gets offsets
|
||||||
let body_offsets = Vec3::new(
|
let body_offsets = Vec3::new(
|
||||||
(data.body.radius() + 1.0) * data.inputs.look_dir.x,
|
(data.body.radius() + 1.0) * data.ori.0.x,
|
||||||
(data.body.radius() + 1.0) * data.inputs.look_dir.y,
|
(data.body.radius() + 1.0) * data.ori.0.y,
|
||||||
data.body.eye_height(),
|
data.body.eye_height(),
|
||||||
) * 0.55;
|
) * 0.55;
|
||||||
// Build up
|
// Build up
|
||||||
@ -245,7 +237,7 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum OrientationBehavior {
|
pub enum MovementBehavior {
|
||||||
Normal,
|
Normal,
|
||||||
Turret(f32),
|
Turret,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::ecs::comp::Interpolated;
|
use crate::ecs::comp::Interpolated;
|
||||||
use common::{
|
use common::{
|
||||||
comp::{Ori, Pos, Vel},
|
comp::{object, Body, Ori, Pos, Vel},
|
||||||
resources::DeltaTime,
|
resources::DeltaTime,
|
||||||
};
|
};
|
||||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||||
@ -17,20 +17,28 @@ impl<'a> System<'a> for Sys {
|
|||||||
ReadStorage<'a, Pos>,
|
ReadStorage<'a, Pos>,
|
||||||
ReadStorage<'a, Ori>,
|
ReadStorage<'a, Ori>,
|
||||||
ReadStorage<'a, Vel>,
|
ReadStorage<'a, Vel>,
|
||||||
|
ReadStorage<'a, Body>,
|
||||||
WriteStorage<'a, Interpolated>,
|
WriteStorage<'a, Interpolated>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
&mut self,
|
&mut self,
|
||||||
(entities, dt, positions, orientations, velocities, mut interpolated): Self::SystemData,
|
(entities, dt, positions, orientations, velocities, mut interpolated, bodies): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
// Update interpolated positions and orientations
|
// Update interpolated positions and orientations
|
||||||
for (pos, ori, i, vel) in (&positions, &orientations, &mut interpolated, &velocities).join()
|
for (pos, ori, i, vel, body) in (
|
||||||
|
&positions,
|
||||||
|
&orientations,
|
||||||
|
&mut interpolated,
|
||||||
|
&velocities,
|
||||||
|
&bodies,
|
||||||
|
)
|
||||||
|
.join()
|
||||||
{
|
{
|
||||||
// Update interpolation values
|
// Update interpolation values
|
||||||
if i.pos.distance_squared(pos.0) < 64.0 * 64.0 {
|
if i.pos.distance_squared(pos.0) < 64.0 * 64.0 {
|
||||||
i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 10.0 * dt.0);
|
i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 5.0 * dt.0);
|
||||||
i.ori = Ori::slerp(i.ori, *ori, 5.0 * dt.0);
|
i.ori = Dir::slerp(i.ori, ori.0, base_ori_interp(body) * dt.0);
|
||||||
} else {
|
} else {
|
||||||
i.pos = pos.0;
|
i.pos = pos.0;
|
||||||
i.ori = *ori;
|
i.ori = *ori;
|
||||||
@ -72,3 +80,14 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::collapsible_match)]
|
||||||
|
fn base_ori_interp(body: &Body) -> f32 {
|
||||||
|
match body {
|
||||||
|
Body::Object(object) => match object {
|
||||||
|
object::Body::Crossbow => 100.0,
|
||||||
|
_ => 10.0,
|
||||||
|
},
|
||||||
|
_ => 10.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -384,7 +384,7 @@ impl ParticleMgr {
|
|||||||
beam.properties.duration,
|
beam.properties.duration,
|
||||||
time + i as f64 / 1000.0,
|
time + i as f64 / 1000.0,
|
||||||
ParticleMode::HealingBeam,
|
ParticleMode::HealingBeam,
|
||||||
pos.0 + *ori.0 * 0.5,
|
pos.0,
|
||||||
pos.0 + *ori.0 * range,
|
pos.0 + *ori.0 * range,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -400,18 +400,12 @@ impl ParticleMgr {
|
|||||||
));
|
));
|
||||||
self.particles.resize_with(
|
self.particles.resize_with(
|
||||||
self.particles.len()
|
self.particles.len()
|
||||||
+ 2 * usize::from(
|
+ 2 * usize::from(self.scheduler.heartbeats(Duration::from_millis(1))),
|
||||||
self.scheduler.heartbeats(Duration::from_millis(1)),
|
|
||||||
),
|
|
||||||
|| {
|
|| {
|
||||||
let phi: f32 =
|
let phi: f32 = rng.gen_range(0.0, beam.properties.angle.to_radians());
|
||||||
rng.gen_range(0.0, beam.properties.angle.to_radians());
|
|
||||||
let theta: f32 = rng.gen_range(0.0, 2.0 * PI);
|
let theta: f32 = rng.gen_range(0.0, 2.0 * PI);
|
||||||
let offset_z = Vec3::new(
|
let offset_z =
|
||||||
phi.sin() * theta.cos(),
|
Vec3::new(phi.sin() * theta.cos(), phi.sin() * theta.sin(), phi.cos());
|
||||||
phi.sin() * theta.sin(),
|
|
||||||
phi.cos(),
|
|
||||||
);
|
|
||||||
let random_ori = offset_z * m * Vec3::new(-1.0, -1.0, 1.0);
|
let random_ori = offset_z * m * Vec3::new(-1.0, -1.0, 1.0);
|
||||||
Particle::new_beam(
|
Particle::new_beam(
|
||||||
beam.properties.duration,
|
beam.properties.duration,
|
||||||
|
Reference in New Issue
Block a user