diff --git a/CHANGELOG.md b/CHANGELOG.md index 01bd5e395b..98afc6589c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - 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 diff --git a/common/net/src/synced_components.rs b/common/net/src/synced_components.rs index d8d5963b35..374931560c 100644 --- a/common/net/src/synced_components.rs +++ b/common/net/src/synced_components.rs @@ -37,6 +37,7 @@ macro_rules! synced_components { density: Density, collider: Collider, sticky: Sticky, + immovable: Immovable, character_state: CharacterState, shockwave: Shockwave, beam_segment: BeamSegment, @@ -188,6 +189,10 @@ impl NetSync for Sticky { const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity; } +impl NetSync for Immovable { + const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity; +} + impl NetSync for CharacterState { const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity; } diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 1640fe0c1a..ba7d19c833 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -96,8 +96,8 @@ pub use self::{ ori::Ori, pet::Pet, phys::{ - Collider, Density, ForceUpdate, Mass, PhysicsState, Pos, PosVelOriDefer, PreviousPhysCache, - Scale, Sticky, Vel, + Collider, Density, ForceUpdate, Immovable, Mass, PhysicsState, Pos, PosVelOriDefer, + PreviousPhysCache, Scale, Sticky, Vel, }, player::DisconnectReason, player::{AliasError, Player, MAX_ALIAS_LEN}, diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index efa306fb28..e352326a76 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -166,6 +166,13 @@ impl Component for Sticky { type Storage = DerefFlaggedStorage>; } +#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Immovable; + +impl Component for Immovable { + type Storage = DerefFlaggedStorage>; +} + // PhysicsState #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct PhysicsState { diff --git a/common/state/src/state.rs b/common/state/src/state.rs index 29a3bf36d6..232c79f1ba 100644 --- a/common/state/src/state.rs +++ b/common/state/src/state.rs @@ -149,6 +149,7 @@ impl State { ecs.register::(); ecs.register::(); ecs.register::(); + ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index e19ca2021b..e45fe28a60 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -2,8 +2,8 @@ use common::{ comp::{ body::ship::figuredata::{VoxelCollider, VOXEL_COLLIDER_MANIFEST}, fluid_dynamics::{Fluid, LiquidKind, Wings}, - Body, CharacterState, Collider, Density, Mass, Ori, PhysicsState, Pos, PosVelOriDefer, - PreviousPhysCache, Projectile, Scale, Stats, Sticky, Vel, + Body, CharacterState, Collider, Density, Immovable, Mass, Ori, PhysicsState, Pos, + PosVelOriDefer, PreviousPhysCache, Projectile, Scale, Stats, Sticky, Vel, }, consts::{AIR_DENSITY, FRIC_GROUND, GRAVITY}, event::{EventBus, ServerEvent}, @@ -110,6 +110,7 @@ pub struct PhysicsRead<'a> { event_bus: Read<'a, EventBus>, scales: ReadStorage<'a, Scale>, stickies: ReadStorage<'a, Sticky>, + immovables: ReadStorage<'a, Immovable>, masses: ReadStorage<'a, Mass>, colliders: ReadStorage<'a, Collider>, is_ridings: ReadStorage<'a, Is>, @@ -327,6 +328,7 @@ impl<'a> PhysicsData<'a> { &read.colliders, read.is_ridings.maybe(), read.stickies.maybe(), + read.immovables.maybe(), &mut write.physics_states, // TODO: if we need to avoid collisions for other things consider // moving whether it should interact into the collider component @@ -350,11 +352,13 @@ impl<'a> PhysicsData<'a> { collider, is_riding, sticky, + immovable, physics, projectile, char_state_maybe, )| { let is_sticky = sticky.is_some(); + let is_immovable = immovable.is_some(); let is_mid_air = physics.on_surface().is_none(); let mut entity_entity_collision_checks = 0; let mut entity_entity_collisions = 0; @@ -459,6 +463,7 @@ impl<'a> PhysicsData<'a> { // physics flags is_mid_air, is_sticky, + is_immovable, is_projectile, // entity we colliding with *other, @@ -1789,6 +1794,7 @@ fn resolve_e2e_collision( // physics flags is_mid_air: bool, is_sticky: bool, + is_immovable: bool, is_projectile: bool, // entity we colliding with other: Uid, @@ -1861,17 +1867,18 @@ fn resolve_e2e_collision( // or if we're colliding with 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 - // (or on the wall). + // Don't apply force when entity is immovable, or a sticky which is on the + // ground (or on the wall). if !forced_movement && (!is_sticky || is_mid_air) && diff.magnitude_squared() > 0.0 && !is_projectile + && !is_immovable && !other_data.collider.is_voxel() && !our_data.collider.is_voxel() { 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 force = ELASTIC_FORCE_COEFFICIENT * distance_coefficient * mass_coefficient; diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 4aaa872aa7..eff687cef4 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -243,7 +243,7 @@ pub fn handle_create_waypoint(server: &mut Server, pos: Vec3) { animated: true, }) .with(WaypointArea::default()) - .with(comp::Mass(10_f32.powi(10))) + .with(comp::Immovable) .with(comp::Auras::new(vec![ Aura::new( AuraKind::Buff {