diff options
| author | untodesu <kirill@untode.su> | 2025-03-21 18:16:40 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-03-21 18:16:40 +0500 |
| commit | 9f80a278a6f188c8e9131df0684bad14a07491ee (patch) | |
| tree | 067c6ad4b892a34c3c03e3ecdbe312453bd46ea4 /game/shared/collision.cc | |
| parent | fddd7f761176bb45cfdd41eeccaeadac22d33ddf (diff) | |
| download | voxelius-9f80a278a6f188c8e9131df0684bad14a07491ee.tar.bz2 voxelius-9f80a278a6f188c8e9131df0684bad14a07491ee.zip | |
Toggles system rework, added flight pmove mode
- Reworked toggles to use a constant-styled enumerations
- Added TOGGLE_PM_FLIGHT and an according movement mode. Now server-side
just doesn't simulate gravity altogether for players, instead relying
on whatever the client provides which works fine for now. Closes #12
Diffstat (limited to 'game/shared/collision.cc')
| -rw-r--r-- | game/shared/collision.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/game/shared/collision.cc b/game/shared/collision.cc index 126d3bb..0593fbb 100644 --- a/game/shared/collision.cc +++ b/game/shared/collision.cc @@ -6,6 +6,7 @@ #include "shared/coord.hh" #include "shared/dimension.hh" #include "shared/globals.hh" +#include "shared/gravity.hh" #include "shared/grounded.hh" #include "shared/transform.hh" #include "shared/velocity.hh" @@ -146,11 +147,15 @@ void CollisionComponent::fixed_update(Dimension *dimension) auto surface = voxel_surface::UNKNOWN; auto vertical_move = vgrid_collide(dimension, 1, collision, transform, velocity, surface); - if(vertical_move == cxpr::sign<int>(dimension->get_gravity())) { - auto &component = dimension->entities.get_or_emplace<GroundedComponent>(entity); - component.surface = surface; + if(dimension->entities.any_of<GravityComponent>(entity)) { + if(vertical_move == cxpr::sign<int>(dimension->get_gravity())) + dimension->entities.emplace_or_replace<GroundedComponent>(entity, GroundedComponent{surface}); + else dimension->entities.remove<GroundedComponent>(entity); } else { + // The entity cannot be grounded because the component + // setup of said entity should not let it comprehend the + // concept of resting on the ground (it flies around) dimension->entities.remove<GroundedComponent>(entity); } |
