mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix waypoints being movable
This commit is contained in:
parent
9539991e8f
commit
94a9b407c2
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed bug that would sometimes cause taking a screenshot to panic because a buffer was mapped a the wrong time.
|
- Fixed bug that would sometimes cause taking a screenshot to panic because a buffer was mapped a the wrong time.
|
||||||
|
- Players can no longer push waypoints around
|
||||||
|
|
||||||
## [0.12.0] - 2022-02-19
|
## [0.12.0] - 2022-02-19
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ macro_rules! synced_components {
|
|||||||
density: Density,
|
density: Density,
|
||||||
collider: Collider,
|
collider: Collider,
|
||||||
sticky: Sticky,
|
sticky: Sticky,
|
||||||
|
immovable: Immovable,
|
||||||
character_state: CharacterState,
|
character_state: CharacterState,
|
||||||
shockwave: Shockwave,
|
shockwave: Shockwave,
|
||||||
beam_segment: BeamSegment,
|
beam_segment: BeamSegment,
|
||||||
@ -188,6 +189,10 @@ impl NetSync for Sticky {
|
|||||||
const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity;
|
const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NetSync for Immovable {
|
||||||
|
const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity;
|
||||||
|
}
|
||||||
|
|
||||||
impl NetSync for CharacterState {
|
impl NetSync for CharacterState {
|
||||||
const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity;
|
const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity;
|
||||||
}
|
}
|
||||||
|
@ -96,8 +96,8 @@ pub use self::{
|
|||||||
ori::Ori,
|
ori::Ori,
|
||||||
pet::Pet,
|
pet::Pet,
|
||||||
phys::{
|
phys::{
|
||||||
Collider, Density, ForceUpdate, Mass, PhysicsState, Pos, PosVelOriDefer, PreviousPhysCache,
|
Collider, Density, ForceUpdate, Immovable, Mass, PhysicsState, Pos, PosVelOriDefer,
|
||||||
Scale, Sticky, Vel,
|
PreviousPhysCache, Scale, Sticky, Vel,
|
||||||
},
|
},
|
||||||
player::DisconnectReason,
|
player::DisconnectReason,
|
||||||
player::{AliasError, Player, MAX_ALIAS_LEN},
|
player::{AliasError, Player, MAX_ALIAS_LEN},
|
||||||
|
@ -166,6 +166,13 @@ impl Component for Sticky {
|
|||||||
type Storage = DerefFlaggedStorage<Self, NullStorage<Self>>;
|
type Storage = DerefFlaggedStorage<Self, NullStorage<Self>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Immovable;
|
||||||
|
|
||||||
|
impl Component for Immovable {
|
||||||
|
type Storage = DerefFlaggedStorage<Self, NullStorage<Self>>;
|
||||||
|
}
|
||||||
|
|
||||||
// PhysicsState
|
// PhysicsState
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct PhysicsState {
|
pub struct PhysicsState {
|
||||||
|
@ -149,6 +149,7 @@ impl State {
|
|||||||
ecs.register::<comp::Density>();
|
ecs.register::<comp::Density>();
|
||||||
ecs.register::<comp::Collider>();
|
ecs.register::<comp::Collider>();
|
||||||
ecs.register::<comp::Sticky>();
|
ecs.register::<comp::Sticky>();
|
||||||
|
ecs.register::<comp::Immovable>();
|
||||||
ecs.register::<comp::CharacterState>();
|
ecs.register::<comp::CharacterState>();
|
||||||
ecs.register::<comp::Object>();
|
ecs.register::<comp::Object>();
|
||||||
ecs.register::<comp::Group>();
|
ecs.register::<comp::Group>();
|
||||||
|
@ -2,8 +2,8 @@ use common::{
|
|||||||
comp::{
|
comp::{
|
||||||
body::ship::figuredata::{VoxelCollider, VOXEL_COLLIDER_MANIFEST},
|
body::ship::figuredata::{VoxelCollider, VOXEL_COLLIDER_MANIFEST},
|
||||||
fluid_dynamics::{Fluid, LiquidKind, Wings},
|
fluid_dynamics::{Fluid, LiquidKind, Wings},
|
||||||
Body, CharacterState, Collider, Density, Mass, Ori, PhysicsState, Pos, PosVelOriDefer,
|
Body, CharacterState, Collider, Density, Immovable, Mass, Ori, PhysicsState, Pos,
|
||||||
PreviousPhysCache, Projectile, Scale, Stats, Sticky, Vel,
|
PosVelOriDefer, PreviousPhysCache, Projectile, Scale, Stats, Sticky, Vel,
|
||||||
},
|
},
|
||||||
consts::{AIR_DENSITY, FRIC_GROUND, GRAVITY},
|
consts::{AIR_DENSITY, FRIC_GROUND, GRAVITY},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
@ -110,6 +110,7 @@ pub struct PhysicsRead<'a> {
|
|||||||
event_bus: Read<'a, EventBus<ServerEvent>>,
|
event_bus: Read<'a, EventBus<ServerEvent>>,
|
||||||
scales: ReadStorage<'a, Scale>,
|
scales: ReadStorage<'a, Scale>,
|
||||||
stickies: ReadStorage<'a, Sticky>,
|
stickies: ReadStorage<'a, Sticky>,
|
||||||
|
immovables: ReadStorage<'a, Immovable>,
|
||||||
masses: ReadStorage<'a, Mass>,
|
masses: ReadStorage<'a, Mass>,
|
||||||
colliders: ReadStorage<'a, Collider>,
|
colliders: ReadStorage<'a, Collider>,
|
||||||
is_ridings: ReadStorage<'a, Is<Rider>>,
|
is_ridings: ReadStorage<'a, Is<Rider>>,
|
||||||
@ -327,6 +328,7 @@ impl<'a> PhysicsData<'a> {
|
|||||||
&read.colliders,
|
&read.colliders,
|
||||||
read.is_ridings.maybe(),
|
read.is_ridings.maybe(),
|
||||||
read.stickies.maybe(),
|
read.stickies.maybe(),
|
||||||
|
read.immovables.maybe(),
|
||||||
&mut write.physics_states,
|
&mut write.physics_states,
|
||||||
// TODO: if we need to avoid collisions for other things consider
|
// TODO: if we need to avoid collisions for other things consider
|
||||||
// moving whether it should interact into the collider component
|
// moving whether it should interact into the collider component
|
||||||
@ -350,11 +352,13 @@ impl<'a> PhysicsData<'a> {
|
|||||||
collider,
|
collider,
|
||||||
is_riding,
|
is_riding,
|
||||||
sticky,
|
sticky,
|
||||||
|
immovable,
|
||||||
physics,
|
physics,
|
||||||
projectile,
|
projectile,
|
||||||
char_state_maybe,
|
char_state_maybe,
|
||||||
)| {
|
)| {
|
||||||
let is_sticky = sticky.is_some();
|
let is_sticky = sticky.is_some();
|
||||||
|
let is_immovable = immovable.is_some();
|
||||||
let is_mid_air = physics.on_surface().is_none();
|
let is_mid_air = physics.on_surface().is_none();
|
||||||
let mut entity_entity_collision_checks = 0;
|
let mut entity_entity_collision_checks = 0;
|
||||||
let mut entity_entity_collisions = 0;
|
let mut entity_entity_collisions = 0;
|
||||||
@ -459,6 +463,7 @@ impl<'a> PhysicsData<'a> {
|
|||||||
// physics flags
|
// physics flags
|
||||||
is_mid_air,
|
is_mid_air,
|
||||||
is_sticky,
|
is_sticky,
|
||||||
|
is_immovable,
|
||||||
is_projectile,
|
is_projectile,
|
||||||
// entity we colliding with
|
// entity we colliding with
|
||||||
*other,
|
*other,
|
||||||
@ -1789,6 +1794,7 @@ fn resolve_e2e_collision(
|
|||||||
// physics flags
|
// physics flags
|
||||||
is_mid_air: bool,
|
is_mid_air: bool,
|
||||||
is_sticky: bool,
|
is_sticky: bool,
|
||||||
|
is_immovable: bool,
|
||||||
is_projectile: bool,
|
is_projectile: bool,
|
||||||
// entity we colliding with
|
// entity we colliding with
|
||||||
other: Uid,
|
other: Uid,
|
||||||
@ -1861,17 +1867,18 @@ fn resolve_e2e_collision(
|
|||||||
// or if we're colliding with a terrain-like entity,
|
// or if we're colliding with a terrain-like entity,
|
||||||
// or if we are a terrain-like entity.
|
// or if we are a terrain-like entity.
|
||||||
//
|
//
|
||||||
// Don't apply force when entity is a sticky which is on the ground
|
// Don't apply force when entity is immovable, or a sticky which is on the
|
||||||
// (or on the wall).
|
// ground (or on the wall).
|
||||||
if !forced_movement
|
if !forced_movement
|
||||||
&& (!is_sticky || is_mid_air)
|
&& (!is_sticky || is_mid_air)
|
||||||
&& diff.magnitude_squared() > 0.0
|
&& diff.magnitude_squared() > 0.0
|
||||||
&& !is_projectile
|
&& !is_projectile
|
||||||
|
&& !is_immovable
|
||||||
&& !other_data.collider.is_voxel()
|
&& !other_data.collider.is_voxel()
|
||||||
&& !our_data.collider.is_voxel()
|
&& !our_data.collider.is_voxel()
|
||||||
{
|
{
|
||||||
const ELASTIC_FORCE_COEFFICIENT: f32 = 400.0;
|
const ELASTIC_FORCE_COEFFICIENT: f32 = 400.0;
|
||||||
let mass_coefficient = our_data.mass.0 / (our_data.mass.0 + our_data.mass.0);
|
let mass_coefficient = other_data.mass.0 / (our_data.mass.0 + other_data.mass.0);
|
||||||
let distance_coefficient = collision_dist - diff.magnitude();
|
let distance_coefficient = collision_dist - diff.magnitude();
|
||||||
let force = ELASTIC_FORCE_COEFFICIENT * distance_coefficient * mass_coefficient;
|
let force = ELASTIC_FORCE_COEFFICIENT * distance_coefficient * mass_coefficient;
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ pub fn handle_create_waypoint(server: &mut Server, pos: Vec3<f32>) {
|
|||||||
animated: true,
|
animated: true,
|
||||||
})
|
})
|
||||||
.with(WaypointArea::default())
|
.with(WaypointArea::default())
|
||||||
.with(comp::Mass(10_f32.powi(10)))
|
.with(comp::Immovable)
|
||||||
.with(comp::Auras::new(vec![
|
.with(comp::Auras::new(vec![
|
||||||
Aura::new(
|
Aura::new(
|
||||||
AuraKind::Buff {
|
AuraKind::Buff {
|
||||||
|
Loading…
Reference in New Issue
Block a user